// ========== Initialisation //----------------------------------------------------------------------------- // DllMain() // Function called by the system when processes and threads are initialized // and terminated. //----------------------------------------------------------------------------- BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved) { BOOL bResult = TRUE; int i; char szMsvcrt[3][16] = { "MSVCRT.dll", "MSVCRT70.dll", "MSVCRT71.dll" }; switch( dwReason ) { case DLL_PROCESS_ATTACH: hDllInstance = hInstance; // save Dll instance handle DEBUGSTR("hDllInstance = 0x%.8x", hDllInstance); bResult &= HookAPIAllMod("KERNEL32.dll", "CreateFileA", (PROC)My_CreateFileA); DEBUGSTR("CreateFileA = %d", bResult); bResult &= HookAPIAllMod("KERNEL32.dll", "GetFileAttributesA", (PROC)My_GetFileAttributesA); DEBUGSTR("GetFileAttributesA = %d", bResult); for (i=0; i<3; i++) { if ( GetModuleHandle(szMsvcrt[i]) ) { bResult &= HookAPIAllMod(szMsvcrt[i], "_stati64", (PROC)My_stati64); bResult &= HookAPIAllMod(szMsvcrt[i], "_stat", (PROC)My_stat); bResult &= HookAPIAllMod(szMsvcrt[i], "_rmdir", (PROC)My_rmdir); bResult &= HookAPIAllMod(szMsvcrt[i], "_chdir", (PROC)My_chdir); DEBUGSTR("%s functions = %d", szMsvcrt[i], bResult); } } case DLL_PROCESS_DETACH: break; } return (bResult); }