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 


Cant find value in dummy program

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

Joined: 08 Oct 2024
Posts: 4

PostPosted: Tue Oct 08, 2024 4:34 pm    Post subject: Cant find value in dummy program Reply with quote

Hello, I made a program to test cheat engine with it, however I tried to use the address given by std::cout but cant use that and cant search for value either.
I would like to have a hint why its not working, thanks
Code:
#include <iostream>

int main()
{
   unsigned int counter = 1;
   unsigned int* ptr;
   while (true) {
      counter = counter + 1;
      std::cout << "counter: " << counter << std::endl << "mem: " << (void*)&counter << std::endl << "size: " << sizeof(counter) << std::endl;
      ptr = &counter;
      std::cout << "ptr: " << *ptr << std::endl << "mem: " << ptr << std::endl;
      std::cin.get();
   }
   return 0;
}
[/code]
Back to top
View user's profile Send private message
ParkourPenguin
I post too much
Reputation: 147

Joined: 06 Jul 2014
Posts: 4537

PostPosted: Tue Oct 08, 2024 4:41 pm    Post subject: Reply with quote

The compiler optimized away all memory accesses to `counter`

Use volatile
Code:
volatile unsigned int counter = 1;

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

Joined: 08 Oct 2024
Posts: 4

PostPosted: Tue Oct 08, 2024 5:45 pm    Post subject: Reply with quote

Changed the code

Code:

#include <stdio.h>


int main()
{
   volatile unsigned int counter = 1;
   while (counter < 100) {
      counter = counter + 1;
      printf("counter: %d, mem: %016llX", counter, &counter);
      getchar();

   }
   return 0;
}


and in the disassembly there is access to memory but still nothing on CE



mem.png
 Description:
 Filesize:  144.99 KB
 Viewed:  1636 Time(s)

mem.png


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

Joined: 06 Jul 2014
Posts: 4537

PostPosted: Tue Oct 08, 2024 6:13 pm    Post subject: Reply with quote

Are you attached to the correct process? i.e. don't attach to the console- attach to the program the console is running
_________________
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
synnefo1337
How do I cheat?
Reputation: 0

Joined: 08 Oct 2024
Posts: 4

PostPosted: Tue Oct 08, 2024 6:25 pm    Post subject: Reply with quote

ParkourPenguin wrote:
Are you attached to the correct process? i.e. don't attach to the console- attach to the program the console is running

that was the problem tyvm
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