From: Ken Thomases Subject: [PATCH 1/2] ntdll: On Mac, store the dyld image info address in the PEB. (try 2) Message-Id: <013BC400-CC88-4966-BA23-979CF46AB121@codeweavers.com> Date: Wed, 4 Dec 2013 16:07:55 -0600 try 2: fix building with 10.5 SDK, which doesn't support the TASK_DYLD_INFO flavor for task_info() For . --- dlls/ntdll/thread.c | 20 ++++++++++++++++++++ include/winternl.h | 3 ++- 2 files changed, 22 insertions(+), 1 deletions(-) diff --git a/dlls/ntdll/thread.c b/dlls/ntdll/thread.c index 9c34c0c..aea93c6 100644 --- a/dlls/ntdll/thread.c +++ b/dlls/ntdll/thread.c @@ -186,6 +186,23 @@ done: return status; } +#ifdef __APPLE__ +#include +#include + +static ULONG get_dyld_image_info_addr(void) +{ + ULONG ret = 0; +#ifdef TASK_DYLD_INFO + struct task_dyld_info dyld_info; + mach_msg_type_number_t size = TASK_DYLD_INFO_COUNT; + if (task_info(mach_task_self(), TASK_DYLD_INFO, (task_info_t)&dyld_info, &size) == KERN_SUCCESS) + ret = dyld_info.all_image_info_addr; +#endif + return ret; +} +#endif /* __APPLE__ */ + /*********************************************************************** * thread_init * @@ -245,6 +262,9 @@ HANDLE thread_init(void) InitializeListHead( &ldr.InMemoryOrderModuleList ); InitializeListHead( &ldr.InInitializationOrderModuleList ); InitializeListHead( &tls_links ); +#ifdef __APPLE__ + peb->MacDyldImageInfo = get_dyld_image_info_addr(); +#endif /* allocate and initialize the initial TEB */ diff --git a/include/winternl.h b/include/winternl.h index d93b37a..7ef6127 100644 --- a/include/winternl.h +++ b/include/winternl.h @@ -235,7 +235,8 @@ typedef struct _PEB PVOID /*PPEBLOCKROUTINE*/ FastPebUnlockRoutine; /* 024/048 */ ULONG EnvironmentUpdateCount; /* 028/050 */ PVOID KernelCallbackTable; /* 02c/058 */ - ULONG Reserved[2]; /* 030/060 */ + ULONG MacDyldImageInfo; /* 030/060 */ + ULONG Reserved; /* 034/064 */ PVOID /*PPEB_FREE_BLOCK*/ FreeList; /* 038/068 */ ULONG TlsExpansionCounter; /* 03c/070 */ PRTL_BITMAP TlsBitmap; /* 040/078 */