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 


dumb question about global vs local values

 
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine
View previous topic :: View next topic  
Author Message
thirdfoot
Newbie cheater
Reputation: 0

Joined: 09 Feb 2019
Posts: 21

PostPosted: Tue Oct 10, 2023 5:04 am    Post subject: dumb question about global vs local values Reply with quote

I created a super simple console c++ with just an infinite loop that prints a variable value. I change it per round as I'm planning to write another program to manipulate it. But first I tested with CE to see if I could find the value.

int testval = 1234;

I find it fine when I declare it globally outside main.

If I declare it inside main, I can't scan the value at all.

Is it because it's on the stack now? Or should I be able to scan it still?

I've been using CE a while (my own renamed/compiled 7.0 build), but it never occurred to me that this may be a thing. I suppose games (albeit few if any) with local variable use may be harder to target then.
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 470

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

PostPosted: Tue Oct 10, 2023 6:24 am    Post subject: Reply with quote

Does your main code modify the testval variable? If not, the compiler may just remove it or replace it with the value.

e.g: a compiler may rewrite this code:
Code:

int a,b;
int x;
a=12;
b=13;
x=b*12-13;
x=x++;
x=x-a;
b=b-a;
b--;
x=x*b;

return x;


into
Code:

return 0;

_________________
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
thirdfoot
Newbie cheater
Reputation: 0

Joined: 09 Feb 2019
Posts: 21

PostPosted: Tue Oct 10, 2023 7:01 am    Post subject: Reply with quote

Started to suspect compiler optimization, thanks for verifying. I got it scannable now.

Thanks.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Cheat Engine Forum Index -> Cheat Engine 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