将 DLL 注入目标进程 VB.NET

发布于 2024-10-18 09:04:50 字数 357 浏览 3 评论 0原文

我最近编写了一个快速的 VB.NET 应用程序,它将 DLL 注入到正在运行的进程中。为了测试它,我创建了自己的 vb.net 类库项目,该项目只是生成一个“Hello World”消息框,希望在我注入 HelloWorld.DLL 后它会出现在目标进程中。

我的问题是,在注入 HelloWorld.DLL 后,消息框永远不会显示。我很确定这是因为一旦我的 HelloWorld.DLL 被注入(因为它是 VB.NET DLL),它就没有 DllMain,因此不知道要执行什么并且什么也不会发生。

我是否必须用 C++ 制作注入 DLL,以便它具有 DllMain?我可以做些什么来解决这个问题吗?或者我对一切都完全错了。

任何见解将不胜感激。谢谢。

I recently wrote a quick VB.NET app that injects a DLL into a running process. To test it I was creating my own vb.net Class Library project which simply spawns a "Hello World" message box in hopes of it showing up in the target process once I injected my HelloWorld.DLL.

My problem is that the message box never shows up after I inject the HelloWorld.DLL. I'm pretty sure the reason for this is because once my HelloWorld.DLL is injected (since it's a VB.NET DLL) it does not have a DllMain and hence has no idea what to execute and nothing happens.

Do I have to make my injection DLL in C++ so it has a DllMain? Is there anything I can do as a work around? Or am I completely wrong about everything.

Any insight would be greatly appreciated. Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

话少情深 2024-10-25 09:04:50

虽然 .NET DLL 从技术上讲是 PE 格式的扩展,但正是该扩展使其与包含纯编译的本机代码的 DLL 有本质上的不同。为了运行 .NET 代码(托管代码),需要由 .NET 解释器在 AppDomain 的上下文中执行。

本质上,.NET 将执行大量操作来启动并运行该代码。

Microsoft(祝福他们!)已经写了一篇文章概述了您需要在此处执行的操作 http://support.microsoft .com/kb/828736

另一种选择是不编写纯 C++ 代码,而是创建一个托管 C++ 项目,这将更容易让两者很好地协同工作。顺便说一句,拥有托管 C++ 项目并不意味着所有代码都必须进行管理

While the .NET DLL is technically an extension of the PE format it is that extension that makes it intrinsically different to a DLL that contains pure compiled, native code. In order for the .NET code (managed code) to be run is will need to be executed by the .NET interpreter and withing the context of an AppDomain.

Essentially there is a load of stuff that .NET will do to get that code up and running.

Microsoft (bless 'em!) have written and article outlining what you need to do here http://support.microsoft.com/kb/828736

Another option is to not write pure C++ code, but instead to create a managed C++ project which will be much easier in getting the two to play nicely together. BTW having a managed C++ project doesn't mean all the code has to be managed either AFAIK

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文