怎么多次调用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中调用...的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: UDP聊天小程序+多线程(Python)
- 下一篇: in会让mysql索引失效吗_mysql