Alexandre Julliard : libwine: Also apply the load delta to the FirstThunk table.

Alexandre Julliard julliard at winehq.org
Mon Sep 18 14:43:48 CDT 2017


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

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Mon Sep 18 15:41:43 2017 +0200

libwine: Also apply the load delta to the FirstThunk table.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 libs/wine/loader.c | 21 +++++++++++++--------
 1 file changed, 13 insertions(+), 8 deletions(-)

diff --git a/libs/wine/loader.c b/libs/wine/loader.c
index 172bfa0..c07042a 100644
--- a/libs/wine/loader.c
+++ b/libs/wine/loader.c
@@ -320,22 +320,27 @@ static inline void fixup_rva_dwords( DWORD *ptr, int delta, unsigned int count )
 }
 
 
+/* fixup an array of name/ordinal RVAs by adding the specified delta */
+static inline void fixup_rva_names( UINT_PTR *ptr, int delta )
+{
+    while (*ptr)
+    {
+        if (!(*ptr & IMAGE_ORDINAL_FLAG)) *ptr += delta;
+        ptr++;
+    }
+}
+
+
 /* fixup RVAs in the import directory */
 static void fixup_imports( IMAGE_IMPORT_DESCRIPTOR *dir, BYTE *base, int delta )
 {
-    UINT_PTR *ptr;
-
     while (dir->Name)
     {
         fixup_rva_dwords( &dir->u.OriginalFirstThunk, delta, 1 );
         fixup_rva_dwords( &dir->Name, delta, 1 );
         fixup_rva_dwords( &dir->FirstThunk, delta, 1 );
-        ptr = (UINT_PTR *)(base + (dir->u.OriginalFirstThunk ? dir->u.OriginalFirstThunk : dir->FirstThunk));
-        while (*ptr)
-        {
-            if (!(*ptr & IMAGE_ORDINAL_FLAG)) *ptr += delta;
-            ptr++;
-        }
+        if (dir->u.OriginalFirstThunk) fixup_rva_names( (UINT_PTR *)(base + dir->u.OriginalFirstThunk), delta );
+        if (dir->FirstThunk) fixup_rva_names( (UINT_PTR *)(base + dir->FirstThunk), delta );
         dir++;
     }
 }




More information about the wine-cvs mailing list