API: Allow passing of load options to binary loaders

This commit is contained in:
Katy Coe
2020-12-11 22:44:48 +01:00
parent 95db3ad19b
commit 08c1559222
9 changed files with 59 additions and 39 deletions

View File

@@ -515,22 +515,22 @@ namespace Il2CppInspector
}
// Load from an AAB, IPA or one or more APK files
public static List<Il2CppInspector> LoadFromPackage(IEnumerable<string> packageFiles, bool silent = false) {
public static List<Il2CppInspector> LoadFromPackage(IEnumerable<string> packageFiles, LoadOptions loadOptions = null, bool silent = false) {
var streams = GetStreamsFromPackage(packageFiles, silent);
if (!streams.HasValue)
return null;
return LoadFromStream(streams.Value.Binary, streams.Value.Metadata, silent: silent);
return LoadFromStream(streams.Value.Binary, streams.Value.Metadata, loadOptions, silent: silent);
}
// Load from a binary file and metadata file
public static List<Il2CppInspector> LoadFromFile(string binaryFile, string metadataFile, bool silent = false)
public static List<Il2CppInspector> LoadFromFile(string binaryFile, string metadataFile, LoadOptions loadOptions = null, bool silent = false)
=> LoadFromStream(new FileStream(binaryFile, FileMode.Open, FileAccess.Read, FileShare.Read),
new MemoryStream(File.ReadAllBytes(metadataFile)),
silent: silent);
loadOptions, silent: silent);
// Load from a binary stream and metadata stream
// Must be a seekable stream otherwise we catch a System.IO.NotSupportedException
public static List<Il2CppInspector> LoadFromStream(Stream binaryStream, MemoryStream metadataStream, EventHandler<string> statusCallback = null, bool silent = false) {
public static List<Il2CppInspector> LoadFromStream(Stream binaryStream, MemoryStream metadataStream, LoadOptions loadOptions = null, EventHandler<string> statusCallback = null, bool silent = false) {
// Silent operation if requested
var stdout = Console.Out;
@@ -553,7 +553,7 @@ namespace Il2CppInspector
// Load the il2cpp code file (try all available file formats)
IFileFormatReader stream;
try {
stream = FileFormatReader.Load(binaryStream, statusCallback);
stream = FileFormatReader.Load(binaryStream, loadOptions, statusCallback);
if (stream == null)
throw new InvalidOperationException("Unsupported executable file format");