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

commit ee8dbf8e10c923575a69597f581fd2293da54180
Author:     winesync <[email protected]>
AuthorDate: Fri Sep 11 13:00:06 2020 +0200
Commit:     Jérôme Gardou <[email protected]>
CommitDate: Wed Sep 16 10:35:31 2020 +0200

    [WINESYNC] dbghelp: Correctly determine the wine loader base address.
    
    Signed-off-by: Zebediah Figura <[email protected]>
    Signed-off-by: Alexandre Julliard <[email protected]>
    
    wine commit id 185d9ee7ebf56e0663f715e532f2ee2c27289f12 by Zebediah Figura 
<[email protected]>
---
 dll/win32/dbghelp/dbghelp_private.h | 21 +++++++++++++++++++++
 dll/win32/dbghelp/elf_module.c      | 23 +++++++++++++++++++++--
 sdk/tools/winesync/dbghelp.cfg      |  2 +-
 3 files changed, 43 insertions(+), 3 deletions(-)

diff --git a/dll/win32/dbghelp/dbghelp_private.h 
b/dll/win32/dbghelp/dbghelp_private.h
index a78bd156673..24db267a6b6 100644
--- a/dll/win32/dbghelp/dbghelp_private.h
+++ b/dll/win32/dbghelp/dbghelp_private.h
@@ -572,6 +572,27 @@ struct cpu
 
 extern struct cpu*      dbghelp_current_cpu DECLSPEC_HIDDEN;
 
+/* Abbreviated 32-bit PEB */
+typedef struct _PEB32
+{
+    BOOLEAN InheritedAddressSpace;
+    BOOLEAN ReadImageFileExecOptions;
+    BOOLEAN BeingDebugged;
+    BOOLEAN SpareBool;
+    DWORD   Mutant;
+    DWORD   ImageBaseAddress;
+    DWORD   LdrData;
+    DWORD   ProcessParameters;
+    DWORD   SubSystemData;
+    DWORD   ProcessHeap;
+    DWORD   FastPebLock;
+    DWORD   FastPebLockRoutine;
+    DWORD   FastPebUnlockRoutine;
+    ULONG   EnvironmentUpdateCount;
+    DWORD   KernelCallbackTable;
+    ULONG   Reserved[2];
+} PEB32;
+
 /* dbghelp.c */
 extern struct process* process_find_by_handle(HANDLE hProcess) DECLSPEC_HIDDEN;
 extern BOOL         validate_addr64(DWORD64 addr) DECLSPEC_HIDDEN;
diff --git a/dll/win32/dbghelp/elf_module.c b/dll/win32/dbghelp/elf_module.c
index 4d877b44214..e047a7f1ecf 100644
--- a/dll/win32/dbghelp/elf_module.c
+++ b/dll/win32/dbghelp/elf_module.c
@@ -1574,8 +1574,27 @@ static BOOL elf_search_loader(struct process* pcs, 
struct elf_info* elf_info)
     ULONG_PTR base = 0;
     BOOL ret;
 
-    if (!NtQueryInformationProcess( pcs->handle, ProcessBasicInformation, 
&pbi, sizeof(pbi), NULL ))
-        ReadProcessMemory( pcs->handle, &pbi.PebBaseAddress->Reserved[0], 
&base, sizeof(base), NULL );
+    if (NtQueryInformationProcess( pcs->handle, ProcessBasicInformation,
+                                   &pbi, sizeof(pbi), NULL ))
+        return FALSE;
+
+    if (!pcs->is_64bit)
+    {
+        PEB32 *peb32 = (PEB32 *)pbi.PebBaseAddress;
+        DWORD base32;
+
+        if (!ReadProcessMemory( pcs->handle, &peb32->Reserved[0], &base32,
+                                sizeof(base32), NULL ))
+            return FALSE;
+
+        base = base32;
+    }
+    else
+    {
+        if (!ReadProcessMemory( pcs->handle, &pbi.PebBaseAddress->Reserved[0],
+                                &base, sizeof(base), NULL ))
+            return FALSE;
+    }
 
     ret = elf_search_and_load_file(pcs, loader, base, 0, elf_info);
     heap_free(loader);
diff --git a/sdk/tools/winesync/dbghelp.cfg b/sdk/tools/winesync/dbghelp.cfg
index db9fd318575..32f984f570e 100644
--- a/sdk/tools/winesync/dbghelp.cfg
+++ b/sdk/tools/winesync/dbghelp.cfg
@@ -3,4 +3,4 @@ directories:
 files:
   include/dbghelp.h: sdk/include/psdk/dbghelp.h
 tags:
-  wine: a981edf0bc7c828e6b55fdc73b51a2f457043c4a
+  wine: 185d9ee7ebf56e0663f715e532f2ee2c27289f12

Reply via email to