Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I determine the architecture of an executable binary on Windows 10

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

  1. its CPU architecture eg Intel/ARM, and
  2. its bitness eg 32 or 64.

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

like image 541
Justicle Avatar asked Feb 22 '19 20:02

Justicle


People also ask

What architecture is this binary?

x86-64 is the architecture of the binary, the 64-bit version of the x86 instruction set originally introduced by AMD.

How do I check the version of an EXE file?

Right click on it and then select Properties. In the Properties window, go to the Details tab. There you will find information about the product name, the product version and so on.

What is executable binary code?

A binary executable file is a file in a machine language for a specific processor. Binary executable files contain executable code that is represented in specific processor instructions. These instructions are executed by a processor directly. A binary file, however, can have text strings (ASCII and/or Unicode).

Is an executable a binary?

In general, executable -- or ready-to-run -- programs are identified as binary files and given a filename extension such as . bin or .exe. Programmers often talk about an executable program as a binary or will refer to their compiled application files as binaries.


1 Answers

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:

  • Go to offset 0x3C in the file. The four bytes there hold the offset of the COFF header (from the beginning of the file).
  • Go to the COFF header pointed by the above field, and advance by four (4) bytes.
  • The following two (2) bytes are the Machine field.

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

EDIT: 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);
}
like image 158
Yakov Galka Avatar answered Sep 22 '22 03:09

Yakov Galka