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