Results 1 to 1 of 1
  1. #1
    Dwar
    Dwar is offline
    Veteran Dwar's Avatar
    Join Date
    2010 Mar
    Posts
    2,222
    Thanks Thanks Given 
    211
    Thanks Thanks Received 
    2,230
    Thanked in
    292 Posts
    Rep Power
    10

    [C++] Basic Game Hacking (Memory Editing)

    Basic C++ Game Hacking (Memory Editing)

    Some simple basic C++ game hacking (egg: memory editing)
    We will start with one of the most simple codes:
     #include <windows.h>

    int main() {
    HWND hWnd = FindWindow(0, "Calculator");
    if(hWnd == 0){
    MessageBox(0, "Error cannot find window.", "Error", MB_OK|MB_ICONERROR);
    } else {
    DWORD proccess_ID;
    GetWindowThreadProcessId(hWnd, &proccess_ID);
    HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, proccess_ID);
    if(!hProcess){
    MessageBox(0, "Could not open the process!", "Error!", MB_OK|MB_ICONERROR);
    } else {
    int newdata = 500;
    DWORD newdatasize = sizeof(newdata);
    if(WriteProcessMemory(hProcess, (LPVOID)0x57C2A4, &newdata, newdatasize, NULL)){
    MessageBox(NULL, "WriteProcessMemory worked.", "Success", MB_OK + MB_ICONINFORMATION);
    } else {
    MessageBox(NULL, "Error cannot WriteProcessMemory!", "Error", MB_OK + MB_ICONERROR);
    }
    CloseHandle(hProcess);
    }
    }
    return 0;
    }

    This will edit the following memory address: 0x57C2A4
    In the calculator window,
     HWND hWnd = FindWindow(0, "Calculator");
    if(hWnd == 0)
    {
    MessageBox(0, "Error cannot find window.", "Error", MB_OK|MB_ICONERROR);
    }

    The lines above will search for a window (process) to edit.
    In this case it is the calculator but if you want to edit the Cod4 Addresses it should be iw3mp!
    The if statement checks if the window is opened and exists. If not you will get a message that it can not be found.

    Scroll down till you see this line:

    if(WriteProcessMemory(hProcess, (LPVOID)0x57C2A4, &newdata, newdatasize, NULL))

    0x57C2A4 is our address, newdata is the value for our adressm and newdatasize is the bytes that the address is (Most 4)
    So you could edit it to:

    if(WriteProcessMemory(hProcess, (LPVOID)0x57C2A4, &567, 4, NULL))

    Which will change the value to 567 with 4 bytes.

    Memory Address freezing

    So there is not a real code to freeze (egg FreezeAdress() it just don't exist>
    But we can freeze it by using an infinite loop

    So we take the code which edits the address value:
     if(WriteProcessMemory(hProcess, (LPVOID)0x57C2A4, &newdata, newdatasize, NULL))
    {
    // Here should be the message box that the change has worked, but you need to remove it when using a loop otherwise you will get a infinite msgbox xD
    }


    and put it in a infinite loop:
     while(1);
    {
    if(WriteProcessMemory(hProcess, (LPVOID)0x57C2A4, &newdata, newdatasize, NULL))
    {

    }
    }

    The code above will freeze your code by using a simple loop.
     for (int i = 0; i >= 0; i++)
    {
    // here the code
    }

    Author: Tukjedude
    Please, post your questions on forum, not by PM or mail

    I spend my time, so please pay a little bit of your time to keep world in equilibrium

  2. The Following User Says Thank You to Dwar For This Useful Post:


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •