diff --git a/dlls/dbghelp/image_private.h b/dlls/dbghelp/image_private.h index 9990850b8f3..a29794ef582 100644 --- a/dlls/dbghelp/image_private.h +++ b/dlls/dbghelp/image_private.h @@ -89,6 +89,7 @@ struct image_file_map #ifdef HAVE_MACH_O_LOADER_H struct mach_header mach_header; + size_t header_size; /* size of real header in file */ const struct load_command* load_commands; const struct uuid_command* uuid; diff --git a/dlls/dbghelp/macho_module.c b/dlls/dbghelp/macho_module.c index 9401dfb0c78..05130b7de8d 100644 --- a/dlls/dbghelp/macho_module.c +++ b/dlls/dbghelp/macho_module.c @@ -415,7 +415,7 @@ static const struct load_command* macho_map_load_commands(struct macho_file_map* if (fmap->load_commands == IMAGE_NO_MAP) { fmap->load_commands = (const struct load_command*) macho_map_range( - fmap, sizeof(fmap->mach_header), fmap->mach_header.sizeofcmds, NULL); + fmap, fmap->header_size, fmap->mach_header.sizeofcmds, NULL); TRACE("Mapped load commands: %p\n", fmap->load_commands); } @@ -433,7 +433,7 @@ static void macho_unmap_load_commands(struct macho_file_map* fmap) { TRACE("Unmapping load commands: %p\n", fmap->load_commands); macho_unmap_range(NULL, (const void**)&fmap->load_commands, fmap, - sizeof(fmap->mach_header), fmap->mach_header.sizeofcmds); + fmap->header_size, fmap->mach_header.sizeofcmds); } } @@ -666,6 +666,7 @@ static BOOL macho_map_file(struct process *pcs, const WCHAR *filenameW, ifm->modtype = DMT_MACHO; ifm->addr_size = (pcs->is_64bit) ? 64 : 32; + fmap->header_size = (pcs->is_64bit) ? sizeof(struct mach_header_64) : sizeof(struct mach_header); len = WideCharToMultiByte(CP_UNIXCP, 0, filenameW, -1, NULL, 0, NULL, NULL); if (!(filename = HeapAlloc(GetProcessHeap(), 0, len)))