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("");
|
||||
|
||||
// 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;
|
||||
|
||||
@@ -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,6 +321,7 @@ namespace Il2CppInspector
|
||||
var eventInfo = new PluginOptionsChangedEventInfo();
|
||||
|
||||
foreach (var plugin in EnabledPlugins)
|
||||
if (plugin.Options != null)
|
||||
foreach (var option in plugin.Options)
|
||||
try {
|
||||
option.Value = option.Value;
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user