Loading...
Loading...
Edit IDA databases. Use when asked to add comments, rename symbols, apply types, create bookmarks, or clean up decompiled code for review.
npx skill4agent add allthingsida/idasql-skills annotationsconnectdecompilertypesre-source-- 1) Confirm target row/function before editing
SELECT * FROM funcs WHERE address = 0x401000;
-- 2) Inspect current comment state
SELECT ea, line, comment
FROM pseudocode
WHERE func_addr = 0x401000
LIMIT 30;
-- 3) Inspect existing disassembly comments
SELECT * FROM comments WHERE address BETWEEN 0x401000 AND 0x401100;func_addr + eaidxslotannotationsdecompilerannotationstypesannotationsre-sourceannotate this functionfuncs.rpt_commentdecompile(addr, 1)add a commentfunc-summaryfunction summaryannotate this functionfuncspseudocodecommentsfuncs.commentfuncs.rpt_commentadd function commentUPDATE funcs SET rpt_comment = ...funcs.commentpseudocodeSELECT address, name, comment, rpt_comment
FROM funcs
WHERE address = 0x401000;
UPDATE funcs
SET rpt_comment = 'One-paragraph summary of what the function does, inputs/outputs, and key behavior.'
WHERE address = 0x401000;pseudocodedecompile(addr)decompilerpseudocode.commentpseudocodeset_func_cmt()funcs.commentfuncs.rpt_commentcommentcomment_placementsemi;block1block2curly1curly2coloncaseelsedoea{}line_numea + comment_placementeaeaSELECT line_num, ea, line, comment
FROM pseudocode
WHERE func_addr = 0x401000
ORDER BY line_num;-- The example UPDATEs below assume 0x401020 is an already resolved writable
-- non-brace anchor from the inspection query above; do not substitute func_addr.
-- Edit: Add inline comment to decompiled code
UPDATE pseudocode SET comment_placement = 'semi',
comment = 'buffer overflow here'
WHERE func_addr = 0x401000 AND ea = 0x401020;
-- Edit: Add block comment (own line above statement)
UPDATE pseudocode SET comment_placement = 'block1', comment = 'vulnerable call'
WHERE func_addr = 0x401000 AND ea = 0x401020;
-- Edit: Delete comments at a resolved unique anchor
-- Warning: comment = NULL currently clears all placements at that ea.
UPDATE pseudocode SET comment = NULL
WHERE func_addr = 0x401000 AND ea = 0x401020;
-- Read edited pseudocode with comments
SELECT ea, line, comment FROM pseudocode WHERE func_addr = 0x401000;pseudocodeSELECT func_addr, func_name, orphan_count
FROM pseudocode_v_orphan_comment_groups
ORDER BY orphan_count DESC
LIMIT 20;
SELECT ea, comment_placement, orphan_comment
FROM pseudocode_orphan_comments
WHERE func_addr = 0x401000
ORDER BY ea, comment_placement;UPDATE pseudocode_orphan_comments
SET orphan_comment = NULL
WHERE func_addr = 0x401000
AND ea = 0x401020
AND comment_placement = 'semi';pseudocode_orphan_commentsWHERE func_addr = ...function summaryfunc-summaryfunction summaryfunc-summaryfuncs.rpt_commentadd function commentpseudocode.commentfuncs.rpt_commentfuncs.commentSELECT address, name, comment, rpt_comment
FROM funcs
WHERE address = 0x401000;
UPDATE funcs
SET rpt_comment = 'One-paragraph summary of what the function does, inputs/outputs, and key behavior.'
WHERE address = 0x401000;function summary 0x401000func-summary DriverEntryfunc-summary this functioncommentsSELECT COALESCE(NULLIF(comment, ''), NULLIF(rpt_comment, '')) AS comment
FROM comments
WHERE address = 0x401000
LIMIT 1;comments| Table | INSERT | UPDATE columns | DELETE |
|---|---|---|---|
| Yes | | Yes |
INSERT INTO comments(address, comment) VALUES (0x401000, 'regular comment');
INSERT INTO comments(address, rpt_comment) VALUES (0x401000, 'repeatable comment');
UPDATE comments SET comment = 'updated comment' WHERE address = 0x401000;
DELETE FROM comments WHERE address = 0x401000;commentsset_cmt()funcs.commentfuncs.rpt_commentset_func_cmt()bookmarks| Column | Type | Description |
|---|---|---|
| INT | Bookmark slot index |
| INT | Bookmarked address |
| TEXT | Bookmark description |
-- List all bookmarks
SELECT printf('0x%X', address) as addr, description FROM bookmarks;
-- Edit: Add bookmark
INSERT INTO bookmarks (address, description) VALUES (0x401000, 'interesting branch');
-- Edit: Update bookmark description
UPDATE bookmarks SET description = 'confirmed branch' WHERE slot = 0;
-- Edit: Delete bookmark
DELETE FROM bookmarks WHERE slot = 0;../connect/references/schema-catalog.mdbookmarksctree_lvarsnametypecommentdecompileridxfunc_addr + idxUPDATE ctree_lvars SET name = ...type = ...comment = ...func_addr + nameidxidx-- Inspect current locals before renaming
SELECT idx, name, type, comment
FROM ctree_lvars
WHERE func_addr = 0x401000
ORDER BY idx;
-- Edit: Rename a local variable by index (canonical, deterministic)
UPDATE ctree_lvars SET name = 'buffer_size' WHERE func_addr = 0x401000 AND idx = 2;
-- Edit: Rename by current name after selecting one deterministic idx
UPDATE ctree_lvars SET name = 'buffer_size'
WHERE func_addr = 0x401000
AND idx = (
SELECT idx FROM ctree_lvars
WHERE func_addr = 0x401000 AND name = 'v2'
ORDER BY idx LIMIT 1
);
-- Edit: Set local-variable comment by index
UPDATE ctree_lvars SET comment = 'points to decrypted buffer' WHERE func_addr = 0x401000 AND idx = 2;
-- Edit: Change variable type
UPDATE ctree_lvars SET type = 'char *'
WHERE func_addr = 0x401000 AND idx = 2;label_num-- Inspect labels before renaming
SELECT label_num, name, printf('0x%X', item_ea) AS item_ea
FROM ctree_labels
WHERE func_addr = 0x401000
ORDER BY label_num;
-- Rename deterministically by label number
UPDATE ctree_labels SET name = 'fail' WHERE func_addr = 0x401000 AND label_num = 12;
-- Equivalent UPDATE path
UPDATE ctree_labels
SET name = 'fail'
WHERE func_addr = 0x401000 AND label_num = 12;parse_decls()set_type()namesfuncstypes-- Apply type to a function
UPDATE funcs SET prototype = 'void __fastcall exec_command(command_t *cmd);'
WHERE address = 0x140001BD0;
-- Apply via set_type function
SELECT set_type(0x140001BD0, 'void __fastcall exec_command(command_t *cmd);');instructionsoperand*_format_spec-- Edit: Apply enum representation to operand 1
UPDATE instructions
SET operand1_format_spec = 'enum:MY_ENUM'
WHERE address = 0x401020;
-- Edit: Apply struct-offset representation
UPDATE instructions
SET operand0_format_spec = 'stroff:MY_STRUCT,delta=0'
WHERE address = 0x401030;
-- Edit: Clear representation back to plain
UPDATE instructions
SET operand1_format_spec = 'clear'
WHERE address = 0x401020;set_union_selection*get_union_selection*decompiler-- 1. Define the enum type (skip if it already exists)
SELECT parse_decls('typedef enum { DLL_PROCESS_DETACH=0, DLL_PROCESS_ATTACH=1 } fdw_reason_t;');
-- 2. Retype the parameter/variable
UPDATE ctree_lvars SET type = 'fdw_reason_t'
WHERE func_addr = 0x180001050 AND idx = 1;
-- 3. Verify
SELECT decompile(0x180001050, 1);set_numform*get_numform*decompilerFollow the read -> edit -> refresh -> verify cycle defined inGlobal Agent Contracts.connect
decompile(addr, 1)-- Good: structural typing first, then refresh, then naming cleanup
UPDATE ctree_lvars SET type = 'MY_CTX *' WHERE func_addr = 0x401000 AND idx = 0;
SELECT decompile(0x401000, 1);
UPDATE ctree_lvars SET name = 'ctx' WHERE func_addr = 0x401000 AND idx = 0;
UPDATE ctree_lvars SET name = 'size' WHERE func_addr = 0x401000 AND idx = 1;
SELECT decompile(0x401000, 1); -- final refresh after cleanuppseudocodedecompile(addr, 1)ctree_lvarsidxsave_database()