Warrock - Code Snippets

03/03/2013 12:58 iSkyLikeX#766
Code:
if( Server.Slots )
{
	_asm
	{
		MOV EAX, DWORD PTR DS:[ADR_SERVERPOINTER];
		MOV DWORD PTR DS:[EAX+0xC70D4], 1h;
		MOV DWORD PTR DS:[EAX+0xC70D5], 1h;
		MOV DWORD PTR DS:[EAX+0xC70D6], 1h;
		MOV DWORD PTR DS:[EAX+0xC70D7], 1h;
	}
}
Code:
if( Player.Jump )
{
   DWORD dwJumpValue = (180 * Player.Jump);
   *reinterpret_cast<float*>(ADR_JUMPVAL,dwJumpValue);
}
03/03/2013 13:41 Raz9r#767
Probably one of the worst things I've ever seen here.

Quote:
Originally Posted by iSkyLikeX View Post
Code:
if( Server.Slots )
{
	_asm
	{
		MOV EAX, DWORD PTR DS:[ADR_SERVERPOINTER];
		MOV DWORD PTR DS:[EAX+0xC70D4], 1h;
		MOV DWORD PTR DS:[EAX+0xC70D5], 1h;
		MOV DWORD PTR DS:[EAX+0xC70D6], 1h;
		MOV DWORD PTR DS:[EAX+0xC70D7], 1h;
	}
}
Code:
uintptr_t *server_ptr = reinterpret_cast<uintptr_t *>(ADR_SERVERPOINTER);
*reinterpret_cast<uint32_t *>(*server_ptr + 0xC70D4) = 0x01010101;
Does the same, is more performant as inline assembly is not going to be optimized.

Quote:
Originally Posted by iSkyLikeX View Post
Code:
if( Player.Jump )
{
   DWORD dwJumpValue = (180 * Player.Jump);
   *reininterpret_cast<float*>(ADR_JUMPVAL,dwJumpValue);
}
What is that supposed to be? reinterpret_cast is spelled another way and it only takes one parameter which is reinterpreted bytewise, no constructor or conversion operator is being called.

From the C++11 Standard, see §5.2.10 "Reinterpret Cast" [expr.reinterpret.cast]:
Quote:
The result of the expression reinterpret_cast<T>(v) is the result of converting the expression v to type T. If T is an lvalue reference type or an rvalue reference to function type, the result is an lvalue; if T is an rvalue reference to object type, the result is an xvalue; otherwise, the result is a prvalue and the lvalue-to- rvalue (4.1), array-to-pointer (4.2), and function-to-pointer (4.3) standard conversions are performed on the expression v. Conversions that can be performed explicitly using reinterpret_cast are listed below. No other conversion can be performed explicitly using reinterpret_cast.
03/03/2013 14:08 SonyRazzer#768
Quote:
Originally Posted by __underScore View Post
Probably one of the worst things I've ever seen here.


Code:
uintptr_t *server_ptr = reinterpret_cast<uintptr_t *>(ADR_SERVERPOINTER);
*reinterpret_cast<uint32_t *>(*server_ptr + 0xC70D4) = 0x01010101;
Does the same, is more performant as inline assembly is not going to be optimized.


What is that supposed to be? reinterpret_cast is spelled another way and it only takes one parameter which is reinterpreted bytewise, no constructor or conversion operator is being called.

From the C++11 Standard, see §5.2.10 "Reinterpret Cast" [expr.reinterpret.cast]:
uintptr_t *server_ptr = reinterpret_cast<uintptr_t *>(ADR_SERVERPOINTER);
Kann man das auch Global, also außerhalb vom Thread packen ? :handsdown:
03/03/2013 14:10 Raz9r#769
Quote:
Originally Posted by SonyRazzer View Post
uintptr_t *server_ptr = reinterpret_cast<uintptr_t *>(ADR_SERVERPOINTER);
Kann man das auch Global, also außerhalb vom Thread packen ? :handsdown:
"Außerhalb vom Thread" existiert nicht.
Was ist bei dir denn "global"?
03/03/2013 17:01 xRoute66x#770
Quote:
Originally Posted by __underScore View Post
"Außerhalb vom Thread" existiert nicht.
Was ist bei dir denn "global"?
Ich glaube , damit du es nur 1x schreiben musst, und es die für alle weiteren Quellcodes dieser Art wirkt.
03/03/2013 18:31 Raz9r#771
Quote:
Originally Posted by xroute66x™ :) View Post
Ich glaube , damit du es nur 1x schreiben musst, und es die für alle weiteren Quellcodes dieser Art wirkt.
Das ergibt nicht einmal grammatikalischen Sinn.

