Win32 Thread Information Block

本文介绍了 Win32 Thread Information Block (TIB) 的详细结构及其在 Windows 操作系统中的作用。TIB 存储了关于当前运行线程的信息,包括线程的异常处理帧、栈顶和栈底等。通过对 TIB 的访问可以获取进程的大量信息而无需调用 Win32 API。

出自: http://en.wikipedia.org/wiki/Win32_Thread_Information_Block

 

Win32 Thread Information Block

From Wikipedia, the free encyclopedia

Jump to: navigation, search

In computing, the Win32 Thread Information Block (TIB) is a data structure in Win32 on x86 that stores info about the currently running thread.

The TIB is officially undocumented for Windows 9x. The Windows NT series DDK includes a struct NT_TIB in winnt.h that documents the subsystem independent part. Wine includes declarations for the extended (subsystem-specific part of) TIB. Yet so many Win32 programs use undocumented fields that it is effectively a part of the API.

The TIB can be used to get a lot of information on the process without calling win32 API. Examples include emulating GetLastError(), GetVersion(). Through the pointer to the PEB one can obtain access to the import tables (IAT), process startup arguments, image name, etc.

[edit] Contents of the TIB

PositionLengthWindows VersionsDescription
FS:[0x00]4Win9x and NTCurrent Structured Exception Handling (SEH) frame
FS:[0x04]4Win9x and NTTop of stack
FS:[0x08]4Win9x and NTCurrent bottom of stack
FS:[0x10]4NTFiber data
FS:[0x14]4Win9x and NTArbitrary data slot
FS:[0x18]4Win9x and NTLinear address of TIB
--NTEnd of NT subsystem independent part
FS:[0x1C]4NTEnvironment Pointer
FS:[0x20]4NTProcess ID
FS:[0x24]4NTCurrent thread ID
FS:[0x28]4NTActive RPC Handle
FS:[0x2C]4Win9x and NTLinear address of the thread-local storage array
FS:[0x30]4NTLinear address of Process Environment Block (PEB)
FS:[0x34]4NTLast error number
FS:[0x38]4NTCount of owned critical sections
FS:[0x3C]4NTAddress of CSR Client Thread
FS:[0x40]4NTWin32 Thread Information
FS:[0x44]124NT,WineWin32 client information (NT), user32 private data (Wine), 0x60 = LastError (Win95), 0x74 = LastError (WinME)
FS:[0xC0]4NTReserved for Wow32
FS:[0xC4]4NTCurrent Locale
FS:[0xC8]4NTFP Software Status Register
FS:[0xCC]216NT,WineReserved for OS (NT), kernel32 private data (Wine)
FS:[0x1A4]4NTException code
FS:[0x1A8]18NTActivation context stack
FS:[0x1BC]24NT,WineSpare bytes (NT), ntdll private data (Wine)
FS:[0x1D4]40NT,WineReserved for OS (NT), ntdll private data (Wine)
FS:[0x1FC]1248NT,WineGDI TEB Batch (OS), vm86 private data (Wine)
FS:[0x6DC]4NTGDI Region
FS:[0x6E0]4NTGDI Pen
FS:[0x6E4]4NTGDI Brush
FS:[0x6E8]4NTReal Process ID
FS:[0x6EC]4NTReal Thread ID
FS:[0x6F0]4NTGDI cached process handle
FS:[0x6F4]4NTGDI client process ID (PID)
FS:[0x6F8]4NTGDI client thread ID (TID)
FS:[0x6FC]4NTGDI thread locale information
FS:[0x700]20NTReserved for user application
FS:[0x714]1248NTReserved for GL
FS:[0xBF4]4NTLast Status Value
FS:[0xBF8]214NTReserved for advapi32
FS:[0xE0C]4NTPointer to deallocation stack
FS:[0xE10]256NTTLS slots, 4 byte per slot
FS:[0xF10]8NTTLS links (LIST_ENTRY structure)
FS:[0xF18]4NTVDM
FS:[0xF1C]4NTReserved for RPC

