This is my code inside the LoadLibraryACallback function:
Code: Select all
DWORD WINAPI LoadLibraryACallback (LPCSTR lpLibFileName)
{
TCHAR szCallingDLLPath[MAX_PATH];
HMODULE hCallingModule = (HMODULE) GetCallingModule();
GetModuleFileName ( hCallingModule, szCallingDLLPath, sizeof(szCallingDLLPath) );
LPTSTR mCallingModuleFilename = PathFindFileName(szCallingDLLPath);
if (lstrcmpi("TEST.EXE",mCallingModuleFilename)==0)
{
char dta [MAX_PATH + 1];
lstrcpyA(dta, "E2:");
lstrcatA(dta, ", ");
lstrcatA(dta, lpLibFileName);
lstrcatA(dta, ", ");
lstrcatA(dta, szCallingDLLPath);
lstrcatA(dta, ", ");
lstrcatA(dta, mCallingModuleFilename);
... and so on
The above was working, but now is returning the module path of the current process.
Checking with the example loadlibrary dll Madshi put in the demo folder, it should be returning something else.
Taken from the log file of the example .dll madshi made for loadlibrary hook:
Test.exe kernel32.dll LoadLibraryExA: $61dd0000 flags: - lib: "MCD32.DLL"
Test.exe Test.exe LoadLibraryA: $61dd0000 flags: - lib: "MCD32.DLL" <<<<I WANT THIS LINE ONLY (notice the 2nd Test.exe!!
Test.exe HookLoadLibrary.dll LoadLibraryExW: $5ed00000 flags: - lib: "USER32.dll"
The above shows 2 test.exe's the first being the process itself, the second being the calling module. The code i made should have filtered this line, and DID, now it doesnt.. maybe ive added something to the c++ project??
Any ideas?
many thanks,
Jon