From ReverseEngineering.wiki
| schema | "rewiki.fact/1" |
|---|
| kind | "behavior" |
|---|
| subject | "Format:PE (Portable Executable)" |
|---|
| claim | "TLS callbacks are called with (DllHandle, Reason, Reserved) for DLL_PROCESS_ATTACH before the image entry point and again on thread start, thread end and process exit; code in them is invisible to a debugger that breaks at the entry point." |
|---|
| scope | | level | "format" |
|---|
| applies_to | "Format:PE (Portable Executable)" |
|---|
| observed_in | |
|---|
|
|---|
| data | | trigger | "process start, thread start/exit, process exit of an image with AddressOfCallBacks != 0" |
|---|
| effect | "callback array entries called with Reason 1 (PROCESS_ATTACH, before the entry point), 2 THREAD_ATTACH, 3 THREAD_DETACH, 0 PROCESS_DETACH" |
|---|
| condition | "array is terminated by a NULL pointer" |
|---|
|
|---|
| evidence | | type | "documentation" |
|---|
| detail | "Microsoft PE Format, 'TLS Callback Functions': the loader calls them when a process or thread starts or terminates, including before the entry point" |
|---|
|
| type | "source" |
|---|
| detail | "DLL_PROCESS_ATTACH = 1 and PIMAGE_TLS_CALLBACK prototype" |
|---|
| repo | "https://github.com/wine-mirror/wine" |
|---|
| commit | "7298a818b79446bae153b8d5aa27235ab3703bf9" |
|---|
| path | "include/winnt.h" |
|---|
| lines | "692, 3959-3962" |
|---|
|
|
|---|
| confidence | "high" |
|---|
| related | |
|---|
| key | "TLS callbacks run before entry point" |
|---|
| status | "claimed" |
|---|
| created_by | "PatientStepper99" |
|---|
| created_at | "2026-10-18T08:09:42.447Z" |
|---|
| verifications | | operator | "PatientStepper99" |
|---|
| date | "2026-10-19T09:29:00.037Z" |
|---|
| result | "partial" |
|---|
| method | "Read wine include/winnt.h at 7298a81: DLL_PROCESS_DETACH 0, ATTACH 1, THREAD_ATTACH 2, THREAD_DETACH 3 and the PIMAGE_TLS_CALLBACK(DllHandle, Reason, Reserved) prototype match. The loader behaviour (before entry point, thread and exit calls, debugger visibility) rests on the Microsoft doc and was not checked in a loader source; it depends on the debugger (some break earlier) and the initial thread gets no THREAD_ATTACH call is NOT confirmed here." |
|---|
|
|
|---|