I have a very basic project which hooks ShellExecuteExA/W apis, but after callback functions are being called, the target process crashes. Here's the code:
Code: Select all
BOOL ShellExecuteExACallback(_Inout_ SHELLEXECUTEINFOA *pExecInfo)
{
return ShellExecuteExANext(pExecInfo);
}
BOOL ShellExecuteExWCallback(_Inout_ SHELLEXECUTEINFOW *pExecInfo)
{
return ShellExecuteExWNext(pExecInfo);
}
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD fdwReason, LPVOID lpReserved)
{
if(fdwReason == DLL_PROCESS_ATTACH) {
InitializeMadCHook();
CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
HookAPI("shell32.dll", "ShellExecuteExA", (PVOID) ShellExecuteExACallback, (PVOID*) &ShellExecuteExANext, 0);
HookAPI("shell32.dll", "ShellExecuteExW", (PVOID) ShellExecuteExWCallback, (PVOID*) &ShellExecuteExWNext, 0);
}
return TRUE;
}