I have readed, and readed again this topic.
I inject my bootstrap in the target process (I'm sure, i can debug it) and it bug on starting of CLR.
EDIT : Here is my code
Code:
#include <windows.h>
#include "MSCorEE.h"
#pragma comment(lib, "mscoree")
DWORD WINAPI StartTheDotNetRuntime( LPVOID lpParameter);
DWORD WINAPI StartTheDotNetRuntime( LPVOID lpParameter)
{
ICLRRuntimeHost *pClrHost = NULL;
HRESULT hr = CorBindToRuntimeEx(
NULL, L"wks", 0, CLSID_CLRRuntimeHost,
IID_ICLRRuntimeHost, (PVOID*)&pClrHost);
hr = pClrHost->Start();
DWORD dwRet = 0;
hr = pClrHost->ExecuteInDefaultAppDomain(
L".\\NetDll.dll",
L"MyNamespace.MyClass", L"MyMethod", L"MyParameter", &dwRet);
hr = pClrHost->Stop();
pClrHost->Release();
return FALSE;
}
INT APIENTRY DllMain( HWND hDLL, DWORD fdwReason, LPVOID lpvReserved )
{
switch ( fdwReason )
{
case DLL_PROCESS_ATTACH:
DWORD dwThreadId;
HANDLE hThread = CreateThread(0, 0, StartTheDotNetRuntime, NULL, 0, &dwThreadId);
break;
}
return TRUE;
}
And my managed dll :
Code:
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;
}
}
}
Now it's bug on ExecuteInDefaultAppDomain