Can a process load two DLLs with the exact same name?

MSDN interpretation reference :

Dynamic link library search order

...

If a DLL with the same module name is already loaded into memory, the system only checks the redirection and manifest before resolving the loaded DLL, no matter what directory it is in. The system does not look for the DLL.

Note. Multiple DLLs with the same name are basically a bad idea, it's just to get a better image.

Consider:

...\x\foo.exe
...\x\a\bar.dll ~ no further dependencies
...\x\b\bar.dll ~ no further dependencies

      

Is it possible to load both of these bar.dll

in foo.exe

with explicit calls to the load library? And where / how is it documented and maintained (otherwise I'll just try.)

That is, will it work reliably on Windows7 +:

// Load using full path:
HANDLE a_mod = LoadLibrary(L"...\x\a\bar.dll");
HANDLE b_mod = LoadLibrary(L"...\x\b\bar.dll");
// now use moth DLLs ...

      

+3


source to share


1 answer


From the documentation (emphasis mine):

Desktop applications can control the location from which the DLL is loaded by specifying the full path using DLL redirection or using a manifest. If none of these methods are used, the system looks for the DLL at boot time, as described in this section.

Before the system looks for a DLL, it checks for the following:

  • If a DLL with the same module name is already loaded into memory, the system uses the loaded DLL, no matter what directory it is in. The system is not looking for a DLL.


So, the sentence you're worried about doesn't apply when the full path is provided.

+4


source







All Articles