Hi,
I am developing an application that loads at runtime executable
code, investigates it and catalogs it (stores some information about
it).
When the executable is managed code, using reflection i can obtain the
metadata information and add it to the catalog. But when the executable
(exe or dll) is an unmanaged code I prompt the user and let him provide
some "metadata".
My problem is that I have not been successful correctly identifying
manage code from unmanaged code at runtime.
My first approach was to expect an exception if i tried to load a dll
or exe using reflection, but at the end of the day, there are a lot of
more reasons for an assembly not to load (e.g. missing required
references).
At this point I don't know what to do.
Thanks,
Lester
Michael Nemtsev - 29 Jul 2006 13:54 GMT
Hello ebucis@gmail.com,
Check PE header of the file whether it contains managed code.
You need to look in COM Descriptor Directory entry in the PE - if there is
nonzero address thus it constains managed code
> Hi,
> I am developing an application that loads at runtime executable
[quoted text clipped - 17 lines]
>
> Lester
---
WBR,
Michael Nemtsev :: blog: http://spaces.msn.com/laflour
"At times one remains faithful to a cause only because its opponents do not
cease to be insipid." (c) Friedrich Nietzsche
ebucis@gmail.com - 31 Jul 2006 20:20 GMT
I also found this based on your hint:
http://geekswithblogs.net/rupreet/archive/2005/11/02/58873.aspx
Thanks!!
> Hello ebucis@gmail.com,
>
[quoted text clipped - 30 lines]
> "At times one remains faithful to a cause only because its opponents do not
> cease to be insipid." (c) Friedrich Nietzsche