diff --git a/include/rz-plugin/console/decompiler.h b/include/rz-plugin/console/decompiler.h index ba2a42c..03afde9 100644 --- a/include/rz-plugin/console/decompiler.h +++ b/include/rz-plugin/console/decompiler.h @@ -26,6 +26,9 @@ class DecompilerConsole: public Console { /// Register all decompilation commands into the given RzCmd instance. static bool registerCommands(RzCmd* cmd); + /// Deregister all decompilation commands into the given RzCmd instance. + static bool deregisterCommands(RzCmd* cmd); + public: /// Representation of pdz command. static const Console::Command DecompileCurrent; diff --git a/src/rz-plugin/console/decompiler.cpp b/src/rz-plugin/console/decompiler.cpp index f84db7b..9e9d183 100644 --- a/src/rz-plugin/console/decompiler.cpp +++ b/src/rz-plugin/console/decompiler.cpp @@ -101,6 +101,12 @@ bool DecompilerConsole::registerCommands(RzCmd* cmd) return DecompilerConsole::console.registerConsole(cmd, root_desc, CMD_PREFIX); } +bool DecompilerConsole::deregisterCommands(RzCmd* cmd) +{ + RzCmdDesc* retdec_desc = rz_cmd_get_desc(cmd, CMD_PREFIX); + return rz_cmd_desc_remove(cmd, retdec_desc); +} + RzAnnotatedCode *DecompilerConsole::runDecompile(RzCore *core) { std::lock_guard lock(mutex); diff --git a/src/rz-plugin/registration.cpp b/src/rz-plugin/registration.cpp index 8425811..e005d85 100644 --- a/src/rz-plugin/registration.cpp +++ b/src/rz-plugin/registration.cpp @@ -21,6 +21,11 @@ static bool rz_retdec_init(RzCore *core) return DecompilerConsole::registerCommands(core->rcmd); } +static bool rz_retdec_fini(RzCore *core) +{ + return DecompilerConsole::deregisterCommands(core->rcmd); +} + // Structure containing plugin info. RzCorePlugin rz_core_plugin_retdec = { /* .name = */ "rz-retdec", @@ -29,7 +34,7 @@ RzCorePlugin rz_core_plugin_retdec = { /* .author = */ "RizinOrg and Avast", /* .version = */ nullptr, /* .init = */ rz_retdec_init, - /* .fini = */ nullptr + /* .fini = */ rz_retdec_fini, }; #ifndef CORELIB @@ -43,7 +48,6 @@ RZ_API RzLibStruct rizin_plugin = { /* .data = */ &rz_core_plugin_retdec, /* .version = */ RZ_VERSION, /* .free = */ nullptr, - /* .pkgname */ "rz-retdec" }; #endif