-----

Heute mal wieder ein kleiner Release zum Thema Hotpatching.
Große Teile der WinAPI sind mit dem Prefix "mov edi, edi" generiert. Das ist das gleiche wie zwei "nop" Anweisungen. Funktionen, die dieses Präfix haben, kann man sehr leicht hooken mit einer Hotpatch genannten Methode.

Mein Snippet setzt dabei folgendes voraus:
- Es wird kompiliert unter Visual Studio 2012,
- Das VC++ November 2012 CTP ist installiert (Download: [Only registered and activated users can see links. Click Here To Register...]) und
- Das VC++ November 2012 CTP ist in Visual Studio aktiviert unter Projekteinstellungen (Alt+F7) > Konfigurationseigenschaften > Allgemein > Plattformtoolset.

Eine kleine Beispielanwendung, die die Anwendung für MessageBoxA/MessageBoxW zeigt, ist diese hier:

Code:
# include <iostream>

# include <Windows.h>
# include <cstdint>
# include <system_error>

class virtual_protect_lock
{
public:
    virtual_protect_lock(void *ptr, const size_t size, const DWORD protection)
        : ptr_(ptr), size_(size)
    {
        if (!::VirtualProtect(ptr_, size_, protection, &old_prot_))
            throw std::system_error(::GetLastError(), std::system_category());
    }

    ~virtual_protect_lock() 
    {
        if (!::VirtualProtect(ptr_, size_, old_prot_, &old_prot_))
            throw std::system_error(::GetLastError(), std::system_category());
    }

private:
    virtual_protect_lock(); // undefined
    
    DWORD old_prot_;
    void *ptr_;
    const size_t size_;
};

template <typename _Return, typename... _Args>
auto install_hotpatch(_Return (__stdcall *target)(_Args...),
                      _Return (__stdcall *hook)(_Args...))
-> _Return (__stdcall *)(_Args...)
{
#   pragma pack(push, 1)
    struct signature_t 
    {
        std::uint8_t  long_jump;
        std::uint32_t long_jump_adr;
        std::uint16_t jump_back;
    };
#   pragma pack(pop)
    
    struct signature_t *signature = reinterpret_cast<struct signature_t *>(
        reinterpret_cast<uintptr_t>(target) - 5);
    
    if ((signature->long_jump     == 0x90)       &&
        (signature->long_jump_adr == 0x90909090) &&
        (signature->jump_back     == 0xFF8B))
    try 
    {
        virtual_protect_lock vplock(signature, sizeof(*signature), 
                                    PAGE_EXECUTE_WRITECOPY);
        signature->long_jump     = 0xE9;
        signature->long_jump_adr = reinterpret_cast<uintptr_t>(hook) 
            - reinterpret_cast<uintptr_t>(target);
        signature->jump_back     = 0xF9EB;
    } 
    catch(const std::system_error &) 
    { 
        throw; 
    }

    return reinterpret_cast<_Return (__stdcall *)(_Args...)>(
                reinterpret_cast<uintptr_t>(target) + 2);
}

