support for syncing names ida -> qira

This commit is contained in:
Ned Williamson 2015-08-24 00:33:28 -04:00
parent bbc1f64abc
commit 56c4efcb27
2 changed files with 36 additions and 2 deletions

View File

@ -3,6 +3,7 @@
#include <loader.hpp>
#include <bytes.hpp>
#include <dbg.hpp>
#include <name.hpp>
//#define DEBUG
@ -92,6 +93,31 @@ static void ws_send(char *str) {
// ***************** IDAPLUGIN *******************
/*
send the (address, name) pairs back to qira
IDA prefers to keep names for basic blocks "local" to the function
so you can reuse the same name (e.g. "loop") in different functions
therefore basic block names won't sync to qira from IDA
I was going to include a json library and do some fancy stuff,
then I realized why not continue the tradition of simple
format strings?
*/
static void send_names() {
char tmp[100];
for (size_t i = 0; i < get_nlist_size(); i++) {
ea_t address = get_nlist_ea(i);
const char *name = get_nlist_name(i);
#ifdef __EA64__
qsnprintf(tmp, 100-1, "setname 0x%llx %s", get_nlist_ea(i), get_nlist_name(i));
#else
qsnprintf(tmp, 100-1, "setname 0x%x %s", get_nlist_ea(i), get_nlist_name(i));
#endif
ws_send(tmp);
}
}
static void update_address(const char *type, ea_t addr) {
char tmp[100];
#ifdef __EA64__
@ -119,6 +145,8 @@ static int idaapi hook(void *user_data, int event_id, va_list va) {
}
}
old_addr = addr;
} else if (event_id == view_activated) {
send_names();
}
return 0;
}

View File

@ -12,17 +12,23 @@ function do_ida_socket(callme) {
callme();
};
ws.onmessage = function(msg) {
//p(msg.data);
var dat = msg.data.split(" ");
if (dat[0] == "setiaddr") {
Session.set("iaddr", dat[1]);
Session.set("dirtyiaddr", true);
}
if (dat[0] == "setdaddr") {
else if (dat[0] == "setdaddr") {
if (get_data_type(dat[1]) != "datainstruction") {
update_dview(dat[1]);
}
}
else if (dat[0] == "setname") {
var send = {}
var address = dat[1];
var name = dat[2];
send[address] = {"name": name};
stream.emit("settags", send);
}
};
} else {
callme();