Created
May 29, 2025 10:28
-
-
Save georgboe/9388dd939126bf807e3dda336cae26c4 to your computer and use it in GitHub Desktop.
Dll hijacking template
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#ifdef RELEASE | |
#define PRINT_DEBUG(a, ...); | |
#else | |
#define PRINT_DEBUG(a, ...) do {FILE *t = NULL; fopen_s(&t, "dll.txt", "a"); if (t) { fprintf(t, "%u " a, GetCurrentThreadId(), __VA_ARGS__); fclose(t); }} while (0) | |
#endif | |
#define EXPORT_FUNC extern "C" __declspec(dllexport) | |
EXPORT_FUNC bool ExampleFunction() { | |
PRINT_DEBUG("%s\n", __FUNCTION__); | |
return TRUE; | |
} | |
BOOL APIENTRY DllMain( HMODULE hModule, | |
DWORD ul_reason_for_call, | |
LPVOID lpReserved | |
) | |
{ | |
switch (ul_reason_for_call) | |
{ | |
case DLL_PROCESS_ATTACH: | |
case DLL_THREAD_ATTACH: | |
case DLL_THREAD_DETACH: | |
case DLL_PROCESS_DETACH: | |
break; | |
} | |
return TRUE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment