Loader: Unwrap FileFormatReader.Load exceptions

This commit is contained in:
Katy Coe
2020-02-24 13:37:06 +01:00
parent 58771cf308
commit 250c3a2fc9

View File

@@ -60,11 +60,16 @@ namespace Il2CppInspector
.Where(x => x.ImplementedInterfaces.Contains(typeof(IFileFormatReader)) && !x.IsGenericTypeDefinition);
foreach (var type in types) {
try {
if (type.GetMethod("Load", BindingFlags.FlattenHierarchy | BindingFlags.Static | BindingFlags.Public,
null, new [] {typeof(Stream), typeof(EventHandler<string>)}, null)
.Invoke(null, new object[] { stream, statusCallback }) is IFileFormatReader loaded)
null, new[] {typeof(Stream), typeof(EventHandler<string>)}, null)
.Invoke(null, new object[] {stream, statusCallback}) is IFileFormatReader loaded)
return loaded;
}
catch (TargetInvocationException ex) {
throw ex.InnerException;
}
}
return null;
}
}