template <typename _Return, typename... _Args>
void uninstall_hotpatch(_Return (__stdcall *target)(_Args...))
{
#   pragma pack(push, 1)
    struct signature_t 
    {
        std::uint8_t  long_jump;
        std::uint32_t long_jump_adr;
        std::uint16_t jump_back;
    };
#   pragma pack(pop)
    
    struct signature_t *signature = reinterpret_cast<struct signature_t *>(
        reinterpret_cast<uintptr_t>(target) - 5);
    
    if ((signature->long_jump     == 0xE9)       &&
        (signature->long_jump_adr != 0x90909090) &&
        (signature->jump_back     == 0xF9EB)) 
    try 
    {
        virtual_protect_lock vplock(signature, sizeof(*signature), 
                                    PAGE_EXECUTE_WRITECOPY);
        signature->long_jump     = 0x90;
        signature->long_jump_adr = 0x90909090;
        signature->jump_back     = 0xFF8B;
    }
    catch(const std::system_error &) 
    { 
        throw; 
    }
}

decltype(MessageBox) *original_MessageBox;
int WINAPI hook_MessageBox(HWND hWnd, LPCTSTR lpText, 
                           LPCTSTR lpCaption, UINT uType)
{
    return original_MessageBox(hWnd, TEXT("replaced text"), 
                               TEXT("replaced caption"), uType);
}

int main(int argc, char *argv[]) try 
{
    original_MessageBox = install_hotpatch(MessageBox, hook_MessageBox);
    MessageBox(nullptr, TEXT("text"), TEXT("caption"), MB_OK);
    uninstall_hotpatch(MessageBox);
    MessageBox(nullptr, TEXT("text"), TEXT("caption"), MB_OK);

    return 0;
}
catch(const std::system_error &err)
{
    std::cout << err.what();
    std::cin.get();

    return err.code().value();
}
Eine kurze Erläuterung zu den einzelnen Sachen, die ich hier zusammengeschrieben habe:
(1) virtual_protect_lock verändert bei Objekterzeugung die Page-Protection, bei Verlassen des Scopes wird diese wieder zurückgesetzt. Tritt hierbei ein Fehler auf, wird ein std::system_error erzeugt und als exception geworfen. Der Errorcode ist das Ergebnis von GetLastError.
(2) install_hotpatch setzt den Hotpatch. Bei einem Fehler von virtual_protect_lock wird die Funktion abgebrochen, indem die Exception erneut geworfen wird. Die Funktion hat zwei Parameter: Einen Zeiger auf die Funktion, die man hooken möchte, und einen Zeiger auf den Hook selbst. Der Rückgabewert der Funktion ist ein Zeiger auf die originale Funktion nach dem Hook. Alle drei Funktionszeiger müssen exakt die gleiche Signatur haben. Wenn die Funktion für einen Hotpatch ungeeignet ist oder bereits einer installiert ist, passiert nichts.
(3) Die Funktion uninstall_hotpatch funktioniert analog zu install_hotpatch und entfernt den Hotpatch, wenn einer gesetzt ist. Einziges Parameter ist hier ein Zeiger auf die Funktion, deren Hotpatch man entfernen möchte.

Es sei dazu noch gesagt, dass man virtual_protect_lock nicht in STL Containern verwenden sollte, weil der Destruktor eine Exception werfen kann.

---

EDIT: Verwarnung, weil ich nach mehreren Tagen ohne aktiven Post einen Release in einen neuen Post packe anstatt sie in den alten zu packen? Was ist das denn bitte für eine Moderation?
03/06/2013 22:51 [N]oSoul#772
if i add this :
Quote:
D3DXCreateBox( pDevice,15,38,15, &pBoxMesh, 0);
I get this problem :

Quote:
1>------ Build started: Project: Frenz Base, Configuration: Release Win32 ------
1> base.cpp
1>LINK : fatal error LNK1104: cannot open file 'libcp.lib'
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Help Me :D


