[Mono-list] replacement for mscoree.dll

Jeroen Janssen japj@xs4all.nl
Mon, 30 Dec 2002 16:53:23 +0100


Hello,

I don't know if anyone has worked on this yet, but I did a small 
experiment creating a replacement for mscoree.dll.
It's very "rude", but it works for simple applications (just a "proof of 
concept"). Maybe someone is interested in working on this in the near 
future.

This is how it works (as far as I understand):
When you build a .NET executable you get a PE executable. This consists 
out of 2 parts: the.NET code and a small stub (x86 code).
The stub references mscoree.dll and calls a function. For simple 
applications it calls _CorExeMain (there are some other function in 
there, but this is the one I used).

Now, this _CorExeMain function can locate a decent .NET runtime 
(example: Mono) and have it execute the .NET code contained in the PE file.

What I did was very simple: just find out what the commandline (exe 
filename) was and call the mono.bat file (from the mono for windows 
distribution) with the found exe (as I said, "very rude").

D:\sandbox\mscortest>test.exe
mscorlib, Version=1.0.3300.0, Culture=neutral, 
PublicKeyToken=b77a5c561934e089

D:\sandbox\mscortest>copy ..\mscoree.dll
        1 file(s) copied.

D:\sandbox\mscortest>test.exe
_CorExeMain> going to execute Mono with [test.exe]
mscorlib, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

_CorExeMain> Press Any Key to Exit

D:\sandbox\mscortest>

Now the next step(s) could be
* directly call the mono jit/interpreter api in order to execute the 
.NET code (can this be done?)
* correctly find out the application path (path to .exe) + parameters 
passed on the commandline

p.s. I can send the example code if anyone wants (5kb zipfile, VS7 project)
---
Jeroen