简体   繁体   English

挂钩到DirectX应用程序

[英]Hooking into DirectX application

I'm currently trying to display some information (as an overlay) to the user inside a DirectX-based game, much like the frame count which Fraps displayed, but I have no clue where to start. 我正在尝试在基于DirectX的游戏中向用户显示一些信息(作为叠加层),就像Fraps显示的帧数一样,但我不知道从哪里开始。 I don't expect a full solution to my problem, just a few hints where I can start and where to get more information about the topic ;) 我不希望我的问题有一个完整的解决方案,只是我可以开始的一些提示以及从哪里获得有关该主题的更多信息;)

Thanks in advance. 提前致谢。

PS: The project I'm working on is written in C# (.NET 3.5) PS:我正在研究的项目是用C#编写的(.NET 3.5)

PPS: To clarify: I mean hooking into any random DX-based game. PPS:澄清:我的意思是挂钩任何随机的DX游戏。 Start my app, start any game, display some kind of overlay. 启动我的应用程序,启动任何游戏,显示某种覆盖。

Well one way is to place a d3d9.dll alongside the executable. 一种方法是将d3d9.dll放在可执行文件旁边。 The DLL search pattern will ALWAYS search the current directory first. DLL搜索模式将始终首先搜索当前目录。

Now its just the "small" matter of implementing the DirectX interface to pass through everything to the REAL d3d9.dll. 现在它只是实现DirectX接口将所有内容传递给REAL d3d9.dll的“小”问题。 After you've done this then every time the user calls present you can inject some rendering of your own. 完成此操作后,每次用户调用时,您都可以注入一些自己的渲染。 In the case of the frame rate example you can measure the time between present calls. 在帧速率示例的情况下,您可以测量当前呼叫之间的时间。

Intercepting loading of the D3D9.dll without placing your own DLL in the way is a LOT more complex. 在不放置自己的DLL的情况下拦截D3D9.dll的加载是很复杂的。

Other sorts of info here: 其他类型的信息:

http://www.codeproject.com/Articles/20084/A-More-Complete-DLL-Injection-Solution-Using-Creat http://www.codeproject.com/Articles/20084/A-More-Complete-DLL-Injection-Solution-Using-Creat

Thanks to Goz, I also found the following interesting resources on the topic: 感谢Goz,我还在这个主题上找到了以下有趣的资源:

Seems like Microsoft Detours is the way to go... Haven't had time to try it out yet, though. 看起来像微软Detours是要走的路......但是还没有时间尝试一下。

not sure if you're still looking for ideas on this one, but for you or anyone else that might be trying this out, here is an example of hooking the IDirect3DDevice9 methods in C# that I've prepared. 不确定你是否还在寻找关于这个的想法,但是对于你或其他任何可能尝试这个的人来说,这里是一个我准备的C#挂钩IDirect3DDevice9方法的例子。

It uses EasyHook for the DLL injection + method hooking, and a small C++ utility dll to determine the function address to hook at runtime. 它使用EasyHook进行DLL注入+方法挂钩,并使用一个小的C ++实用程序来确定在运行时挂钩的函数地址。 EasyHook picks up where Microsoft Detours left off. EasyHook选择微软Detours停止的地方。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM