[PATCH v2 3/3] dbghelp: Correctly determine the wine loader base address.
Zebediah Figura
zfigura at codeweavers.com
Thu May 31 09:47:50 CDT 2018
Signed-off-by: Zebediah Figura <zfigura at codeweavers.com>
---
dlls/dbghelp/dbghelp_private.h | 21 +++++++++++++++++++++
dlls/dbghelp/elf_module.c | 23 +++++++++++++++++++++--
2 files changed, 42 insertions(+), 2 deletions(-)
diff --git a/dlls/dbghelp/dbghelp_private.h b/dlls/dbghelp/dbghelp_private.h
index 3c1b3dd..935e766 100644
--- a/dlls/dbghelp/dbghelp_private.h
+++ b/dlls/dbghelp/dbghelp_private.h
@@ -542,6 +542,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/dlls/dbghelp/elf_module.c b/dlls/dbghelp/elf_module.c
index 4d877b4..e047a7f 100644
--- a/dlls/dbghelp/elf_module.c
+++ b/dlls/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);
--
2.7.4
More information about the wine-devel
mailing list