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 


making a healthbar mod, stuck on obtaining data from memory

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

Joined: 16 Oct 2024
Posts: 4

PostPosted: Wed Oct 16, 2024 3:09 am    Post subject: making a healthbar mod, stuck on obtaining data from memory Reply with quote

I'm trying to make a dll that injects into the game Titan Quest to draw health bars over entities. so far I've got imgui working and drawing health bars over my main character in the centre of the screen, but I'm lost on how to read data in C++ from a specific location in memory.

speaking of which, I have a cheat table for the game that has a godmode script. I see some address of esi+1C but I'm not sure how to interpret that into a form used in C++, probably hexadecimal? also not sure what code I would be using to read that data from that location, I'm assuming some kind of pointer stuff but not confident. any help would be greatly appreciated!
Back to top
View user's profile Send private message
neur0tox1n
How do I cheat?
Reputation: 0

Joined: 16 Oct 2024
Posts: 4

PostPosted: Thu Oct 17, 2024 12:40 am    Post subject: Reply with quote

I think what I need is the knowledge of converting this pointerscan result into c++ code.

Code:
#define BASEPLAYERHP 0x00A567C
#define OFFSET 0x0000BE0


DWORD* BaseAddress = (DWORD*)GetModuleHandle("TQ.exe");
DWORD* address = (DWORD*)((char*)BaseAddress + BASEPLAYERHP);
address = (DWORD*)((char*)*address + OFFSET);
int currentHP = *(int*)address;

something like this? doesn't work but I'll keep tinkering



snip.PNG
 Description:
 Filesize:  23.28 KB
 Viewed:  3154 Time(s)

snip.PNG


Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4695

PostPosted: Thu Oct 17, 2024 1:06 am    Post subject: Reply with quote

Pointers are 8 bytes in 64-bit processes

You're not dereferencing nodes in the pointer path:
https://forum.cheatengine.org/viewtopic.php?p=5791330#5791330

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
neur0tox1n
How do I cheat?
Reputation: 0

Joined: 16 Oct 2024
Posts: 4

PostPosted: Thu Oct 17, 2024 2:53 am    Post subject: Reply with quote

I believe the application I'm working with is 32bit so I have it in x86 mode in my c++
and forgive me, I'm not the best at pointer mathematics.

ParkourPenguin wrote:
`[address1 + offset] -> address2` means "the value of the pointer at the address `address1 + offset` is equal to `address2`"

Don't just add a bunch of offsets to each other. You have to dereference addresses as you traverse the pointer path.


so if I understand the context of the op, they are adding up the different offsets like 238 68 18, just straight up, and that is giving them the wrong address.

so given this address view, does this mean I should now dereference and connect to a final pointer position from ("TQ.exe"+002B1F0C + A90) + C7C? and that will give me the address of the variable in memory?

Code:
HandleOf("TQ.exe") returns an address; T
then add 0x02B1F0C to that address; T+0x02B1F0C
then add 0x0000A90 to that address; T+0x02B1F0C+0x0000A90
then get the value of memory at that location; dereference(T+0x02B1F0C+0x0000A90)
then add 0x0000C7C to that value of memory which is another address
dereference(T+0x02B1F0C+0x0000A90)+0x0000C7C

final result pointer to desired value
dereference(T+0x02B1F0C+0x0000A90)+0x0000C7C


something like this?
Code:
#define BASEPLAYERHP 0x02B1F0C
#define OFFSET1 0x0000A90
#define OFFSET2 0x0000C7C

DWORD* BaseAddress = (DWORD*)GetModuleHandle("TQ.exe");
DWORD* subAddress = (DWORD*)((char*)BaseAddress + BASEPLAYERHP + OFFSET1);
DWORD nextSubAddress = *subAddress;
DWORD* address = (DWORD*)((char*)nextSubAddress + OFFSET2);
int currentHP = *(int*)address;
this definitely isn't it though because I crash as soon as I inject it


Capture.PNG
 Description:
 Filesize:  12.78 KB
 Viewed:  3123 Time(s)

Capture.PNG


Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

Joined: 09 May 2003
Posts: 25778
Location: The netherlands

PostPosted: Thu Oct 17, 2024 4:43 am    Post subject: Reply with quote

https://forum.cheatengine.org/viewtopic.php?t=422516
_________________
Do not ask me about online cheats. I don't know any and wont help finding them.

Like my help? Join me on Patreon so i can keep helping
Back to top
View user's profile Send private message MSN Messenger
ParkourPenguin
I post too much
Reputation: 152

Joined: 06 Jul 2014
Posts: 4695

PostPosted: Thu Oct 17, 2024 10:11 am    Post subject: Reply with quote

neur0tox1n wrote:
then add 0x0000A90 to that address; T+0x02B1F0C+0x0000A90
No
The pointer path is `[[game.exe+2B1F0C]+A90]+C7C`

If the pointer path had been `[game.exe+2B1F0C+A90]+C7C`, then CE would've given the pointer path `[game.exe+2B299C]+C7C` instead

_________________
I don't know where I'm going, but I'll figure it out when I get there.
Back to top
View user's profile Send private message
neur0tox1n
How do I cheat?
Reputation: 0

Joined: 16 Oct 2024
Posts: 4

PostPosted: Thu Oct 17, 2024 7:48 pm    Post subject: Reply with quote

Code:
#define BASEPLAYER 0x2B1F0C
#define B_OFFSET 0xA90
#define HP_OFFSET 0xC7C

uintptr_t TQ_Addr = (uintptr_t)GetModuleHandle("TQ.exe");

uintptr_t baseAddress = *(uintptr_t*)(TQ_Addr + BASEPLAYER);

uintptr_t localPlayer = *(uintptr_t*)(baseAddress + B_OFFSET);

int currentHP = *((int*)(localPlayer + HP_OFFSET));


so I technically got this to work by first checking inside Cheat Engine with a pointerscan, using those values, then rebuilding the code. however the moment I closed the game and relaunched it, the code crashed. so I think I need to find an entity table first, locate the player object pointer inside that table, then use the two offsets.
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