• C++Program: Help Hooking a Function

    Fierro Member

    I’m having a hard time hooking a function of a game.
    I can use the function, so the Address and Offset are correct.
    What I am trying to do is, retrieve what arguments this function push’s into the game.
    But it doesn’t actually get hooked, any help ?
    I’m using Visual C++ 2008 to compile it.

    HookVTable Function:

    DWORD HookVTable( DWORD* dwFuncPtr, DWORD dwHook)
    {
        DWORD dwOld = NULL;
        VirtualProtect((void*)dwFuncPtr, 4, PAGE_EXECUTE_READWRITE, &dwOld);
    
        DWORD pOrig = *(PDWORD)dwFuncPtr;
        *(PDWORD)dwFuncPtr = (DWORD)dwHook;
    
        VirtualProtect((void*)dwFuncPtr, 4, dwOld, &dwOld);
    
        return pOrig;
    }
    

    Rest of the Code

    DWORD dwBase = reinterpret_cast< DWORD >( GetModuleHandle( L"GameClient.dll" ) );
    DWORD ILTClientPtr = *reinterpret_cast< DWORD* >( dwBase + 0x509A58 );
    DWORD* lpRunConsoleString = reinterpret_cast< DWORD* >( ILTClientPtr + 0x130 );
    
    
    void WINAPIV hkFrontConsoleCommand( const char* Commands ){
    
       g_LTClient = (CLTClient*)*(DWORD*)ADDR_ILTCLIENT;
       add_log("Log.txt", Commands);
       return ( ( void (WINAPIV* )( const char* ) )*( DWORD* )( **( DWORD** )( 0x10509A58 ) + 0x130 ) )( Commands );
    }
    
    int HookSVC(){
       if ( pEngine->ValidGamePointers() ){
       HookVTable( lpRunConsoleString, (DWORD)hkFrontConsoleCommand );
    }
    }
    
  • SapnaVishwas Member

    IT’s hard to say , but seems that you point a some wrong area memory , try to implement some flag or reference count , and check the result …

    I would to see all the code … to know exactly what happen..

Viewing 1 reply thread
  • You must be logged in to reply to this topic.
en_USEnglish