在 c++ 中,我想将多个 dll 挂接到一个进程。现在我使用 CreateProcesswithdll()
一次只能 Hook 一个 api。如何注入(inject)多个 dll?
我遇到这个问题是因为 MS detours 要求我们将自定义 dll 命名为与原始 dll 相同的名称,以便正确绕过 api 调用。因此,即使我可以在我创建的同一个绕行 dll 中处理不同的 api 调用,我也需要有不同的名称来 Hook 来自不同 api 的调用,这意味着我需要不同的绕行 Dll。这也意味着我需要注入(inject)不同的 DLL。我说得对吗?
如果我不清楚某事,我会尝试更清楚地展示它 :D
谢谢!
P.S:只是为了让我的问题更清晰。我需要将 1 个以上的 dll 注入(inject)到同一个进程中。 CreateProcesswithdll()
创建一个线程处于 sleep 状态的新进程。在绕道完成注入(inject)dll和设置钩子(Hook)后被唤醒。如果我想注入(inject)多个 dll,我显然不能重复调用 CreateProcesswithdll()
那我该怎么办??或者我对此的某些方面的理解是错误的吗?
最佳答案
调用 LoadLibrary() 和 FreeLibrary() 是 NOT SAFE来自 DLLMain()。来自 TFA:
"The entry-point function should perform only simple initialization or termination tasks. It must not call the LoadLibrary or LoadLibraryEx function (or a function that calls these functions), because this may create dependency loops in the DLL load order. This can result in a DLL being used before the system has executed its initialization code. Similarly, the entry-point function must not call the FreeLibrary function (or a function that calls FreeLibrary) during process termination, because this can result in a DLL being used after the system has executed its termination code."
编辑:抱歉 - 这是对 Serge 上述回答的评论。
关于c++ - 是否可以通过MS弯路注入(inject)多个Dll?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6143689/