3

IDC has a RunPlugin() function but there seems to be no way to unload a plugin explicitly. I searched high and wide - including the Hex-Rays forums - but found no answers. And judging by this post I'm not the only one.

At the moment I'm trying to figure out how certain SDK functions work, by adding some test code to a plugin and loading it into IDA. If I use PLUGIN_KEEP then I can experiment by calling my functions from the IDC prompt, but I have to close the database to unload the plugin. If I use PLUGIN_UNL then I effectively have only one function with a single integer parameter, which severely restricts experimentation...

Currently I'm working around that by having PLUGIN_KEEP set upon load but patching PLUGIN_UNL into PLUGIN.flags if the plugin's run function is called with parameter 666, or if the parameter is 0 and this isn't the first call to the run function. The latter is convenient because it allows loading/unloading with a single hotkey, without farting around with the command prompt. The plugin gets loaded automatically when an .IDB is opened, and then it can be unloaded and reloaded freely via the hotkey configured in PLUGIN.wanted_hotkey.

However, overall it seems a rather hackish approach relying on undocumented functionality. Is there a better/cleaner way of unloading a plugin, or are there caveats that I should be aware of?

2

Currently I'm working around that by having PLUGIN_KEEP set upon load but patching PLUGIN_UNL into PLUGIN.flags

This is not a "workaround" but actually a documented way to have IDA unload your plugin.

#define PLUGIN_UNL  0x0008      ///< Unload the plugin immediately after calling 'run'.
                                ///< This flag may be set anytime.
                                ///< The kernel checks it after each call to 'run'
                                ///< The main purpose of this flag is to ease
                                ///< the debugging of new plugins.
  • Thanks, I must have overlooked the "flag may be set anytime" bit when I combed the header files for little crumbs of info... – DarthGizka Jan 8 '15 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.