The Thread Local Storage (TLS) contains static or global values for a thread. Those values can be very important to find reliable references to memory structures when the memory locations are not static.

I would like to get the Thread Local Storage of another process.

The TLS should be at [FS:0x2C] in the Thread Information Block (TIB). Though I quite don't understand how the FS register works. I guess I have to find the TIB Base address first? I think I can find it in the Thread Context I can get with WINAPI GetThreadContext, but I am a little bit overwhelmed.

  • Are you looking for ways to access it in the same process? different process? Clarify your situation and what exactly you need to do.
    – Igor Skochinsky
    Dec 7, 2013 at 0:36
  • I try to do it for a different process. I will update my question for clarification.
    – samuirai
    Dec 7, 2013 at 0:49

1 Answer 1


You need to use GetThreadSelectorEntry().


GetThreadContext(hThread, &context);
GetThreadSelectorEntry(hThread, context.SegFs, &selectorEntry);
ReadProcessMemory(hProcess, (selectorEntry.BaseLow | (selectorEntry.HighWord.Bytes.BaseMid << 0x10) | (selectorEntry.HighWord.Bytes.BaseHi << 0x18)) + 0x2C, &pTLS, sizeof(pTLS), &numberOfBytesRead);

You can see the function GetProcessEntryPointAddress() here for some sample code that does something similar.

  • thank you, it worked like a charm :) I didn't know GetThreadSelectorEntry()
    – samuirai
    Dec 7, 2013 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.