Search code examples
windowsmultithreadingseh

Finding another thread's Thread Information Block


Is there a way to find the Thread Information Block (TIB) of another thread running in your process?

I need to construct an exception handler for another thread but I can't do it in the thread itself. Therefore I need to find it's TIB and construct it from inside another thread. How can I achieve this?


Solution

  • You can access the address of the TIB directly from the FS register (check http://www.microsoft.com/msj/archive/S2CE.aspx). So to get the TIB for another thread maybe can use GetThreadContext() to get the value of FS and therefore the address of the TIB? (just a guess, I didn't try this!)