I’m trying to run QueryPerformanceCounter() function from a particular process and get its return value to my C# application. Since those two processes (my application and the application i’m trying to affect) are different, what kind of strategy should i follow?
I’m trying to run QueryPerformanceCounter() function from a particular process and get its return
Share
QueryPerformanceCounteris synchronized across all processes on a computer. You can just call it locally. That’s the same value that the other process would have received.Update: Okay, you’re defending against cheaters. If they are hooking your process, then they are also going to hook your child processes, so spawning a helper process won’t help much.
One thing you can do is correlate multiple timers. For example,
All four timers (QPC,
GetTickCount,GetSystemTimeAsFileTime, andSleep) should agree to within measurement error.Another thing you can do is correlate against an external source. For example, you can write a function which obtains the time from the file system by creating a file and then asking for the file creation time. Correlate this against the other four timers. Other external sources are the sound and video hardware. For example, you can play a 1 second sound clip and see how long it takes. Or wait for the vertical blank and see if it matches the monitor refresh rate.