热门问题
时间线
聊天
视角
執行緒信息塊
来自维基百科,自由的百科全书
Remove ads
Win32執行緒信息塊(TIB)是32位Windows作業系統的執行緒使用的資料結構,存儲了每個執行緒的運行時信息。 也稱作「執行緒環境塊」(Thread Environment Block,TEB)。[1]
此條目需要補充更多來源。 (2019年1月12日) |
Windows NT系列的DDK在winnt.h中包括了一個struct NT_TIB,為獨立於subsystem的部分。Wine包含了TIB與subsystem相關的擴展部分。由於非常多程序使用了TIB,事實上TIB成為Windows API的一部分。[1]
TIB可用於獲取很多進程相關信息,而不必調用Win32 API。例如,模擬GetLastError()或GetVersion()。通過PEB可以獲取訪問導入表(import table, IAT)、進程啟動參數、程序名字等。
32位程序通過FS段暫存器,64位程序通過GS段暫存器可以獲得TIB
Remove ads
TIB的內容
Remove ads
訪問TIB
// gcc (AT&T-style inline assembly).
void *getTIB() {
void *pTIB;
__asm__("movl %%fs:0x18, %0" : "=r" (pTIB) : : );
return pTIB;
}
// Microsoft C
__declspec(naked)
void *getTIB() {
__asm mov EAX, FS:[18h]
}
// Using Microsoft's intrinsics instead of inline assembly (works for both X86 and X64 architectures)
void *getTIB() {
#ifdef _M_IX86
return (void *)__readfsdword(0x18);
#elif _M_AMD64
return (void *)__readgsqword(0x30);
#endif
}
Remove ads
參見
參考文獻
進一步閱讀
外部連結
Wikiwand - on
Seamless Wikipedia browsing. On steroids.
Remove ads