mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-01 21:17:44 -05:00
git: Properly verify that plugins built from the plugin template can be loaded by ImHex (#2352)
This commit is contained in:
@@ -27,7 +27,7 @@ namespace hex::plugin::builtin {
|
||||
void handleDemangleCommand(const std::vector<std::string> &args);
|
||||
void handleSettingsResetCommand(const std::vector<std::string> &args);
|
||||
void handleDebugModeCommand(const std::vector<std::string> &args);
|
||||
|
||||
void handleValidatePluginCommand(const std::vector<std::string> &args);
|
||||
|
||||
void registerCommandForwarders();
|
||||
|
||||
|
||||
@@ -415,7 +415,37 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
void handleDebugModeCommand(const std::vector<std::string> &) {
|
||||
hex::dbg::setDebugModeEnabled(true);
|
||||
dbg::setDebugModeEnabled(true);
|
||||
}
|
||||
|
||||
void handleValidatePluginCommand(const std::vector<std::string> &args) {
|
||||
if (args.size() != 1) {
|
||||
log::println("usage: imhex --validate-plugin <plugin path>");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
log::resumeLogging();
|
||||
|
||||
const auto plugin = Plugin(args[0]);
|
||||
|
||||
if (!plugin.isLoaded()) {
|
||||
log::println("Plugin couldn't be loaded. Make sure the plugin was built using the SDK of this ImHex version!");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!plugin.isValid()) {
|
||||
log::println("Plugin is missing required init function! Make sure your plugin has a IMHEX_PLUGIN_SETUP or IMHEX_LIBRARY_SETUP block!");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (!plugin.initializePlugin()) {
|
||||
log::println("An error occurred while trying to initialize the plugin. Check the logs for more information.");
|
||||
std::exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
log::println("Plugin is valid!");
|
||||
|
||||
std::exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -444,7 +444,7 @@ namespace hex::plugin::builtin {
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(plugin.getPluginDescription().c_str());
|
||||
ImGui::TableNextColumn();
|
||||
ImGui::TextUnformatted(plugin.isLoaded() ? ICON_VS_CHECK : ICON_VS_CLOSE);
|
||||
ImGui::TextUnformatted(plugin.isInitialized() ? ICON_VS_CHECK : ICON_VS_CLOSE);
|
||||
|
||||
if (open) {
|
||||
for (const auto &feature : plugin.getFeatures()) {
|
||||
|
||||
@@ -62,28 +62,29 @@ namespace hex::plugin::builtin {
|
||||
}
|
||||
|
||||
IMHEX_PLUGIN_SUBCOMMANDS() {
|
||||
{ "help", "h", "Print help about this command", hex::plugin::builtin::handleHelpCommand },
|
||||
{ "version", "", "Print ImHex version", hex::plugin::builtin::handleVersionCommand },
|
||||
{ "version-short", "", "Print only the version info in plain text", hex::plugin::builtin::handleVersionShortCommand },
|
||||
{ "plugins", "", "Lists all plugins that have been installed", hex::plugin::builtin::handlePluginsCommand },
|
||||
{ "language", "", "Changes the language ImHex uses", hex::plugin::builtin::handleLanguageCommand },
|
||||
{ "verbose", "v", "Enables verbose debug logging", hex::plugin::builtin::handleVerboseCommand },
|
||||
{ "help", "h", "Print help about this command", hex::plugin::builtin::handleHelpCommand },
|
||||
{ "version", "", "Print ImHex version", hex::plugin::builtin::handleVersionCommand },
|
||||
{ "version-short", "", "Print only the version info in plain text", hex::plugin::builtin::handleVersionShortCommand },
|
||||
{ "plugins", "", "Lists all plugins that have been installed", hex::plugin::builtin::handlePluginsCommand },
|
||||
{ "language", "", "Changes the language ImHex uses", hex::plugin::builtin::handleLanguageCommand },
|
||||
{ "verbose", "v", "Enables verbose debug logging", hex::plugin::builtin::handleVerboseCommand },
|
||||
|
||||
{ "open", "o", "Open files passed as argument. [default]", hex::plugin::builtin::handleOpenCommand },
|
||||
{ "new", "n", "Create a new empty file", hex::plugin::builtin::handleNewCommand },
|
||||
{ "open", "o", "Open files passed as argument. [default]", hex::plugin::builtin::handleOpenCommand },
|
||||
{ "new", "n", "Create a new empty file", hex::plugin::builtin::handleNewCommand },
|
||||
|
||||
{ "select", "", "Select a range of bytes in the Hex Editor", hex::plugin::builtin::handleSelectCommand },
|
||||
{ "pattern", "", "Sets the loaded pattern", hex::plugin::builtin::handlePatternCommand },
|
||||
{ "calc", "", "Evaluate a mathematical expression", hex::plugin::builtin::handleCalcCommand },
|
||||
{ "hash", "", "Calculate the hash of a file", hex::plugin::builtin::handleHashCommand },
|
||||
{ "encode", "", "Encode a string", hex::plugin::builtin::handleEncodeCommand },
|
||||
{ "decode", "", "Decode a string", hex::plugin::builtin::handleDecodeCommand },
|
||||
{ "magic", "", "Identify file types", hex::plugin::builtin::handleMagicCommand },
|
||||
{ "pl", "", "Interact with the pattern language", hex::plugin::builtin::handlePatternLanguageCommand, SubCommand::Type::SubCommand },
|
||||
{ "hexdump", "", "Generate a hex dump of the provided file", hex::plugin::builtin::handleHexdumpCommand },
|
||||
{ "demangle", "", "Demangle a mangled symbol", hex::plugin::builtin::handleDemangleCommand },
|
||||
{ "reset-settings", "", "Resets all settings back to default", hex::plugin::builtin::handleSettingsResetCommand },
|
||||
{ "debug-mode", "", "Enables debugging features", hex::plugin::builtin::handleDebugModeCommand, }
|
||||
{ "select", "", "Select a range of bytes in the Hex Editor", hex::plugin::builtin::handleSelectCommand },
|
||||
{ "pattern", "", "Sets the loaded pattern", hex::plugin::builtin::handlePatternCommand },
|
||||
{ "calc", "", "Evaluate a mathematical expression", hex::plugin::builtin::handleCalcCommand },
|
||||
{ "hash", "", "Calculate the hash of a file", hex::plugin::builtin::handleHashCommand },
|
||||
{ "encode", "", "Encode a string", hex::plugin::builtin::handleEncodeCommand },
|
||||
{ "decode", "", "Decode a string", hex::plugin::builtin::handleDecodeCommand },
|
||||
{ "magic", "", "Identify file types", hex::plugin::builtin::handleMagicCommand },
|
||||
{ "pl", "", "Interact with the pattern language", hex::plugin::builtin::handlePatternLanguageCommand, SubCommand::Type::SubCommand },
|
||||
{ "hexdump", "", "Generate a hex dump of the provided file", hex::plugin::builtin::handleHexdumpCommand },
|
||||
{ "demangle", "", "Demangle a mangled symbol", hex::plugin::builtin::handleDemangleCommand },
|
||||
{ "reset-settings", "", "Resets all settings back to default", hex::plugin::builtin::handleSettingsResetCommand },
|
||||
{ "debug-mode", "", "Enables debugging features", hex::plugin::builtin::handleDebugModeCommand, },
|
||||
{ "validate-plugin", "", "Validates that a plugin can be loaded", hex::plugin::builtin::handleValidatePluginCommand }
|
||||
};
|
||||
|
||||
IMHEX_PLUGIN_SETUP("Built-in", "WerWolv", "Default ImHex functionality") {
|
||||
|
||||
Reference in New Issue
Block a user