Plugins: Prevent app from starting without plugins

This commit is contained in:
Katy Coe
2021-01-12 01:11:05 +01:00
parent 930b00f588
commit a9ab4e627c
3 changed files with 27 additions and 13 deletions

View File

@@ -169,6 +169,15 @@ namespace Il2CppInspector.CLI
Console.WriteLine(asmInfo.LegalCopyright);
Console.WriteLine("");
// Safe plugin manager load
try {
PluginManager.EnsureInit();
}
catch (Exception ex) when (ex is InvalidOperationException || ex is DirectoryNotFoundException) {
Console.Error.WriteLine(ex.Message);
Environment.Exit(1);
}
// Check plugin options are valid
if (!PluginOptions.ParsePluginOptions(options.PluginOptions, PluginOptions.GetPluginOptionTypes()))
return 1;

View File

@@ -176,9 +176,13 @@ namespace Il2CppInspector
AsInstance.ManagedPlugins.Clear();
// Don't do anything if there's no plugins folder
if (!Directory.Exists(pluginFolder))
return;
// Don't allow the user to start the application if there's no plugins folder
if (!Directory.Exists(pluginFolder)) {
throw new DirectoryNotFoundException(
"Plugins folder not found. Please ensure you have installed the latest set of plugins before starting. "
+ "The plugins folder should be placed in the same directory as Il2CppInspector. "
+ "Use get-plugins.ps1 or get-plugins.sh to update your plugins. For more information, see the Il2CppInspector README.md file.");
}
// Get every DLL
// NOTE: Every plugin should be in its own folder together with its dependencies
@@ -317,15 +321,16 @@ namespace Il2CppInspector
var eventInfo = new PluginOptionsChangedEventInfo();
foreach (var plugin in EnabledPlugins)
foreach (var option in plugin.Options)
try {
option.Value = option.Value;
}
catch (Exception ex) {
eventInfo.Error = new PluginOptionErrorEventArgs { Plugin = plugin, Exception = ex, Option = option, Operation = "options update" };
ErrorHandler?.Invoke(AsInstance, eventInfo);
break;
}
if (plugin.Options != null)
foreach (var option in plugin.Options)
try {
option.Value = option.Value;
}
catch (Exception ex) {
eventInfo.Error = new PluginOptionErrorEventArgs { Plugin = plugin, Exception = ex, Option = option, Operation = "options update" };
ErrorHandler?.Invoke(AsInstance, eventInfo);
break;
}
return eventInfo;
}

View File

@@ -131,7 +131,7 @@ namespace Il2CppInspectorGUI
// Load plugins if they aren't already
try {
PluginManager.EnsureInit();
} catch (InvalidOperationException ex) {
} catch (Exception ex) when (ex is InvalidOperationException || ex is DirectoryNotFoundException) {
MessageBox.Show(ex.Message, "Fatal error loading plugins");
Environment.Exit(1);
}