EDIT : RESOLVED ;)
03/07/2013 15:53 Xave :)#773
Code:
VOID CALLBACK HackShieldBypass()
{
	/*         __   __            
		   \ \ / /               
		    \ V / __ ___   _____ 
		     > < / _` \ \ / / _ \
		  _ / . \ (_| |\ V /  __/
	         (_)_/ \_\__,_| \_/ \___|
	*/
	DWORD hEhSvc = (DWORD)GetModuleHandleA("EhSvc.dll");
        if ( hEhSvc !=0 )
        {
		/* MODULE: EHSVC.DLL */
		MemoryEdit((PVOID)(hEhSvc + 0x007B8B6),(PBYTE)"\xC3",1);
		MemoryEdit((PVOID)(hEhSvc + 0x000A098),(PBYTE)"\x74",1);
		MemoryEdit((PVOID)(hEhSvc + 0x009E7EC),(PBYTE)"\x03\xD2",2);
		MemoryEdit((PVOID)(hEhSvc + 0x009C0FF),(PBYTE)"\xB8\x00\x00\x00\x00",5);

		/*  MODULE: WARROCK.EXE  */
		MemoryEdit((PVOID)(0x004D51BC),(PBYTE)"\xC3",1);
		MemoryEdit((PVOID)(0x0050C8E2),(PBYTE)"\xC2\x0C\x00",3);
		MemoryEdit((PVOID)(0x005DAB9E),(PBYTE)"\xC3",1);
	}
}
03/07/2013 21:44 Lazl07#774
non work at here
Windows XP
32 bit.
03/08/2013 15:50 ~ExoduS~*#775
Quote:
Originally Posted by .χανє View Post
Code:
VOID CALLBACK HackShieldBypass()
{
	/*         __   __            
		   \ \ / /               
		    \ V / __ ___   _____ 
		     > < / _` \ \ / / _ \
		  _ / . \ (_| |\ V /  __/
	         (_)_/ \_\__,_| \_/ \___|
	*/
	DWORD hEhSvc = (DWORD)GetModuleHandleA("EhSvc.dll");
        if ( hEhSvc !=0 )
        {
		/* MODULE: EHSVC.DLL */
		MemoryEdit((PVOID)(hEhSvc + 0x007B8B6),(PBYTE)"\xC3",1);
		MemoryEdit((PVOID)(hEhSvc + 0x000A098),(PBYTE)"\x74",1);
		MemoryEdit((PVOID)(hEhSvc + 0x009E7EC),(PBYTE)"\x03\xD2",2);
		MemoryEdit((PVOID)(hEhSvc + 0x009C0FF),(PBYTE)"\xB8\x00\x00\x00\x00",5);

		/*  MODULE: WARROCK.EXE  */
		MemoryEdit((PVOID)(0x004D51BC),(PBYTE)"\xC3",1);
		MemoryEdit((PVOID)(0x0050C8E2),(PBYTE)"\xC2\x0C\x00",3);
		MemoryEdit((PVOID)(0x005DAB9E),(PBYTE)"\xC3",1);
	}
}
100% it will crash :D I think you need to make it with packets etc Oo :D
03/08/2013 16:32 Xave :)#776
Quote:
Originally Posted by ~ExoduS~* View Post
100% it will crash :D I think you need to make it with packets etc Oo :D
It's working for me ;O
03/08/2013 16:54 hansewurst#777
hey lieber coder ;)

Hab paar kleine probleme mit meinen source code :/

Code:
//--------------------------Define Hacks--------------------------//

DWORD *ingame = (DWORD*)ADR_PLAYERPOINTER;
DWORD *outgame = (DWORD*)ADR_SERVERPOINTER;


