QuestionSimple Game Hack

Posts 15 of 5 · Page 1 of 1
Simple Game Hack
ok, so i'm trying to make a hack for a game, just some simple point cheat. so here's the code i have written following a tutorial.

Code:
#include <windows.h>


using namespace std;

DWORD WINAPI LoopFunction( LPVOID lpParam )
{

    BYTE pointsON[] = {0x83, 0x05, 0xE8, 0x26, 0x4C, 0x00, 0x80};
    BYTE pointsOFF[] = {0x83, 0x05, 0xE8, 0x26, 0x4C, 0x00, 0x19};

    bool pointCheat = false;

    HANDLE Game = GetCurrentProcess();

    while(1) {
        if (GetAsyncKeyState(VK_F1)&0x80000) {
            if (pointCheat == true) {
                WriteProcessMemory(Game, (LPVOID*)0x44B62D, &pointsOFF, 7, 0);
                pointCheat = false;

            }
            else if( pointCheat == false) {
                WriteProcessMemory(Game, (LPVOID*)0x44B62D, &pointsON, 7, 0);
                pointCheat = true;
            }

        }
    }
//some CPU relief
    Sleep(200);
    return 0;
}

BOOL WINAPI DllMain (HINSTANCE hModule, DWORD dwAttached, LPVOID lpvReserved)
{
    if (dwAttached == DLL_PROCESS_ATTACH) {
        CreateThread(NULL,0,&LoopFunction,NULL,0,NULL);
    }
    return 1;
}
whenever i compile and inject this dll, it does nothing in the game, i press f1 but the points i get stay the same...any help?
First of all, you are injecting this dll, so you don't need to use WriteProcessmemory since you're in the module. You can directly change stuff, like let's say the score is an integer you can do this: *(DWORD*)(addie) = yourvalue;
that won't let me edit bytes though, just values held in addresses? also, even if i comment out the createthread and just make it popup a messagebox, the messagebox never shows on injection, could this be due to using a 64 bit os? idk, every tutorial i follow the results never work no matter what.
Quote Originally Posted by turdsammiches View Post
that won't let me edit bytes though, just values held in addresses? also, even if i comment out the createthread and just make it popup a messagebox, the messagebox never shows on injection, could this be due to using a 64 bit os? idk, every tutorial i follow the results never work no matter what.
Use character pointers to edit the bytes at a particular address. What 258456 meant to say was, because you're in the same address-space as your target process, there is no need to go through the Windows API to alter the address.

For example:
Code:
char* pBytes = 0x40A000
pBytes[0] = 10;
In your case, you can just use the memcpy method in the C++ standard library:
Code:
BYTE pointsON[] = {0x83, 0x05, 0xE8, 0x26, 0x4C, 0x00, 0x80};
BYTE pointsOFF[] = {0x83, 0x05, 0xE8, 0x26, 0x4C, 0x00, 0x19};
//memcpy(void* pDest, void* pSrc, size_t szLen)
//So to turn them on...
memcpy(DEST_ADDRESS, &pointsON[0], sizeof(pointsON);
As for your DLL, first, check if CreateThread fails - if it does, it is safe to log this error with OutputDebugStringA (as it is contained within the kernel32 library...). If it does fail, use GetLastError to figure out what went wrong.
It is a quite obvious problem, you never set the bool pointCheat to true and this:
Code:
             if (pointCheat == true) {
                WriteProcessMemory(Game, (LPVOID*)0x44B62D, &pointsOFF, 7, 0);
                pointCheat = false;

            }
will never be executed

Do something like this:

Code:
bool pointCheat = false;

while(1)
{
if(GetAsyncKeyState(VK_F1))
{
pointCheat =! pointCheat;//Will switch from false to true and vice versa
if(pointCheat)//Is true do stuff
{

}
else//Is false do the other stuff
{
}

}
Sleep(250);
}

Also:
Code:
CreateThread(0,0,LoopFunction,0,0,0);
Posts 15 of 5 · Page 1 of 1

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?