Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How does programs like Fraps or Dxtory get FPS?
Engelard last edited by
I know that for example Fraps attach FRAPS.dll to other process, and then, as i understand, it's using game itself to draw the numbers just inside the game. But how Fraps know to which process need attach it's DLL? I mean, some time ago i've made simple OpenGL exercise which was only drawing couple of polygons, and FRAPS automatically detect my app and start showing FPS inside my just created app. So i can't understand next things:
- How does such programs can draw inside other apps?
- How it define that target program have frames at the first place, and which apps does'nt, so it start working only with proper apps.
- Where FPS variable of app is stored and how such programs find it so quickly, or it's scaling somehow FPS by itself?
Pls clarify me.
ben.cottrell last edited by
@Engelard this involves Windows API functions which find the window from the cursor point, possibly with
WindowFromPointwhich returns an
HWND. From that
HWNDyou can resolve the parent process with
At the core of Windows applications is the message loop within which it calls a callback function, or window procedure, to handle event messages. There's a function called
SetWinEventHookwhich allows intercepting certain window messages in a given range.
Now, if fraps can get the
HWNDof your app it can either intercept the
WM_PAINTmessage to get a device context to draw over the top of the content, or it could create a child window displaying the FPS. But those are guesses.
Other than what I've speculated on, if you want to find out what's actually happening, you could use OllyDbg to reverse engineer the program.