@DarthTon oh thank you very much that is pretty much the same way i do it. I found a bug in my tls copy code so now it copies the tls correctly and doesnt crash anymore. but somehow i ran directly in a new problem: Instead of crashing the game instantly disconnects me now if i call a function which contains a call to tls. So i hit up ollydbg and checked if the copied values are correct. they are correct. so now i am stuck and dont know how to trace down the code which is causing the disconnect.
DarthTon what exactly do you copy in your TLSCopy function? only the 64 tls slots and expansion slots?
that is how i copy the tls values into the teb of my thread
Code:
DWORD pTLSVal = 0;
for(int i = 0;i<64;i++)
{
ReadProcessMemory(g_process,LPCVOID(basicInfo.TebBaseAddress+0xE10+i*4),&pTLSVal,sizeof(DWORD),NULL);
WriteProcessMemory(g_process, (BYTE*)(basicInfo.TebBaseAddress+0xE10+i*4), &TLSValue[i], sizeof(DWORD), NULL);
printf("rewriting tls slot[%d] from %x to %x\n",i,pTLSVal,TLSValue[i]);
}
and thats the code snippet with which i read it from the mainthread:
Code:
DWORD TLSValue[64];
for(int i = 0;i<64;i++)
{
ReadProcessMemory(g_process,LPCVOID(basicInfo.TebBaseAddress+0xE10+i*4),&TLSValue[i],sizeof(DWORD),NULL);
printf("TLS val[%d]:%x\n",i,TLSValue[i]);
}
edit: i got it now working in a little bit hacky way. if i copy only the tls slot which is used (slot 0x25) then it works perfectly. Is there any explanation why it doesnt work when i copy all slots with the code i posted above?