| View previous topic :: View next topic |
| Author |
Message |
larcerkev Newbie cheater
Reputation: 0
Joined: 17 Aug 2012 Posts: 17
|
Posted: Fri Aug 17, 2012 2:00 am Post subject: C++ ReadProcessMemory acting like it is reading a cached mem |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25867 Location: The netherlands
|
Posted: Fri Aug 17, 2012 3:53 am Post subject: |
|
|
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 |
|
 |
larcerkev Newbie cheater
Reputation: 0
Joined: 17 Aug 2012 Posts: 17
|
Posted: Fri Aug 17, 2012 10:14 am Post subject: |
|
|
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 |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25867 Location: The netherlands
|
Posted: Fri Aug 17, 2012 2:25 pm Post subject: |
|
|
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 |
|
 |
larcerkev Newbie cheater
Reputation: 0
Joined: 17 Aug 2012 Posts: 17
|
Posted: Fri Aug 17, 2012 3:09 pm Post subject: |
|
|
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?
|
|
| Back to top |
|
 |
Dark Byte Site Admin
Reputation: 472
Joined: 09 May 2003 Posts: 25867 Location: The netherlands
|
Posted: Sat Aug 18, 2012 8:35 am Post subject: |
|
|
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 |
|
 |
larcerkev Newbie cheater
Reputation: 0
Joined: 17 Aug 2012 Posts: 17
|
Posted: Sun Aug 19, 2012 1:27 am Post subject: |
|
|
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 |
|
 |
|