??Windows????????С? -- ??????
???????????? ???????[ 2012/12/4 10:31:42 ] ????????
?????????????
????CreateThread ????????????? ???? ????????????????????????????ü????2???? ??????????????1???????????????????1 ??????????????????????? CreateThread ??????????????????????????????????????????????????????????????????????1??????????豸STILE_ACTIVE??0x103??????????????δ????????
????????????????????????棬??????????á???????????????????????????????????????????????????д??????????????????1???????????????????????????
?????????????????????CPU?????????????????????context????????????????????????????????CPU???????????CONTEXT???????????????????С?
?????????????????????????CONTEXT??????????????????pfnStartAddr????????е??????????????????????RtlUserThreadStart??????????
VOID RtlUserThreadStart(PTHREAD_START_ROUTINE pfnStartAddr?? PVOID pvParam) {
__try {
ExitThread((pfnStartAddr)(pvParam));
}
__except(UnhandledExceptionFilter(GetExceptionInformation())) {
ExitProcess(GetExceptionCode());
}
// NOTE: We never get here.
}
???????????????????????CREATE_SUSPENDED?????????????CreateThread???????????????д???????????????????????0???????????????????????????С???????????? CPU??????м????????????????????б???????????????????????????????????д??????????????
????????????RtlUserThreadStart??????????????????????飺
????Χ??????????????????????????????SEH????????????????????????????????κ????????????????????
???????????????????????CreateThread??????pvParam????????????
?????????????????RtlUserThreadStart????ExitThread???????????????????????????????????????ü???????????????????С?
??????????????????δ???????????RtlUserThreadStart???????????SEH?????????????????????ζ??????????????????????????????????????????RtlUserThreadStart?????ExitProcess?????????????????????????????????
?????????????????????????????????????RtlUserThreadStart????RtlUserThreadStart????????????????C/C++???п???????????????????????????_tmain??_tWinMain??????
???????C/C++???п????????
?????????C??C++???????ó??????????У????????????????????????????C/C++???п????????????????????????C/C++???п????????Щ????????????????????????????飬?????????????????
??????дC/C++??ó????????????ò???????CreateThread????????????????C/C++???п???_beginthreadex??
uintptr_t __cdecl _beginthreadex ( void *psa?? unsigned cbStackSize?? unsigned (__stdcall * pfnStartAddr) (void *)??
void * pvParam?? unsigned dwCreateFlags?? unsigned *pdwThreadID)
{
_ptiddata ptd; // Pointer to thread's data block
uintptr_t thdl; // Thread's handle
// Allocate data block for the new thread.
if ((ptd = (_ptiddata)_calloc_crt(1?? sizeof(struct _tiddata))) == NULL)
goto error_return; // Initialize the data block.
initptd(ptd); // Save the desired thread function and the parameter
// we want it to get in the data block.
ptd->_initaddr = (void *) pfnStartAddr;
ptd->_initarg = pvParam;
ptd->_thandle = (uintptr_t)(-1); // Create the new thread.
thdl = (uintptr_t) CreateThread ((LPSECURITY_ATTRIBUTES)psa?? cbStackSize?? _threadstartex ?? (PVOID) ptd?? dwCreateFlags?? pdwThreadID);
if (thdl == 0) {
// Thread couldn't be created?? cleanup and return failure.
goto error_return;
} // Thread created OK?? return the handle as unsigned long.
return(thdl);
error_return:
// Error: data block or thread couldn't be created.
// GetLastError() is mapped into errno corresponding values
// if something wrong happened in CreateThread.
_free_crt(ptd);
return((uintptr_t)0L);
}
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11