Re: Poor man's mscoree.dll - working

Maciek <[email protected]>
Newsgroups gmane.comp.gnu.dotgnu.developer
Message-ID <[email protected]>
OK, here's the whole thing (mscoree.dll, source and MSVC7.1 project): 
http://mil-sim.net/download/pnet/coremul.zip

If you have a system without MS.NET, copy the DLL to C:\Program 
Files\PNET\bin (it should be in PATH).

Maciek wrote:

> Hello,
> 
> I started playing with coremul last night and after figuring out how to 
> export the DLL function properly i came up with a _very simple_ solution 
> to mscoree.dll problem. Here's basically how it works:
> 
> pnet/coremul/shim.c:
> 
> __declspec(dllexport) __int32 _CorExeMain(void)
> {
>     /* Get the full pathname of the application */
>     #ifdef _COR_REAL_WIN32
>         TCHAR path[1024];
>         GetModuleFileName(0, path, 1023);
> 
>         STARTUPINFO    si;
>         PROCESS_INFORMATION  pi;
> 
>         GetStartupInfo(&si);
> 
>         char cmd[1100];
> 
>         sprintf(cmd, "%s \"%s\"", "ilrun", path);
> 
>         /* Execute 'ilrun "path/app.exe"' */
>         CreateProcess(
>             NULL,
>             cmd,
>             NULL,
>             NULL,
>             FALSE,
>             0,
>             NULL,
>             NULL,
>             &si,
>             &pi);
> 
>         exit(0);
>     #endif
> 
>     return 0;
> }
> 
> ---
> 
> I've compiled the DLL (on mingw) this way:
> 
> cd coremul/
> gcc -c cocreate.cpp
> gcc -c guid.cpp
> gcc -c shim.c
> dllwrap --output-lib=libmscoreedll.a --dllname=mscoree.dll 
> --driver-name=gcc cocreate.o guid.o shim.o
> 
> ---
> 
> As you can see, it's a really half-assed approach (EXEs only), 
> completely disregarding the way the 'shim' should work in real life. 
> Obviously, this approach only works on Windows, I don't even know if 
> mscoree.dll would be useful on other platforms. But it works for simple 
> testing, you no longer have to type 'ilrun app.exe' on Windows to 
> execute .NET applications.
> 
> If you're interested in having this until I come up with a better 
> solution, I can submit a patch.
> 
> Please let me know what you think about it.
> 
> Regards,
> 
> Maciek
> 
> _______________________________________________
> Developers mailing list
> [email protected]
> http://dotgnu.org/mailman/listinfo/developers
> 
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.