将托管DLL注入.net 4.0应用程序
发布时间:2020-12-14 04:35:36 所属栏目:Windows 来源:网络整理
导读:我已经成功地使用bootloader dll(在c中)将托管DLL注入到.net 3.5应用程序中,然后在(c#)中将我的“payload”dll注入. 当我尝试这样做.net 4.0应用程序总是崩溃. Bootloader C: #include "MSCorEE.h" void StartTheDotNetRuntime() { // Bind to the CLR runt
我已经成功地使用bootloader dll(在c中)将托管DLL注入到.net 3.5应用程序中,然后在(c#)中将我的“payload”dll注入.
当我尝试这样做.net 4.0应用程序总是崩溃. Bootloader C: #include "MSCorEE.h" void StartTheDotNetRuntime() { // Bind to the CLR runtime.. ICLRRuntimeHost *pClrHost = NULL; HRESULT hr = CorBindToRuntimeEx( NULL,L"wks",CLSID_CLRRuntimeHost,IID_ICLRRuntimeHost,(PVOID*)&pClrHost); hr = pClrHost->Start(); // Okay,the CLR is up and running in this (previously native) process. // Now call a method on our managed C# class library. DWORD dwRet = 0; hr = pClrHost->ExecuteInDefaultAppDomain( L"payload.dll",L"MyNamespace.MyClass",L"MyMethod",L"MyParameter",&dwRet); // Optionally stop the CLR runtime (we could also leave it running) hr = pClrHost->Stop(); // Don't forget to clean up. pClrHost->Release(); } 有效载荷C#: using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Windows.Forms; namespace MyNamespace { public class MyClass { // This method will be called by native code inside the target process... public static int MyMethod(String pwzArgument) { MessageBox.Show("Hello World"); return 0; } } } 我试过使用下面的修复程序,但没有用,有什么想法吗? hr = pMetaHost->GetRuntime(L"v4.0.30319",IID_ICLRRuntimeInfo,(LPVOID*)&lpRuntimeInfo);
接口随.NET 4.0改变.您应该使用新的ICLRMetaHost
interface,而不是使用CorBindToRuntimeEx.
代码可能类似于以下内容(没有错误检查): ICLRMetaHost *pMetaHost = NULL; CLRCreateInstance(CLSID_CLRMetaHost,IID_ICLRMetaHost,(LPVOID*)&pMetaHost); ICLRRuntimeInfo *pRuntimeInfo = NULL; pMetaHost->GetRuntime(L"v4.0.30319",(LPVOID*)&pRuntimeInfo); ICLRRuntimeHost *pClrRuntimeHost = NULL; pRuntimeInfo->GetInterface(CLSID_CLRRuntimeHost,(LPVOID*)&pClrRuntimeHost); pClrRuntimeHost->Start(); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 【DIY】FFmpeg Joiner – 多段视频「无损合并」小工具 [Win
- 图像处理---《在图片上打印文字 windows+GDI+TrueType字体》
- windows-server-2008 – 当CA证书在我的Windows域中过期时,
- windows – 有用的WMI管理脚本
- 在Windows Powershell中忽略错误级别!= 0
- windows – 如何理解获取和释放语义?
- 身份验证 – Windows Server 2012 R2 – 证书开始工作之前的
- 在Windows中识别unicode编码的文本文件的最好方法是什么?
- windows-8 – 如何在Windows 8.1(IE11和Modern UI)上调试PA
- 在window系统上安装redis服务-Invalid argument during sta
推荐文章
站长推荐
热点阅读