Hey ilfak nice to chat with you again.
Okay, got to do the work for this.
Simple plugin based on the IDA hello world example:
import idaapi
import ida_hexrays
class load_test_t(idaapi.plugin_t):
flags = 0 # Same as Gepetto’s
comment = “comment”
help = “help”
wanted_name = “* Decomp load order test *”
wanted_hotkey = “Alt-F8”
def init(self):
print("*Test: init() init_hexrays_plugin() ->", ida_hexrays.init_hexrays_plugin())
return idaapi.PLUGIN_KEEP
def run(self, arg):
print("*Test: run() init_hexrays_plugin() ->", ida_hexrays.init_hexrays_plugin())
return 0
def PLUGIN_ENTRY():
print(“*Test: PLUGIN_ENTRY() hotkey Alt-F8.”)
return load_test_t()
The test is have a filename that should load first vs a filename that should load last vs the decompiler plugin load order.
As plugin named “aaaa_decomp_load_test.py” so it’s the first:
IDA Home 9.2: “hexcx64.dll”
*Test: PLUGIN_ENTRY() hotkey Alt-F8.
*Test: init() init_hexrays_plugin() → False
Hex-Rays Cloud Decompiler plugin has been loaded (v9.2.0.250908)
..
*Test: run() init_hexrays_plugin() → True
Okay just as you say “alphabetical order”. We see our Python script init() before Hex-Rays done as evident by log lines. ‘A’ is before ‘H”. At least assuming the Qt log line events came in order.
Now lets rename the plugin to “zzzz_decomp_load_test.py” so that it should be the last to load:
IDA Home 9.2: “hexcx64.dll”
Hex-Rays Cloud Decompiler plugin has been loaded (v9.2.0.250908)
*Test: PLUGIN_ENTRY() hotkey Alt-F8.
*Test: init() init_hexrays_plugin() → True
..
*Test: run() init_hexrays_plugin() → True
Also what you say as ‘H’ comes before ‘Z’.
I only have an IDA 9.2 license for home currently, but tested it on IDA Pro 8.4 and I get the same exact results.
Okay I don’t see it documented in the IDA API docs any place, but it makes sense.
We find out, normally you don’t want to call “init_hexrays_plugin()” inside of a plugin’s init().
In Gepetto it’s used there there to both initialize the Hex-Rays for plugin use, and also to see if it even exists.
Which IS kind of unnecessary because if someone is silly enough to install a plugin that requires the decompiler, but then doesn’t have it, they have bigger problems. And decompiler API functions are not called until later, long after init(), it would just throw some exception in the code.
But strange thing is that still, it apparently doesn’t happening in IDA Pro 9.2. I’m the first person to bring up this issue with the plugin and it’s very popular. Can you guys try this script on IDA Pro 9.2 for Windows and Linux and see if the behavior is different?
I’ll ask the author of the plugin to try it too.