diff options
| author | lumenpearson <139921639+lumenpearson@users.noreply.github.com> | 2026-11-22 23:25:25 +0300 |
|---|---|---|
| committer | lumenpearson <139921639+lumenpearson@users.noreply.github.com> | 2026-11-22 23:25:25 +0300 |
| commit | f324bfbc71f0eabf9515bcd7c8b7c9e4b89448bf (patch) | |
| tree | 2db4ae6fd5412abbbc3e1894f8bc7ed88c8ae514 /runtime/shims/library_loader.cpp | |
| parent | 18380c6d2baf1422109b369860a6e8be5e185b05 (diff) | |
| parent | f847748cc76bd3777f9c070c4034eb2fc1c04e64 (diff) | |
Merge upstream main into SHADER-537
Diffstat (limited to 'runtime/shims/library_loader.cpp')
| -rw-r--r-- | runtime/shims/library_loader.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/runtime/shims/library_loader.cpp b/runtime/shims/library_loader.cpp index 0093e6050..66feefb9b 100644 --- a/runtime/shims/library_loader.cpp +++ b/runtime/shims/library_loader.cpp | |||
| @@ -214,6 +214,17 @@ BOOL WINAPI free_library(HMODULE module) { | |||
| 214 | return FreeLibrary(module); | 214 | return FreeLibrary(module); |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | // DisableThreadLibraryCalls(hinstance) from a mapped image's DllMain. The real function only accepts a module the | ||
| 218 | // Windows loader mapped, so for ours it fails, and a DllMain that returns its result (the MSVC runtime's satellite | ||
| 219 | // DLLs do) fails Loader::initialise() with "DllMain returned FALSE". Owned and mapped modules answer TRUE. The loader | ||
| 220 | // sends no thread events to a DllMain, so there is nothing further to switch off; every other handle goes to the | ||
| 221 | // real function. | ||
| 222 | BOOL WINAPI disable_thread_calls(HMODULE module) { | ||
| 223 | if (pseudo(module)) return TRUE; | ||
| 224 | if (owns_bundled_module_handle(module)) return TRUE; | ||
| 225 | return DisableThreadLibraryCalls(module); | ||
| 226 | } | ||
| 227 | |||
| 217 | #define LOADER(dll) \ | 228 | #define LOADER(dll) \ |
| 218 | {dll, "LoadLibraryA", reinterpret_cast<void*>(&rt::shims::library_loader::load_library_a)}, \ | 229 | {dll, "LoadLibraryA", reinterpret_cast<void*>(&rt::shims::library_loader::load_library_a)}, \ |
| 219 | {dll, "LoadLibraryW", reinterpret_cast<void*>(&rt::shims::library_loader::load_library_w)}, \ | 230 | {dll, "LoadLibraryW", reinterpret_cast<void*>(&rt::shims::library_loader::load_library_w)}, \ |
| @@ -222,7 +233,8 @@ BOOL WINAPI free_library(HMODULE module) { | |||
| 222 | {dll, "GetModuleHandleA", reinterpret_cast<void*>(&rt::shims::library_loader::get_module_handle_a)}, \ | 233 | {dll, "GetModuleHandleA", reinterpret_cast<void*>(&rt::shims::library_loader::get_module_handle_a)}, \ |
| 223 | {dll, "GetModuleHandleW", reinterpret_cast<void*>(&rt::shims::library_loader::get_module_handle_w)}, \ | 234 | {dll, "GetModuleHandleW", reinterpret_cast<void*>(&rt::shims::library_loader::get_module_handle_w)}, \ |
| 224 | {dll, "GetProcAddress", reinterpret_cast<void*>(&rt::shims::library_loader::get_proc_address)}, \ | 235 | {dll, "GetProcAddress", reinterpret_cast<void*>(&rt::shims::library_loader::get_proc_address)}, \ |
| 225 | {dll, "FreeLibrary", reinterpret_cast<void*>(&rt::shims::library_loader::free_library)} | 236 | {dll, "FreeLibrary", reinterpret_cast<void*>(&rt::shims::library_loader::free_library)}, \ |
| 237 | {dll, "DisableThreadLibraryCalls", reinterpret_cast<void*>(&rt::shims::library_loader::disable_thread_calls)} | ||
| 226 | 238 | ||
| 227 | } // namespace | 239 | } // namespace |
| 228 | } // namespace rt::shims::library_loader | 240 | } // namespace rt::shims::library_loader |