Advertisement
Guest User

test dll

a guest
Jun 26th, 2025
38
0
364 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.71 KB | None | 0 0
  1. #include <windows.h>
  2.  
  3. void NTAPI tls_callback(PVOID hModule, DWORD reason, PVOID reserved)
  4. {
  5.     if (reason == DLL_PROCESS_ATTACH)
  6.         MessageBoxA(NULL, "TLS callback fired", "TLS", MB_OK);
  7. }
  8.  
  9. // Tell the linker to place `tls_callback` into the TLS callback table
  10. #ifdef _MSC_VER
  11. #pragma const_seg(".CRT$XLB")
  12. EXTERN_C const PIMAGE_TLS_CALLBACK pTlsCallback = tls_callback;
  13. #pragma const_seg()
  14. #else
  15. PIMAGE_TLS_CALLBACK __attribute__((section(".CRT$XLB"))) pTlsCallback = tls_callback;
  16. #endif
  17.  
  18. BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
  19. {
  20.     if (fdwReason == DLL_PROCESS_ATTACH)
  21.     {
  22.         MessageBoxA(NULL, "DllMain fired", "DLL", MB_OK);
  23.     }
  24.     return TRUE;
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement