Abstract binary file format detection into FileFormatReader.Load

This commit is contained in:
Katy Coe
2019-10-21 10:15:06 +02:00
parent 661d2c6ca7
commit 2ae0904226
2 changed files with 20 additions and 7 deletions

View File

@@ -157,13 +157,8 @@ namespace Il2CppInspector
Console.WriteLine("Detected metadata version " + metadata.Version);
// Load the il2cpp code file (try ELF, PE, Mach-O and Universal Binary)
var memoryStream = new MemoryStream(File.ReadAllBytes(codeFile));
IFileFormatReader stream =
(((IFileFormatReader) ElfReader.Load(memoryStream) ??
PEReader.Load(memoryStream)) ??
MachOReader.Load(memoryStream)) ??
UBReader.Load(memoryStream);
// Load the il2cpp code file (try all available file formats)
IFileFormatReader stream = FileFormatReader.Load(new MemoryStream(File.ReadAllBytes(codeFile)));
if (stream == null) {
Console.Error.WriteLine("Unsupported executable file format");
return null;