从外部程序中检索程序的FPS? [英] Retrieve FPS of a program from external program?

查看:123
本文介绍了从外部程序中检索程序的FPS?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发Win32 C ++程序,它使用Windows中的 CreateProcess(...)功能创建游戏程序的子进程(即 Game.exe ) API。



(此游戏由外部方开发,因此,我没有该程序的源代码,也使用direct3D进行3D绘图和nvidia Physx进行物理模拟。)



- 我的程序的责任是启动这个游戏程序,收集

游戏基准测试的数据然后每当需要
时终止游戏。



为了表示正确的基准测试结果,我需要计算 FPS 作为子进程处理。这意味着我的程序(父进程)应该有一种机制来捕获该游戏程序的FPS计数。



- 我的问题是,如果我们编写一个Visual C ++程序来对游戏进行基准测试,我们如何计算该游戏的fps?



(最流行的 Fraps 程序这样做,作为一个外部程序,它可以计算在OS上运行的任何游戏的fps,我需要知道他们是如何实现这种机制的吗?并在我的程序中打印该机制以检索fps。)



为方便起见,请参阅: -



1. https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx

2. http://www.fraps.com/



我的尝试:



我试图通过Windows钩子实现fps它没有用。

I am developing Win32 C++ Program which creates child process of a Game Program(i.e "Game.exe"),using CreateProcess(...) function in Windows API.

(This Game was developed by an external party therefore,I don't have the source code of the program and also it uses direct3D for 3D-drawing purpose and nvidia Physx for physics simulations.)

- Responsibility of my program is to start this game program ,collect
the data for game benchmarking and then terminate the game whenever
required.

In order to reprent proper benchmark results, I need to count FPS of that Game program which is handled as child process.That means somehow my program(Parent process) should have a mechanism to capture the FPS count from that Game program.

- My question is,If we write a Visual C++ program to benchmark a game,how can we count the fps of that game?

(Most popular Fraps program does this,by being an external program it can count fps of any game run on OS,I need to know that how they achieve that mechanism? and imprint that mechanism in my program in order to retrieve fps.)

For your convenience please refer :-

1. https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx
2. http://www.fraps.com/

What I have tried:

I tried to do achieve fps through windows hooks It did not work.

推荐答案

我发现发布链接但内容很长并不好。

我使用Direct3D应用程序



以下是实现目标的初步步骤的简短摘录。



我们提供的代码以挂起模式启动目标进程,并挂钩d3d9.dll中的Direct3DCreate9入口点。

I realise it's not great to just post a link but the content is long.
Instrumenting Direct3D applications

Here is a short excerpt of the initial steps to achieve your goal.

The code we have provided starts the target process in suspended mode, and hooks the Direct3DCreate9 entry point in the d3d9.dll.
Once we catch a Direct3DCreate9 call, we can use the returned IDirect3D9 pointer to index the VTable. Since the call occurred in the target process address space, we cannot use the pointer directly in our host application; however, we can use Deviare’s functions to read the hooked process memory (starting with the IDirect3D9 pointer) to get the method addresses. This is a very interesting and useful technique which avoids sending address data from the intercepted process to the host processes.


这篇关于从外部程序中检索程序的FPS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