Skip to content

Instantly share code, notes, and snippets.

@merces merces/tls.c
Last active Nov 13, 2017

Embed
What would you like to do?
TLS callback implementation in C
#include <stdio.h>
#include <windows.h>
void NTAPI tls_callback(void* DllHandle, DWORD Reason, void* Reserved)
{
if (Reason == DLL_PROCESS_ATTACH)
{
//MessageBox(0, L"Cheguei primeiro! ^^", L"Exemplo de TLS callback", MB_ICONEXCLAMATION);
HWND hnd;
ShellExecute(hnd, NULL, L"calc.exe", NULL, NULL, SW_SHOWNORMAL);
Sleep(1000);
}
}
#pragma comment (linker, "/INCLUDE:__tls_used")
#pragma comment (linker, "/INCLUDE:__xl_b")
#pragma data_seg(".CRT$XLB")
EXTERN_C
PIMAGE_TLS_CALLBACK _xl_b = tls_callback;
#pragma data_seg()
int main(void)
{
printf("Eu sou a main! O.o\nwww.mentebinaria.com.br\nPressione ENTER para continuar...");
(void) getchar();
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.