Ich habe im Spiel S4 League TlsSetVale gehookt.
Nur leider crasht das Spiel die ganze Zeit. Ich weiß nicht warum, die Calling Convention ist richtig, die Parameter und der Rückgabetyp.
PHP Code:
#include <Windows.h>
#include "detours.h"
#pragma comment(lib,"detours.lib")
typedef BOOL (WINAPI* TlsSetValue_t)(DWORD,LPVOID);
TlsSetValue_t TlsSetValue_orig = 0;
BOOL WINAPI hkTlsSetValue(DWORD dwTlsIndex,LPVOID lpTlsValue);
DWORD WINAPI Init(LPVOID);
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
switch(fdwReason)
{
case DLL_PROCESS_ATTACH:
CreateThread(0,0,Init,0,0,0);
break;
}
return TRUE;
}
DWORD WINAPI Init(LPVOID)
{
TlsSetValue_orig = (TlsSetValue_t)DetourFunction((PBYTE)TlsSetValue,(PBYTE)hkTlsSetValue);
return TRUE;
}
BOOL WINAPI hkTlsSetValue(DWORD dwTlsIndex,LPVOID lpTlsValue)
{
return TlsSetValue_orig(dwTlsIndex,lpTlsValue);
}