bootloader dll (C++)을 사용하고 나서 "payload"dll (C#)을 사용하여 관리되는 DLL을 .net 3.5 응용 프로그램에 성공적으로 주입했습니다.관리되는 DLL을 .net 4.0 응용 프로그램에 삽입
내가하려고 할 때이. NET 4.0 응용 프로그램에 항상 충돌이 발생합니다.
부트 로더 C++ :
#include "MSCorEE.h"
void StartTheDotNetRuntime()
{
// Bind to the CLR runtime..
ICLRRuntimeHost *pClrHost = NULL;
HRESULT hr = CorBindToRuntimeEx(
NULL, L"wks", 0, 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);