Formats: Allow LoadOptions to be null

This commit is contained in:
Katy Coe
2021-01-12 00:21:57 +01:00
parent 68d251926d
commit 61eb6964fc
3 changed files with 4 additions and 4 deletions

View File

@@ -203,13 +203,13 @@ namespace Il2CppInspector
// Dumped images must be rebased // Dumped images must be rebased
if (isMemoryImage) { 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"); 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, // Rebase if requested (whether dumped or not) and treat it as a memory image,
// disabling processing of relocations, symbols and decryption // disabling processing of relocations, symbols and decryption
if (LoadOptions.ImageBase != 0) { if (LoadOptions?.ImageBase != 0) {
isMemoryImage = true; isMemoryImage = true;
rebase(conv.FromULong(LoadOptions.ImageBase)); rebase(conv.FromULong(LoadOptions.ImageBase));
} }

View File

@@ -149,7 +149,7 @@ namespace Il2CppInspector
// Get file path // 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 // 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"); 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 // Attempt to load DLL and run startup functions

View File

@@ -54,7 +54,7 @@ namespace Il2CppInspector
// Get file path // 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 // 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"); throw new InvalidOperationException("To load a Linux process map, you must specify the maps file path in LoadOptions");
if (!mapsPath.ToLower().EndsWith("-maps.txt")) if (!mapsPath.ToLower().EndsWith("-maps.txt"))