Is this DLL managed or unmanaged?

后端 未结 3 1104
温柔的废话
温柔的废话 2020-12-09 09:29

I hold before you a DLL. Using only the Win32 SDK, can you tell me if this DLL is a .NET assembly?

Why? Our application loads plugins in the form of DLLs. We are try

3条回答
  •  一整个雨季
    2020-12-09 09:45

    To determine whether a DLL (or EXE) is managed or unmanaged, use dumpbin.exe with the /dependents switch. If you see mscoree.dll in the output, then the assembly is a managed assembly.

    For example, for a managed DLL that I created in Visual Studio 2010, I get the following output:

    Dump of file .dll
    
    File Type: DLL
    
      Image has the following dependencies:
    
        mscoree.dll
    
      Summary
    
            2000 .reloc
            2000 .rsrc
            2000 .sdata
           12000 .text
    

    dumpbin.exe is delivered as part of the Visual Studio Tools. To run it, a convenient way to do so is via the Visual Studio Command Prompt. For example, from my Windows 7 machine running Visual Studio 2010, I find the Visual Studio Command Prompt in the Windows Start Menu at:

    Microsoft Visual Studio 2010 => Visual Studio Tools => Visual Studio Command Prompt (2010)

    Then, within the Visual Studio Command Prompt just enter:

    dumpbin /dependents DLL_OF_INTEREST.DLL
    

    or

    dumpbin /dependents EXE_OF_INTEREST.EXE
    

    As an alternative, you can use the corflags.exe utility that is also included with Visual Studio Tools. Running it from the Visual Studio Command Prompt on an unmanaged assembly:

    corflags UNMANAGED.DLL
    

    ..you'll get:

    corflags : error CF008 : The specified file does not have a valid managed header
    

    ...whereas on a managed assembly, you'll get something like:

    Version   : v2.0.50727
    CLR Header: 2.5
    PE        : PE32
    CorFlags  : 1
    ILONLY    : 1
    32BIT     : 0
    Signed    : 0
    

    Related:

    • How to determine if a .NET assembly was built for x86 or x64?, and
    • How can I detect the type of a dll? (COM, .NET, WIN32).

提交回复
热议问题