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.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
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?