[C++]Attackspeed Hack without offsets

07/07/2012 09:12 wurstbrot123#1
hook.h is the Header of my own Hooking class but you
can just use Microsoft Detours instead ( its very very similar
to my Code ). For a MS Detours Tutorial take a look here:

[Only registered and activated users can see links. Click Here To Register...]

With this way you can also change Runspeed, Range,
Skillspeed and much more. This is just a small example,
allthough i did not try this Code it should work perfectly
fine. With this way you dont need any Offsets / Baseaddresses
only the function strings for GetProcAddress, you can find
those with OllyDBG 2.0 and IDA.

If you have any Questions, feel free to ask.

Code:
#include <windows.h>
#include "hook.h"
Hook * Attackspeedhook = NULL;

DWORD WINAPI hookthread( LPVOID Param );
char __fastcall myGetAttackSpeed( void* this, DWORD unusededx );


typedef char (__thiscall* CPlayer_GetAttackSpeed )( void* ecx );

CPlayer_GetAttackSpeed oGetAttackSpeed = NULL;

BOOL WINAPI DllMain( HMODULE hModule, DWORD reason, LPVOID lpReserved )
{    
    UNREFERENCED_PARAMETER(lpReserved);
    if (reason == DLL_PROCESS_ATTACH)
    {
        DisableThreadLibraryCalls(hModule);
        CreateThread(NULL, NULL, hookthread, NULL, NULL, NULL);
        return 1;
    }      
    else if (reason == DLL_PROCESS_DETACH)    
    {        
        Attackspeedhook->RemoveHook();        
        return 0;    
    }      
    return 0;
}  

char __fastcall myGetAttackSpeed( void * ecx, DWORD unusededx )
{    
    return 5; // Attackspeed Value
}  

DWORD WINAPI hookthread( LPVOID Param )
{    
    HMODULE hmod = 0;
    while(!hmod)
    {
        hmod = GetModuleHandle("entitiesmp");
        Sleep(50);
    }
    unsigned long GetAttackspeedadr = reinterpret_cast<unsigned long>( GetProcAddress( hmod, "?GetAttackspeed@CPlayer@@UAECXZ" ));
    if( GetAttackspeedadr )
    {
        Attackspeedhook= new Hook( GetAttackspeedadr , 5, (DWORD)myGetAttackSpeed);
        oGetAttackSpeed = (CPlayer_GetAttackSpeed)Attackspeedhook->HookFunc();
    }
    return 0;
}
07/07/2012 09:28 lcprox3#2
Quote:
Originally Posted by wurstbrot123 View Post
hook.h is the Header of my own Hooking class but you
can just use Microsoft Detours instead ( its very very similar
to my Code ). For a MS Detours Tutorial take a look here:

[Only registered and activated users can see links. Click Here To Register...]

With this way you can also change Runspeed, Range,
Skillspeed and much more. This is just a small example,
allthough i did not try this Code it should work perfectly
fine. With this way you dont need any Offsets / Baseaddresses
only the function strings for GetProcAddress, you can find
those with OllyDBG 2.0 and IDA.

If you have any Questions, feel free to ask.

Code:
#include <windows.h>
#include "hook.h"
Hook * Attackspeedhook = NULL;

DWORD WINAPI hookthread( LPVOID Param );
char __fastcall myGetAttackSpeed( void* this, DWORD unusededx );


typedef char (__thiscall* CPlayer_GetAttackSpeed )( void* ecx );

CPlayer_GetAttackSpeed oGetAttackSpeed = NULL;

BOOL WINAPI DllMain( HMODULE hModule, DWORD reason, LPVOID lpReserved )
{    
    UNREFERENCED_PARAMETER(lpReserved);
    if (reason == DLL_PROCESS_ATTACH)
    {
        DisableThreadLibraryCalls(hModule);
        CreateThread(NULL, NULL, hookthread, NULL, NULL, NULL);
        return 1;
    }      
    else if (reason == DLL_PROCESS_DETACH)    
    {        
        Attackspeedhook->RemoveHook();        
        return 0;    
    }      
    return 0;
}  

char __fastcall myGetAttackSpeed( void * ecx, DWORD unusededx )
{    
    return 5; // Attackspeed Value
}  

DWORD WINAPI hookthread( LPVOID Param )
{    
    HMODULE hmod = 0;
    while(!hmod)
    {
        hmod = GetModuleHandle("entitiesmp");
        Sleep(50);
    }
    unsigned long GetAttackspeedadr = reinterpret_cast<unsigned long>( GetProcAddress( hmod, "?GetAttackspeed@CPlayer@@UAECXZ" ));
    if( GetAttackspeedadr )
    {
        Attackspeedhook= new Hook( GetAttackspeedadr , 5, (DWORD)myGetAttackSpeed);
        oGetAttackSpeed = (CPlayer_GetAttackSpeed)Attackspeedhook->HookFunc();
    }
    return 0;
}
Wenn ich das jetz richtig verstanden hab muss ich des jetz zu ner .DLL compilen, oder?^^ *noob*
07/07/2012 17:15 boblar#3
Wursti rette uns Ger noobs doch mal bitte endlich, wir peilen doch nix mensch :(
07/07/2012 17:36 dsfgd#4
Quote:
Originally Posted by boblar View Post
Wursti rette uns Ger noobs doch mal bitte endlich, wir peilen doch nix mensch :(
Es ist genau für euch nicht gedacht, man brauch kentnisse in
- C oder C++
- Hooks/Microsoft Detours
- dll injection

Es ist mehr ein sample code, wie man mithilfe von dll injection und hooking die standard funktion "GetAttackspeed" in eine funktion ändert, die einen beliebigen wert liefert um so ohne offsets/pointer den attackspeed beliebig manipulieren zu können.

Nebenbei, bei dieser simplen funktion (sie ist 7 Byte groß und hat 9 byte alignment ^^) reicht es auch sie mithilfe von writeprocessmemory oder memcpy zu überschreiben.
07/07/2012 17:39 wurstbrot123#5
Quote:
Originally Posted by dsfgd View Post
Nebenbei, bei dieser simplen funktion (sie ist 7 Byte groß und hat 9 byte alignment ^^) reicht es auch sie mithilfe von writeprocessmemory oder memcpy zu überschreiben.
Natürlich reicht das, aber wenn man jetzt zum Beispiel
so Radarfunktionen hat zum deaktivieren oder wenn der
User verschiedene Settings testen möchte, müsste
man nicht immer memcpy nutzen :)
Naja muss man ja beim patchen auch nicht wenn mans direkt
so patcht das es auf eine Variable zugreift :p