mirror of
https://github.com/ProjectLeonida/mandy.git
synced 2026-12-06 23:08:36 +00:00
Two bugs from kevincommits' finding in #1608 (item 2): - module_name() and module_name_w() stripped the directory and then added ".dll" when no '.' was left, so "" and a path ending in a slash came out as ".dll". That passed every `dll.empty()` guard and went to the bundled loader's lookups as a module name. Both now return an empty name there. - host_module_name() caches HMODULE -> module name for GetProcAddress on host modules, and free_library() never removed the entry. A DLL loaded later at the same base was then served the freed module's shims. free_library() now erases the entry when FreeLibrary succeeds; a module that is still loaded is looked up again on the next call. New test library_loader_names: a fake bundled loader records the names it is asked for, and a fixture DLL with no relocations at a fixed base is loaded as wsock32.dll (a shimmed host module), freed, and loaded again under a plain name at the same base. Both checks fail on main. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
15 lines
617 B
C++
15 lines
617 B
C++
// A DLL with no relocations, linked /FIXED at one base: every copy of it loads at that address, so a test can load one
|
|
// copy, free it and get the next copy at the same HMODULE (library_loader_names_test). Built without the CRT; it does
|
|
// nothing and exports nothing. No game data.
|
|
#include <windows.h>
|
|
|
|
#ifdef __MSVC_RUNTIME_CHECKS
|
|
// Debug builds compile with /RTC1, whose checks call into the CRT; /NODEFAULTLIB leaves them unresolved.
|
|
extern "C" {
|
|
void __cdecl _RTC_InitBase() {}
|
|
void __cdecl _RTC_Shutdown() {}
|
|
}
|
|
#endif
|
|
|
|
extern "C" BOOL WINAPI fixed_base_probe_main(HINSTANCE, DWORD, LPVOID) { return TRUE; }
|