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>