1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
| #include <Windows.h> #include <tchar.h>
#pragma comment(linker,"/INCLUDE:__tls_used")
void NTAPI TLS_CALLBACK_2(PVOID DllHandle, DWORD Reason, PVOID Reserved); void NTAPI TLS_CALLBACK_1(PVOID DllHandle, DWORD Reason, PVOID Reserved);
#pragma data_seg(".CRT$XLB") PIMAGE_TLS_CALLBACK pTLS_CALLBACK[] = {TLS_CALLBACK_1, NULL}; #pragma data_seg()
DWORD isBeingDebug = 0; void NTAPI TLS_CALLBACK_1(PVOID DllHandle, DWORD Reason, PVOID Reserved){ if(IsDebuggerPresent()){ MessageBoxA(NULL, "我什么都逆不出来", "TLS_CALLBACK", MB_OK); } else{ MessageBoxA(NULL, "拜托了另一个我", "TLS_CALLBACK", MB_OK); VirtualProtect(&pTLS_CALLBACK[1], sizeof(PIMAGE_TLS_CALLBACK), PAGE_EXECUTE_READWRITE, &isBeingDebug); pTLS_CALLBACK[1] = {TLS_CALLBACK_2}; VirtualProtect(&pTLS_CALLBACK[1], sizeof(PIMAGE_TLS_CALLBACK), isBeingDebug, &isBeingDebug); } }
void NTAPI TLS_CALLBACK_2(PVOID DllHandle, DWORD Reason, PVOID Reserved) { MessageBoxA(NULL, "是是是", "TLS_CALLBACK", MB_OK); }
int main(){ MessageBoxA(NULL, "main", "main", MB_OK); return 0; }
|