Add function analysis and comment controls

This commit is contained in:
pancake committed 2026-11-04 21:37:00 +01:00
1 parent cca9a17488
commit 0db7b3c82d
2 files changed
+27 -2

No files matched your search

+1 -1
View File
@@ -8,7 +8,7 @@
<script src="app.js" defer></script>
</head>
<body>
<div id="bar"><span id="tags"></span><span id="lay" role="button" tabindex="0" title="Cycle layout"></span><span id="seek"></span><span id="title"></span><button id="openfilebutton" type="button" title="Replace the current session with another file (Shift+O)">Open file</button><button id="projectsbutton" type="button">Projects</button><button id="notesbutton" type="button">Notes</button><button id="packagesbutton" type="button">r2pm</button><button id="newpane" type="button" title="Open a frame with any r2 command (o or Alt+P)">+ New frame</button><button id="hint" type="button" title="Help (? or F1)" aria-label="Help" aria-controls="help">?</button></div>
<div id="bar"><span id="tags"></span><span id="lay" role="button" tabindex="0" title="Cycle layout"></span><span id="seek"></span><span id="title"></span><button id="openfilebutton" type="button" title="Replace the current session with another file (Shift+O)">Open file</button><button id="analyzefunction" type="button" title="Analyze function at the focused address">Analyze function</button><button id="unanalyzefunction" type="button" title="Remove function analysis at the focused address">Unanalyze function</button><button id="commentbutton" type="button" title="Edit or delete comment at the focused address">Comment</button><button id="projectsbutton" type="button">Projects</button><button id="notesbutton" type="button">Notes</button><button id="packagesbutton" type="button">r2pm</button><button id="newpane" type="button" title="Open a frame with any r2 command (o or Alt+P)">+ New frame</button><button id="hint" type="button" title="Help (? or F1)" aria-label="Help" aria-controls="help">?</button></div>
<div id="wm"></div>
<div id="menu" hidden><input id="mi" spellcheck="false" autocomplete="off"><div id="menuhint" hidden></div><div id="ml"></div></div>
<div id="help" role="dialog" aria-label="Help and keyboard shortcuts" tabindex="-1" hidden><button id="helpclose" type="button">Close · Esc</button><pre id="helptext"></pre></div>
+26 -1
View File
@@ -811,6 +811,9 @@ function bindControls () {
$('hint').onclick = () => showHelp();
$('helpclose').onclick = () => showHelp(false);
$('newpane').onclick = openPane;
$('analyzefunction').onclick = () => functionAction('af');
$('unanalyzefunction').onclick = () => functionAction('af-');
$('commentbutton').onclick = editComment;
$('projectsbutton').onclick = uiTools.openProjects;
$('openfilebutton').onclick = uiTools.openFileDialog;
$('notesbutton').onclick = uiTools.openNotes;
@@ -882,6 +885,28 @@ const firstAddr = (h) => (h.match(/data-a="(0x[0-9a-f]+)"/) || [])[1];
const quote = (s) => '"' + s.replace(/"/g, '') + '"';
const jsonList = async (c, fn) => { try { return JSON.parse(await r2At(cur, c)).map(fn); } catch (e) { return []; } };
async function functionAction (command) {
const target = { addr: cur ? cur.addr : seek };
try {
const out = strip(await r2At(target, command)).trim();
if (out) toast(out);
await refreshAll();
} catch (e) { toast(e.message); }
}
async function editComment () {
const target = { addr: cur ? cur.addr : seek };
try {
const current = (await r2At(target, 'CC.')).replace(/\r?\n$/, '');
menu('Comment at ' + target.addr, [], async (value) => {
try {
await r2At(target, value ? 'CCu base64:' + encodeText(value) : 'CC-');
await refreshAll();
} catch (e) { toast(e.message); }
}, { raw: true, value: current, hint: 'Edit and press Enter to save. Clear the text and press Enter to delete.' });
} catch (e) { toast(e.message); }
}
async function evalMenu (query = '', values) {
try {
values = values || JSON.parse(await r2('ej'));
@@ -1129,7 +1154,7 @@ function paneKey (k) {
menu('xrefs to ' + (p ? p.addr : seek), jsonList('axtj', (x) => `${norm(String(x.from))} ${x.type} ${x.fcn_name || ''} ${x.opcode || ''}`),
(v) => seekPane(p, v.split(' ')[0]));
break;
case ';': menu('comment at ' + (p ? p.addr : seek), [], (v) => cmd(quote('CC ' + v)), { raw: true }); break;
case ';': editComment(); break;
case 'n': menu('rename function', [], (v) => cmd('afn ' + v.replace(/[^\w.]/g, '_')), { raw: true }); break;
case 'o': wmKey('KeyP'); break;
case 'q': closePane(); break;