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:
Diffstat (limited to 'runtime/shims/library_loader.cpp')
-rw-r--r--runtime/shims/library_loader.cpp14
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.
222BOOL 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