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 


C++ How to loop through entity name list?

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

Joined: 05 Feb 2016
Posts: 54
Location: 127.0.0.1

PostPosted: Wed Jun 14, 2017 9:38 am    Post subject: C++ How to loop through entity name list? Reply with quote

[code]char readTest[32]; DWORD BaseAddress = get_module_base(procID, "Game.exe");
ReadProcessMemory(handle, (LPCVOID*)(BaseAddress + 0x01BA0520), &buffer, sizeof(buffer), NULL);
ReadProcessMemory(handle, (LPCVOID*)(buffer + 0x1C0), &buffer, sizeof(buffer), NULL);
ReadProcessMemory(handle, (LPCVOID*)(buffer + 0x738), &buffer, sizeof(buffer), NULL);
ReadProcessMemory(handle, (LPCVOID*)(buffer + 0xD0), &buffer, sizeof(buffer), NULL);
ReadProcessMemory(handle, (LPCVOID*)(buffer + 0x3A4), &buffer, sizeof(buffer), NULL);
for (int i = 1; i<5; i++){
ReadProcessMemory(handle, (LPCVOID*)buffer + 0x1, &readTest, sizeof(readTest), NULL);// crashes me
cout << readTest << endl;
}
Back to top
View user's profile Send private message AIM Address Yahoo Messenger MSN Messenger
atom0s
Moderator
Reputation: 198

Joined: 25 Jan 2006
Posts: 8516
Location: 127.0.0.1

PostPosted: Wed Jun 14, 2017 1:05 pm    Post subject: Reply with quote

Without seeing other bits of information or how the pointer is setup there is no way anyone is going to be able to help you with this.
_________________
- Retired.
Back to top
View user's profile Send private message Visit poster's website
hitmetwice
Advanced Cheater
Reputation: 0

Joined: 20 Nov 2012
Posts: 63

PostPosted: Thu Jun 22, 2017 8:09 am    Post subject: Reply with quote

I have done it using this simple library before: https://github.com/T-vK/Memory-Hacking-Class
Not sure if your entity list is laid out the same way. But for the game I tried it on it worked pretty well:

Code:
#include "Memory.hpp"
using std::string;

int main() {
    char* TARGET_PROCESS_NAME = "League of Legends.exe";
   
    HANDLE processHandle;
    int baseAddress;
   
    //////////////////////////////////////////////////////////////////////////////////
   
    int PLAYERS_MODULE_OFFSET = 0x1DAAED4;
        int HEALTH_OFFSET = 0x124;
        int MANA_OFFSET = 0x190;
       
    //////////////////////////////////////////////////////////////////////////////////
   
    Memory Memory;
    Memory.GetDebugPrivileges();
    processId = Memory.GetProcessId(TARGET_PROCESS_NAME);
    processHandle = OpenProcess(PROCESS_ALL_ACCESS, false, processId);
   
    baseAddress = Memory.GetModuleBase(processHandle, (string)TARGET_PROCESS_NAME);
    std::cout << "Base address for module \"" << TARGET_PROCESS_NAME << "\" is " << baseAddress << " (in dec)..."<< std::endl;
   
    int playersAddress =     baseAddress + PLAYERS_MODULE_OFFSET;
    int gameVersionAddress = baseAddress + GAME_VERSION_MODULE_OFFSET;
   
    for (int i=0x0; i<0x4*10; i=i+0x4) {
        int ptrOffset[] = {i};
        int playerOneAddress = Memory.ReadPointerInt(processHandle, playersAddress, ptrOffset, 1);
   
        float playerOneHealth = Memory.ReadFloat(processHandle, playerOneAddress + HEALTH_OFFSET);
        float playerOneMana =   Memory.ReadFloat(processHandle, playerOneAddress + MANA_OFFSET);
   
        string gameVersion = Memory.ReadText(processHandle, gameVersionAddress);
   
        std::cout << "Player #" << i/0x4 << " has " << playerOneHealth << " health!" std::endl;
        std::cout << "Player #" << i/0x4 << " one has " << playerOneMana << " mana!" std::endl;
    }

    cin.get();
    return 0;
}
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