[C++]
#1

Well i was boring and was searching for something to hook the GS with C#

 

I found a Tutorial what is Explaining something and i wanna try it out^^ Link : 2

 

They say i need to Creat a .dll in C++ to run the .Net runtime

 

the code looks so :

// InjectDLL.h

#pragma once
#include "MSCorEE.h"
#include "InjectDLL.h"

using namespace System;

namespace InjectDLL {

public ref class Class1
{

void StartTheDotNetRuntime()
{

// Bind to the CLR runtime..
ICLRRuntimeHost *pClrHost = NULL;
HRESULT hr = CorBindToRuntimeEx(
NULL, L"wks", 0, CLSID_CLRRuntimeHost,
IID_ICLRRuntimeHost, (PVOID*)&pClrHost);

// Push the big START button shown above
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"c:\\PathToYourManagedAssembly\\MyManagedAssembly.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();

return;
}

};

}

 

Well i can compile this, but did i need to Call the Function now or not?

Because then i try to call it i get errors so maybe i dont need to call them?^^

#2

With this you only create a wrapper for the Managed Apps, but if you want to inject the dll to the app, you only create functions that wrap your managed dll classes.

 

There are 2 methods to wrap this:

1)Interoperability

2

2)or using CLR(Managed C++)

2

2

 

I think its much simpler to write it all in C/C++ then make it work with c#(you still need to make a dll wrapper for C++)

 

Or you can do it natively from ASM loading MSCorEE.dll.

 

But still managed code is slow.

#3
2


Forum Jump:


Users browsing this thread: 1 Guest(s)