Detect x64 and AArch64 ISAs in all binary formats

This commit is contained in:
Katy Coe
2019-10-21 14:31:09 +02:00
parent e46cca08e0
commit fde19c8972
3 changed files with 25 additions and 39 deletions

View File

@@ -7,6 +7,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
@@ -23,18 +24,13 @@ namespace Il2CppInspector
public override string Format => "ELF";
public override string Arch {
get {
switch (elf_header.e_machine) {
case 0x03:
return "x86";
case 0x28:
return "ARM";
default:
return "Unsupported";
}
}
}
public override string Arch => elf_header.e_machine switch {
0x03 => "x86", // EM_386
0x28 => "ARM", // EM_ARM
0x3E => "x64", // EM_X86_64
0xB7 => "ARM64", // EM_AARCH64
_ => "Unsupported"
};
public override int Bits => (elf_header.m_arch == 2) ? 64 : 32;

View File

@@ -6,6 +6,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using NoisyCowStudios.Bin2Object;
@@ -25,20 +26,13 @@ namespace Il2CppInspector
public override string Format => "Mach-O";
public override string Arch {
get {
switch ((MachO)header.CPUType) {
case MachO.CPU_TYPE_ARM:
case MachO.CPU_TYPE_ARM64:
return "ARM";
case MachO.CPU_TYPE_X86:
case MachO.CPU_TYPE_X86_64:
return "x86";
default:
return "Unsupported";
}
}
}
public override string Arch => (MachO)header.CPUType switch {
MachO.CPU_TYPE_ARM => "ARM",
MachO.CPU_TYPE_ARM64 => "ARM64",
MachO.CPU_TYPE_X86 => "x86",
MachO.CPU_TYPE_X86_64 => "x64",
_ => "Unsupported"
};
public override int Bits => is64 ? 64 : 32;

View File

@@ -21,19 +21,15 @@ namespace Il2CppInspector
public override string Format => "PE";
public override string Arch {
get {
switch (coff.Machine) {
case 0x14C:
return "x86";
case 0x1C0: // ARMv7
case 0x1C4: // ARMv7 Thumb (T1)
return "ARM";
default:
return "Unsupported";
}
}
}
public override string Arch => coff.Machine switch {
0x8664 => "x64", // IMAGE_FILE_MACHINE_AMD64
0x1C0 => "ARM", // IMAGE_FILE_MACHINE_ARM
0xAA64 => "ARM64", // IMAGE_FILE_MACHINE_ARM64
0x1C4 => "ARM", // IMAGE_FILE_MACHINE_ARMINT (Thumb-2)
0x14C => "x86", // IMAGE_FILE_MACHINE_I386
0x1C2 => "ARM", // IMAGE_FILE_MACHINE_THUMB (Thumb)
_ => "Unsupported"
};
// IMAGE_NT_OPTIONAL_HDR64_MAGIC = 0x20B
// IMAGE_NT_OPTIONAL_HDR32_MAGIC = 0x10B