我怎样才能得到一个集DLL的处理器架构? [英] How can I get the processor architecture of an assembly dll?

查看:105
本文介绍了我怎样才能得到一个集DLL的处理器架构?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在处理器架构通过编程方式加载DLL在C#?

Can I get the processor architecture by loading the dll programmatically in c#?

有一个类,能做到这一点?

Is there a class that can do this?

我需要得到阉dll是86,64,MSIL等。

I need to get wether the dll is x86, x64, MSIL etc..

推荐答案

假设你只盯着.NET程序集,你可以使用的CoreFlags.exe 了解看图像的标题。

Assuming you are only looking at .net assemblies, you can use CoreFlags.exe for look at the header of the image.

本博客文章解释用法determing如何阅读结果。摘录:

This blog post explains the usage to determing how to read the results. Excerpt:

用法:Corflags.exe大会[选项]

Usage: Corflags.exe Assembly [options]

如果未指定任何选项,将显示标志给定的图像。

If no options are specified, the flags for the given image are displayed.

...

这里是头部的每个组件是指:

版本:包含.NET的Redist的版本的二进制是   建成。

Version: Contains the version of .NET Redist with which the binary is built.

CLR头:2.0表示一个NET 1.0或.Net 1.1(埃弗雷特)的图像,而2.5表示NET 2.0(Whidbey的)图像

CLR Header: 2.0 indicates a .Net 1.0 or .Net 1.1 (Everett) image while 2.5 indicates a .Net 2.0 (Whidbey) image.

CorFlags:这是由OR'g特定的标志来计算,以指示是否   图像ILONLY,其位数等,并   所使用的加载程序。 ILONLY:托管   图像被允许包含本地   code。为了值为anycpu的图像应   只包含IL。

CorFlags: This is computed by OR’g specific flags to indicate whether the image is ILONLY, its bitness etc. and is used by the loader. ILONLY: Managed images are allowed to contain native code. To be "anycpu" an image shall only contain IL.

32BIT:即使你只包含IL它仍然可能会在图像   有平台依赖性,32位   标志是用来区分86   图片来自值为anycpu的图像。 64位   图像是由以下事实区分   他们有PE32 +的PE类型。
  最有趣的方面是PE和头部的32BIT标志。   这些结合起来,指定程序集   类型。下面是他们会怎么看   像:

32BIT: Even if you have an image that only contains IL it still might have platform dependencies, the 32BIT flag is used to distinguish "x86" images from "anycpu" images. 64-bit images are distinguished by the fact that they have a PE type of PE32+.
The most interesting aspect is the PE and the 32BIT flag of the header. These combine to specify the assembly types. Here is how they would look like for:

      
  • 值为anycpu:PE = PE32和32位= 0
  •   
  • 86:PE = PE32和32位= 1
  •   
  • 64位:PE = PE32 +和32位= 0
  •   
  • anycpu: PE = PE32 and 32BIT = 0
  • x86: PE = PE32 and 32BIT = 1
  • 64-bit: PE = PE32+ and 32BIT = 0

这篇关于我怎样才能得到一个集DLL的处理器架构?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