3F / DllExport

.NET DllExport with .NET Core support (aka 3F/DllExport aka DllExport.bat)
MIT License
940 stars 131 forks source link

Is there any limitations? #89

Closed CaledoniaProject closed 5 years ago

CaledoniaProject commented 5 years ago

I came from this post, it uses a much more complex way to load .NET DLL into unmanaged processes.

int wmain(int argc, wchar_t* argv[])
{
    HRESULT hr;
    ICLRMetaHost *pMetaHost = NULL;
    ICLRRuntimeInfo *pRuntimeInfo = NULL;
    ICLRRuntimeHost *pClrRuntimeHost = NULL;

    // build runtime
    hr = CLRCreateInstance(CLSID_CLRMetaHost, IID_PPV_ARGS(&pMetaHost));
    hr = pMetaHost->GetRuntime(L"v4.0.30319", IID_PPV_ARGS(&pRuntimeInfo));
    hr = pRuntimeInfo->GetInterface(CLSID_CLRRuntimeHost, 
        IID_PPV_ARGS(&pClrRuntimeHost));

    // start runtime
    hr = pClrRuntimeHost->Start();

    // execute managed assembly
    DWORD pReturnValue;
    hr = pClrRuntimeHost->ExecuteInDefaultAppDomain(
        L"T:\\FrameworkInjection\\_build\\debug\\anycpu\\InjectExample.exe", 
        L"InjectExample.Program", 
        L"EntryPoint", 
        L"hello .net runtime", 
        &pReturnValue);

    // free resources
    pMetaHost->Release();
    pRuntimeInfo->Release();
    pClrRuntimeHost->Release();

    return 0;
}

Then I started wondering, since DLLExport is so much easier to use, does it have any limitations? The Wiki says nothing about it.

3F commented 5 years ago

since DLLExport is so much easier to use, does it have any limitations? The Wiki says nothing about it.

Isn't it? wiki:

...

But:

does it have any limitations

In general, you need to clarify the question because of really abstract case.

The mentioned way is the old known way through Unmanaged API. But this is other big story.

Here's MSDN full docs about runtime hosts, compilers, disassemblers, etc.: