mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-07 10:33:30 +00:00
Lot of enhacements in the webui, add Cz
Code cleanup and fixes for 'afr' WebUI (enyo) is much more usable now New command 'Cz' as an alias for 'Cs len'
This commit is contained in:
parent
bab19e4164
commit
36b3177d92
@ -497,7 +497,7 @@ static int cmd_anal(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
{
|
||||
if (1) { //input[2]==' ' && input[3]) {
|
||||
RAnalFunction *fcn;
|
||||
ut64 off = core->offset;
|
||||
char *p, *name = strdup (input+3);
|
||||
@ -505,16 +505,18 @@ static int cmd_anal(void *data, const char *input) {
|
||||
*p++ = 0;
|
||||
off = r_num_math (core->num, p);
|
||||
}
|
||||
fcn = r_anal_fcn_find (core->anal, off,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (fcn) {
|
||||
eprintf ("fr %s %s @ 0x%"PFMT64x,
|
||||
fcn->name, name, off);
|
||||
r_core_cmdf (core, "fr %s %s @ 0x%"PFMT64x,
|
||||
fcn->name, name, off);
|
||||
free (fcn->name);
|
||||
fcn->name = strdup (name);
|
||||
} else eprintf ("Cannot find function '%s' at 0x%08llx\n", name, off);
|
||||
if (*name) {
|
||||
fcn = r_anal_fcn_find (core->anal, off,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (fcn) {
|
||||
eprintf ("fr %s %s@ 0x%"PFMT64x"\n",
|
||||
fcn->name, name, off);
|
||||
r_core_cmdf (core, "fr %s %s@ 0x%"PFMT64x,
|
||||
fcn->name, name, off);
|
||||
free (fcn->name);
|
||||
fcn->name = strdup (name);
|
||||
} else eprintf ("Cannot find function '%s' at 0x%08llx\n", name, off);
|
||||
} else eprintf ("Usage: afr [newname] [off]\n");
|
||||
}
|
||||
break;
|
||||
case 'e':
|
||||
|
@ -180,7 +180,7 @@ static int cmd_flag(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
case 'r':
|
||||
{
|
||||
if (input[1]==' ' && input[2]) {
|
||||
char *old, *new;
|
||||
RFlagItem *item;
|
||||
old = str+1;
|
||||
|
@ -3,10 +3,15 @@
|
||||
// XXX this command is broken. output of _list is not compatible with input
|
||||
static int cmd_meta(void *data, const char *input) {
|
||||
RCore *core = (RCore*)data;
|
||||
int n = 0, type = input[0];
|
||||
ut64 addr = core->offset;
|
||||
char *t, *p, name[256];
|
||||
int i, ret, line = 0;
|
||||
ut64 addr_end = 0LL;
|
||||
ut64 addr = core->offset;
|
||||
RAnalFunction *f;
|
||||
RListIter *iter;
|
||||
char file[1024];
|
||||
|
||||
switch (*input) {
|
||||
case '*':
|
||||
r_meta_list (core->anal->meta, R_META_TYPE_ANY, 1);
|
||||
@ -77,6 +82,13 @@ static int cmd_meta(void *data, const char *input) {
|
||||
} else eprintf ("Cannot find meta information at 0x%08"PFMT64x"\n", core->offset);
|
||||
break;
|
||||
// XXX: use R_META_TYPE_XXX here
|
||||
case 'z': /* string */
|
||||
{
|
||||
r_core_read_at (core, addr, (ut8*)name, sizeof (name));
|
||||
name[sizeof(name)] = 0;
|
||||
n = strlen (name);
|
||||
eprintf ("%d\n", n);
|
||||
}
|
||||
case 'C': /* comment */
|
||||
case 's': /* string */
|
||||
case 'd': /* data */
|
||||
@ -87,7 +99,6 @@ static int cmd_meta(void *data, const char *input) {
|
||||
eprintf ("See C?\n");
|
||||
break;
|
||||
case '-':
|
||||
addr = core->offset;
|
||||
switch (input[2]) {
|
||||
case '*':
|
||||
core->num->value = r_meta_del (core->anal->meta, input[0], 0, UT64_MAX, NULL);
|
||||
@ -99,9 +110,6 @@ static int cmd_meta(void *data, const char *input) {
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case '\0':
|
||||
r_meta_list (core->anal->meta, input[0], 0);
|
||||
break;
|
||||
case '*':
|
||||
r_meta_list (core->anal->meta, input[0], 1);
|
||||
break;
|
||||
@ -118,10 +126,12 @@ static int cmd_meta(void *data, const char *input) {
|
||||
}
|
||||
break;
|
||||
default: {
|
||||
char *t, *p, name[256];
|
||||
int n = 0, type = input[0];
|
||||
if (type!='z' && !input[1]) {
|
||||
r_meta_list (core->anal->meta, input[0], 0);
|
||||
break;
|
||||
}
|
||||
t = strdup (input+2);
|
||||
if (atoi (t)>0) {
|
||||
if (!*t || atoi (t)>0) {
|
||||
RFlagItem *fi;
|
||||
p = strchr (t, ' ');
|
||||
if (p) {
|
||||
@ -129,6 +139,8 @@ static int cmd_meta(void *data, const char *input) {
|
||||
strncpy (name, p+1, sizeof (name)-1);
|
||||
} else
|
||||
switch (type) {
|
||||
case 'z':
|
||||
type='s';
|
||||
case 's':
|
||||
// TODO: filter \n and so on :)
|
||||
strncpy (name, t, sizeof (name)-1);
|
||||
@ -144,7 +156,7 @@ static int cmd_meta(void *data, const char *input) {
|
||||
// return 1;
|
||||
}
|
||||
}
|
||||
n = atoi (input+1);
|
||||
if (!n) n = atoi (input+1);
|
||||
} else {
|
||||
p = NULL;
|
||||
strncpy (name, t, sizeof (name)-1);
|
||||
@ -152,31 +164,30 @@ static int cmd_meta(void *data, const char *input) {
|
||||
if (!n) n++;
|
||||
addr_end = addr + n;
|
||||
if (!r_meta_add (core->anal->meta, type, addr, addr_end, name))
|
||||
free (t);
|
||||
free (t);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 'v':
|
||||
switch (input[1]) {
|
||||
case '?':
|
||||
r_cons_printf ("Usage: Cv[-*][ off reg name] \n");
|
||||
break;
|
||||
case '-':
|
||||
{
|
||||
RAnalFunction *f;
|
||||
RListIter *iter;
|
||||
ut64 offset;
|
||||
if (input[2]==' ') {
|
||||
offset = r_num_math (core->num, input+3);
|
||||
if ((f = r_anal_fcn_find (core->anal, offset, R_ANAL_FCN_TYPE_NULL)) != NULL)
|
||||
memset (f->varsubs, 0, sizeof(f->varsubs));
|
||||
memset (f->varsubs, 0, sizeof (f->varsubs));
|
||||
} else if (input[2]=='*') {
|
||||
r_list_foreach (core->anal->fcns, iter, f)
|
||||
memset (f->varsubs, 0, sizeof(f->varsubs));
|
||||
memset (f->varsubs, 0, sizeof (f->varsubs));
|
||||
}
|
||||
}
|
||||
break;
|
||||
case '*':
|
||||
{
|
||||
RAnalFunction *f;
|
||||
RListIter *iter;
|
||||
r_list_foreach (core->anal->fcns, iter, f) {
|
||||
for (i = 0; i < R_ANAL_VARSUBS; i++) {
|
||||
if (f->varsubs[i].pat[0] != '\0')
|
||||
@ -184,16 +195,14 @@ static int cmd_meta(void *data, const char *input) {
|
||||
else break;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
{
|
||||
RAnalFunction *f;
|
||||
char *ptr = strdup (input+2);
|
||||
const char *varsub = NULL;
|
||||
const char *pattern = NULL;
|
||||
ut64 offset = -1LL;
|
||||
int i, n = r_str_word_set0 (ptr);
|
||||
n = r_str_word_set0 (ptr);
|
||||
if (n > 2) {
|
||||
switch(n) {
|
||||
case 3: varsub = r_str_word_get0 (ptr, 2);
|
||||
@ -236,15 +245,11 @@ static int cmd_meta(void *data, const char *input) {
|
||||
" Cm[-] [sz] [fmt..] # magic parse (see pm?)\n");
|
||||
break;
|
||||
case 'F':
|
||||
{
|
||||
RAnalFunction *f = r_anal_fcn_find (core->anal, core->offset,
|
||||
f = r_anal_fcn_find (core->anal, core->offset,
|
||||
R_ANAL_FCN_TYPE_FCN|R_ANAL_FCN_TYPE_SYM);
|
||||
if (f) r_anal_str_to_fcn (core->anal, f, input+2);
|
||||
else eprintf ("Cannot find function here\n");
|
||||
}
|
||||
break;
|
||||
}
|
||||
return R_TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* radare - LGPL - Copyright 2009-2012 - pancake */
|
||||
/* radare - LGPL - Copyright 2009-2013 - pancake */
|
||||
|
||||
#include "r_core.h"
|
||||
|
||||
|
@ -1231,6 +1231,7 @@ R_API void r_core_visual_define (RCore *core) {
|
||||
} while (ntotal<core->blocksize);
|
||||
break;
|
||||
case 's':
|
||||
// TODO: r_core_cmd0 (core, "Cz");
|
||||
{
|
||||
char *name;
|
||||
int n = r_str_nlen ((const char*)p, plen)+1;
|
||||
|
@ -72,10 +72,12 @@ static int replace(int argc, const char *argv[], char *newstr) {
|
||||
}
|
||||
|
||||
static int parse(RParse *p, const char *data, char *str) {
|
||||
char w0[64], w1[64], w2[64], w3[64];
|
||||
char w0[256], w1[256], w2[256], w3[256];
|
||||
int i, len = strlen (data);
|
||||
char *buf, *ptr, *optr;
|
||||
|
||||
if (len>=sizeof (w0))
|
||||
return R_FALSE;
|
||||
// malloc can be slow here :?
|
||||
if ((buf = malloc (len+1)) == NULL)
|
||||
return R_FALSE;
|
||||
|
@ -68,3 +68,17 @@ a {
|
||||
background-color: black;
|
||||
width: 90%;
|
||||
}
|
||||
.topbox {
|
||||
position:absolute;
|
||||
left: 48px;
|
||||
padding:0px;
|
||||
margin:0px;
|
||||
top:0px;
|
||||
display:inline;
|
||||
}
|
||||
.top {
|
||||
position:float;
|
||||
padding:8px;
|
||||
margin:0px;
|
||||
display:inline;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -9,6 +9,7 @@ var Config = {
|
||||
"g": "r2ui.openpage(3)",
|
||||
"c": "r2ui.openpage(5)",
|
||||
"s": "r2ui.openpage(8)",
|
||||
";": "r2.cmd('CC '+prompt('comment'));r2ui.seek('$$',true);",
|
||||
//"C-3": "this.setIndex(2)",
|
||||
}
|
||||
}
|
||||
|
@ -2,12 +2,12 @@ enyo.kind ({
|
||||
name: "Disassembler",
|
||||
kind: "Scroller",
|
||||
tag: "div",
|
||||
style:"margin:0px;background-color:#a0a0a0",
|
||||
style:"margin:0px;background-color:#c0c0c0",
|
||||
data: null,
|
||||
components: [
|
||||
{tag: "div", allowHtml: true, classes: "colorbar", name: "colorbar" },
|
||||
{tag: "div", content: "^", classes: "moreless", ontap: "less"},
|
||||
{tag: "pre", allowHtml: true, name: "text", content: ".."},
|
||||
{tag: "pre", allowHtml: true, name: "text", content: "..", style:"margin-left:5px"},
|
||||
{tag: "div", content: "v", classes: "moreless", ontap: "more"},
|
||||
/*
|
||||
{kind: "List", count:3, name: "list", style:"height:400px", realtimeFit:false, onSetupItem: "setupItem", components: [
|
||||
@ -73,24 +73,26 @@ enyo.kind ({
|
||||
var y = JSON.parse (x);
|
||||
} catch (e) {
|
||||
alert (e);
|
||||
return;
|
||||
return;
|
||||
}
|
||||
console.log (y);
|
||||
|
||||
// TODO: use canvas api for faster rendering and smaller dom
|
||||
var c = "<table class='colorbar'><tr valign=top style='height:20px;border-spacing:0'>";
|
||||
var colors = {
|
||||
flags: "#c0c0c0",
|
||||
comments: "yellow",
|
||||
functions: "#5050f0",
|
||||
strings: "orange",
|
||||
};
|
||||
var colors = {
|
||||
flags: "#c0c0c0",
|
||||
comments: "yellow",
|
||||
functions: "#5050f0",
|
||||
strings: "orange",
|
||||
};
|
||||
|
||||
var off = "";
|
||||
var HEIGHT = 30;
|
||||
var off = "";
|
||||
var WIDTH = 10;
|
||||
var HEIGHT = 30;
|
||||
for (var i=0; i< y.blocks.length; i++) {
|
||||
var block = y.blocks[i];
|
||||
var r = "<div style='background-color:#404040;width:10px;'> </div>";
|
||||
var r = "<div style='overflow:hidden;background-color:#404040;width:"
|
||||
+ WIDTH+"px;'> </div>";
|
||||
if (block.offset) { // Object.keys(block).length>1) {
|
||||
var r = "<table height="+HEIGHT+" style='border-spacing:0px'>";
|
||||
var count = 0;
|
||||
@ -104,16 +106,18 @@ var off = "";
|
||||
for (var k in colors) {
|
||||
var color = colors[k];
|
||||
if (block[k])
|
||||
r += "<tr><td style='width:10px;width:100%;;background-color: "+
|
||||
colors[k]+"'><div style='width:10px;overflow:hidden;height:"+h+"px'> </div></td></tr>";
|
||||
r += "<tr><td style='width:"+WIDTH+"px;background-color:"
|
||||
+ colors[k]+"'><div style='width:"+WIDTH+"px;overflow:"
|
||||
+ "hidden;height:"+h+"px'> </div></td></tr>";
|
||||
}
|
||||
r += "</table>";
|
||||
off = "0x"+block.offset.toString (16);
|
||||
} else {
|
||||
off = "0x"+(y.from + (y.blocksize * i)).toString (16);
|
||||
}
|
||||
c += "<td onclick='r2ui.seek("+off+",true)' title='"+off+"' style='height:"+HEIGHT+"px' "+
|
||||
"width=100%>"+r+"</td>";
|
||||
c += "<td onclick='r2ui.seek("+off+",true)' title='"+off
|
||||
+ "' style='height:"+HEIGHT+"px' "
|
||||
+ "width=15px>"+r+"</td>";
|
||||
}
|
||||
c += "</tr></table>";
|
||||
self.$.colorbar.setContent (c);
|
||||
|
@ -1,15 +1,127 @@
|
||||
enyo.kind ({
|
||||
name: "Hexdump",
|
||||
kind: "Scroller",
|
||||
style: "background-color:#c0c0c0;padding:8px",
|
||||
tag: "div",
|
||||
style:"margin:0px;background-color:#c0c0c0",
|
||||
data: null,
|
||||
components: [
|
||||
{tag: "pre", allowHtml: true, name: "output"}
|
||||
{tag: "div", allowHtml: true, classes: "colorbar", name: "colorbar" },
|
||||
{tag: "div", content: "^", classes: "moreless", ontap: "less"},
|
||||
{tag: "pre", allowHtml: true, name: "text", content: "..", style:"margin-left:5px"},
|
||||
{tag: "div", content: "v", classes: "moreless", ontap: "more"},
|
||||
/*
|
||||
{kind: "List", count:3, name: "list", style:"height:400px", realtimeFit:false, onSetupItem: "setupItem", components: [
|
||||
{kind: "onyx.Item", layoutKind: "HFlexLayout", style:"padding:0px", components: [
|
||||
{kind: "onyx.Button", name: "msg", fit:true, active: true, ontap: "rowTap"}
|
||||
]}
|
||||
]}
|
||||
*/
|
||||
],
|
||||
min: 0,
|
||||
max: 0,
|
||||
block: 1024,
|
||||
base: "entry0",
|
||||
less: function() {
|
||||
var self = this;
|
||||
var text = this.$.text;
|
||||
this.min += this.block;
|
||||
r2.get_hexdump (this.base+"-"+this.min, this.block, function (x) {
|
||||
x = r2.filter_asm (x, "px");
|
||||
var oldy = r2ui._hex.getScrollBounds().height;
|
||||
text.setContent (x+text.getContent());
|
||||
var newy = r2ui._hex.getScrollBounds().height;
|
||||
r2ui._hex.scrollTo (0, newy-oldy);
|
||||
});
|
||||
},
|
||||
more: function() {
|
||||
var text = this.$.text;
|
||||
this.max += this.block;
|
||||
r2.get_hexdump (this.base+"+"+this.max, this.block, function (x) {
|
||||
x = r2.filter_asm (x, "px");
|
||||
text.setContent (text.getContent() + x);
|
||||
});
|
||||
},
|
||||
seek: function(addr) {
|
||||
var text = this.$.text;
|
||||
this.base = addr;
|
||||
this.min = this.max = 0;
|
||||
r2.get_hexdump (addr, this.block, function (x) {
|
||||
x = r2.filter_asm (x, "px");
|
||||
text.setContent (x);
|
||||
});
|
||||
this.colorbar_create ();
|
||||
},
|
||||
create: function() {
|
||||
this.inherited (arguments);
|
||||
var output = this.$.output;
|
||||
r2.cmd ("px 8192", function(a) {
|
||||
output.setContent (r2.filter_asm (a, "px"));
|
||||
// this.$.list.setCount (this.data.length) ;
|
||||
var text = this.$.text;
|
||||
this.seek ("entry0");
|
||||
r2ui._hex = this;
|
||||
r2ui.history_push ("entry0");
|
||||
|
||||
this.colorbar_create ();
|
||||
//this.refresh ();
|
||||
},
|
||||
setupItem: function (inSender, inIndex) {
|
||||
this.$.msg.setContent (this.data[inIndex.index]);
|
||||
return true;
|
||||
},
|
||||
/* TODO: spaggety. see disassemble.js . must be a separate kind */
|
||||
colorbar_create: function () {
|
||||
var self = this;
|
||||
r2.cmd ("pvj", function(x) {
|
||||
try {
|
||||
var y = JSON.parse (x);
|
||||
} catch (e) {
|
||||
alert (e);
|
||||
return;
|
||||
}
|
||||
console.log (y);
|
||||
|
||||
// TODO: use canvas api for faster rendering and smaller dom
|
||||
var c = "<table class='colorbar'><tr valign=top style='height:20px;border-spacing:0'>";
|
||||
var colors = {
|
||||
flags: "#c0c0c0",
|
||||
comments: "yellow",
|
||||
functions: "#5050f0",
|
||||
strings: "orange",
|
||||
};
|
||||
|
||||
var off = "";
|
||||
var WIDTH = 10;
|
||||
var HEIGHT = 30;
|
||||
for (var i=0; i< y.blocks.length; i++) {
|
||||
var block = y.blocks[i];
|
||||
var r = "<div style='overflow:hidden;background-color:#404040;width:"
|
||||
+ WIDTH+"px;'> </div>";
|
||||
if (block.offset) { // Object.keys(block).length>1) {
|
||||
var r = "<table height="+HEIGHT+" style='border-spacing:0px'>";
|
||||
var count = 0;
|
||||
for (var k in colors) {
|
||||
if (block[k])
|
||||
count++;
|
||||
}
|
||||
count++; // avoid 0div wtf
|
||||
if (count==1) break;
|
||||
var h = HEIGHT / count;
|
||||
for (var k in colors) {
|
||||
var color = colors[k];
|
||||
if (block[k])
|
||||
r += "<tr><td style='width:"+WIDTH+"px;background-color:"
|
||||
+ colors[k]+"'><div style='width:"+WIDTH+"px;overflow:"
|
||||
+ "hidden;height:"+h+"px'> </div></td></tr>";
|
||||
}
|
||||
r += "</table>";
|
||||
off = "0x"+block.offset.toString (16);
|
||||
} else {
|
||||
off = "0x"+(y.from + (y.blocksize * i)).toString (16);
|
||||
}
|
||||
c += "<td onclick='r2ui.seek("+off+",true)' title='"+off
|
||||
+ "' style='height:"+HEIGHT+"px' "
|
||||
+ "width=15px>"+r+"</td>";
|
||||
}
|
||||
c += "</tr></table>";
|
||||
self.$.colorbar.setContent (c);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
@ -1,9 +1,9 @@
|
||||
|
||||
enyo.kind ({
|
||||
name: "MainPanel",
|
||||
classes: "onyx",
|
||||
kind: "FittableRows",
|
||||
classes: "enyo-fit",
|
||||
style: "margin:0px;padding:0px;border:0px",
|
||||
//style: "background-color: #c0c0c0",
|
||||
data: null,
|
||||
/*
|
||||
@ -12,6 +12,7 @@ enyo.kind ({
|
||||
this.$.list.refresh (); // necessary?? // inherit??
|
||||
},
|
||||
*/
|
||||
/* callbacks */
|
||||
buttonClicked: function (x) {
|
||||
alert ("let's play!");
|
||||
},
|
||||
@ -25,62 +26,160 @@ enyo.kind ({
|
||||
r2ui.opendis (off);
|
||||
}
|
||||
},
|
||||
goRename: function() {
|
||||
var msg = prompt ("New name?");
|
||||
r2.cmd("afr "+name, function() {
|
||||
/* menu actions */
|
||||
goRename: function() {
|
||||
var msg = prompt ('New name?', '');
|
||||
if(msg)
|
||||
r2.cmd("afr "+msg, function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
goComment: function() {
|
||||
var msg = prompt ('Comment?', '');
|
||||
if(msg)
|
||||
r2.cmd("CC "+msg, function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
goFlag: function() {
|
||||
var msg = prompt ('Flag name?', '');
|
||||
if(msg)
|
||||
r2.cmd("f "+msg, function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
goUnflag: function() {
|
||||
r2.cmd("f-$$", function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
goAnalyze: function() {
|
||||
r2.cmd("af", function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
goAnalyze: function() {
|
||||
r2.cmd("af", function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
});
|
||||
},
|
||||
goCopy: function() {
|
||||
var msg = prompt ('How many bytes?', '');
|
||||
if(msg)
|
||||
r2.cmd("y "+msg, function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
goPaste: function() {
|
||||
r2.cmd("yy", function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
/*-- write */
|
||||
wrString: function() {
|
||||
var msg = prompt ('Text', '');
|
||||
if(msg)
|
||||
r2.cmd("w "+msg, function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
wrOpcode: function() {
|
||||
var msg = prompt ('Opcode', '');
|
||||
if(msg)
|
||||
r2.cmd ("wa "+msg, function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
wrFile: function() {
|
||||
var msg = prompt ('Filename', '');
|
||||
if(msg)
|
||||
r2.cmd("wf "+msg, function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
wrHex: function() {
|
||||
var msg = prompt ('Hexpair', '');
|
||||
if(msg)
|
||||
r2.cmd("wx "+msg, function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
/* -- convert */
|
||||
coCode: function() {
|
||||
var msg = prompt ('How many bytes?', '');
|
||||
if(msg)
|
||||
r2.cmd("y "+msg, function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
coString: function() {
|
||||
r2.cmd("Cz", function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
coData: function() {
|
||||
var msg = prompt ('How many bytes?', '');
|
||||
if(msg)
|
||||
r2.cmd("Cd "+msg, function() {
|
||||
r2ui.seek ("$$", true);
|
||||
});
|
||||
},
|
||||
setTitle: function (title) {
|
||||
if (title) {
|
||||
this.$.title.setContent (title);
|
||||
this.$.title.setStyle ("visibility:visible;top:8px");
|
||||
this.$.extra.setStyle ("visibility:hidden;");//position:absolute;left:48px;scroll:overflow");
|
||||
} else {
|
||||
this.$.title.setStyle ("visibility:hidden");
|
||||
this.$.extra.setStyle ("visibility:visible;");//position:absolute;left:48px;scroll:overflow");
|
||||
}
|
||||
},
|
||||
/* widgets dom */
|
||||
components: [
|
||||
{kind: "onyx.Toolbar", components: [
|
||||
//{kind: "onyx.MoreToolbar", components: [
|
||||
{kind: "onyx.Button", content: "[", ontap: "openSidebar", style: "padding:4px"},
|
||||
{kind: "onyx.Button", content: "[", ontap: "openSidebar", classes: "top" },
|
||||
{name: "title", tag: "h2", content: "Assembler", classes: "topbox", style: "visibility:hidden" },
|
||||
{name: "extra", tag: "div", classes: "topbox", components: [
|
||||
//style: "position:absolute;top:0px;left:48px;scroll:overflow;visibility:visible", components: [
|
||||
/*
|
||||
{kind: "onyx.Button", content: "]", ontap: "openSidebar2", style: "padding:4px"},
|
||||
*/
|
||||
{kind: "onyx.Button", content: "<", ontap: "prevSeek", style: "padding:8px"},
|
||||
{kind: "onyx.Button", content: ">", ontap: "nextSeek", style:"padding:8px"},
|
||||
{kind: "onyx.InputDecorator", style: "width: 200px;", components: [
|
||||
{kind: "onyx.Input", name:"input", value: 'entry0', onchange: "gotoSeek", onkeydown:"inputKey"}
|
||||
]},
|
||||
{kind: "onyx.Button", content: "<", ontap: "prevSeek", classes: "top" },
|
||||
{kind: "onyx.Button", content: ">", ontap: "nextSeek", classes: "top" },
|
||||
{kind: "onyx.InputDecorator", style: "width: 200px;", components: [
|
||||
{kind: "onyx.Input", name:"input", value: 'entry0', onchange: "gotoSeek", onkeydown:"inputKey"}
|
||||
]},
|
||||
//{kind: "onyx.Button", content: "Go", ontap: "gotoSeek"},
|
||||
{kind: "onyx.PickerDecorator", components: [
|
||||
{kind: "onyx.Button", content: "Actions"},
|
||||
{kind: "onyx.Picker", components: [
|
||||
{content: "Analyze", ontap: "goAnalyze"},
|
||||
{content: "Rename", ontap: "goRename"},
|
||||
{content: "Comment"},
|
||||
{content: "Flag"},
|
||||
{content: "Copy"},
|
||||
{content: "Paste"}
|
||||
]}
|
||||
]},
|
||||
{kind: "onyx.PickerDecorator", components: [
|
||||
{kind: "onyx.PickerDecorator", classes: "top", components: [
|
||||
{kind: "onyx.Button", content: "Actions"},
|
||||
{kind: "onyx.Picker", components: [
|
||||
{content: "Analyze", ontap: "goAnalyze"},
|
||||
{content: "Rename", ontap: "goRename"},
|
||||
{content: "Comment", ontap: "goComment"},
|
||||
{content: "Flag", ontap: "goFlag"},
|
||||
{content: "Unflag", ontap: "goUnflag"},
|
||||
{content: "Copy", ontap: "goCopy"},
|
||||
{content: "Paste", ontap: "goPaste"}
|
||||
]}
|
||||
]},
|
||||
{kind: "onyx.PickerDecorator", style: "display:inline", components: [
|
||||
{kind: "onyx.Button", content: "Convert"},
|
||||
{kind: "onyx.Picker", components: [
|
||||
{content: "Data"},
|
||||
{content: "Code"},
|
||||
{content: "String"},
|
||||
{content: "Data", ontap: 'coData'},
|
||||
{content: "Code", ontap: 'coCode'},
|
||||
{content: "String", ontap: 'coString'},
|
||||
]}
|
||||
]},
|
||||
{kind: "onyx.PickerDecorator", components: [
|
||||
{kind: "onyx.PickerDecorator", style: "display:inline", components: [
|
||||
{kind: "onyx.Button", content: "Write"},
|
||||
{kind: "onyx.Picker", components: [
|
||||
{content: "File"},
|
||||
{content: "Hexpair"},
|
||||
{content: "String"},
|
||||
{content: "Opcode"},
|
||||
{content: "File", ontap: 'wrFile'},
|
||||
{content: "Hexpair", ontap: 'wrHex'},
|
||||
{content: "String", ontap: 'wrString'},
|
||||
{content: "Opcode", ontap: 'wrOpcode'},
|
||||
]}
|
||||
]},
|
||||
/*
|
||||
{kind: "onyx.Button", content: "Add", ontap: "addPanel"},
|
||||
{kind: "onyx.Button", content: "Delete", ontap: "deletePanel"}
|
||||
*/
|
||||
]},
|
||||
]},
|
||||
{kind: "Panels", name:"panels", fit:true, draggable: false,
|
||||
realtimeFit: true, components: [
|
||||
@ -114,23 +213,38 @@ goAnalyze: function() {
|
||||
this.inherited(arguments);
|
||||
},
|
||||
openPage: function(idx) {
|
||||
var str, sp = this.$.panels;
|
||||
eval ("var x = this.$.page"+idx);
|
||||
var str, sp = this.$.panels;
|
||||
// TODO: this is just a hack
|
||||
switch (idx) {
|
||||
case "Disassembler": idx = 0; break;
|
||||
case "Assembler": idx = 1; break;
|
||||
case "Hexdump": idx = 2; break;
|
||||
case "Graph": idx = 3; break;
|
||||
case "Search": idx = 4; break;
|
||||
case "Console": idx = 5; break;
|
||||
case "Logs": idx = 6; break;
|
||||
case "Script": idx = 7; break;
|
||||
case "Settings": idx = 8; break;
|
||||
case "About": idx = 9; break;
|
||||
var r = -1;
|
||||
switch (idx) {
|
||||
case "Disassembler": r = 0; break;
|
||||
case "Assembler": r = 1; break;
|
||||
case "Hexdump": r = 2; break;
|
||||
case "Graph": r = 3; break;
|
||||
case "Search": r = 4; break;
|
||||
case "Console": r = 5; break;
|
||||
case "Logs": r = 6; break;
|
||||
case "Script": r = 7; break;
|
||||
case "Settings": r = 8; break;
|
||||
case "About": r = 9; break;
|
||||
}
|
||||
if (r==-1) {
|
||||
// alert ("Unknown page");
|
||||
sp.setIndex (idx);
|
||||
return;
|
||||
}
|
||||
eval ("var x = this.$.page"+idx);
|
||||
switch (r) {
|
||||
case 0:
|
||||
case 2:
|
||||
this.setTitle ();
|
||||
break;
|
||||
default:
|
||||
this.setTitle (idx);
|
||||
break;
|
||||
}
|
||||
//x.setContent (str);
|
||||
sp.setIndex (idx);
|
||||
sp.setIndex (r);
|
||||
},
|
||||
seekStack: [],
|
||||
nextSeek: function() {
|
||||
@ -175,4 +289,3 @@ var i = 3;
|
||||
*/
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -49,6 +49,9 @@ r2.disassemble = function (offset, bytes, fn) {
|
||||
r2.cmd (str, fn);
|
||||
}
|
||||
|
||||
r2.get_hexdump = function (offset, length, cb) {
|
||||
r2.cmd ("px "+length+"@"+offset, cb);
|
||||
}
|
||||
r2.get_disasm = function (offset, length, cb) {
|
||||
// TODO: honor offset and length
|
||||
r2.cmd ("pD "+length+"@"+offset, cb);
|
||||
@ -112,15 +115,20 @@ r2.bin_sections = function (cb) {
|
||||
}
|
||||
|
||||
r2.cmds = function (cmds, cb) {
|
||||
(function lala(cmds, cb) {
|
||||
var cmd = cmds[0];
|
||||
if (cmds.length==0) return;
|
||||
var cmd = cmds[0];
|
||||
cmds = cmds.splice (1);
|
||||
function lala () {
|
||||
if (cmd == undefined || cmds.length == 0) {
|
||||
cb ();
|
||||
return;
|
||||
}
|
||||
cmd = cmds[0];
|
||||
cmds = cmds.splice (1);
|
||||
r2.cmd (cmd, lala)
|
||||
})(cmds, cb);
|
||||
r2.cmd (cmd, lala);
|
||||
if (cb) cb ();
|
||||
return;
|
||||
}
|
||||
r2.cmd (cmd, lala);
|
||||
}
|
||||
|
||||
r2.cmd = function (c, cb) {
|
||||
@ -202,7 +210,7 @@ r2.filter_asm = function (x, display) {
|
||||
var lines = x.split (/\n/g);
|
||||
r2.cmd ("s", function (x) { curoff = x; });
|
||||
for (var i=lines.length-1;i>0;i--) {
|
||||
var a = lines[i].match (/0x([a-fA-F0-9]*)/);
|
||||
var a = lines[i].match (/0x([a-fA-F0-9]+)/);
|
||||
if (a && a.length>0) {
|
||||
lastoff = a[0].replace (/:/g, "");
|
||||
break;
|
||||
@ -261,19 +269,19 @@ r2.filter_asm = function (x, display) {
|
||||
if (haveDisasm (display)) {
|
||||
x = x.replace (/function:/g,"<span style=color:green>function:</span>");
|
||||
x = x.replace (/;(\s+)/g, ";");
|
||||
x = x.replace (/;(.*)/g, "// <span style='color:white'>$1</span>");
|
||||
x = x.replace (/(bl|call)/g, "<b style='color:green'>call</b>");
|
||||
x = x.replace (/;(.*)/g, "// <span style='color:#209020'>$1</span>");
|
||||
x = x.replace (/(bl|goto|call)/g, "<b style='color:green'>call</b>");
|
||||
x = x.replace (/(jmp|bne|beq|js|jnz|jae|jge|jbe|jg|je|jl|jz|jb|ja|jne)/g, "<b style='color:green'>$1</b>");
|
||||
x = x.replace (/(dword|qword|word|byte|movzx|movsxd|cmovz|mov\ |lea\ )/g, "<b style='color:#1070d0'>$1</b>");
|
||||
x = x.replace (/(hlt|leave|iretd|retn|ret)/g, "<b style='color:red'>$1</b>");
|
||||
x = x.replace (/(add|sbb|sub|mul|div|shl|shr|and|not|xor|inc|dec|sar|sal)/g, "<b style='color:#d06010'>$1</b>");
|
||||
x = x.replace (/(push|pop)/g, "<b style='color:#40a010'>$1</b>");
|
||||
x = x.replace (/(test|cmp)/g, "<b style='color:#c04080'>$1</b>");
|
||||
x = x.replace (/(out|invalid|int|int3|trap|main|in)/g, "<b style='color:red'>$1</b>");
|
||||
x = x.replace (/(outsd|out|string|invalid|int |int3|trap|main|in)/g, "<b style='color:red'>$1</b>");
|
||||
x = x.replace (/nop/g, "<b style='color:blue'>nop</b>");
|
||||
x = x.replace (/(sym|fcn|imp|loc).([^<(\\\/ \|)\->]+)/g, "<a href='javascript:r2ui.seek(\"$1.$2\")'>$1.$2</a>");
|
||||
x = x.replace (/(sym|fcn|imp|loc).([^:<(\\\/ \|)\->]+)/g, "<a href='javascript:r2ui.seek(\"$1.$2\")'>$1.$2</a>");
|
||||
}
|
||||
x = x.replace (/0x([a-zA-Z0-9]*)/g, "<a href='javascript:r2ui.seek(\"0x$1\")'>0x$1</a>");
|
||||
x = x.replace (/0x([a-zA-Z0-9]+)/g, "<a href='javascript:r2ui.seek(\"0x$1\")'>0x$1</a>");
|
||||
// registers
|
||||
if (backward) {
|
||||
prev_curoff = curoff;
|
||||
|
@ -39,17 +39,23 @@ r2ui.seek = function (addr, x) {
|
||||
r2ui.history_push (addr);
|
||||
if (r2ui.ra.getIndex ()==2)
|
||||
r2ui.ra.setIndex (1);
|
||||
r2.cmd ("s "+addr);
|
||||
r2ui._dis.seek (addr);
|
||||
r2ui._dis.scrollTo (0, 0);
|
||||
r2.cmd ("s "+addr, function () {
|
||||
r2ui._dis.seek (addr);
|
||||
r2ui._dis.scrollTo (0, 0);
|
||||
r2ui._hex.seek (addr);
|
||||
r2ui._hex.scrollTo (0, 0);
|
||||
});
|
||||
}
|
||||
|
||||
r2ui.seek_prev = function () {
|
||||
// XXX. this is only for disasm
|
||||
var addr = r2ui.history.pop ();
|
||||
r2.cmd ("s "+addr);
|
||||
r2ui._dis.seek (addr);
|
||||
r2ui._dis.scrollTo (0, 0);
|
||||
r2.cmd ("s "+addr, function () {
|
||||
r2ui._dis.seek (addr);
|
||||
r2ui._dis.scrollTo (0, 0);
|
||||
r2ui._hex.seek (addr);
|
||||
r2ui._hex.scrollTo (0, 0);
|
||||
});
|
||||
}
|
||||
|
||||
/* used from mainpanel */
|
||||
|
@ -6,7 +6,18 @@ enyo.kind ({
|
||||
style:"padding-left:16px",
|
||||
components: [
|
||||
{kind: "FittableRows", fit: false, components: [
|
||||
{tag: "h2", content: "CPU" }
|
||||
{tag: "h2", content: "General" },
|
||||
{kind: "onyx.InputDecorator", components: [
|
||||
{tag: "p", content: "Two panels", classes:"rowline" },
|
||||
{kind: "onyx.ToggleButton", name: "twopanels"},
|
||||
]},
|
||||
{kind: "onyx.InputDecorator", components: [
|
||||
{tag: "p", content: "Edit keybindings", classes:"rowline" },
|
||||
{kind: "onyx.Button", content: '+'},
|
||||
]}
|
||||
]},
|
||||
{kind: "FittableRows", fit: false, components: [
|
||||
{tag: "h2", content: "Target" }
|
||||
,{kind: "onyx.InputDecorator", components: [
|
||||
{tag: "p", content: "Arch", classes:"rowline"},
|
||||
{kind: "onyx.PickerDecorator", components: [
|
||||
@ -55,10 +66,22 @@ enyo.kind ({
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
,{kind: "onyx.InputDecorator", components: [
|
||||
{tag: "p", content: "OS", classes:"rowline"},
|
||||
{kind: "onyx.PickerDecorator", components: [
|
||||
{},
|
||||
{kind: "onyx.Picker", components: [
|
||||
{content: "linux", active: true},
|
||||
{content: "darwin"},
|
||||
{content: "w32"},
|
||||
{content: "dos"},
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
,{tag: "h2", content: "Disassembly" },
|
||||
{kind: "onyx.InputDecorator", components: [
|
||||
{tag: "p", content: "Show bytes", classes:"rowline", ontap: "nextPanel"},
|
||||
{kind: "onyx.ToggleButton", name: "toggle_bytes "},
|
||||
{kind: "onyx.ToggleButton", name: "toggle_bytes"},
|
||||
]}
|
||||
,{kind: "onyx.InputDecorator",components: [
|
||||
{tag: "p", content: "Show offsets", classes:"rowline", ontap: "nextPanel"},
|
||||
@ -80,15 +103,45 @@ enyo.kind ({
|
||||
]}
|
||||
,{tag: "div", style: "height:64px"}
|
||||
],
|
||||
load: function() {
|
||||
var self = this;
|
||||
self.$.twopanels.setActive (document.referrer.indexOf ("/two") != -1);
|
||||
r2.cmd ("e asm.bytes", function (x) {
|
||||
self.$.toggle_bytes.setActive (x[0] == 't');
|
||||
});
|
||||
r2.cmd ("e asm.pseudo", function (x) {
|
||||
self.$.toggle_pseudo.setActive (x[0] == 't');
|
||||
});
|
||||
r2.cmd ("e asm.offset", function (x) {
|
||||
self.$.toggle_offset.setActive (x[0] == 't');
|
||||
});
|
||||
},
|
||||
create: function () {
|
||||
this.inherited (arguments);
|
||||
this.load ();
|
||||
},
|
||||
save: function() {
|
||||
var arch = this.$.arch.selected.content;
|
||||
var bits = this.$.bits.selected.content;
|
||||
r2.cmds (["e asm.arch="+arch, "e asm.bits="+bits]);
|
||||
alert ("save");
|
||||
var show_bytes = this.$.toggle_bytes.active;
|
||||
var show_pseudo = this.$.toggle_pseudo.active;
|
||||
var show_offset = this.$.toggle_offset.active;
|
||||
var twopanels = this.$.twopanels.active;
|
||||
r2.cmds ([
|
||||
"e asm.arch="+arch,
|
||||
"e asm.bits="+bits,
|
||||
"e asm.bytes="+show_bytes,
|
||||
"e asm.offset="+show_offset,
|
||||
"e asm.pseudo="+show_pseudo
|
||||
]);
|
||||
if (twopanels) {
|
||||
window.parent.location ="/enyo/two";
|
||||
} else {
|
||||
window.parent.location ="/enyo/";
|
||||
}
|
||||
r2ui.seek ("$$", true);
|
||||
},
|
||||
reset: function() {
|
||||
r2.cmd ("e asm.arch", function (x) {
|
||||
alert ("arch = "+x);
|
||||
});
|
||||
this.load ();
|
||||
}
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user