如何将dll注入另一个程序

编程入门 行业动态 更新时间:2024-10-27 17:11:27
本文介绍了如何将dll注入另一个程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

如何将dll注入另一个程序中,我想在winmine上添加一个菜单,并为该菜单添加句柄

how to inject dll into another programe,i want to add a menu on winmine,and add handle for that menu

推荐答案

CreateRemoteThread的方法,这是代码 how about CreateRemoteThread,here is the code HANDLE hThread; char szLibPath[_MAX_PATH]; void* pLibRemote; DWORD hLibModule; HMODULE hKernel32 = ::GetModuleHandle("Kernel32"); pLibRemote = ::VirtualAllocEx( hProcess, NULL, sizeof(szLibPath), MEM_COMMIT, PAGE_READWRITE ); ::WriteProcessMemory( hProcess, pLibRemote, (void*)szLibPath, sizeof(szLibPath), NULL ); hThread = ::CreateRemoteThread( hProcess, NULL, 0,(LPTHREAD_START_ROUTINE) ::GetProcAddress( hKernel32, "LoadLibraryA" ), pLibRemote, 0, NULL ); ::WaitForSingleObject( hThread, INFINITE ); ::GetExitCodeThread( hThread, &hLibModule ); ::CloseHandle( hThread ); ::VirtualFreeEx( hProcess, pLibRemote, sizeof(szLibPath), MEM_RELEASE ); hThread = ::CreateRemoteThread( hProcess, NULL, 0, (LPTHREAD_START_ROUTINE) ::GetProcAddress( hKernel32, "FreeLibrary" ), (void*)hLibModule, 0, NULL ); ::WaitForSingleObject( hThread, INFINITE ); ::CloseHandle( hThread );

您不能将DLL注入"到现有程序中.可执行代码必须调出DLL.您可以(可能)将Windows DLL替换为自己的版本,该版本提供经过修改的功能,但这并不是一件容易的事. You cannot ''inject'' a DLL into an existing program. The executable code has to make a call out to the DLL. You could (possibly) replace a Windows DLL with your own version which offers modified functionality, but it would not be a trivial task.

更多推荐

如何将dll注入另一个程序

本文发布于:2023-11-13 11:52:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1584288.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何将   程序   dll

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!