我正在尝试使用 dll 注入(inject)来拦截从我的应用程序调用 Direct3DCreate8
以获取 Direct3d 设备的句柄并在它投影的屏幕上绘制覆盖图。对该 API 的调用在应用程序执行后立即发生,如果我理解正确的话,这会使 dll 注入(inject)正在运行的进程 技术变得无用,因为我之后的 API 调用已经在我注入(inject) dll 时发生了。
这个假设是否正确?如果是,如何在流程执行期间注入(inject) dll 以捕获所需的 API 调用?
编辑:我知道系统范围的 api Hook ,但很高兴听到这个问题的“本地”解决方案。
编辑 2: 忘记提及,替换应用程序文件夹中的 .dll 是没有用的,因为应用程序在 System32/SysWOW64 中查找 .dll(在我的例子中是 d3d8.dll)目录。
最佳答案
聚会有点晚了,我想为您提供一个使用 Microsoft Detours 的解决方案(在 x86 平台上免费用于非商业用途,否则需要花费巨额资金)。它们具有可能适合您需要的 DetourCreateProcessWithDllEx
函数。
引用 Detours 文档:
The process is created in a suspended state with the CREATE_SUSPENDED flag to CreateProcess. Detours then modifies the image of the application binary in the new process to include the specified DLL as its first import. Execution in the process is then resumed. When execution resumes, the Windows process loader will first load the target DLL and then any other DLLs in the application's import table, before calling the application entry point.
关于c++ - 在进程执行之前注入(inject) DLL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27981778/