zig/lib/std/os/windows
Alex Rønne Petersen cb1fffb29e
std.os.windows.tls: Set AddressOfCallBacks to &__xl_a + 1.
`__xl_a` is just a global variable containing a null function pointer. There's
nothing magical about it or its name at all.

The section names used on `__xl_a` and `__xl_b` (`.CRT$XLA` and `.CRT$XLZ`) are
the real magic here. The compiler emits TLS variables into `.CRT$XL<x>`
sections, where `x` is an uppercase letter between A and Z (exclusive). The
linker then sorts those sections alphabetically (due to the `$`), and the result
is a neat array of TLS initialization callbacks between `__xl_a` and `__xl_z`.

That array is null-terminated, though! Normally, `__xl_z` serves as the null
terminator; however, by pointing `AddressesOfCallBacks` to `__xl_a`, which just
contains a null function pointer, we've effectively made it so that the PE
loader will just immediately stop invoking TLS callbacks. Fix that by pointing
to the first actual TLS callback instead (or `__xl_z` if there are none).
2024-08-03 20:55:00 +02:00
..
advapi32.zig std.os.windows.advapi32: add RegLoadAppKeyW 2023-07-23 17:10:57 +06:00
crypt32.zig clean up windows cert scanning 2023-01-17 00:08:42 -07:00
kernel32.zig Fix compile error due to GetModuleFileNameW binding change 2024-07-29 16:06:36 -07:00
lang.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
nls.zig Add os.windows.nls.upcaseW, a cross-platform implementation of RtlUpcaseUnicodeChar 2023-06-30 15:29:43 -07:00
ntdll.zig Windows: Replace CreatePipe with ntdll implementation 2024-03-16 23:37:50 +11:00
ntstatus.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
sublang.zig remove redundant license headers from zig standard library 2021-08-24 12:25:09 -07:00
test.zig std: Convert deprecated aliases to compile errors and fix usages 2024-06-13 10:18:59 -04:00
tls.zig std.os.windows.tls: Set AddressOfCallBacks to &__xl_a + 1. 2024-08-03 20:55:00 +02:00
win32error.zig os.windows: Fix error 258 name in Win32Error 2024-01-23 18:06:23 -08:00
ws2_32.zig std.c reorganization 2024-07-19 00:30:32 -07:00