Skip to content

Instantly share code, notes, and snippets.

@georgboe
Created May 29, 2025 10:28
Show Gist options
  • Save georgboe/9388dd939126bf807e3dda336cae26c4 to your computer and use it in GitHub Desktop.
Save georgboe/9388dd939126bf807e3dda336cae26c4 to your computer and use it in GitHub Desktop.
Dll hijacking template
#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