Cheat Engine Forum Index Cheat Engine
The Official Site of Cheat Engine
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 


Help with incorporating static address & offsets into C+

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking
View previous topic :: View next topic  
Author Message
zebrabacon
How do I cheat?
Reputation: 0

Joined: 26 Dec 2016
Posts: 3

PostPosted: Wed Jan 11, 2017 4:32 pm    Post subject: Help with incorporating static address & offsets into C+ Reply with quote

The game I'm using is Assult Cube.

As the title states, I am having some trouble getting my cheat to work with static addresses and offsets. Here's my code:


Code:

int main()
{
    int newAmmoValue = 999;
    HWND hWnd = FindWindow(0, "AssaultCube");
    if (hWnd == 0) {
        cout << "Cannot find window." << endl;
        Sleep(5000);
    } else {
        DWORD pId;
        GetWindowThreadProcessId(hWnd, &pId);
        HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);

        if (!hProc) {
            cout << "Cannot open process." << endl;
            Sleep(5000);
        } else {
                static int LMGoffset = 0x150;
                int PlayerBase = 0x00509B74;
                int LmgAddress= PlayerBase + LMGoffset;

            int success = WriteProcessMemory(hProc, (LPVOID)[b][size=18]LmgAddress[/size][/b], &newAmmoValue, (DWORD)sizeof(newAmmoValue), NULL);

            if (success > 0) {
                cout << "Success." << endl;
                Sleep(5000);
            }
            else {
                cout << "Failure." << endl;
                Sleep(5000);
            }
            CloseHandle(hProc);
        }
    }

}


The problem is with "LmgAmmo" in the code, just following the (LPVOID)because that is where I am running into trouble. With the code the way it is right now, I get a full execution of the code and get "Success." returned to me, but the value associated with LmgAddress is not changed. If I replace LmgAddress with a dynamic address I find using cheat engine, my code works to change the ammo. But for some reason when I replace that address with the static address + offset it will not change the value in game. If I go into cheat engine and input the static address with the offset, I can change the ammo from there like normal, so I'm not sure why it is not working in my code.
Back to top
View user's profile Send private message
Filipe_Br
Master Cheater
Reputation: 3

Joined: 07 Jan 2016
Posts: 272
Location: My house

PostPosted: Wed Jan 11, 2017 5:20 pm    Post subject: Re: Help with incorporating static address & offsets int Reply with quote

From what I understand, the error occurred while using a static address + offset, to change the address of your ammo.
If so then you do not know how pointers work.
If I have this static address "01234120" and this offset "18", it points to this address "011EBC78". What will happen is this. The address "01234120" will have this value (011EBC60) that added to "18" which is my offset, will work at this address "011EBC78".
Understood?

_________________
...
Back to top
View user's profile Send private message
ulysse31
Master Cheater
Reputation: 2

Joined: 19 Mar 2015
Posts: 324
Location: Paris

PostPosted: Wed Jan 11, 2017 5:47 pm    Post subject: Re: Help with incorporating static address & offsets int Reply with quote

zebrabacon wrote:


Code:

int main()
{
    int newAmmoValue = 999;
    HWND hWnd = FindWindow(0, "AssaultCube");
    if (hWnd == 0) {
        cout << "Cannot find window." << endl;
        Sleep(5000);
    } else {
        DWORD pId;
        GetWindowThreadProcessId(hWnd, &pId);
        HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);

        if (!hProc) {
            cout << "Cannot open process." << endl;
            Sleep(5000);
        } else {
                static int LMGoffset = 0x150;
int nAddress;
                int PlayerBase = 0x00509B74;
ReadProcessMemory(hProc, (LPVOID)PlayerBase , &nAddress, sizeof(nAddress), NULL);
                int LmgAddress= nAddress + LMGoffset;

            int success = WriteProcessMemory(hProc, (LPVOID)LmgAddress, &newAmmoValue, (DWORD)sizeof(newAmmoValue), NULL);

            if (success > 0) {
                cout << "Success." << endl;
                Sleep(5000);
            }
            else {
                cout << "Failure." << endl;
                Sleep(5000);
            }
            CloseHandle(hProc);
        }
    }

}
Back to top
View user's profile Send private message
zebrabacon
How do I cheat?
Reputation: 0

Joined: 26 Dec 2016
Posts: 3

PostPosted: Wed Jan 11, 2017 6:12 pm    Post subject: Re: Help with incorporating static address & offsets int Reply with quote

ulysse31 wrote:


Code:

int main()
{
    int newAmmoValue = 999;
    HWND hWnd = FindWindow(0, "AssaultCube");
    if (hWnd == 0) {
        cout << "Cannot find window." << endl;
        Sleep(5000);
    } else {
        DWORD pId;
        GetWindowThreadProcessId(hWnd, &pId);
        HANDLE hProc = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pId);

        if (!hProc) {
            cout << "Cannot open process." << endl;
            Sleep(5000);
        } else {
                static int LMGoffset = 0x150;
int nAddress;
                int PlayerBase = 0x00509B74;
ReadProcessMemory(hProc, (LPVOID)PlayerBase , &nAddress, sizeof(nAddress), NULL);
                int LmgAddress= nAddress + LMGoffset;

            int success = WriteProcessMemory(hProc, (LPVOID)LmgAddress, &newAmmoValue, (DWORD)sizeof(newAmmoValue), NULL);

            if (success > 0) {
                cout << "Success." << endl;
                Sleep(5000);
            }
            else {
                cout << "Failure." << endl;
                Sleep(5000);
            }
            CloseHandle(hProc);
        }
    }

}


This fixed it. Thank you! Very Happy
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> General Gamehacking All times are GMT - 6 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Powered by phpBB © 2001, 2005 phpBB Group

CE Wiki   IRC (#CEF)   Twitter
Third party websites