I have an urgent need to detect from a C# application what type of file I am dealing with.
As you know Windows has overloaded the DLL and EXE formats to contain so many different types of executables, that it is hard to determine which file is which. I assume I can identify a .NET assembly by finding files that depends on MSCOREE.DLL and COM files can be identified by the fact that they export several self register functions such as DllRegisterServer, DllUnregisterServer etc... Win32 files will then be whatever does not identify as a COM or .NET file.
However, now the question: how can I get a list of file dependencies for a file, and how can I get a list of the exports from a file (dll only). I have found some code here and there, but maybe there is a simpler approach that can be used?
This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Detect file type from code
Started by
Glytzhkof
, Mar 22 2006 04:38
4 replies to this topic
Posted 22 March 2006 - 07:11
I think I have found two EXE files that I can use:
Detect Dependencies:
depends.exe (CLI version) http://www.microsoft...odeupdates.aspx
Detect DLL Exports:
pexports.exe
Detect Dependencies:
depends.exe (CLI version) http://www.microsoft...odeupdates.aspx
Detect DLL Exports:
pexports.exe
Edited by Glytzhkof, 22 March 2006 - 07:12.
Regards
-Stein Åsmul
-Stein Åsmul
Posted 22 March 2006 - 10:50
Can't you detect the file type from the PE header?
Dependency Walker also displays dependencies and exported functions (but I don't think its source code is available)
Dependency Walker also displays dependencies and exported functions (but I don't think its source code is available)
Stefan Krüger
InstallSite.org twitter facebook
Posted 22 March 2006 - 11:05
So if I got it you want to know if you are dealing with managed or unmanaged code?
If so something like the Reflector aplication will help you. And as the name says it works using .Net reflection. Try that.
If so something like the Reflector aplication will help you. And as the name says it works using .Net reflection. Try that.
Posted 22 March 2006 - 11:25
Hi Stefan, yes that is probably the right way to do it, but I was looking for something faster for now. I probably have to bite the bullet and dig out the winnt.h later on :-(.
Regards
-Stein Åsmul
-Stein Åsmul