Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <io.h>
- #include <windows.h>
- #include <stdio.h>
- #include "NCodeHook/NCodeHookInstantiation.h"
- __declspec(dllexport) void dummyExport() {}
- FILE *err;
- FILE *out;
- typedef VOID (WINAPI *ExitProcessFPtr)(UINT uExitCode);
- ExitProcessFPtr originalExitProcess = NULL;
- VOID WINAPI ExitProcessHook(UINT uExitCode)
- {
- //MessageBox(0, L"Good bye!", L"You've been hooked!", MB_ICONINFORMATION);
- fprintf(out, "Unloading");
- fclose(out);
- fclose(err);
- originalExitProcess(uExitCode);
- }
- NCodeHookIA32 nCodeHook;
- void hookExitProcess()
- {
- originalExitProcess = nCodeHook.createHookByName("kernel32.dll", "ExitProcess", ExitProcessHook);
- }
- void initializeHooks()
- {
- err = fopen("c:\\error.log", "w");
- out = fopen("c:\\output.log", "w");
- fprintf(out, "Initializing");
- hookExitProcess();
- }
- BOOL APIENTRY DllMain( HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved )
- {
- switch (ul_reason_for_call)
- {
- case DLL_PROCESS_ATTACH:
- initializeHooks();
- break;
- case DLL_THREAD_ATTACH:
- case DLL_THREAD_DETACH:
- case DLL_PROCESS_DETACH:
- break;
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment