如何确定Windows 10上的可执行二进制文件的体系结构 [英] How do I determine the architecture of an executable binary on Windows 10

查看:95
本文介绍了如何确定Windows 10上的可执行二进制文件的体系结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Windows上给出一些 Random.exe ,我该如何确定

Given some Random.exe on Windows, how can I determine

  1. 其CPU架构,例如Intel/ARM,和
  2. 它的位数,例如32或64.

我可以使用文件浏览器中的属性,其他工具或编程方法吗?

Is there a property in File Explorer, some other tool, or programatic method I can use?

推荐答案

可执行文件的体系结构写在COFF标头的计算机"字段中.您可以通过编程方式或使用十六进制编辑器手动对其进行检索:

The architecture of the executable is written in the Machine field of the COFF header. You can retrieve it programatically or manually with a hex editor:

  • 转到文件中的偏移量0x3C.那里的四个字节保存了COFF标头的偏移量(从文件开头开始).
  • 转到上述字段所指向的COFF标头,然后前进四(4)个字节.
  • 以下两(2)个字节是机器"字段.

您可以在此处中看到PE结构.在此处.

You can see PE structure here. The valid Machine field values are listed here.

编辑:这是未经测试的C代码,可以完成此操作:

Here's a C code that does that, untested:

int main(int argc, char *argv[]) {
    FILE *f = fopen(argv[1], "rb");
    uint32_t offset = 0;
    fseek(f, 0x3c, SEEK_SET);
    fread(&offset, sizeof(offset), 1, f);
    fseek(f, offset + 4, SEEK_SET);
    uint16_t machine = 0;
    fread(&machine, sizeof(machine), 1, f);
    printf("Machine: 0x%.4x\n", machine);
}

这篇关于如何确定Windows 10上的可执行二进制文件的体系结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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