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 


how to write pointer in C++ ...

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
gavrielsinvani
Cheater
Reputation: 0

Joined: 29 May 2019
Posts: 25

PostPosted: Sun May 17, 2020 3:47 pm    Post subject: how to write pointer in C++ ... Reply with quote

i have pointers without offset,

HP Max Address:
TimeLapse.dll+B05BC

MP Max Address:
TimeLapse.dll+B05C4

I want to get their value in c ++.


thanks.
Back to top
View user's profile Send private message
explicity
How do I cheat?
Reputation: 0

Joined: 20 May 2020
Posts: 1

PostPosted: Wed May 20, 2020 11:05 pm    Post subject: Reply with quote

Those aren't pointers you posted, that is the module name and offset. You would need the address(location) of that module and add the offset to get the value you want.

HP Max Address:
TimeLapse.dll+B05BC

MP Max Address:
TimeLapse.dll+B05C4

You could do something like :
unsigned int base = reinterpret_cast<unsigned int>(GetModuleHandleA(TimeLapse.dll)) + 0xB05BC;

Retrieve the value by casting and then dereferencing it as the type you expect it to be, for example:
unsigned int hpMax = *reinterpret_cast<unsigned int*>(base);

Writing is similar: *reinterpret_cast<unsigned int*>(base) = some_value;

The above code requires you have direct access to the process's memory. If you don't, you'd need to replace GetModuleHandleA with another function or iterate through the Module List using MODULEENTRY32 and use ReadProcessMemory.
Back to top
View user's profile Send private message
Astaroth4256
Advanced Cheater
Reputation: 0

Joined: 25 May 2014
Posts: 59

PostPosted: Fri Jun 19, 2020 10:09 am    Post subject: Reply with quote

1. Find process
Code:

vector<UINT> GetProcessList(const char* exeName) {
        vector<UINT> aprocessList;
        aprocessList.clear();
        PROCESSENTRY32 entry;
        ZeroMemory(&entry, sizeof(entry));
        entry.dwSize = sizeof(PROCESSENTRY32);

        HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);

        if(snapshot == NULL) {
                printf("Null snapshot\n");
                getchar();
                CloseHandle(snapshot);
                return aprocessList;
        }
        if(snapshot == INVALID_HANDLE_VALUE) {
                printf("INVALID_HANDLE_VALUE);
                aprocessList.clear();
                CloseHandle(snapshot);
                return aprocessList;
        }

        if(Process32First(snapshot, &entry) == TRUE) {
                while (Process32Next(snapshot, &entry) == TRUE) {
                        if (_stricmp(entry.szExeFile, exeName) == 0) {
                                aprocessList.push_back(entry.th32ProcessID);
                        }
                }
        } else {
                printf("Error ");
                cout<<GetLastError()<<endl;
                CloseHandle(snapshot);
                getchar();
        }

        CloseHandle(snapshot);
        return aprocessList;
}


2. Get process handle
Code:

processHandle = OpenProcess(PROCESS_ALL_ACCESS, FALSE, PID);

3. Get module base
Code:

void MEMORY::GetModuleBaseAddress(UINT PID) {
        const char* moduleName = "game.exe";
        MODULEENTRY32 module32;
        module32.dwSize = sizeof(MODULEENTRY32);
        HANDLE hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPMODULE, PID);
        Module32First(hSnap, &module32);
        do {
                if(!strcmp(module32.szModule, moduleName)) {
                        moduleBase = (DWORD64)module32.modBaseAddr;
                        break;
                }
        } while(Module32Next(hSnap, &module32));
        CloseHandle(hSnap);
}

4. Traverse pointer path
Can't give you an example of code for this cause mine is a quickfix. The general idea for this is:
-add base address to module base (now you get a static address - green in CE)
-add offset to result from up there^
-read memory at result from up there^
-if you have another offset, add offset to result from up there^
-read memory at result from up there^
-if you don't have more offsets, this is your desired address
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 programming 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