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
    Commented Dec 7, 2013 at 0:36
  • I try to do it for a different process. I will update my question for clarification.
    – samuirai
    Commented 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
    Commented Dec 7, 2013 at 20:00
  • @jason-geffner 10 years have gone by and your link is now dead. You don't happen to have a copy of the content? The answers to such questions never get old :)
    – Benni
    Commented Dec 28, 2023 at 22:07
  • 1
    @Benni, you're in luck! See blogorama.nerdworks.in/content/images/nerdworks/downloads/… Commented Feb 19 at 21:04
  • thanks a lot! I found it hard to find commented sample code for it.
    – Benni
    Commented Feb 19 at 21:50

Your Answer

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

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