ntdll: Implemented LdrProcessRelocationBlock.
authorAlexandre Julliard <julliard@winehq.org>
Wed, 2 Apr 2008 18:38:51 +0000 (20:38 +0200)
committerAlexandre Julliard <julliard@winehq.org>
Wed, 2 Apr 2008 18:38:51 +0000 (20:38 +0200)
dlls/ntdll/loader.c
dlls/ntdll/ntdll.spec
include/winternl.h

index 1091c327dc7f324ffd9dce11e75faecd3dbf4502..b0000b8704df6661afc9b7894349d2e369bc11fa 100644 (file)
@@ -2035,6 +2035,41 @@ NTSTATUS WINAPI LdrAddRefDll( ULONG flags, HMODULE module )
 }
 
 
+/***********************************************************************
+ *           LdrProcessRelocationBlock  (NTDLL.@)
+ *
+ * Apply relocations to a given page of a mapped PE image.
+ */
+IMAGE_BASE_RELOCATION * WINAPI LdrProcessRelocationBlock( void *page, UINT count,
+                                                          USHORT *relocs, INT delta )
+{
+    while (count--)
+    {
+        USHORT offset = *relocs & 0xfff;
+        int type = *relocs >> 12;
+        switch(type)
+        {
+        case IMAGE_REL_BASED_ABSOLUTE:
+            break;
+        case IMAGE_REL_BASED_HIGH:
+            *(short *)((char *)page + offset) += HIWORD(delta);
+            break;
+        case IMAGE_REL_BASED_LOW:
+            *(short *)((char *)page + offset) += LOWORD(delta);
+            break;
+        case IMAGE_REL_BASED_HIGHLOW:
+            *(int *)((char *)page + offset) += delta;
+            break;
+        default:
+            FIXME("Unknown/unsupported fixup type %x.\n", type);
+            return NULL;
+        }
+        relocs++;
+    }
+    return (IMAGE_BASE_RELOCATION *)relocs;  /* return address of next block */
+}
+
+
 /******************************************************************
  *             LdrQueryProcessModuleInformation
  *
index 2d27d61ae6d79f34d36d0167ada002836eb0bec1..23ee968da7ceec1a479fa69aef73f01e116ebcd3 100644 (file)
@@ -72,7 +72,7 @@
 @ stub LdrLoadAlternateResourceModule
 @ stdcall LdrLoadDll(wstr long ptr ptr)
 @ stdcall LdrLockLoaderLock(long ptr ptr)
-@ stub LdrProcessRelocationBlock
+@ stdcall LdrProcessRelocationBlock(ptr long ptr long)
 @ stub LdrQueryImageFileExecutionOptions
 @ stdcall LdrQueryProcessModuleInformation(ptr long ptr)
 @ stub LdrSetAppCompatDllRedirectionCallback
index eafbbedab64e9b9e31e6c82b7474ca9e1474cf03..39339c2b77a2ad991adef558c8d8ed13ceb57504 100644 (file)
@@ -1844,6 +1844,7 @@ NTSYSAPI NTSTATUS  WINAPI LdrGetProcedureAddress(HMODULE, const ANSI_STRING*, UL
 NTSYSAPI void      WINAPI LdrInitializeThunk(ULONG,ULONG,ULONG,ULONG);
 NTSYSAPI NTSTATUS  WINAPI LdrLoadDll(LPCWSTR, DWORD, const UNICODE_STRING*, HMODULE*);
 NTSYSAPI NTSTATUS  WINAPI LdrLockLoaderLock(ULONG,ULONG*,ULONG*);
+IMAGE_BASE_RELOCATION * WINAPI LdrProcessRelocationBlock(void*,UINT,USHORT*,INT);
 NTSYSAPI NTSTATUS  WINAPI LdrQueryProcessModuleInformation(SYSTEM_MODULE_INFORMATION*, ULONG, ULONG*);
 NTSYSAPI void      WINAPI LdrShutdownProcess(void);
 NTSYSAPI void      WINAPI LdrShutdownThread(void);