Repository navigation
Conversation
on_tls_event ran the TLS callbacks of every registered module on each DLL_THREAD_ATTACH / DETACH, and checked `initialized` only before DllMain. A game DLL is registered, and its TLS callbacks read, before its pages get their protections and before its PROCESS_ATTACH (init_dll). So when the title LoadLibrary's a game DLL while another of its threads starts or ends, that DLL's callback can run on code that is not executable yet (a DEP fault) or before the DLL's runtime has set itself up. Windows' loader sends thread notifications only to modules whose process attach has run. The module loop is now thread_event, which skips DLLs that are not initialised for both callbacks and DllMain; the executable, which never sets the flag, still gets its callbacks. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Owner
Author
|
Upstream PR xcl-dev#1119 was closed or merged. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
loader::on_tls_eventran the TLS callbacks of every registered module on eachDLL_THREAD_ATTACH/DETACH, and checkedinitializedonly before calling DllMain. A game DLL is registered, and its TLS callbacks are read (map_image_exstep 5), before its pages get their protections (step 6) and before its PROCESS_ATTACH (init_dll).So if the title
LoadLibrarys a game DLL with TLS callbacks while another of its threads starts or ends, that DLL's callback can run:0xc0000005);Windows' loader sends thread notifications only to modules whose process attach has run.
What is in it
crates/xcl/src/loader.rs:on_tls_eventis nowthread_event;initialized, still gets its callbacks;thread_callbacks_wait_for_a_dll_to_be_initialised:left: 5, right: 0(both callbacks ran).Tested
x86_64-pc-windows-msvc; DXC 1.9.2602.17; debug for the suite, release for the runs.cargo test --workspace -- --test-threads=4at df36761: 742 passed, 0 failed, 41 ignored; noSKIPPEDlines.Regression run
The
gpu:line names a virtual display adapter of this machine (what #281 / #282 / #285 fix); XCL's log namesbackend 'real' – AMD Radeon RX 9060 XT (16188 MiB VRAM).main:
PR:
Not tested
AI use
map_image_ex/init_dll/on_tls_event;🤖 Generated with Claude Code
Mirror of xcl-dev#1119 (auto-synced, do not edit).