getting the CContext from Tls

Issue #47 closed
Anmar created an issue

Hey and thanks for the awesome work on the lib.

I’m in the middle of learning and through reading the offset.h you mentioned that the CContext would be in the thread local storage at the offset of 0x2c. Is there anyway to access the Tls and getting this pointer?
I tried googling for Tls and I kinda got lost. would be nice if you include a short snippet to help me understand .

Thanks

Comments (8)

  1. hairys

    thread local storage just means you can store data, in a special heap, that is only accessible by the same thread that originally stored it. Trying to access that data from another thread results in an error. The game stores a list of context pointers in its main thread. The only way for us to access that data is to hook into the main thread. We search for a string in the game called "ViewAdvanceDevice" and hook into the main thread from that. Check main.cpp for "ViewAdvanceDevice" and follow it.

  2. Anmar reporter

    Interesting, correct me if I am wrong, wasn’t that local thread storage is kinda of shared by all threads?

  3. Anmar reporter

    Now I kind of understand. thats why when i tried calling the function from the thread in the injected dll it returns 0. following the viewadvancedevice , So you hook into the alertctx right? what does the original function do? and why particularly this one? i recon that you do have backup functions.
    sorry for asking a lot. I know I can just use your lib and call it a day but I want to understand the functionality around.

    also another question when trying to follow the code , i don’t quite understand the hl::FollowRelativeAddress . i tried to find the address of the alertctx to try to hook in it but could not fully understand.

  4. Anmar reporter

    another issue i am facing right now is compiling in windows using visual studio 2022, facing alot of undeclared identifers in gamedata.h

  5. Anmar reporter

    Issue fixed. Seems like I used c++20 and changing it back to 17 fixed it and it compiles. Will open a new issue for the other problems though.

  6. Log in to comment