#include <windows.h>
#include <process.h>
#pragma code_seg(".text")
__declspec(naked)static void test(void* a)
{
char str[8];
DWORD tThread;
tThread = GetCurrentThreadId();
_itoa_s(tThread, str, 10);
MessageBoxA(0,str,"线程Id",0);
__asm ret
}
#pragma code_seg(".text")
static void fun_END() {}
int _tmain(int argc, _TCHAR* argv[])
{
typedef void (*tHreadFun)(void* arg);
int funsize = (int)fun_END - (int)test;
char* tBuffer = new char[funsize];
if(0 == tBuffer)
{
printf("virtual alloc fail\n");
system("pause");
return 0;
}
test(NULL);
memset(tBuffer, 0, funsize);
memcpy(tBuffer, (void*)test, funsize);
_beginthread((tHreadFun)tBuffer, NULL, NULL);
system("pause");
delete[] tBuffer;
return 0;
}




求拍砖。
[招生]科锐逆向工程师培训(2025年3月11日实地,远程教学同时开班, 第52期)!