dbghelp: For Mach-O, get the address of the process's image info from its PEB.

This commit is contained in:
Ken Thomases 2013-12-04 16:08:06 -06:00 committed by Alexandre Julliard
parent 22cf68e1bc
commit 1577fb6c3f

View File

@ -24,6 +24,8 @@
#include "config.h"
#include "wine/port.h"
#include "ntstatus.h"
#define WIN32_NO_STATUS
#include "dbghelp_private.h"
#ifdef HAVE_MACH_O_LOADER_H
@ -963,10 +965,36 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename,
/* Find the dynamic loader's table of images loaded into the process.
*/
if (macho_info->flags & MACHO_INFO_DEBUG_HEADER)
{
PROCESS_BASIC_INFORMATION pbi;
NTSTATUS status;
ret = FALSE;
/* Get address of PEB */
status = NtQueryInformationProcess(pcs->handle, ProcessBasicInformation,
&pbi, sizeof(pbi), NULL);
if (status == STATUS_SUCCESS)
{
ULONG dyld_image_info;
/* Read dyld image info address from PEB */
if (ReadProcessMemory(pcs->handle, &pbi.PebBaseAddress->Reserved,
&dyld_image_info, sizeof(dyld_image_info), NULL))
{
TRACE("got dyld_image_info 0x%08x from PEB %p MacDyldImageInfo %p\n",
dyld_image_info, pbi.PebBaseAddress, &pbi.PebBaseAddress->Reserved);
macho_info->dbg_hdr_addr = dyld_image_info;
ret = TRUE;
}
}
if (!ret)
{
static void* dyld_all_image_infos_addr;
/* This symbol should be in the same place in all processes. */
/* Our next best guess is that dyld was loaded at its base address
and we can find the dyld image infos address by looking up its symbol. */
if (!dyld_all_image_infos_addr)
{
struct nlist nl[2];
@ -977,10 +1005,13 @@ static BOOL macho_load_file(struct process* pcs, const WCHAR* filename,
}
if (dyld_all_image_infos_addr)
{
TRACE("got dyld_image_info %p from /usr/lib/dyld symbol table\n",
dyld_all_image_infos_addr);
macho_info->dbg_hdr_addr = (unsigned long)dyld_all_image_infos_addr;
else
ret = FALSE;
TRACE("dbg_hdr_addr = 0x%08lx\n", macho_info->dbg_hdr_addr);
ret = TRUE;
}
}
}
if (macho_info->flags & MACHO_INFO_MODULE)