Skip to content

Add a new callback decompilation_changed in decompilers#180

Open
NishTheFish-dev wants to merge 23 commits intomainfrom
feat/new_dcmpchanged_callback
Open

Add a new callback decompilation_changed in decompilers#180
NishTheFish-dev wants to merge 23 commits intomainfrom
feat/new_dcmpchanged_callback

Conversation

@NishTheFish-dev
Copy link

@NishTheFish-dev NishTheFish-dev commented Jan 30, 2026

Closes #176

Adds a new hook for IDA that detects when the decompilation has changed. Also includes a test case to verify this works correctly (now implemented!)

@NishTheFish-dev NishTheFish-dev self-assigned this Jan 30, 2026
@NishTheFish-dev
Copy link
Author

@NishTheFish-dev NishTheFish-dev marked this pull request as ready for review February 4, 2026 01:14
deci.artifact_change_callbacks[Decompilation].append(on_decompilation_change)

# mock objects to simulate IDA's HexRays structures
class MockCfunc:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hehe I can tell this part was Claude written.

return

dec = Decompilation(
# only IDA support for now
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A pointless comment. This code is already in IDA.


deci.shutdown()

def test_ida_hook_decompilation_event(self):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

High-level comments:
This is a bad way to test if a feature works. I understand the logic (or the AI's logic?) here, but it's too contrived. Why directly grab the HexraysHook, cause a fake trigger, and then observe if the new hook works?

Why not just get an IDA deci, do some action that forces a refresh (like renaming a variable or calling the refresh API), then seeing if your new hook gets hit. An example of a place I tested a callback implicitly:

retrieved_segment = ida_deci.segments[test_segment_name]

func_addr = ida_deci.art_lifter.lift_addr(0x40071d)
dec = ida_deci.decompile(func_addr)
assert dec is not None, "Failed to decompile main"
ida_deci.decompilation_changed(dec)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arn't you calling the event directly here? You should trigger it indirectly to prove that the callback works.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

function rename trigger

@NishTheFish-dev NishTheFish-dev force-pushed the feat/new_dcmpchanged_callback branch from 5e2b99d to c231021 Compare February 16, 2026 01:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Create a callback for decompilation_changed in decompilers

2 participants