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++ Not Matching Cheat Engine

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> General programming
View previous topic :: View next topic  
Author Message
ParkourPenguin
I post too much
Reputation: 70

Joined: 06 Jul 2014
Posts: 2295

PostPosted: Wed Jul 24, 2019 7:04 pm    Post subject: Reply with quote

processBaseAddress is a uint32_t*. Arithmetic addition/subtraction on pointers is done in units of the size of the pointed-to type. i.e. this code works as expected:
Code:
int mem[5] = {0,1,4,9,16};
int *p = mem;
*p;      // 0
*(p+1);  // 1
*(p+2);  // 4
...

In your case, the expression "processBaseAddress + 0x00224308" evaluates to 0x00400000 + 4 * 0x00224308 = 00C90C20.

_________________
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
Winter_Snake
How do I cheat?
Reputation: 0

Joined: 22 Jul 2019
Posts: 8

PostPosted: Wed Jul 24, 2019 7:13 pm    Post subject: Reply with quote

How would I go about to make this work then?
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 70

Joined: 06 Jul 2014
Posts: 2295

PostPosted: Wed Jul 24, 2019 7:21 pm    Post subject: Reply with quote

You could change it to a char* or unsigned char *. Or maybe divide the offset by 4. Whatever you feel like doing.
_________________
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
Winter_Snake
How do I cheat?
Reputation: 0

Joined: 22 Jul 2019
Posts: 8

PostPosted: Wed Jul 24, 2019 8:28 pm    Post subject: Reply with quote

Dividing the 0x00224308 by 2 or 4 still result in the wrong placement.

Code:

[0x00400000] + [0x00224308] = [0x00C90C20]
[0x00224308] / 2= [0x00112184] -> [0x00400000] + [0x00112184] = [0x00848610]
[0x00224308] / 4= [0x000890C2] -> [0x00400000] + [0x000890C2] = [0x00624308]


None of which give me the same address Cheat Engine is pointing too. (Again, [0x0019A3E8])

As for changing the type to char/unsigned char - it results in the cashBaseAddress being empty and processBaseAddress as weird letters.

https://imgur.com/qKvlBzC
https://imgur.com/Q0lecSn

(Sorry about the pictures, I can't upload files/pictures either - it just errors out.)

Mod edit: fixed image links.
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 70

Joined: 06 Jul 2014
Posts: 2295

PostPosted: Wed Jul 24, 2019 8:52 pm    Post subject: Reply with quote

You're printing the address and not the value stored at the address.
"game.exe+00224308 -> 0019A3E8" means the value stored at the address game.exe+00224308 is 0019A3E8.

Putting a char* through a stream will output the text stored at the address rather than the address itself. void* should work as well:
https://stackoverflow.com/questions/17813423/cout-with-char-argument-prints-string-not-pointer-value

Honestly, there are a lot of wrong things with your code, and I don't think I can help you learn how to do it correctly in a few forum posts.
(dividing the offset by 4 isn't good either, but it is the simplest hack I could think of to fix your code)

Perhaps you should start on a simpler project first. The book C++ Primer (5th edition) is a good resource for beginners to learn C++. There have been a lot of changes to C++ since then, but it's still a good resource today.
Beyond the basics, learn about strict aliasing and the C++ type system in general. You could also benefit from information on best practices and good interface design.
https://stackoverflow.com/questions/388242/the-definitive-c-book-guide-and-list

_________________
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
Winter_Snake
How do I cheat?
Reputation: 0

Joined: 22 Jul 2019
Posts: 8

PostPosted: Wed Jul 24, 2019 9:28 pm    Post subject: Reply with quote

That's okay, I actually figured it out and got it to work without dividing by 4 and all that other hacky nonsense.

My main problem was I thought Cheat Engine was showing the address, not the value. Wasn't thinking too bright on that one. So thanks for pointing it out.
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