Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the filename of a DLL?

Tags:

c++

windows

dll

I have a C++ Windows application myapp.exe which loads several plug-ins.

Plug-ins need to find the path to their DLLs. I can use GetModuleFileName for this, but it need the handle for the plug-in DLL. I don't know where to get this handle. GetModuleHandle(NULL) returns the handle to the executable.

One option is to use GetModuleHandle (GetModuleHandle("myplugin.dll") ) , but this requires the name of the plugin to be hardcoded which I want to avoid.

Any help is appreciated.

Paul

like image 583
Paul Baumer Avatar asked May 10 '09 20:05

Paul Baumer


People also ask

How do I find the path of a DLL file?

Your DLL files are located in C:\Windows\System32. When Windows Defender runs a Full Scan, it includes that directory and so all of your DLLs will be scanned. This will scan your DLL files for any malware infections.


1 Answers

I don't know where to get this handle

It's passed as a parameter to your DLLMain() entry function.

If the plugin can't access its DLLMain() entry function, it can use the VirtualQuery function on a piece of its own memory and use the AllocationBase field of the filled-in MEMORY_BASIC_INFORMATION structure as its HMODULE.

like image 123
ChrisW Avatar answered Sep 28 '22 09:09

ChrisW