Hi,
I have been trying to hook FindNextFileW in Explorer.exe.
I have used IAT hooking and I manage to successfully change the address of FindNextfileW in the import table but when I execute the program, after the address is changed, explorer.exe restarts.
I get a message box ,Data Execution Prevention, and then explorer restarts. So I turned off the Data Execution Prevention for Explorer.exe and now I don't get any erro message and explorer doesn't restart but when I open a directory nothing happens.
Is there a problem in the definition
of myFindFirstFileExW or is there something else I am missing?
BOOL myFindNextFileW (HANDLE hFindFile,LPWIN32_FIND_DATA lpFindFileData);
int WINAPI DllEntryPoint(HINSTANCE hinstDll, unsigned long fdwReason,
void* fImpLoad) {
char lib_name[50];
GetModuleFileName(hinstDll, lib_name, 50);
LoadLibrary(lib_name);
switch(fdwReason) {
case DLL_PROCESS_ATTACH: {
ShowMessage("DLL_PROCESS_ATTACH");
HookAPI("FindNextFileW", (DWORD)myFindNextFileW);
}
case DLL_PROCESS_DETACH: {
break;
}
case DLL_THREAD_ATTACH: {
break;
}
case DLL_THREAD_DETACH: {
break;
}
}
return(TRUE);
}
BOOL myFindNextFileW (HANDLE hFindFile,LPWIN32_FIND_DATA lpFindFileData)
{
FILE *hfptr4;
hfptr4 = fopen("c:\\hookedCP.txt", "a");
fprintf(hfptr4, "%s", "findNextFile\n");
fclose(hfptr4);
ShowMessage("FindNextFileW");
return FindNextFileW(hFindFile, (_WIN32_FIND_DATAW *)lpFindFileData);
}