怎么多次调用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返回,线程将执行.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值