dbghelp: Correctly determine the wine loader base address.

Signed-off-by: Zebediah Figura <zfigura@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Zebediah Figura 2018-05-31 09:47:50 -05:00 committed by Alexandre Julliard
parent a981edf0bc
commit 185d9ee7eb
2 changed files with 42 additions and 2 deletions

View File

@ -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;

View File

@ -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);