Results 1 to 3 of 3
  1. #1
    MartinMorcos's Avatar
    Join Date
    Dec 2014
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0

    Question my static + offsets code doesnt work

    i am trying to make a external trainer that just overwrite the current address , everything goes very well till the writing part
    every time i press F1 i get a fatel error =D and F2 doesnt work i got the static address and offsets and iam sure that they are 100% for a game called "AssaultCube" so Here's my code:


    #include <iostream>
    #include <Windows.h>
    #include <ctime>
    #include <string>

    using namespace std;
    void WritetoMemory(HANDLE hProcess);
    DWORD find(int PointerLevel, HANDLE hProcess, DWORD offset[], DWORD BaseAddress);



    string GameName = "AssaultCube";
    LPCSTR LGameWindow = "AssaultCube";
    string GameStatus;

    bool isgameavail;
    bool updateonNextrun;

    //Ammo
    bool AmmoStatus;
    BYTE AmmoValue[] = { 0xA4, 0x1C, 0x0, 0x0 };
    DWORD AmmoOFFsets[] = { 0x384,0x14,0x0 };
    DWORD AmmoBaseAddress = { 0x00509B74 };
    //HP
    bool HPStatus;
    BYTE HPValue[] = { 0x39, 0x5, 0x0, 0x0 };
    DWORD HPOFFsets[] = { 0xF8 };
    DWORD HPBaseAddress = { 0x0050F4F4 };


    int main(){
    system("Color B");
    HWND hGameWindow = NULL;
    HANDLE hProcess = NULL;
    DWORD pid = NULL;
    int isgameavailTMR = clock();
    int onepressTMR = clock();
    int timeSinceLastUpdate = clock();
    updateonNextrun = true;
    string sAmmo = "OFF";
    string sHP = "OFF";
    while (!GetAsyncKeyState(VK_INSERT)){
    if (clock() - isgameavailTMR > 100){
    isgameavailTMR = clock();
    isgameavail = false;
    hGameWindow = FindWindow(NULL, LGameWindow);
    if (hGameWindow){
    GetWindowThreadProcessId(hGameWindow, &pid);
    if (pid != 0){
    hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pid);
    if (hProcess == INVALID_HANDLE_VALUE || hProcess == NULL){
    GameStatus = "No Process Found\n";
    }
    else{
    GameStatus ="Game is Ready for Hack\n";
    isgameavail = true;
    }
    }
    else{
    GameStatus = "Invalid Process\n";
    }
    }
    else{
    GameStatus = " Game: NOT FOUND!!\n";
    }
    if (updateonNextrun || clock() - timeSinceLastUpdate > 5000){
    system("cls");
    cout << "===============================" << endl;
    cout << " AssaultCube " << endl;
    cout << "===============================" << endl;
    cout << "GameStatus" << GameStatus << endl;
    cout << "[F1] Unlimited Ammo -> " << sAmmo << " <-" << endl;
    cout << "[F2] HP -> " << sHP << " <-" << endl;
    cout << "[INSERT] Exit" << endl;
    updateonNextrun = false;
    timeSinceLastUpdate = clock();
    }
    if (isgameavail){
    WritetoMemory(hProcess);
    }
    }
    if (clock() - onepressTMR > 400){
    if (isgameavail){
    if (GetAsyncKeyState(VK_F1)){
    onepressTMR = clock();
    AmmoStatus = !AmmoStatus;
    updateonNextrun = true;
    if (AmmoStatus) sAmmo = "ON";
    else sAmmo = "OFF";
    }
    if (GetAsyncKeyState(VK_F2)){
    onepressTMR = clock();
    HPStatus = !HPStatus;
    updateonNextrun = true;
    if (HPStatus) sHP = "ON";
    else sHP = "OFF";
    }

    }

    }
    }
    return ERROR_SUCCESS;
    }

    DWORD find(int PointerLevel, HANDLE hProcess,DWORD OFFsets[], DWORD BaseAddress){
    DWORD Pointer = BaseAddress;
    DWORD ptemp;
    DWORD Pointeraddr;
    for (int i = 0; i < PointerLevel; i++){
    if (i == 0){
    ReadProcessMemory(hProcess, (LPCVOID)Pointer, &ptemp, sizeof(ptemp), NULL);
    }
    Pointeraddr = Pointer + OFFsets[i];
    ReadProcessMemory(hProcess, (LPCVOID)Pointeraddr,&ptemp, sizeof(ptemp), NULL);
    }
    return Pointeraddr;
    }

    void WritetoMemory(HANDLE hProcess){
    DWORD AddresstoWrite;
    if (AmmoStatus){
    AddresstoWrite = find(3, hProcess,AmmoOFFsets ,AmmoBaseAddress);
    WriteProcessMemory(hProcess, (BYTE*)AddresstoWrite, &AmmoValue, sizeof(AmmoValue), NULL);
    }
    if (HPStatus){
    AddresstoWrite = find(1, hProcess, HPOFFsets, HPBaseAddress);
    WriteProcessMemory(hProcess, (BYTE*)AddresstoWrite, &HPValue,sizeof(HPValue), NULL);
    }
    }

  2. #2
    ERGaergaergaergaergearg's Avatar
    Join Date
    Apr 2011
    Gender
    male
    Posts
    172
    Reputation
    19
    Thanks
    30
    My Mood
    Amazed
    One question, do you even know what any of this code does?

    And make sure to post it in [code] tags.

  3. #3
    MartinMorcos's Avatar
    Join Date
    Dec 2014
    Gender
    male
    Posts
    2
    Reputation
    10
    Thanks
    0
    u need to know what the whole code means? ...
    from int main()
    its basically checking every 5 seconds whether the game is opened or not
    closes when i press insert button
    (clock() - onepressTMR > 400)
    is the timer of the ON or OFF every 4 milliseconds when i press F1 or F2 so that the console doesnt crush
    ofc hProcess = GetWindowThreadProcessId is to get the pid of the game when u press Alt + crtl + delete in the process tab
    DWORD find function is to read address with OFFSETS which maybe i have an error with it
    and last WritetoMemory function is to write on it =D thats the summary of the code + iam here for solutions not explaining my code...

Similar Threads

  1. [Discussion] Okay ..so i adjusted the code a little bit but still doesnt work..
    By moathebest in forum CrossFire Hack Coding / Programming / Source Code
    Replies: 9
    Last Post: 11-25-2011, 11:04 AM
  2. DS2 doesnt work
    By acepwnage in forum General Gaming
    Replies: 1
    Last Post: 07-03-2006, 10:21 PM
  3. Warrok Doesnt work for me!?!?!
    By acepwnage in forum General Gaming
    Replies: 8
    Last Post: 06-13-2006, 09:55 PM
  4. The Weopons hack doesnt work???
    By Coolman in forum WarRock - International Hacks
    Replies: 18
    Last Post: 05-25-2006, 07:04 AM
  5. WPE doesnt work anymore!!!!!!!!!!!!!!!!!!!!
    By kayhesse in forum WarRock - International Hacks
    Replies: 3
    Last Post: 01-22-2006, 12:47 PM

Tags for this Thread