• Ken Thomases's avatar
    ntdll: For Mac 64-bit, poke NtCurrentTeb()->ThreadLocalStoragePointer to the… · 3d8efb23
    Ken Thomases authored
    ntdll: For Mac 64-bit, poke NtCurrentTeb()->ThreadLocalStoragePointer to the corresponding offset from %gs.
    
    64-bit Windows apps have hard-coded accesses to %gs:0x58 baked into them.  They
    need to find the ThreadLocalStoragePointer there.
    
    Technically, the gsbase register and the memory it points to belong to the
    pthread implementation on macOS.  It's used for the pthread TLS implementation.
    Slot 11 (offset 0x58) is currently used for the implementation of the ttyname()
    system library function.  We do not anticipate that Wine or any of the system
    libraries or frameworks it uses will call ttyname().  Furthermore, Apple has
    made it so that future releases of macOS will no longer use that slot.  So, we
    hijack it for our purposes.
    Signed-off-by: 's avatarKen Thomases <ken@codeweavers.com>
    Signed-off-by: 's avatarAlexandre Julliard <julliard@winehq.org>
    3d8efb23
loader.c 113 KB