Commit 9713d62e authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

ntdll: IMAGE_REL_BASED_HIGH, IMAGE_REL_BASED_LOW and IMAGE_REL_BASED_HIGHLOW…

ntdll: IMAGE_REL_BASED_HIGH, IMAGE_REL_BASED_LOW and IMAGE_REL_BASED_HIGHLOW should be supported on win64.
parent 20a42b4c
......@@ -2120,7 +2120,6 @@ IMAGE_BASE_RELOCATION * WINAPI LdrProcessRelocationBlock( void *page, UINT count
{
case IMAGE_REL_BASED_ABSOLUTE:
break;
#ifdef __i386__
case IMAGE_REL_BASED_HIGH:
*(short *)((char *)page + offset) += HIWORD(delta);
break;
......@@ -2130,7 +2129,7 @@ IMAGE_BASE_RELOCATION * WINAPI LdrProcessRelocationBlock( void *page, UINT count
case IMAGE_REL_BASED_HIGHLOW:
*(int *)((char *)page + offset) += delta;
break;
#elif defined(__x86_64__)
#ifdef __x86_64__
case IMAGE_REL_BASED_DIR64:
*(INT_PTR *)((char *)page + offset) += delta;
break;
......
......@@ -72,6 +72,9 @@ static DWORD (WINAPI *pRtlGetThreadErrorMode)(void);
static NTSTATUS (WINAPI *pRtlSetThreadErrorMode)(DWORD, LPDWORD);
static HMODULE hkernel32 = 0;
static BOOL (WINAPI *pIsWow64Process)(HANDLE, PBOOL);
static IMAGE_BASE_RELOCATION *(WINAPI *pLdrProcessRelocationBlock)(void*,UINT,USHORT*,INT_PTR);
#define LEN 16
static const char* src_src = "This is a test!"; /* 16 bytes long, incl NUL */
static ULONG src_aligned_block[4];
......@@ -107,6 +110,7 @@ static void InitFunctionPtrs(void)
pNtCurrentTeb = (void *)GetProcAddress(hntdll, "NtCurrentTeb");
pRtlGetThreadErrorMode = (void *)GetProcAddress(hntdll, "RtlGetThreadErrorMode");
pRtlSetThreadErrorMode = (void *)GetProcAddress(hntdll, "RtlSetThreadErrorMode");
pLdrProcessRelocationBlock = (void *)GetProcAddress(hntdll, "LdrProcessRelocationBlock");
}
hkernel32 = LoadLibraryA("kernel32.dll");
ok(hkernel32 != 0, "LoadLibrary failed\n");
......@@ -1094,6 +1098,37 @@ static void test_RtlThreadErrorMode(void)
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)
{
InitFunctionPtrs();
......@@ -1114,4 +1149,5 @@ START_TEST(rtl)
test_RtlAllocateAndInitializeSid();
test_RtlDeleteTimer();
test_RtlThreadErrorMode();
test_LdrProcessRelocationBlock();
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment