我如何检测一个dll的类型? (COM,.NET,WIN32)类型、dll、COM、NET

2023-09-02 10:38:41 作者:相思引

我需要处理一些DLL的和exe文件的文件夹中,并确定哪些类型的文件,我处理:.NET,COM,Win32的或其他的外星生命形式

I need to process a number of dll's and exe files in a folder and determine what type of file I am dealing with: .NET, COM, Win32 or some other alien life form.

我一直在尝试确定要检测一个DLL的类型,最简单的方法,您如何看待此事的:

I've been trying to determine the easiest way to detect the type of a DLL, what do you think of this:

COM DLL =>我做的LoadLibrary,然后调用GetProcAddress的中的DllRegisterServer 。如果我得到一个有效的回报,这是一个COM文件。

COM dll => I do a LoadLibrary, then GetProcAddress for "DllRegisterServer". If I get a valid return, it's a COM file.

.NET的DLL =>如果DLL取决于 MSCorEE.dll中它总是一个.NET的DLL?

.NET dll => If the dll depends on MSCOREE.DLL it's always a .NET dll?

的Win32 DLL =>如果以上两个测试失败,这是一个Win32 DLL?

Win32 dll => If both the above tests fail, it's a Win32 dll?

当然,必须有一个更好的方式来检测是什么类型的dll我们正在处理。以上是很笨重的,不会对EXE文件工作?必须有,我没有想到的其他方式。

Surely there must be a better way to detect what type of dll we are dealing with. The above is very clunky, and won't work for EXE files? There must be some other way that I am not thinking of.

在理想情况下,我想能够使解析器确定编译文件编译时使用,什么功能,它使用如MFC,ATL,STL等...但我怀疑这是可能在$ p $对反映时代?

Ideally I'd like to be able to make the parser determine what compiler the file was compiled with, and what features it uses such as MFC, Atl, Stl etc... But I doubt that's possible in the pre-reflection era?

推荐答案

您必须检查这些文件的PE头。所有的DLL和可执行文件,Win32和.NET,有PE头。

You must check the PE Header of these files. All DLL and executables, Win32 and .NET, have a PE header.

了深入查找到的Win32可移植可执行文件格式

的.NET文件格式

移植可执行

再见。