From 61eb6964fc38de705f9c90562f61bfaeceb379cc Mon Sep 17 00:00:00 2001 From: Katy Coe Date: Tue, 12 Jan 2021 00:21:57 +0100 Subject: [PATCH] Formats: Allow LoadOptions to be null --- Il2CppInspector.Common/FileFormatStreams/ElfReader.cs | 4 ++-- Il2CppInspector.Common/FileFormatStreams/PEReader.cs | 2 +- Il2CppInspector.Common/FileFormatStreams/ProcessMapReader.cs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/Il2CppInspector.Common/FileFormatStreams/ElfReader.cs b/Il2CppInspector.Common/FileFormatStreams/ElfReader.cs index 1dc9b5e..3d11ad6 100644 --- a/Il2CppInspector.Common/FileFormatStreams/ElfReader.cs +++ b/Il2CppInspector.Common/FileFormatStreams/ElfReader.cs @@ -203,13 +203,13 @@ namespace Il2CppInspector // Dumped images must be rebased if (isMemoryImage) { - if (LoadOptions.ImageBase == 0) + if (LoadOptions == null || LoadOptions.ImageBase == 0) throw new InvalidOperationException("To load a dumped ELF image, you must specify the image base virtual address"); } // Rebase if requested (whether dumped or not) and treat it as a memory image, // disabling processing of relocations, symbols and decryption - if (LoadOptions.ImageBase != 0) { + if (LoadOptions?.ImageBase != 0) { isMemoryImage = true; rebase(conv.FromULong(LoadOptions.ImageBase)); } diff --git a/Il2CppInspector.Common/FileFormatStreams/PEReader.cs b/Il2CppInspector.Common/FileFormatStreams/PEReader.cs index 3bf3e5d..648ccec 100644 --- a/Il2CppInspector.Common/FileFormatStreams/PEReader.cs +++ b/Il2CppInspector.Common/FileFormatStreams/PEReader.cs @@ -149,7 +149,7 @@ namespace Il2CppInspector // Get file path // This error should never occur with the bundled CLI and GUI; only when used as a library by a 3rd party tool - if (!(LoadOptions.BinaryFilePath is string dllPath)) + if (LoadOptions == null || !(LoadOptions.BinaryFilePath is string dllPath)) throw new InvalidOperationException("To load a packed PE file, you must specify the DLL file path in LoadOptions"); // Attempt to load DLL and run startup functions diff --git a/Il2CppInspector.Common/FileFormatStreams/ProcessMapReader.cs b/Il2CppInspector.Common/FileFormatStreams/ProcessMapReader.cs index 2279d9e..db30fe9 100644 --- a/Il2CppInspector.Common/FileFormatStreams/ProcessMapReader.cs +++ b/Il2CppInspector.Common/FileFormatStreams/ProcessMapReader.cs @@ -54,7 +54,7 @@ namespace Il2CppInspector // Get file path // This error should never occur with the bundled CLI and GUI; only when used as a library by a 3rd party tool - if (!(LoadOptions.BinaryFilePath is string mapsPath)) + if (LoadOptions == null || !(LoadOptions.BinaryFilePath is string mapsPath)) throw new InvalidOperationException("To load a Linux process map, you must specify the maps file path in LoadOptions"); if (!mapsPath.ToLower().EndsWith("-maps.txt"))