![]() |
|
[C++] - Printable Version +- LCKB (https://lckb.dev/forum) +-- Forum: ** OLD LCKB DATABASE ** (https://lckb.dev/forum/forumdisplay.php?fid=109) +--- Forum: Programmers Gateway (https://lckb.dev/forum/forumdisplay.php?fid=196) +---- Forum: Coders Talk (https://lckb.dev/forum/forumdisplay.php?fid=192) +---- Thread: [C++] (/showthread.php?tid=1010) |
- Nikolee - 10-20-2012 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?^^ - someone - 10-21-2012 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. - Wizatek - 10-21-2012 2 |