Jacek Caban : ntdll: IMAGE_REL_BASED_HIGH, IMAGE_REL_BASED_LOW and IMAGE_REL_BASED_HIGHLOW should be supported on win64 .

Alexandre Julliard julliard at winehq.org
Fri Aug 20 10:19:11 CDT 2010


Module: wine
Branch: master
Commit: 9713d62e89997eae0a9ebcc50f4e738b04cd2835
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=9713d62e89997eae0a9ebcc50f4e738b04cd2835

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Thu Aug 19 20:07:01 2010 +0200

ntdll: IMAGE_REL_BASED_HIGH, IMAGE_REL_BASED_LOW and IMAGE_REL_BASED_HIGHLOW should be supported on win64.

---

 dlls/ntdll/loader.c    |    3 +--
 dlls/ntdll/tests/rtl.c |   36 ++++++++++++++++++++++++++++++++++++
 2 files changed, 37 insertions(+), 2 deletions(-)

diff --git a/dlls/ntdll/loader.c b/dlls/ntdll/loader.c
index 4a2641b..79ae817 100644
--- a/dlls/ntdll/loader.c
+++ b/dlls/ntdll/loader.c
@@ -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;
diff --git a/dlls/ntdll/tests/rtl.c b/dlls/ntdll/tests/rtl.c
index 6e76a3c..8a83feb 100644
--- a/dlls/ntdll/tests/rtl.c
+++ b/dlls/ntdll/tests/rtl.c
@@ -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();
 }




More information about the wine-cvs mailing list