Plugins: Prevent app from starting without plugins
This commit is contained in:
@@ -169,6 +169,15 @@ namespace Il2CppInspector.CLI
|
|||||||
Console.WriteLine(asmInfo.LegalCopyright);
|
Console.WriteLine(asmInfo.LegalCopyright);
|
||||||
Console.WriteLine("");
|
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
|
// Check plugin options are valid
|
||||||
if (!PluginOptions.ParsePluginOptions(options.PluginOptions, PluginOptions.GetPluginOptionTypes()))
|
if (!PluginOptions.ParsePluginOptions(options.PluginOptions, PluginOptions.GetPluginOptionTypes()))
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -176,9 +176,13 @@ namespace Il2CppInspector
|
|||||||
|
|
||||||
AsInstance.ManagedPlugins.Clear();
|
AsInstance.ManagedPlugins.Clear();
|
||||||
|
|
||||||
// Don't do anything if there's no plugins folder
|
// Don't allow the user to start the application if there's no plugins folder
|
||||||
if (!Directory.Exists(pluginFolder))
|
if (!Directory.Exists(pluginFolder)) {
|
||||||
return;
|
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
|
// Get every DLL
|
||||||
// NOTE: Every plugin should be in its own folder together with its dependencies
|
// NOTE: Every plugin should be in its own folder together with its dependencies
|
||||||
@@ -317,15 +321,16 @@ namespace Il2CppInspector
|
|||||||
var eventInfo = new PluginOptionsChangedEventInfo();
|
var eventInfo = new PluginOptionsChangedEventInfo();
|
||||||
|
|
||||||
foreach (var plugin in EnabledPlugins)
|
foreach (var plugin in EnabledPlugins)
|
||||||
foreach (var option in plugin.Options)
|
if (plugin.Options != null)
|
||||||
try {
|
foreach (var option in plugin.Options)
|
||||||
option.Value = option.Value;
|
try {
|
||||||
}
|
option.Value = option.Value;
|
||||||
catch (Exception ex) {
|
}
|
||||||
eventInfo.Error = new PluginOptionErrorEventArgs { Plugin = plugin, Exception = ex, Option = option, Operation = "options update" };
|
catch (Exception ex) {
|
||||||
ErrorHandler?.Invoke(AsInstance, eventInfo);
|
eventInfo.Error = new PluginOptionErrorEventArgs { Plugin = plugin, Exception = ex, Option = option, Operation = "options update" };
|
||||||
break;
|
ErrorHandler?.Invoke(AsInstance, eventInfo);
|
||||||
}
|
break;
|
||||||
|
}
|
||||||
return eventInfo;
|
return eventInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -131,7 +131,7 @@ namespace Il2CppInspectorGUI
|
|||||||
// Load plugins if they aren't already
|
// Load plugins if they aren't already
|
||||||
try {
|
try {
|
||||||
PluginManager.EnsureInit();
|
PluginManager.EnsureInit();
|
||||||
} catch (InvalidOperationException ex) {
|
} catch (Exception ex) when (ex is InvalidOperationException || ex is DirectoryNotFoundException) {
|
||||||
MessageBox.Show(ex.Message, "Fatal error loading plugins");
|
MessageBox.Show(ex.Message, "Fatal error loading plugins");
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user