TlsSetValue Hook crasht

03/08/2012 16:34 Omdi#1
Hey,

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 (WINAPITlsSetValue_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);

03/08/2012 18:26 SmackJew#2
BP auf LoadLibrary, .dll injecten, bis zum Crash durchsteppen, dich selbst erleuchten.