欢迎访问 生活随笔!

生活随笔

当前位置: 首页 >

怎么多次调用c语言dll,c-如何从注入到同一程序的另一个.dll中调用...

发布时间:2025/3/15 26 豆豆
生活随笔 收集整理的这篇文章主要介绍了 怎么多次调用c语言dll,c-如何从注入到同一程序的另一个.dll中调用... 小编觉得挺不错的,现在分享给大家,帮大家做个参考.

在过去,我们使用CreateRemoteThread并将LoadLibraryA用作lpStartAddress的地址(该地址在所有进程中都相同).诀窍是使用VirtualAllocEx分配要注入的DLL名称,并将其用作lpParameter.实际上,您的线程使用您要注入的DLL名称调用LoadLibraryA.加载Dll时,将调用Dllmain,并且可以在附加dll的时间内在Dllmain中运行代码(DLL_PROCESS_ATTACH).

link在执行此操作时具有一些非常好的信息.但是,此技术依赖于Dllmain函数.如果可以使用Dllmain,则此机制可能会起作用.该文章的步骤摘要提供了一个概述:

现在,我们可以通过以下步骤总结该技术:

Retrieve a HANDLE to the remote process (OpenProces).

Allocate memory in the remote process's address space for injected data (VirtualAllocEx).

Write a copy of the initialised INJDATA structure to the allocated memory (WriteProcessMemory).

Allocate memory in the remote process's address space for injected code.

Write a copy of ThreadFunc to the allocated memory.

Start the remote copy of ThreadFunc via CreateRemoteThread.

Wait until the remote thread terminates (WaitForSingleObject).

Retrieve the result from the remote process (ReadProcessMemory or GetExitCodeThread).

Free the memory allocated in Steps #2 and #4 (VirtualFreeEx).

Close the handles retrieved in Steps #6 and #1 (CloseHandle).

我看到您对过多信息的评论.不确定我是否完全理解.但是Dllmain有一些限制,例如不能使用大多数Win32 API调用.有一些例外,一种是CreateThread.您是否考虑过拆线工作?如果在Dllmain中使用CreateThread,则它会被有效阻止,直到Dllmain退出.因此,一旦Dllmain返回,线程将执行.

总结

以上是生活随笔为你收集整理的怎么多次调用c语言dll,c-如何从注入到同一程序的另一个.dll中调用...的全部内容,希望文章能够帮你解决所遇到的问题。

如果觉得生活随笔网站内容还不错,欢迎将生活随笔推荐给好友。