upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
path: root/runtime/shims/library_loader.cpp
diff options
context:
space:
mode:
authorSc4ros <353102343+Sc4ros@users.noreply.github.com>2026-11-22 18:23:23 +0100
committerSc4ros <353102343+Sc4ros@users.noreply.github.com>2026-11-22 18:23:23 +0100
commit5620a444ad6536e6f3d3447b711c98019d6d93a2 (patch)
tree8b47c9c2fb37c01f359de5f073381dd587636e11 /runtime/shims/library_loader.cpp
parent4c9d995b2632d83480d8bb37965426958b4e47b9 (diff)
Runtime: review fixes for DisableThreadLibraryCalls
- the DisableThreadLibraryCalls table entry gets its own continued line (it shared FreeLibrary's, 231 columns wide), and its comment is wrapped to 120; - dll_thread_calls_test also calls the shim with a shim pseudo-handle (the handle GetModuleHandleA("xmem.dll") returns), which the Windows function would refuse: removing the pseudo(module) branch now fails the test. xmem.cpp is linked into the test only to give the shims a module to own. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Diffstat (limited to 'runtime/shims/library_loader.cpp')
-rw-r--r--runtime/shims/library_loader.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/runtime/shims/library_loader.cpp b/runtime/shims/library_loader.cpp
index 2740089c9..1aaa7c142 100644
--- a/runtime/shims/library_loader.cpp
+++ b/runtime/shims/library_loader.cpp
@@ -214,9 +214,10 @@ BOOL WINAPI free_library(HMODULE module) {
214} 214}
215 215
216// DisableThreadLibraryCalls(hinstance) from a mapped image's DllMain. The real function only accepts a module the 216// DisableThreadLibraryCalls(hinstance) from a mapped image's DllMain. The real function only accepts a module the
217// Windows loader mapped, so for ours it fails, and a DllMain that returns its result (the MSVC runtime's satellite DLLs 217// Windows loader mapped, so for ours it fails, and a DllMain that returns its result (the MSVC runtime's satellite
218// do) fails Loader::initialise() with "DllMain returned FALSE". Owned and mapped modules answer TRUE. The loader sends 218// DLLs do) fails Loader::initialise() with "DllMain returned FALSE". Owned and mapped modules answer TRUE. The loader
219// no thread events to a DllMain, so there is nothing further to switch off; every other handle goes to the real function. 219// sends no thread events to a DllMain, so there is nothing further to switch off; every other handle goes to the
220// real function.
220BOOL WINAPI disable_thread_calls(HMODULE module) { 221BOOL WINAPI disable_thread_calls(HMODULE module) {
221 if (pseudo(module)) return TRUE; 222 if (pseudo(module)) return TRUE;
222 if (owns_bundled_module_handle(module)) return TRUE; 223 if (owns_bundled_module_handle(module)) return TRUE;
@@ -231,7 +232,8 @@ BOOL WINAPI disable_thread_calls(HMODULE module) {
231 {dll, "GetModuleHandleA", reinterpret_cast<void*>(&rt::shims::library_loader::get_module_handle_a)}, \ 232 {dll, "GetModuleHandleA", reinterpret_cast<void*>(&rt::shims::library_loader::get_module_handle_a)}, \
232 {dll, "GetModuleHandleW", reinterpret_cast<void*>(&rt::shims::library_loader::get_module_handle_w)}, \ 233 {dll, "GetModuleHandleW", reinterpret_cast<void*>(&rt::shims::library_loader::get_module_handle_w)}, \
233 {dll, "GetProcAddress", reinterpret_cast<void*>(&rt::shims::library_loader::get_proc_address)}, \ 234 {dll, "GetProcAddress", reinterpret_cast<void*>(&rt::shims::library_loader::get_proc_address)}, \
234 {dll, "FreeLibrary", reinterpret_cast<void*>(&rt::shims::library_loader::free_library)}, {dll, "DisableThreadLibraryCalls", reinterpret_cast<void*>(&rt::shims::library_loader::disable_thread_calls)} 235 {dll, "FreeLibrary", reinterpret_cast<void*>(&rt::shims::library_loader::free_library)}, \
236 {dll, "DisableThreadLibraryCalls", reinterpret_cast<void*>(&rt::shims::library_loader::disable_thread_calls)}
235 237
236} // namespace 238} // namespace
237} // namespace rt::shims::library_loader 239} // namespace rt::shims::library_loader