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++ ReadProcessMemory acting like it is reading a cached mem

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

Joined: 17 Aug 2012
Posts: 17

PostPosted: Fri Aug 17, 2012 2:00 am    Post subject: C++ ReadProcessMemory acting like it is reading a cached mem Reply with quote

I've got my program made and everything, I have to read 3 memory addresses with it. I use these three lines:

Code:
ReadProcessMemory(Process, (LPCVOID)LowerAddress, &CurrentMillisecond, sizeof(double), 0);
   ReadProcessMemory(Process, (LPCVOID)MiddleAddress, &MillisecondsCount, sizeof(int), 0);
   ReadProcessMemory(Process, (LPCVOID)TimingPointUsedAddress, &TimingOffset, sizeof(int), 0);


These read the memory fine for me, but these values update constantly. Mainly just the LowerAddress, it is a ms counter which I need to be able to get an accurate reading from.

My main problem is that when I read the memory, often I get the same value 2-3 times in a row before it appears to change. When I look at the address in Cheat Engine, the value does not do this type of behavior, it is constantly updating every ms.

Does anyone know what could be happening?
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 472

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

PostPosted: Fri Aug 17, 2012 3:53 am    Post subject: Reply with quote

How often do you call this code?
If it's less than 1 millisecond you'll get the same value

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

Joined: 17 Aug 2012
Posts: 17

PostPosted: Fri Aug 17, 2012 10:14 am    Post subject: Reply with quote

When I display the code using cout, it calls the code about 2-3 times and then I see the value change by 15-20ms. Based on that I think it only calls the code every 5-6ms. I also had sleep timers in so it would call the code every ms.

Edit: Here is an example of what it looks like when read. I have a 2ms sleep timer in there also.

0.8555 - 33 - 0
0.883833 - 33 - 0
0.883833 - 33 - 0
0.912167 - 33 - 0
0.912167 - 33 - 0
0.9405 - 33 - 0
0.9405 - 33 - 0
0.968833 - 33 - 0
0.968833 - 33 - 0
0.997167 - 33 - 0
0.0255 - 34 - 0
0.0255 - 34 - 0
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 472

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

PostPosted: Fri Aug 17, 2012 2:25 pm    Post subject: Reply with quote

Change the sleep to at least 35 ms, it could be the target process hasn't had time to execute yet
_________________
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
larcerkev
Newbie cheater
Reputation: 0

Joined: 17 Aug 2012
Posts: 17

PostPosted: Fri Aug 17, 2012 3:09 pm    Post subject: Reply with quote

Unless I can get a reading every 3-4ms, my bot is useless. I need the program to read it fast. Why can Cheat Engine read the value so well but my program can't? Sad
Back to top
View user's profile Send private message
Dark Byte
Site Admin
Reputation: 472

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

PostPosted: Sat Aug 18, 2012 8:35 am    Post subject: Reply with quote

If you need to know the time then use the windows tickcount and don't read it from the game.
Cheat engine also only reads it every 200ms or so
Anyhow, after each read you must wait till the thread that updates the timer has run, that's just the way amultitasking os works. Every thread gets a few milliseconds of runtime, thenit gets interrupted, and another thread runs for a few ms

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

Joined: 17 Aug 2012
Posts: 17

PostPosted: Sun Aug 19, 2012 1:27 am    Post subject: Reply with quote

Thanks for the help, I guess I'm just going to have to settle with using the windows tickcount. Even though it makes me cringe having to request input from the user.

Thanks for taking the time to help me!
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