//--------------------------Start Hacks--------------------------//
void PlayerHacks()
{
DWORD dwPlayerPtr = *(DWORD*)ADR_PLAYERPOINTER;
if(dwPlayerPtr != 0)
{
//Super Jump
{
if(GetAsyncKeyState(VK_CONTROL) &1)
{
*(float*)(dwPlayerPtr + OFS_Z) = 2000;
}
}

{
DWORD dwPlayerPtr = *(DWORD*)ADR_PLAYERPOINTER;
if(dwPlayerPtr != 0)
{
*(float*)ADR_FASTREPAIR = 10.0f;
*(float*)ADR_FASTHEALTH = 5.0f;
*(float*)ADR_FASTFLAG = 10.0f;
*(float*)ADR_FASTAMMO = 5.0f;
}
}

//No Fall Damage

{
*(float*)(dwPlayerPtr +OFS_NOFALLDAMAGE) = -2000;
}


//Super No Spread
if(ADR_SUPERNOSPREAD)
{
*(double*)ADR_SUPERNOSPREAD = 0;
}
else
{
*(double*)ADR_SUPERNOSPREAD = 5;
}



//Speed




{
DWORD dwPlayerPtr = *(DWORD*)ADR_PLAYERPOINTER;
if(dwPlayerPtr != 0)
{
*(float*)(dwPlayerPtr+OFS_NORECOIL1) = 0;
*(float*)(dwPlayerPtr+OFS_NORECOIL2) = 0;
*(float*)(dwPlayerPtr+OFS_NORECOIL3) = 0;
}
}

//No Reload
{
DWORD dwPlayerPtr = *(DWORD*)ADR_PLAYERPOINTER;
if(dwPlayerPtr != 0)
{
*(float*)(dwPlayerPtr+OFS_NORELOAD) = 0;

}
}

{
if(GetAsyncKeyState(VK_MENU) &1)
{
DWORD dwPlayerPtr = *(DWORD*)ADR_PLAYERPOINTER;
if(dwPlayerPtr != 0)
{
*(float*)(dwPlayerPtr+OFS_Z) = -2000;
}
}
}


}
}
void ServerHacks()
{
DWORD dwSrvrPtr = *(DWORD*)ADR_SERVERPOINTER;
if(dwSrvrPtr != 0)
{



//Slot Stuff

//5 Slot
{
*(long*)(dwSrvrPtr + OFS_5SLOT) = 1;
}

//6 Slot
{
*(long*)(dwSrvrPtr + OFS_6SLOT) = 1;
}

//7 Slot
{
*(long*)(dwSrvrPtr + OFS_7SLOT) = 1;
}

//8 Slot
{
*(long*)(dwSrvrPtr + OFS_8SLOT) = 1;
}
}
}

//-------------------------HackThread--------------------------//

void HackThread()
{
for(;; )
{
if(*ingame)
{


PlayerHacks();
}
if(*outgame)
{
ServerHacks();
}
}
Sleep( 200 );
}
BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpvReserved)
{
if(dwReason == DLL_PROCESS_ATTACH)
{
CreateThread(0, 0, (LPTHREAD_START_ROUTINE)HackThread, 0, 0, 0);
}
return TRUE;
}

1. Soweit klappt alles, nur wie is die source für den speedhack? Hab schon alles mögliche ausprobiert aber nichts klappt :/
2. No spread bzw. Super No spread geht nicht bzw. stürzt bei anderen source ab
3. No reload funktioniert auch nicht

Wenn ihr mier helfen würdet wäre schon ganz cool
danke schonmal :)
03/08/2013 17:07 xRoute66x#778
Quote:
Originally Posted by hansewurst View Post
1337 source
Brauchst einen Patch für Speed,SperNospread usw. usw.
Benutz die Suchfunktion, da wirst du schon was finden ;)
03/08/2013 17:14 Xave :)#779
Quote:
Originally Posted by hansewurst View Post
...
SpeedSource:
Code:
 _Player->pLocal->PlayerSpeed = -200.00F; // 2x Speed
NoSpread Source:
Code:
 _Player->pLocal->Spread = 0.00F;
Structs:
[Only registered and activated users can see links. Click Here To Register...]
03/08/2013 17:23 hansewurst#780
Gibt es ein Tut in dem beschrieben wird wie das mit dem Patchen geht?
Und braucht man einen patch oder mehrere?

if(x_Speed => 0 && x_Speed < 7)
Patch<double>(reinterpret_cast<void*>(ADR_SPEED), 96.0 * (x_Speed + 1));

Das hab ich gefunden, hilft das was?

@ .xave
Dein source ist aber nicht auf meinen source gemacht ( richtige wort fällt mir grad nicht ein :D ), oder?

Und ich dachte no menu hacks für warrock wären eine leichte sache ._. :(