Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- void NTAPI tls_callback(PVOID hModule, DWORD reason, PVOID reserved)
- {
- if (reason == DLL_PROCESS_ATTACH)
- MessageBoxA(NULL, "TLS callback fired", "TLS", MB_OK);
- }
- // Tell the linker to place `tls_callback` into the TLS callback table
- #ifdef _MSC_VER
- #pragma const_seg(".CRT$XLB")
- EXTERN_C const PIMAGE_TLS_CALLBACK pTlsCallback = tls_callback;
- #pragma const_seg()
- #else
- PIMAGE_TLS_CALLBACK __attribute__((section(".CRT$XLB"))) pTlsCallback = tls_callback;
- #endif
- BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
- {
- if (fdwReason == DLL_PROCESS_ATTACH)
- {
- MessageBoxA(NULL, "DllMain fired", "DLL", MB_OK);
- }
- return TRUE;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement