https://git.reactos.org/?p=reactos.git;a=commitdiff;h=e27e4dbaee71dc7fe527b88b07bc08336ceb6df4

commit e27e4dbaee71dc7fe527b88b07bc08336ceb6df4
Author:     winesync <[email protected]>
AuthorDate: Fri Sep 11 16:53:37 2020 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Wed Sep 16 10:35:43 2020 +0200

    [WINESYNC] dbghelp: Support 32 and 64-bit binaries in 
ImageDirectoryEntryToDataEx.
    
    Signed-off-by: Piotr Caban <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id ab4c64a4093b98ca7a74ec29a9d947333791b26d by Piotr Caban 
<[email protected]>
---
 dll/win32/dbghelp/pe_module.c  | 22 ++++++++++++++++++----
 sdk/tools/winesync/dbghelp.cfg |  2 +-
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/dll/win32/dbghelp/pe_module.c b/dll/win32/dbghelp/pe_module.c
index f458b8aa516..7fcaf27e6c7 100644
--- a/dll/win32/dbghelp/pe_module.c
+++ b/dll/win32/dbghelp/pe_module.c
@@ -896,11 +896,25 @@ PVOID WINAPI ImageDirectoryEntryToDataEx( PVOID base, 
BOOLEAN image, USHORT dir,
     if (section) *section = NULL;
 
     if (!(nt = RtlImageNtHeader( base ))) return NULL;
-    if (dir >= nt->OptionalHeader.NumberOfRvaAndSizes) return NULL;
-    if (!(addr = nt->OptionalHeader.DataDirectory[dir].VirtualAddress)) return 
NULL;
+    if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR64_MAGIC)
+    {
+        const IMAGE_NT_HEADERS64 *nt64 = (const IMAGE_NT_HEADERS64 *)nt;
 
-    *size = nt->OptionalHeader.DataDirectory[dir].Size;
-    if (image || addr < nt->OptionalHeader.SizeOfHeaders) return (char *)base 
+ addr;
+        if (dir >= nt64->OptionalHeader.NumberOfRvaAndSizes) return NULL;
+        if (!(addr = nt64->OptionalHeader.DataDirectory[dir].VirtualAddress)) 
return NULL;
+        *size = nt64->OptionalHeader.DataDirectory[dir].Size;
+        if (image || addr < nt64->OptionalHeader.SizeOfHeaders) return (char 
*)base + addr;
+    }
+    else if (nt->OptionalHeader.Magic == IMAGE_NT_OPTIONAL_HDR32_MAGIC)
+    {
+        const IMAGE_NT_HEADERS32 *nt32 = (const IMAGE_NT_HEADERS32 *)nt;
+
+        if (dir >= nt32->OptionalHeader.NumberOfRvaAndSizes) return NULL;
+        if (!(addr = nt32->OptionalHeader.DataDirectory[dir].VirtualAddress)) 
return NULL;
+        *size = nt32->OptionalHeader.DataDirectory[dir].Size;
+        if (image || addr < nt32->OptionalHeader.SizeOfHeaders) return (char 
*)base + addr;
+    }
+    else return NULL;
 
     return RtlImageRvaToVa( nt, base, addr, section );
 }
diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg
index 3a6c57148d7..dcca9791c8c 100644
--- a/sdk/tools/winesync/dbghelp.cfg
+++ b/sdk/tools/winesync/dbghelp.cfg
@@ -4,4 +4,4 @@ files:
   include/dbghelp.h: sdk/include/psdk/dbghelp.h
   include/wine/mscvpdb.h: sdk/include/reactos/wine/mscvpdb.h
 tags:
-  wine: 8000b5415d2c249176bda3d8b49f8fc9978e1623
+  wine: ab4c64a4093b98ca7a74ec29a9d947333791b26d

Reply via email to