Skip to content

Instantly share code, notes, and snippets.

@blaquee
Created November 15, 2014 02:06
Show Gist options
  • Save blaquee/9d605d2ce93d99daaa74 to your computer and use it in GitHub Desktop.
Save blaquee/9d605d2ce93d99daaa74 to your computer and use it in GitHub Desktop.
explicit TLS
#undef UNICODE
#include <Windows.h>
#pragma comment(linker, "/INCLUDE:__tls_used")
void NTAPI TlsCallBack(PVOID h, DWORD dwReason, PVOID pv);
#pragma data_seg(".CRT$XLB")
PIMAGE_TLS_CALLBACK p_thread_callback = TlsCallBack;
#pragma data_seg()
int myglobal_;
void NTAPI TlsCallBack(PVOID h, DWORD dwReason, PVOID pv)
{
MessageBox(NULL, "In TLS", "Inside TLS func", MB_OK);
return;
}
int main(int argc, char** argv)
{
MessageBox(NULL, "Main func", "In main func", MB_OK);
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment