HighTechTalks DotNet Forums  

Determining executable code type

Dotnet Framework (CLR) microsoft.public.dotnet.framework.clr


Discuss Determining executable code type in the Dotnet Framework (CLR) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default Determining executable code type - 07-29-2006 , 08:29 AM






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


Reply With Quote
  #2  
Old   
Michael Nemtsev
 
Posts: n/a

Default Re: Determining executable code type - 07-29-2006 , 08:54 AM






Hello ebucis (AT) gmail (DOT) 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

Quote:
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

---
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




Reply With Quote
  #3  
Old   
AT
 
Posts: n/a

Default Re: Determining executable code type - 07-31-2006 , 03:20 PM



I also found this based on your hint:

http://geekswithblogs.net/rupreet/ar.../02/58873.aspx

Thanks!!

Michael Nemtsev wrote:
Quote:
Hello ebucis (AT) gmail (DOT) 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
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

---
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


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.