implement qira -> ida syncing of names and comments, as the user makes them

also, fix small bugs in renaming
This commit is contained in:
Ned Williamson 2015-09-10 22:20:47 -04:00
parent cd421fb9a8
commit 1ac1915137
4 changed files with 63 additions and 6 deletions

View File

@ -2,7 +2,6 @@
#include <idp.hpp>
#include <loader.hpp>
#include <bytes.hpp>
#include <dbg.hpp>
#include <name.hpp>
//#define DEBUG
@ -69,6 +68,38 @@ static int callback_qira(struct libwebsocket_context* context,
ea_t addr = strtoul((char*)in+sizeof("setaddress ")-1, NULL, 0);
#endif
thread_safe_jump_to(addr);
} else if (memcmp(in, "setname ", sizeof("setname ")-1) == 0) {
char *dat = (char*)in + sizeof("setname ") - 1;
//parsing code borrowed from 1995
char *space = strchr(dat, ' ');
*space = '\0';
char *name = space + 1;
char *addr_s = dat;
#ifdef __EA64__
ea_t addr = strtoull(addr_s, NULL, 0);
#else
ea_t addr = strtoul(addr_s, NULL, 0);
#endif
set_name(addr, name, 0);
} else if (memcmp(in, "setcmt ", sizeof("setcmt ")-1) == 0) {
char *dat = (char*)in + sizeof("setcmt ") - 1;
//copy paste "inlining". microsoft levels of 1995
char *space = strchr(dat, ' ');
*space = '\0';
char *cmt = space + 1;
char *addr_s = dat;
#ifdef __EA64__
ea_t addr = strtoull(addr_s, NULL, 0);
#else
ea_t addr = strtoul(addr_s, NULL, 0);
#endif
bool repeatable = false;
set_cmt(addr, cmt, repeatable);
}
break;
default:

View File

@ -210,6 +210,9 @@ window.onkeydown = function(e) {
if (tagname == 'name') {
var dat = prompt("Rename address "+addr, old);
//having no comment makes sense. having no name does not.
//or we should default to the autogen name like IDA
if (dat == "") return;
} else {
var dat = prompt("Enter comment for "+addr, old);
}
@ -224,8 +227,14 @@ window.onkeydown = function(e) {
replace_names();
} else if (tagname == 'comment') {
// do this explictly?
$(".comment_"+addr).html("; "+dat);
if (dat != "")
$(".comment_"+addr).html("; "+dat);
else
$(".comment_"+addr).html("");
}
Session.set("ida_sync_addr", addr);
Session.set("ida_sync_tagname", tagname);
Session.set("ida_sync_dat", dat);
} else if (e.keyCode == 71) {
var dat = prompt("Enter change or address");
if (dat == undefined) return;

View File

@ -42,16 +42,33 @@ function do_ida_socket(callme) {
}
}
Deps.autorun(function() { DA("send setaddress to ida");
var iaddr = Session.get('iaddr');
function send_cmd(cmd) {
do_ida_socket(function() {
cmd = 'setaddress '+iaddr;
try {
ws.send(cmd);
} catch(err) {
// nothing
}
});
}
Deps.autorun(function() { DA("send setaddress to ida");
var iaddr = Session.get('iaddr');
send_cmd('setaddress '+iaddr);
});
Deps.autorun(function() { DA("send user names and comments to ida");
var addr = Session.get("ida_sync_addr");
var tagname = Session.get("ida_sync_tagname");
var dat = Session.get("ida_sync_dat");
if (addr == undefined || tagname == undefined || dat == undefined) return;
if (tagname == "name")
send_cmd('setname ' + addr + " " + dat);
else if (tagname == "comment")
send_cmd('setcmt ' + addr + " " + dat);
else {
p("Unknown tag type from user: " + tagname)
}
});

View File

@ -37,7 +37,7 @@ function on_instructions(msg) { DS("instructions");
'<div class="change '+(ins.slice ? "halfhighlight": "")+' clnum clnum_'+ins.clnum+'">'+ins.clnum+'</div> '+
'<span class="insaddr datainstruction addr addr_'+ins.address+'">'+ins.address+'</span> '+
'<div class="instructiondesc">'+highlight_instruction(ins.instruction)+'</div> '+
'<span class="comment comment_'+ins.address+'">'+(ins.comment !== undefined ? "; "+ins.comment : "")+'</span>'+
'<span class="comment comment_'+ins.address+'">'+(ins.comment !== undefined && ins.comment !== "" ? "; "+ins.comment : "")+'</span>'+
'</div>';
}
}