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

View File

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

View File

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