diff options
| author | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 23:08:12 -0500 |
|---|---|---|
| committer | ItsNotRexed <300290919+ItsNotRexed@users.noreply.github.com> | 2026-11-22 23:08:12 -0500 |
| commit | 44d705ce4b34002c61cb65786c4faaffde08d1f2 (patch) | |
| tree | f9657f02bd83bd151ab999640b7d9a32b448e925 /runtime/src/pe_loader.h | |
| parent | 210813af2a1e628f7bcba57a69cf486abe81962b (diff) | |
| parent | 2fb013cd9b6ac1062625fbdb556cd1535db008f1 (diff) | |
Merge pull request #3671 from kotorvr
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/src/pe_loader.h')
| -rw-r--r-- | runtime/src/pe_loader.h | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/runtime/src/pe_loader.h b/runtime/src/pe_loader.h index d7e5be91c..57962c9b4 100644 --- a/runtime/src/pe_loader.h +++ b/runtime/src/pe_loader.h | |||
| @@ -50,7 +50,8 @@ struct Module { | |||
| 50 | // __declspec(thread) reads; it is not a TlsAlloc slot. The loader reserves distinct indices by loading | 50 | // __declspec(thread) reads; it is not a TlsAlloc slot. The loader reserves distinct indices by loading |
| 51 | // gta6rt_tls_host.dll (and cloning it on demand for additional simultaneous TLS modules, up to 16 at a time). | 51 | // gta6rt_tls_host.dll (and cloning it on demand for additional simultaneous TLS modules, up to 16 at a time). |
| 52 | // Every thread started after load() gets its own copy through the helper's DLL_THREAD_ATTACH, and gives it back | 52 | // Every thread started after load() gets its own copy through the helper's DLL_THREAD_ATTACH, and gives it back |
| 53 | // at DLL_THREAD_DETACH; install_tls_for_thread() is for threads that already existed. | 53 | // at DLL_THREAD_DETACH. A thread that was already running gets its copy from load() itself, as it would from |
| 54 | // Windows for a DLL Windows loads: a block, no DLL_THREAD_ATTACH, and DLL_THREAD_DETACH when it ends. | ||
| 54 | uint32_t tls_index = kNoTlsIndex; | 55 | uint32_t tls_index = kNoTlsIndex; |
| 55 | uint32_t tls_slot = kNoTlsIndex; // index into the loader's reserved TLS-host slot pool | 56 | uint32_t tls_slot = kNoTlsIndex; // index into the loader's reserved TLS-host slot pool |
| 56 | uint64_t tls_generation = 0; // unique token per TLS initialisation, distinguishing reused slots/addresses | 57 | uint64_t tls_generation = 0; // unique token per TLS initialisation, distinguishing reused slots/addresses |
| @@ -104,11 +105,11 @@ public: | |||
| 104 | void run_tls_callbacks(Module& m, uint32_t reason); | 105 | void run_tls_callbacks(Module& m, uint32_t reason); |
| 105 | 106 | ||
| 106 | // Installs/removes this module's template copy in the calling thread's TEB slot. load() does this for its caller | 107 | // Installs/removes this module's template copy in the calling thread's TEB slot. load() does this for its caller |
| 107 | // and the thread events for threads started after it; both are no-ops on a thread that already has this module's | 108 | // and for every other thread running at the time, and the thread events for threads started after it, so on any |
| 108 | // copy. Call install on a thread that existed before load(), before mapped code runs there, and uninstall before | 109 | // of those both are no-ops. They remain for a thread load() could not reach (pe_loader.cpp, "Threads that |
| 109 | // that thread exits. Each module's copy sits in its own TEB slot, so one thread can hold copies of several | 110 | // existed before load()", lists the cases): install before mapped code runs there, uninstall before the thread |
| 110 | // modules. These do not run TLS callbacks (use | 111 | // exits. Each module's copy sits in its own TEB slot, so one thread can hold copies of several modules. These do |
| 111 | // run_tls_callbacks with DLL_THREAD_ATTACH/DETACH for that). | 112 | // not run TLS callbacks (use run_tls_callbacks with DLL_THREAD_ATTACH/DETACH for that). |
| 112 | void install_tls_for_thread(Module& m); | 113 | void install_tls_for_thread(Module& m); |
| 113 | void uninstall_tls_for_thread(Module& m); | 114 | void uninstall_tls_for_thread(Module& m); |
| 114 | 115 | ||