[edit] Accessing the TIB

The TIB can be accessed as an offset of segment register FS.

It is common to not access TIB fields by offset from FS:[0], but rather first getting a the linear self-referencing pointer to the stored at FS:[0x18]. That pointer is used in means of pointer arithmetics or cast to a struct pointer.

Example in C inlined-assembly for 32-bit x86:

// gcc (AT&T-style inline assembly).
void *getTIB()
{
    void *pTib;
    __asm__("movl %%fs:0x18, %0" : "=r" (pTib) : : );
    return pTib;
}
// Microsoft C
void *getTib()
{
    void *pTib;
    __asm {
        mov EAX, FS:[18h]
        mov [pTib], EAX
    }
    return pTib;
}

[edit] External links

MSC Nastran V2019.0 (Intel Windows 10 Home China 6.2 9200) Control File: ----------------------------------------------------------------- $ sysfield=SCR*(RAW=YES,BUFFIO=YES,wnum=16,wsize=16mb) $(c:/msc.software/msc_nastran/20190/conf/nast20190.rcf[2]) $ sysfield=DBALL(RAW=YES,BUFFIO=YES,wnum=16,wsize=16mb) $(c:/msc.software/msc_nastran/20190/conf/nast20190.rcf[3]) Nastran BUFFSIZE=32769 $(c:/msc.software/msc_nastran/20190/conf/nast20190.rcf[6]) JID='c:/users/21959/desktop/new folder2/project.bdf' OUT='./project' MEM=8004MB $ MACH='Intel' OPER='Windows 10 Home China' OSV='6.2 9200' MODEL='Xeon/6900 (LAPTOP-T8QR16J2)' NPROC='20' CONFIG=6 NPROC=20 symbol=DELDIR='c:/msc.software/msc_nastran/20190/msc20190/nast/del' $(program default) symbol=DEMODIR='c:/msc.software/msc_nastran/20190/msc20190/nast/demo' $(program default) symbol=LM_NO_SNMP=1 $(c:/msc.software/msc_nastran/20190/conf/nast20190.rcf[10]) symbol=MKL_INTERFACE_LAYER=ILP64 $(c:/msc.software/msc_nastran/20190/conf/nast20190.rcf[1]) symbol=SSSALTERDIR='c:/msc.software/msc_nastran/20190/msc20190/nast/sssalter' $(program default) symbol=TPLDIR='c:/msc.software/msc_nastran/20190/msc20190/nast/tpl' $(program default) SDIR='c:/scratch/project.T27132_24' DBS='c:/scratch/project.T27132_24' SCR='yes' SMEM=100 BPOOL=7407.7MB DMPMEM=estimate NEWDEL='c:/msc.software/msc_nastran/20190/msc20190/win64i8/sss' DEL='MSCDEF' DML=MSCDEF SDL=MSCDEF AUTH='C:\MSC.Software\MSC.Licensing\11.13\license.dat' AUTHQUE=20 MSGCAT='c:/msc.software/msc_nastran/20190/msc20190/win64i8/analysis.msg' MSGDEST='f06' NEWS='c:/msc.software/msc_nastran/20190/msc20190/nast/news.txt' ----------------------------------------------------------------- MSC_ISHELLPATH=C:\MSC.Software\MSC_Nastran\20190\msc20190\actran\win64\Actran_19.0.rc0.115900\bin;C:\MSC.Software\MSC_Nastran\20190\msc20190\nast; MSC_JIDPATH= PATH=c:\msc.software\msc_nastran\20190\msc20190\win64i8;c:\msc.software\msc_nastran\20190\msc20190\win64i8\nCode\bin;c:\msc.software\msc_nastran\20190\msc20190\win64i8\nvidia;c:\msc.software\msc_nastran\20190\msc20190\win64i8\lib;c:\msc.software\msc_nastran\20190\msc20190\win64i8;C:\MSC.Software\Patran_x64\20190\bin;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\NVIDIA Corporation\NVIDIA app\NvDLISR;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Users\21959\AppData\Local\Microsoft\WindowsApps; SCA_SERVICE_CATALOG="c:\msc.software\msc_nastran\20190\msc20190\res\SCAServiceCatalog.xml" SCA_RESOURCE_DIR="c:\msc.software\msc_nastran\20190\msc20190\res" Cmd Line: C:\MSC.Software\MSC_Nastran\20190\msc20190\win64i8\nastran.exe JID=C:\Users\21959\Desktop\New Folder2\project.bdf Current Dir: C:\Users\21959\Desktop\New Folder2 Time Cmd: c:\msc.software\msc_nastran\20190\msc20190\win64i8\msctime Executable: c:\msc.software\msc_nastran\20190\msc20190\win64i8\analysis.exe Arch= Kywd: [Not specified] MSC_MSG: stderr FPE: yes ----------------------------------------------------------------- Current resource limits: Physical memory: 16008 MB Physical memory available: 3474 MB Paging file size: 21389 MB Paging file size available: 3581 MB Virtual memory: 134217727 MB Virtual memory available: 134213506 MB ----------------------------------------------------------------- System configuration: Hostname: LAPTOP-T8QR16J2 Architecture: win64i8 Platform: Intel Windows 10 Home China 6.2 9200 (Windows Compute Cluster) Model: Xeon/1805 Clock freq.: 1967 MHz Number of CPUs: 20 Executable: standard Raw model ID: 6 Config number: 6 Physical memory: 16008 MB Virtual memory: 21389 MB Numeric format: 64-bit little-endian IEEE. Bytes per word: 8 Disk block size: 512 bytes (64 words) Remote shell cmd: "c:/msc.software/msc_nastran/20190/msc20190/win64i8/mscrmtcmd.exe" (Windows non-CCS nodes, UNIX) <ccs_cmd> (Windows CCS nodes) ----------------------------------------------------------------- MSC Nastran started Fri Jan 2 17:40:25 ?D1 ? ?? 2026 17:40:28 Beginning Analysis SCA Kernel 22.2.602065 successfully initialized BLAS/LAPACK .dll "c:\msc.software\msc_nastran\20190\msc20190\win64i8\libimalloc.dll" has been loaded. BLAS/LAPACK .dll "c:\msc.software\msc_nastran\20190\msc20190\win64i8\mkl_core.dll" has been loaded. BLAS/LAPACK .dll "c:\msc.software\msc_nastran\20190\msc20190\win64i8\mkl_intel_thread.dll" has been loaded. BLAS/LAPACK .dll "c:\msc.software\msc_nastran\20190\msc20190\win64i8\mkl_rt.dll" has been loaded. BLAS/LAPACK .dll "c:\msc.software\msc_nastran\20190\msc20190\win64i8\MSCblas.dll" has been loaded. 17:40:29 MSC Authorization Information - System Attributes (1004, 0) 17:40:29 ----------------------------------------------------------- Date: Fri Jan 2 17:40:29 2026 MSC Id: 08bfb8c7645b (ethernet) (Intel) Hostname: LAPTOP-T8QR16J2 (user 21959, display LAPTOP-T8QR16J2) License files: C:\MSC.Software\MSC.Licensing\11.13\license.dat CEID: B8C7645B-32166371 User: 21959 Display: LAPTOP-T8QR16J2 LAPI Version: LAPI 10.4.6 (FLEXlm 11.13.1.3) * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * MSC Customer Entitlement ID * * * * B8C7645B-32166371 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * 17:40:30 MSC Authorization Information - Checkout Successful (1016, 0) 17:40:30 ------------------------------------------------------------- 17:40:30 Acquired 1 license for MSC Nastran from license server on host LAPTOP-T8QR16J2 Beginning bulk data processing using the IFPStar component. For more information on IFPStar, please see KB article KB8019200 on our support pages, at http://simcompanion.mscsoftware.com. 17:40:30 52083 records read from JID file "c:/users/21959/desktop/new folder2/project.bdf" Processing of bulk data entries is complete. 17:40:31 Analysis started. 17:40:31 Geometry access/verification to CAD part initiated (if needed). 17:40:31 Geometry access/verification to CAD part successfully completed (if needed). 17:40:31 Finite element model generation started. ================================================== Warning/Fatal Message Summary Occurrence USER WARNING MESSAGE 5276.0 1 USER WARNING MESSAGE 5276.0 299 USER FATAL MESSAGE 4288.0 8 USER WARNING MESSAGE 9031.0 1 ================================================== 17:40:31 20 records read from JID file "c:/users/21959/desktop/new folder2/project.bdf" 17:40:31 NSEXIT: EXIT(20) 17:40:31 Analysis complete -20 20 createMemPool, context=RMRGDROT Real: 3.408 seconds ( 0:00:03.408) User: 1.765 seconds ( 0:00:01.765) Sys: 0.765 seconds ( 0:00:00.765) ================================================== OS: 6.2 OEM ID: 9 Number of processors: 20 Page size: 4096 Processor type: 8664 Minimum application address: 10000 Maximum application address: fffeffff Active processor mask: 1048575 Nsocket: 0 Ncore: 20 Ram: 16008 Mb ================================================== Time Summary CPU Wall ( Time in Seconds ) Consider using SOLVE=AUTO if you have not. ===================================================== Detailed performance information can be found in the "MSC Nastran High Performance Computing User's Guide" ===================================================== MSC Nastran finished Fri Jan 2 17:40:32 ?D1 ? ?? 2026
最新发布
01-03
USER FATAL MESSAGE 4288.0 通常与文件读取或输入数据的错误有关,可能是输入文件格式不正确、文件损坏或者文件路径存在问题。例如,如果输入文件中存在非法字符或者数据格式不符合 MSC Nastran 的要求,就可能触发该错误。 USER WARNING MESSAGE 5276.0 一般涉及到单元连接性的问题,可能是模型中某些单元的节点连接不正确,导致计算过程中出现异常。比如单元的节点编号不连续或者重复,会使得软件在处理单元信息时发出该警告。 USER WARNING MESSAGE 9031.0 往往和材料属性的定义有关,可能是材料属性参数设置不合理或者缺失某些必要的材料参数,使得软件在进行力学分析时无法准确处理材料相关的计算。 以下是针对这些问题可能的解决办法: 对于 USER FATAL MESSAGE 4288.0: - 检查输入文件的格式,确保文件中没有非法字符,并且数据格式符合 MSC Nastran 的规范。可以使用文本编辑器打开输入文件,仔细检查每一行数据。 - 确认输入文件的路径是否正确,避免出现空格、特殊字符等可能导致文件读取失败的情况。 - 尝试重新生成输入文件,以确保文件没有损坏。 对于 USER WARNING MESSAGE 5276.0: - 检查模型中单元的节点连接情况,使用软件的可视化工具查看节点编号是否连续且正确。 - 对模型进行网格检查,修复可能存在的重复节点或者连接错误的单元。 对于 USER WARNING MESSAGE 9031.0: - 仔细检查材料属性的定义,确保所有必要的参数都已经正确设置,如弹性模量、泊松比等。 - 参考 MSC Nastran 的文档,确认材料属性的设置是否符合软件的要求。 ```python # 这里可以是一些示例代码,用于检查文件路径和格式 import os input_file = 'your_input_file.bdf' if os.path.exists(input_file): print("文件路径存在") with open(input_file, 'r') as f: lines = f.readlines() for line in lines: # 可以在这里添加更多的格式检查逻辑 if len(line.strip()) == 0: continue # 示例:检查行长度是否符合要求 if len(line) > 72: print("行长度可能不符合要求:", line) else: print("文件路径不存在,请检查") ```
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值