ntdll: IMAGE_REL_BASED_HIGH, IMAGE_REL_BASED_LOW and IMAGE_REL_BASED_HIGHLOW should be supported on win64.
This commit is contained in:
parent
20a42b4c98
commit
9713d62e89
|
@ -2120,7 +2120,6 @@ IMAGE_BASE_RELOCATION * WINAPI LdrProcessRelocationBlock( void *page, UINT count
|
||||||
{
|
{
|
||||||
case IMAGE_REL_BASED_ABSOLUTE:
|
case IMAGE_REL_BASED_ABSOLUTE:
|
||||||
break;
|
break;
|
||||||
#ifdef __i386__
|
|
||||||
case IMAGE_REL_BASED_HIGH:
|
case IMAGE_REL_BASED_HIGH:
|
||||||
*(short *)((char *)page + offset) += HIWORD(delta);
|
*(short *)((char *)page + offset) += HIWORD(delta);
|
||||||
break;
|
break;
|
||||||
|
@ -2130,7 +2129,7 @@ IMAGE_BASE_RELOCATION * WINAPI LdrProcessRelocationBlock( void *page, UINT count
|
||||||
case IMAGE_REL_BASED_HIGHLOW:
|
case IMAGE_REL_BASED_HIGHLOW:
|
||||||
*(int *)((char *)page + offset) += delta;
|
*(int *)((char *)page + offset) += delta;
|
||||||
break;
|
break;
|
||||||
#elif defined(__x86_64__)
|
#ifdef __x86_64__
|
||||||
case IMAGE_REL_BASED_DIR64:
|
case IMAGE_REL_BASED_DIR64:
|
||||||
*(INT_PTR *)((char *)page + offset) += delta;
|
*(INT_PTR *)((char *)page + offset) += delta;
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -72,6 +72,9 @@ static DWORD (WINAPI *pRtlGetThreadErrorMode)(void);
|
||||||
static NTSTATUS (WINAPI *pRtlSetThreadErrorMode)(DWORD, LPDWORD);
|
static NTSTATUS (WINAPI *pRtlSetThreadErrorMode)(DWORD, LPDWORD);
|
||||||
static HMODULE hkernel32 = 0;
|
static HMODULE hkernel32 = 0;
|
||||||
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
|
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
|
||||||
|
static IMAGE_BASE_RELOCATION *(WINAPI *pLdrProcessRelocationBlock)(void*,UINT,USHORT*,INT_PTR);
|
||||||
|
|
||||||
|
|
||||||
#define LEN 16
|
#define LEN 16
|
||||||
static const char* src_src = "This is a test!"; /* 16 bytes long, incl NUL */
|
static const char* src_src = "This is a test!"; /* 16 bytes long, incl NUL */
|
||||||
static ULONG src_aligned_block[4];
|
static ULONG src_aligned_block[4];
|
||||||
|
@ -107,6 +110,7 @@ static void InitFunctionPtrs(void)
|
||||||
pNtCurrentTeb = (void *)GetProcAddress(hntdll, "NtCurrentTeb");
|
pNtCurrentTeb = (void *)GetProcAddress(hntdll, "NtCurrentTeb");
|
||||||
pRtlGetThreadErrorMode = (void *)GetProcAddress(hntdll, "RtlGetThreadErrorMode");
|
pRtlGetThreadErrorMode = (void *)GetProcAddress(hntdll, "RtlGetThreadErrorMode");
|
||||||
pRtlSetThreadErrorMode = (void *)GetProcAddress(hntdll, "RtlSetThreadErrorMode");
|
pRtlSetThreadErrorMode = (void *)GetProcAddress(hntdll, "RtlSetThreadErrorMode");
|
||||||
|
pLdrProcessRelocationBlock = (void *)GetProcAddress(hntdll, "LdrProcessRelocationBlock");
|
||||||
}
|
}
|
||||||
hkernel32 = LoadLibraryA("kernel32.dll");
|
hkernel32 = LoadLibraryA("kernel32.dll");
|
||||||
ok(hkernel32 != 0, "LoadLibrary failed\n");
|
ok(hkernel32 != 0, "LoadLibrary failed\n");
|
||||||
|
@ -1094,6 +1098,37 @@ static void test_RtlThreadErrorMode(void)
|
||||||
pRtlSetThreadErrorMode(oldmode, NULL);
|
pRtlSetThreadErrorMode(oldmode, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void test_LdrProcessRelocationBlock(void)
|
||||||
|
{
|
||||||
|
IMAGE_BASE_RELOCATION *ret;
|
||||||
|
USHORT reloc;
|
||||||
|
DWORD addr32;
|
||||||
|
SHORT addr16;
|
||||||
|
|
||||||
|
if(!pLdrProcessRelocationBlock) {
|
||||||
|
win_skip("LdrProcessRelocationBlock not available\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
addr32 = 0x50005;
|
||||||
|
reloc = IMAGE_REL_BASED_HIGHLOW<<12;
|
||||||
|
ret = pLdrProcessRelocationBlock(&addr32, 1, &reloc, 0x500050);
|
||||||
|
ok((USHORT*)ret == &reloc+1, "ret = %p, expected %p\n", ret, &reloc+1);
|
||||||
|
ok(addr32 == 0x550055, "addr32 = %x, expected 0x550055\n", addr32);
|
||||||
|
|
||||||
|
addr16 = 0x505;
|
||||||
|
reloc = IMAGE_REL_BASED_HIGH<<12;
|
||||||
|
ret = pLdrProcessRelocationBlock(&addr16, 1, &reloc, 0x500060);
|
||||||
|
ok((USHORT*)ret == &reloc+1, "ret = %p, expected %p\n", ret, &reloc+1);
|
||||||
|
ok(addr16 == 0x555, "addr16 = %x, expected 0x555\n", addr16);
|
||||||
|
|
||||||
|
addr16 = 0x505;
|
||||||
|
reloc = IMAGE_REL_BASED_LOW<<12;
|
||||||
|
ret = pLdrProcessRelocationBlock(&addr16, 1, &reloc, 0x500060);
|
||||||
|
ok((USHORT*)ret == &reloc+1, "ret = %p, expected %p\n", ret, &reloc+1);
|
||||||
|
ok(addr16 == 0x565, "addr16 = %x, expected 0x565\n", addr16);
|
||||||
|
}
|
||||||
|
|
||||||
START_TEST(rtl)
|
START_TEST(rtl)
|
||||||
{
|
{
|
||||||
InitFunctionPtrs();
|
InitFunctionPtrs();
|
||||||
|
@ -1114,4 +1149,5 @@ START_TEST(rtl)
|
||||||
test_RtlAllocateAndInitializeSid();
|
test_RtlAllocateAndInitializeSid();
|
||||||
test_RtlDeleteTimer();
|
test_RtlDeleteTimer();
|
||||||
test_RtlThreadErrorMode();
|
test_RtlThreadErrorMode();
|
||||||
|
test_LdrProcessRelocationBlock();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue