Add 'annotate-usecode' command to import USECODE IR JSON annotations

- Introduced a new command 'annotate-usecode' to import USECODE IR JSON annotation hints as Ghidra comments on compiled anchors.
- Added argument parsing for multiple IR JSON files, comment type selection, and a dry-run option.
- Implemented logic to read annotation records from the provided IR files and set comments on the corresponding addresses in Ghidra.
- Enhanced JSON schema to include response structure for the new command.
This commit is contained in:
MaddoScientisto 2026-03-24 18:14:20 +01:00
commit daa363c3d2
39 changed files with 41450 additions and 871 deletions

View file

@ -4,7 +4,7 @@
"3","code","0x40400","0x55A","None","","","","crusader_ne_segments.csv"
"4","code","0x40A00","0x10B1","Foothold","Reset/cache entry path","runtime_cache_reset_sequence","ASYLUM.24 and downstream reset callers still need tighter classification","crusader_decompilation_notes.md; plan-mid.md"
"5","code","0x41E00","0x8D7","Partial","Startup/display transition prepare/driver lane","startup_display_transition_prepare; startup_display_transition_driver","The two main seg005 bodies are now named and tied to caller-side validation through vtable +0x0c, the seg108 0x4f38 sprite/object helper lane, the shared active-dispatch hold byte at 0x6828, the seg049 watch/controller lane at 0x2bd8, and the seg126 follow-up path; the exact higher-level state label is still unresolved","crusader_decompilation_notes.md; plan-mid.md"
"6","code","0x42C00","0x75E","None","","","","crusader_ne_segments.csv"
"6","code","0x42C00","0x75E","Foothold","Gameplay-side masked materializer and local state/value selector lane","entity_vm_context_try_create_mask_0008_slot30_with_offset; entity_vm_context_try_create_mask_0010_slot08_with_offset_if_ready","Outer callers for the renamed seg006 helpers are still unresolved, and the higher-level gameplay subsystem owning the local state-selector and adjacent class-linked value family still needs caller-side recovery","plan-mid.md; docs/raw-0008-000c.md"
"7","code","0x43600","0x484","None","","","","crusader_ne_segments.csv"
"8","code","0x43C00","0x1386","None","","","","crusader_ne_segments.csv"
"9","code","0x45400","0x495","None","","","","crusader_ne_segments.csv"
@ -47,7 +47,7 @@
"46","code","0x7A200","0x7DC","None","","","","crusader_ne_segments.csv"
"47","code","0x7AC00","0x9B4","None","","","","crusader_ne_segments.csv"
"48","code","0x7B800","0x63","None","","","","crusader_ne_segments.csv"
"49","code","0x7BA00","0x1E3F","Foothold","Watch/camera controller object lane","watch_entity_controller_create_global; watch_entity_controller_create; watch_entity_controller_dispatch_if_present; entity_set_watch_ptr","Exact controller-vs-watched-entity ownership is still open, but startup_display_transition_driver now gives caller-side confirmation that the shared active-dispatch hold byte is raised before the 0x2bd8 vtable +0x2c dispatch and cleared again immediately after the same watch/controller phase","crusader_decompilation_notes.md; plan-mid.md"
"49","code","0x7BA00","0x1E3F","Partial","Watch/camera controller object lane","watch_entity_controller_create_global; watch_entity_controller_create; watch_entity_controller_dispatch_if_present; entity_set_watch_ptr","The 0x2bd8 lane is now a real shared watch/controller object with verified vtable +0x2c/+0x30 dispatch, and the startup/display handoff bodies consistently raise or clear the borrowed active-dispatch hold byte around that controller phase; the exact controller-vs-watched-entity ownership label is still open","crusader_decompilation_notes.md; plan-mid.md"
"50","code","0x7DE00","0x9C8","None","","","","crusader_ne_segments.csv"
"51","code","0x7EA00","0x1D02","None","","","","crusader_ne_segments.csv"
"52","code","0x80A00","0x1D65","None","","","","crusader_ne_segments.csv"
@ -68,7 +68,7 @@
"67","code","0x8FE00","0x839","None","","","","crusader_ne_segments.csv"
"68","code","0x90800","0xB4A","None","","","","crusader_ne_segments.csv"
"69","code","0x91800","0x2A0","None","","","","crusader_ne_segments.csv"
"70","code","0x91C00","0xF24","Foothold","File-handle allocation/open wrappers","file_handle_alloc_init_and_open; file_handle_open_with_mode","Exact DOS open/create flags and mode semantics still need caller-side argument decoding","crusader_decompilation_notes.md"
"70","code","0x91C00","0xF24","Partial","DOS file-handle lifecycle and owner-resource twin file-family loaders","file_handle_alloc_init_and_open; file_handle_open_with_mode","Exact DOS open/create flags and the per-family record schema behind the twin `0009:67b6` / `0009:6916` loader passes still need caller-side decoding","crusader_decompilation_notes.md; docs/raw-000a-000d.md; docs/raw-0008-000c.md"
"71","code","0x92E00","0x6C2","None","","","","crusader_ne_segments.csv"
"72","code","0x93600","0xCA1","None","","","","crusader_ne_segments.csv"
"73","code","0x94600","0x9AA","None","","","","crusader_ne_segments.csv"
@ -106,7 +106,7 @@
"105","code","0xAEC00","0x9F6","None","","","","crusader_ne_segments.csv"
"106","code","0xAF800","0x1795","None","","","","crusader_ne_segments.csv"
"107","code","0xB1400","0x40C","None","","","","crusader_ne_segments.csv"
"108","code","0xB1A00","0x113F","Foothold","Active sprite/object state lane","sprite_object_clear_flag40_if_present; sprite_object_set_flag40_if_present","startup_display_transition_prepare now confirms repeated seg108 helper use around the shared active-dispatch creation, and the same window shows a bounded local counter/stack at object +0x196/+0x186 rather than reuse of the caller object validated through vtable +0x0c; the local bit 0x40 contract at 0x4f38+0x32 is now separated from the shared active-dispatch owner byte at 0x6828+0x40, but the higher-level meaning of the sprite/object lane and its relation to 0x4588 is still unresolved","crusader_decompilation_notes.md; plan-mid.md"
"108","code","0xB1A00","0x113F","Partial","Active sprite/object state lane","sprite_object_clear_flag40_if_present; sprite_object_set_flag40_if_present; sprite_object_push_state_word; sprite_object_pop_state_word","The 0x4f38 lane is now a verified bounded sprite/object state-word stack at +0x186/+0x196 with a separate local bit-0x40 contract at +0x32. It is reused across startup/display and later UI flows, and it is now clearly separated from both the validated seg005 caller object and the shared active-dispatch hold byte at 0x6828+0x40; the higher-level sprite/object meaning and any link to 0x4588 remain unresolved","crusader_decompilation_notes.md; plan-mid.md"
"109","code","0xB2E00","0x1424","None","","","High-value gap around 000b:2e00 still unresolved","crusader_ne_segments.csv; crusader_decomp_progress.md"
"110","code","0xB4400","0x4C4","None","","","","crusader_ne_segments.csv"
"111","code","0xB4A00","0x489","None","","","","crusader_ne_segments.csv"
@ -131,9 +131,9 @@
"130","code","0xCEA00","0x47D","None","","","","crusader_ne_segments.csv"
"131","code","0xCF000","0x44D","None","","","","crusader_ne_segments.csv"
"132","code","0xCF600","0x3EB8","None","","","","crusader_ne_segments.csv"
"133","code","0xD3800","0x215A","None","","","","crusader_ne_segments.csv"
"134","code","0xD6000","0xEF0","Foothold","VM runtime bootstrap and post-init seeding","entity_vm_runtime_init_from_path_if_configured; entity_vm_referent_registry_init; entity_vm_runtime_release_slots; entity_vm_runtime_init_slots","Configured path/global at 0x65a and the exact external file format behind the 0x6611 runtime owner table still need tighter classification","plan-mid.md; docs/raw-0008-000c.md"
"135","code","0xD7000","0x3B7","Foothold","VM runtime owner-resource helper","entity_vm_runtime_owner_resource_create; entity_vm_runtime_owner_resource_destroy","Embedded file-backed helper class and 0x0d-stride slot-table population semantics still need callee-side recovery","plan-mid.md; docs/raw-0008-000c.md"
"133","code","0xD3800","0x215A","Partial","VM masked-context creation, context save/load, and slot-value reload lane","entity_vm_context_try_create_masked_for_entity; entity_vm_context_create_from_slot_index; entity_vm_context_save; entity_vm_context_load; entity_vm_slot_load_value_plus_offset","The outer selector into entity_vm_opcode_sequence_run and the direct caller roles for the `0x0400/0x000a` and `0x0800/0x000b` offset-specialized wrappers remain unresolved, but the generic masked-create hub and persisted slot-plus-offset lane are now stable","plan-mid.md; docs/raw-0008-000c.md; docs/raw-000a-000d.md"
"134","code","0xD6000","0xEF0","Partial","VM runtime bootstrap, context seeding, and opcode sequencer support","entity_vm_runtime_init_from_path_if_configured; entity_vm_referent_registry_init; entity_vm_runtime_release_slots; entity_vm_runtime_init_slots; entity_vm_opcode_sequence_run","The upstream selector path into entity_vm_opcode_sequence_run and the exact configured owner-file naming at 0x65a still need caller-side recovery, but the runtime bootstrap, persisted slot-plus-offset lane, and sequencer entry/exit contract are now stable enough for partial coverage","plan-mid.md; docs/raw-0008-000c.md; docs/raw-000a-000d.md"
"135","code","0xD7000","0x3B7","Partial","VM runtime owner-resource helper and paired external file-family loader","entity_vm_runtime_owner_resource_create; entity_vm_runtime_owner_resource_destroy","The helper now has two parallel file-family loops at 0009:67b6 and 0009:6916 feeding separate buffers, but the exact per-family record schema and higher-level resource names are still unresolved","plan-mid.md; docs/raw-0008-000c.md"
"136","code","0xD7600","0x5BD","Partial","Shared active dispatch-entry owner and hold-state controller","active_dispatch_entry_mark_enabled; active_dispatch_entry_mark_disabled; active_dispatch_entry_create_default","The shared active entry is now tied to the seg126 DS:0x6341 transition-animation path and to the shared 0x31a2 break/hold depth; current evidence also separates its borrowed +0x40 presentation hold token from the seg108-local 0x4f38 bit-0x40 lane, but the exact higher-level transition/callback subsystem name is still unresolved","crusader_decompilation_notes.md; plan-mid.md"
"137","code","0xD7E00","0xFBB","Partial","Palette and dispatch-entry emission helper family","entity_dispatch_entry_init_runtime_state; entity_dispatch_entry_release_runtime_state; vga_palette_set_all_black; vga_palette_set_all_white; vga_palette_set_all_rgb; dispatch_entry_create_black_palette_state_active; dispatch_entry_create_grayscale_palette_state_active; dispatch_entry_create_solid_palette_state_active","Higher-level event/script meaning is still unresolved, especially the paired 0x68bf object and the exact role of the 0004:5ad4-5b6e caller sequence","crusader_decompilation_notes.md; plan-mid.md"
"138","code","0xD9200","0x32E4","Partial","Entity cleanup/finalize with callback, watch-controller release, and dispatch-entry palette emission","entity_cleanup_resources_and_dispatch; sprite_redraw_global_if_active; FUN_000d_938c","Concrete callback-object subsystem naming is still unresolved, but this lane now has verified caller-side control of watch/controller state at 0x2bd8, uses the shared active-dispatch byte +0x40 as a borrowed presentation hold token rather than a local owner install, and emits two distinct 0x4588 payload pairs (entity +0x12d/+0x12f and +0x74f/+0x751) in addition to the palette-emission helpers","crusader_decompilation_notes.md; plan-mid.md"

1 Segment Type FileOffset Length CoverageStatus KnownSubsystem KeyNamedFunctions Blockers NotesSource
4 3 code 0x40400 0x55A None crusader_ne_segments.csv
5 4 code 0x40A00 0x10B1 Foothold Reset/cache entry path runtime_cache_reset_sequence ASYLUM.24 and downstream reset callers still need tighter classification crusader_decompilation_notes.md; plan-mid.md
6 5 code 0x41E00 0x8D7 Partial Startup/display transition prepare/driver lane startup_display_transition_prepare; startup_display_transition_driver The two main seg005 bodies are now named and tied to caller-side validation through vtable +0x0c, the seg108 0x4f38 sprite/object helper lane, the shared active-dispatch hold byte at 0x6828, the seg049 watch/controller lane at 0x2bd8, and the seg126 follow-up path; the exact higher-level state label is still unresolved crusader_decompilation_notes.md; plan-mid.md
7 6 code 0x42C00 0x75E None Foothold Gameplay-side masked materializer and local state/value selector lane entity_vm_context_try_create_mask_0008_slot30_with_offset; entity_vm_context_try_create_mask_0010_slot08_with_offset_if_ready Outer callers for the renamed seg006 helpers are still unresolved, and the higher-level gameplay subsystem owning the local state-selector and adjacent class-linked value family still needs caller-side recovery crusader_ne_segments.csv plan-mid.md; docs/raw-0008-000c.md
8 7 code 0x43600 0x484 None crusader_ne_segments.csv
9 8 code 0x43C00 0x1386 None crusader_ne_segments.csv
10 9 code 0x45400 0x495 None crusader_ne_segments.csv
47 46 code 0x7A200 0x7DC None crusader_ne_segments.csv
48 47 code 0x7AC00 0x9B4 None crusader_ne_segments.csv
49 48 code 0x7B800 0x63 None crusader_ne_segments.csv
50 49 code 0x7BA00 0x1E3F Foothold Partial Watch/camera controller object lane watch_entity_controller_create_global; watch_entity_controller_create; watch_entity_controller_dispatch_if_present; entity_set_watch_ptr Exact controller-vs-watched-entity ownership is still open, but startup_display_transition_driver now gives caller-side confirmation that the shared active-dispatch hold byte is raised before the 0x2bd8 vtable +0x2c dispatch and cleared again immediately after the same watch/controller phase The 0x2bd8 lane is now a real shared watch/controller object with verified vtable +0x2c/+0x30 dispatch, and the startup/display handoff bodies consistently raise or clear the borrowed active-dispatch hold byte around that controller phase; the exact controller-vs-watched-entity ownership label is still open crusader_decompilation_notes.md; plan-mid.md
51 50 code 0x7DE00 0x9C8 None crusader_ne_segments.csv
52 51 code 0x7EA00 0x1D02 None crusader_ne_segments.csv
53 52 code 0x80A00 0x1D65 None crusader_ne_segments.csv
68 67 code 0x8FE00 0x839 None crusader_ne_segments.csv
69 68 code 0x90800 0xB4A None crusader_ne_segments.csv
70 69 code 0x91800 0x2A0 None crusader_ne_segments.csv
71 70 code 0x91C00 0xF24 Foothold Partial File-handle allocation/open wrappers DOS file-handle lifecycle and owner-resource twin file-family loaders file_handle_alloc_init_and_open; file_handle_open_with_mode Exact DOS open/create flags and mode semantics still need caller-side argument decoding Exact DOS open/create flags and the per-family record schema behind the twin `0009:67b6` / `0009:6916` loader passes still need caller-side decoding crusader_decompilation_notes.md crusader_decompilation_notes.md; docs/raw-000a-000d.md; docs/raw-0008-000c.md
72 71 code 0x92E00 0x6C2 None crusader_ne_segments.csv
73 72 code 0x93600 0xCA1 None crusader_ne_segments.csv
74 73 code 0x94600 0x9AA None crusader_ne_segments.csv
106 105 code 0xAEC00 0x9F6 None crusader_ne_segments.csv
107 106 code 0xAF800 0x1795 None crusader_ne_segments.csv
108 107 code 0xB1400 0x40C None crusader_ne_segments.csv
109 108 code 0xB1A00 0x113F Foothold Partial Active sprite/object state lane sprite_object_clear_flag40_if_present; sprite_object_set_flag40_if_present sprite_object_clear_flag40_if_present; sprite_object_set_flag40_if_present; sprite_object_push_state_word; sprite_object_pop_state_word startup_display_transition_prepare now confirms repeated seg108 helper use around the shared active-dispatch creation, and the same window shows a bounded local counter/stack at object +0x196/+0x186 rather than reuse of the caller object validated through vtable +0x0c; the local bit 0x40 contract at 0x4f38+0x32 is now separated from the shared active-dispatch owner byte at 0x6828+0x40, but the higher-level meaning of the sprite/object lane and its relation to 0x4588 is still unresolved The 0x4f38 lane is now a verified bounded sprite/object state-word stack at +0x186/+0x196 with a separate local bit-0x40 contract at +0x32. It is reused across startup/display and later UI flows, and it is now clearly separated from both the validated seg005 caller object and the shared active-dispatch hold byte at 0x6828+0x40; the higher-level sprite/object meaning and any link to 0x4588 remain unresolved crusader_decompilation_notes.md; plan-mid.md
110 109 code 0xB2E00 0x1424 None High-value gap around 000b:2e00 still unresolved crusader_ne_segments.csv; crusader_decomp_progress.md
111 110 code 0xB4400 0x4C4 None crusader_ne_segments.csv
112 111 code 0xB4A00 0x489 None crusader_ne_segments.csv
131 130 code 0xCEA00 0x47D None crusader_ne_segments.csv
132 131 code 0xCF000 0x44D None crusader_ne_segments.csv
133 132 code 0xCF600 0x3EB8 None crusader_ne_segments.csv
134 133 code 0xD3800 0x215A None Partial VM masked-context creation, context save/load, and slot-value reload lane entity_vm_context_try_create_masked_for_entity; entity_vm_context_create_from_slot_index; entity_vm_context_save; entity_vm_context_load; entity_vm_slot_load_value_plus_offset The outer selector into entity_vm_opcode_sequence_run and the direct caller roles for the `0x0400/0x000a` and `0x0800/0x000b` offset-specialized wrappers remain unresolved, but the generic masked-create hub and persisted slot-plus-offset lane are now stable crusader_ne_segments.csv plan-mid.md; docs/raw-0008-000c.md; docs/raw-000a-000d.md
135 134 code 0xD6000 0xEF0 Foothold Partial VM runtime bootstrap and post-init seeding VM runtime bootstrap, context seeding, and opcode sequencer support entity_vm_runtime_init_from_path_if_configured; entity_vm_referent_registry_init; entity_vm_runtime_release_slots; entity_vm_runtime_init_slots entity_vm_runtime_init_from_path_if_configured; entity_vm_referent_registry_init; entity_vm_runtime_release_slots; entity_vm_runtime_init_slots; entity_vm_opcode_sequence_run Configured path/global at 0x65a and the exact external file format behind the 0x6611 runtime owner table still need tighter classification The upstream selector path into entity_vm_opcode_sequence_run and the exact configured owner-file naming at 0x65a still need caller-side recovery, but the runtime bootstrap, persisted slot-plus-offset lane, and sequencer entry/exit contract are now stable enough for partial coverage plan-mid.md; docs/raw-0008-000c.md plan-mid.md; docs/raw-0008-000c.md; docs/raw-000a-000d.md
136 135 code 0xD7000 0x3B7 Foothold Partial VM runtime owner-resource helper VM runtime owner-resource helper and paired external file-family loader entity_vm_runtime_owner_resource_create; entity_vm_runtime_owner_resource_destroy Embedded file-backed helper class and 0x0d-stride slot-table population semantics still need callee-side recovery The helper now has two parallel file-family loops at 0009:67b6 and 0009:6916 feeding separate buffers, but the exact per-family record schema and higher-level resource names are still unresolved plan-mid.md; docs/raw-0008-000c.md
137 136 code 0xD7600 0x5BD Partial Shared active dispatch-entry owner and hold-state controller active_dispatch_entry_mark_enabled; active_dispatch_entry_mark_disabled; active_dispatch_entry_create_default The shared active entry is now tied to the seg126 DS:0x6341 transition-animation path and to the shared 0x31a2 break/hold depth; current evidence also separates its borrowed +0x40 presentation hold token from the seg108-local 0x4f38 bit-0x40 lane, but the exact higher-level transition/callback subsystem name is still unresolved crusader_decompilation_notes.md; plan-mid.md
138 137 code 0xD7E00 0xFBB Partial Palette and dispatch-entry emission helper family entity_dispatch_entry_init_runtime_state; entity_dispatch_entry_release_runtime_state; vga_palette_set_all_black; vga_palette_set_all_white; vga_palette_set_all_rgb; dispatch_entry_create_black_palette_state_active; dispatch_entry_create_grayscale_palette_state_active; dispatch_entry_create_solid_palette_state_active Higher-level event/script meaning is still unresolved, especially the paired 0x68bf object and the exact role of the 0004:5ad4-5b6e caller sequence crusader_decompilation_notes.md; plan-mid.md
139 138 code 0xD9200 0x32E4 Partial Entity cleanup/finalize with callback, watch-controller release, and dispatch-entry palette emission entity_cleanup_resources_and_dispatch; sprite_redraw_global_if_active; FUN_000d_938c Concrete callback-object subsystem naming is still unresolved, but this lane now has verified caller-side control of watch/controller state at 0x2bd8, uses the shared active-dispatch byte +0x40 as a borrowed presentation hold token rather than a local owner install, and emits two distinct 0x4588 payload pairs (entity +0x12d/+0x12f and +0x74f/+0x751) in addition to the palette-emission helpers crusader_decompilation_notes.md; plan-mid.md