mirror of
https://github.com/radareorg/radare2.git
synced 2024-10-07 10:33:30 +00:00
Add 'fj' and 'fsj' commands to show json instead of blocks
This commit is contained in:
parent
a4c8b96e20
commit
18ff639bd6
@ -113,12 +113,14 @@ static int cmd_flag(void *data, const char *input) {
|
||||
break;
|
||||
case 's':
|
||||
switch (input[1]) {
|
||||
case 'j':
|
||||
case '\0':
|
||||
case '*':
|
||||
r_flag_space_list (core->flags, input[1]);
|
||||
break;
|
||||
case ' ':
|
||||
r_flag_space_set (core->flags, input+2);
|
||||
break;
|
||||
case '*':
|
||||
r_flag_space_set (core->flags, "*");
|
||||
break;
|
||||
case 'm':
|
||||
{ RFlagItem *f;
|
||||
ut64 off = core->offset;
|
||||
|
@ -1,6 +1,7 @@
|
||||
/* radare - LGPL - Copyright 2008-2012 - pancake */
|
||||
/* radare - LGPL - Copyright 2008-2013 - pancake */
|
||||
|
||||
#include <r_flags.h>
|
||||
#include <r_cons.h>
|
||||
|
||||
R_API int r_flag_space_get(RFlag *f, const char *name) {
|
||||
int i;
|
||||
@ -54,11 +55,29 @@ R_API void r_flag_space_set(RFlag *f, const char *name) {
|
||||
}
|
||||
}
|
||||
|
||||
R_API void r_flag_space_list(RFlag *f) {
|
||||
int i,j = 0;
|
||||
for (i=0;i<R_FLAG_SPACES_MAX;i++) {
|
||||
if (f->spaces[i])
|
||||
printf ("%02d %c %s\n", j++,
|
||||
(i==f->space_idx)?'*':' ', f->spaces[i]);
|
||||
R_API int r_flag_space_list(RFlag *f, int mode) {
|
||||
int i, j = 0;
|
||||
if (mode == 'j')
|
||||
r_cons_printf ("[");
|
||||
for (i=0; i<R_FLAG_SPACES_MAX; i++) {
|
||||
if (!f->spaces[i]) continue;
|
||||
if (mode=='j') {
|
||||
r_cons_printf ("%s{\"name\":\"%s\"%s}",
|
||||
j? ",":"", f->spaces[i],
|
||||
(i==f->space_idx)?
|
||||
",\"selected\":true":"");
|
||||
} else if (mode=='*') {
|
||||
r_cons_printf ("fs %02d %c %s\n", j++,
|
||||
(i==f->space_idx)?'*':' ',
|
||||
f->spaces[i]);
|
||||
} else {
|
||||
r_cons_printf ("%02d %c %s\n", j++,
|
||||
(i==f->space_idx)?'*':' ',
|
||||
f->spaces[i]);
|
||||
}
|
||||
j++;
|
||||
}
|
||||
if (mode == 'j')
|
||||
r_cons_printf ("]\n");
|
||||
return j;
|
||||
}
|
||||
|
@ -66,7 +66,7 @@ R_API RFlagItem *r_flag_get_at(RFlag *f, ut64 off);
|
||||
R_API int r_flag_space_get(RFlag *f, const char *name);
|
||||
R_API const char *r_flag_space_get_i(RFlag *f, int idx);
|
||||
R_API void r_flag_space_set(RFlag *f, const char *name);
|
||||
R_API void r_flag_space_list(RFlag *f);
|
||||
R_API int r_flag_space_list(RFlag *f, int mode);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -35,7 +35,8 @@
|
||||
}
|
||||
|
||||
.r2ui-input {
|
||||
background-color: #606060;
|
||||
margin-top:8px;
|
||||
background-color: #909090;
|
||||
width: 90%;
|
||||
display: inline-block;
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -1,24 +1,20 @@
|
||||
enyo.kind({
|
||||
name: "Assembler",
|
||||
kind: "Scroller",
|
||||
style: "background-color:#303030",
|
||||
// kind: "Scroller",
|
||||
components: [
|
||||
{tag: "center", components: [
|
||||
{tag: "h1", style: "color:#f0f0f0", content: "Assembler"},
|
||||
]},
|
||||
{tag: "form", style:"margin-left:10px", attributes: {action:"javascript:#"}, components: [
|
||||
{tag: "form", style:"margin-top:8px;margin-left:8px", attributes: {action:"javascript:#"}, components: [
|
||||
{kind: "FittableRows", fit: true, components: [
|
||||
{kind: "onyx.InputDecorator", classes: "r2ui-input", components: [
|
||||
{tag: "p", content: "opcode", style:"margin-right:20px"},
|
||||
{kind: "Input", value: '', style:"width:90%", onkeydown: "assembleOpcode", attributes: {autocapitalize:"off"}, name: "opcode"},
|
||||
{tag: "font", content: "opcode", style:"font-weight:bold;margin-right:20px"},
|
||||
{kind: "Input", value: '', style:"width:89%", onkeydown: "assembleOpcode", attributes: {autocapitalize:"off"}, name: "opcode"},
|
||||
]},
|
||||
{kind: "onyx.InputDecorator", classes: "r2ui-input", components: [
|
||||
{tag: "p", content: "bytes", style:"margin-right:20px"},
|
||||
{kind: "Input", value: '', style:"width:90%", onkeydown: "assembleOpcode", attributes: {autocapitalize:"off"}, name: "bytes"},
|
||||
{tag: "font", content: "bytes", style:"margin-right:20px;font-weight:bold"},
|
||||
{kind: "Input", value: '', style:"width:120px", onkeydown: "assembleOpcode", attributes: {autocapitalize:"off"}, name: "bytes"},
|
||||
]},
|
||||
{kind: "onyx.InputDecorator", classes: "r2ui-input", components: [
|
||||
{tag: "p", content: "offset", style:"margin-right:20px"},
|
||||
{kind: "Input", value: 'entry0', style:"width:90%", onkeydown: "assembleOpcode", attributes: {autocapitalize:"off"}, name: "offset"},
|
||||
{tag: "font", content: "offset", style:"margin-right:20px;font-weight:bold"},
|
||||
{kind: "Input", value: 'entry0', style:"width:120px", onkeydown: "assembleOpcode", attributes: {autocapitalize:"off"}, name: "offset"},
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
|
7
shlr/www/enyo/js/config.js
Normal file
7
shlr/www/enyo/js/config.js
Normal file
@ -0,0 +1,7 @@
|
||||
var Config = {
|
||||
"keys": {
|
||||
"C-1": "this.setIndex(0)",
|
||||
"C-2": "this.setIndex(1)",
|
||||
"C-3": "this.setIndex(2)",
|
||||
}
|
||||
}
|
@ -2,12 +2,12 @@ enyo.kind({
|
||||
name: "Console",
|
||||
kind: "Scroller",
|
||||
tag: "div",
|
||||
style:"margin-left:16px",
|
||||
style:"margin-left:8px",
|
||||
components: [
|
||||
{tag: "form", attributes: {action:"javascript:#"}, components: [
|
||||
{kind: "FittableRows", fit: true, classes: "fittable-sample-shadow", components: [
|
||||
{kind: "onyx.InputDecorator", style: "width: 90%;display:inline-block", components: [
|
||||
{kind: "Input", style:"width:100%", value: '', onkeydown: "runCommand", attributes: {autocapitalize:"off"}, name: "input"},
|
||||
{kind: "onyx.InputDecorator", style: "margin-top:8px;background-color:#404040;width: 90%;display:inline-block", components: [
|
||||
{kind: "Input", style:"width:100%;color:white", value: '', onkeydown: "runCommand", attributes: {autocapitalize:"off"}, name: "input"},
|
||||
]},
|
||||
{tag: "pre", classes:"r2ui-terminal", style:"width:90%;", fit: true, allowHtml: true, name:"output"}
|
||||
]}
|
||||
|
@ -5,21 +5,27 @@ enyo.kind({
|
||||
style:"margin-left:16px",
|
||||
data: [ "pop eax", "push ecx", "jmp 0x80040", "call 0x80404", "xor eax, eax", "int 0x80" ],
|
||||
components: [
|
||||
{tag: "h2",content: "TODO : Disasm"},
|
||||
// 3
|
||||
{tag: "pre", allowHtml: true, name: "text", content: "TODO : Disasm"},
|
||||
/*
|
||||
{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"}
|
||||
]}
|
||||
]}
|
||||
*/
|
||||
],
|
||||
create: function() {
|
||||
this.inherited (arguments);
|
||||
this.$.list.setCount (this.data.length) ;
|
||||
// this.$.list.setCount (this.data.length) ;
|
||||
var text = this.$.text;
|
||||
r2.get_disasm ("entry0", 1024, function (x) {
|
||||
x = r2.filter_asm (x, "pd");
|
||||
text.setContent (x);
|
||||
});
|
||||
//this.refresh ();
|
||||
},
|
||||
setupItem: function (inSender, inIndex) {
|
||||
this.$.msg.setContent (this.data[inIndex.index]); //"patata"); //item.name);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -7,20 +7,14 @@ enyo.kind ({
|
||||
components: [
|
||||
{ name: "lp", kind: "LeftPanel" },
|
||||
{ name: "mp", kind: "MainPanel" },
|
||||
{ name: "rp", kind: "RightPanel" }
|
||||
{ name: "rp", kind: "RightPanel" },
|
||||
{ kind: enyo.Signals, onkeypress: "handleKeyPress" }
|
||||
],
|
||||
setPanel0: function () {
|
||||
this.$.RadareApp.setIndex (1);
|
||||
},
|
||||
create: function() {
|
||||
this.inherited (arguments);
|
||||
var mp = this.$.mp;
|
||||
var ra = this.$.RadareApp;
|
||||
this.$.lp.openCallback = function (idx) {
|
||||
mp.openPage (idx);
|
||||
};
|
||||
this.$.mp.ra = this;
|
||||
this.$.lp.ra = this;
|
||||
var data = [
|
||||
{ name: "Disassembler", active: true },
|
||||
{ name: "Assembler" },
|
||||
@ -31,7 +25,44 @@ enyo.kind ({
|
||||
];
|
||||
this.$.lp.data = data;
|
||||
this.$.mp.data = data;
|
||||
this.$.mp.ra =
|
||||
this.$.lp.ra =
|
||||
this.$.rp.ra = this;
|
||||
var mp = this.$.mp;
|
||||
this.$.lp.openCallback = function (idx) {
|
||||
mp.openPage (idx);
|
||||
};
|
||||
this.$.lp.refresh ();
|
||||
},
|
||||
handleKeyPress: function(inSender, inEvent) {
|
||||
for (var key in Config.keys) {
|
||||
if (key.substring (0, 2) == "C-") {
|
||||
if (inEvent.ctrlKey) {
|
||||
var k = key.substring (2).charCodeAt (0);
|
||||
if (inEvent.charCode == k) {
|
||||
var cmd = Config.keys[key];
|
||||
eval (cmd+";");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
var k = key.substring (2).charCodeAt (0);
|
||||
if (inEvent.charCode == k) {
|
||||
var cmd = Config.keys[key];
|
||||
eval (cmd+";");
|
||||
}
|
||||
}
|
||||
}
|
||||
//dump (inEvent);
|
||||
//alert (inEvent.ctrlKey);
|
||||
// Use inEvent.charCode to detect spacebar
|
||||
/*
|
||||
if (inEvent.charCode === 32) {
|
||||
this.$.myContent.setContent("I thought");
|
||||
} else {
|
||||
var key = String.fromCharCode(inEvent.charCode).toUpperCase();
|
||||
this.$.myContent.setContent("Last key pressed: " + key);
|
||||
}
|
||||
*/
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -10,6 +10,7 @@ enyo.kind ({
|
||||
{content: "Disassembler", classes: "onyx-dark menu-button", ontap:"openPanel", name: "Disassembler", active: true},
|
||||
{content: "Assembler", classes: "onyx-dark menu-button", ontap:"openPanel", name: "Assembler" },
|
||||
{content: "Hexdump", classes: "onyx-dark menu-button", ontap:"openPanel", name: "Hexdump" },
|
||||
{content: "Search", classes: "onyx-dark menu-button", ontap:"openPanel", name: "Search" },
|
||||
{content: "Console", classes: "onyx-dark menu-button", ontap:"openPanel", name: "Console" },
|
||||
{content: "Settings", classes: "onyx-dark menu-button", ontap:"openPanel", name: "Settings" },
|
||||
{content: "About", classes: "onyx-dark menu-button" , ontap: "openPanel", name:"About"},
|
||||
|
@ -6,10 +6,12 @@ enyo.kind ({
|
||||
classes: "enyo-fit",
|
||||
style: "background-color: #c0c0c0",
|
||||
data: null,
|
||||
/*
|
||||
refresh: function () {
|
||||
this.$.list.setCount (this.data.length);
|
||||
this.$.list.refresh (); // necessary?? // inherit??
|
||||
},
|
||||
*/
|
||||
buttonClicked: function (x) {
|
||||
alert ("let's play!");
|
||||
},
|
||||
@ -20,13 +22,14 @@ enyo.kind ({
|
||||
{kind: "FittableColumns", noStretch: true, classes: "onyx-toolbar onyx-toolbar-inline", components: [
|
||||
{kind: "Scroller", thumb: false, fit: true, touch: false, vertical: "hidden", style: "margin: 0;", components: [
|
||||
{classes: "onyx-toolbar-inline", style: "white-space: nowrap;", components: [
|
||||
{kind: "onyx.Button", content: "=", ontap: "openSidebar"},
|
||||
{kind: "onyx.Button", content: "[", ontap: "openSidebar", style: "padding:8px"},
|
||||
{kind: "onyx.Button", content: "]", ontap: "openSidebar2", style: "padding:8px"},
|
||||
{kind: "onyx.Button", content: "<", ontap: "prevSeek"},
|
||||
{kind: "onyx.Button", content: ">", ontap: "nextSeek"},
|
||||
{kind: "onyx.InputDecorator", style: "width: 200px;", components: [
|
||||
{kind: "onyx.Input", value: 'entry0', onchange: "gotoSeek"}
|
||||
]},
|
||||
{kind: "onyx.Button", content: "Go", ontap: "gotoSeek"},
|
||||
//{kind: "onyx.Button", content: "Go", ontap: "gotoSeek"},
|
||||
{kind: "onyx.PickerDecorator", components: [
|
||||
{kind: "onyx.Button", content: "Actions"},
|
||||
{kind: "onyx.Picker", components: [
|
||||
@ -66,6 +69,7 @@ enyo.kind ({
|
||||
{kind:"Disassembler", name: "pageDisassembler"},
|
||||
{kind:"Assembler", name:"pageAssembler"},
|
||||
{kind:"Hexdump", name: "pageHexdump"},
|
||||
{kind:"Search", name: "pageSearch"},
|
||||
{kind:"Console", name: "pageConsole"},
|
||||
{kind:"Preferences", name:"pagePreferences"},
|
||||
{kind:"About", name: "pageAbout"},
|
||||
@ -81,6 +85,9 @@ enyo.kind ({
|
||||
openSidebar: function() {
|
||||
this.ra.setIndex (this.ra.index? 0:1);
|
||||
},
|
||||
openSidebar2: function() {
|
||||
this.ra.setIndex (2); //(this.ra.index<2)? 2:1);
|
||||
},
|
||||
rendered: function() {
|
||||
this.inherited(arguments);
|
||||
},
|
||||
@ -92,9 +99,10 @@ enyo.kind ({
|
||||
case "Disassembler": idx = 0; break;
|
||||
case "Assembler": idx = 1; break;
|
||||
case "Hexdump": idx = 2; break;
|
||||
case "Console": idx = 3; break;
|
||||
case "Settings": idx = 4; break;
|
||||
case "About": idx = 5; break;
|
||||
case "Search": idx = 3; break;
|
||||
case "Console": idx = 4; break;
|
||||
case "Settings": idx = 5; break;
|
||||
case "About": idx = 6; break;
|
||||
}
|
||||
//x.setContent (str);
|
||||
sp.setIndex (idx);
|
||||
|
@ -1,5 +1,13 @@
|
||||
/* radare2 Copyleft 2013 pancake */
|
||||
|
||||
var r2 = {};
|
||||
|
||||
var backward = false;
|
||||
var next_curoff = 0;
|
||||
var next_lastoff = 0;
|
||||
var prev_curoff = 0;
|
||||
var prev_lastoff = 0;
|
||||
|
||||
r2.root = ""; // prefix path
|
||||
|
||||
Array.prototype.push = function (x) {
|
||||
@ -27,18 +35,17 @@ function objtostr(obj) {
|
||||
}
|
||||
|
||||
function Ajax (method, uri, body, fn) {
|
||||
var x = new XMLHttpRequest ();
|
||||
x.open (method, uri, false);
|
||||
x.setRequestHeader ('Accept', 'text/plain');
|
||||
x.setRequestHeader ('Accept', 'text/html');
|
||||
x.setRequestHeader ("Content-Type",
|
||||
"application/x-ww-form-urlencoded; charset=UTF-8");
|
||||
x.onreadystatechange = function (y) {
|
||||
if (x.status == 200) {
|
||||
if (fn) fn (x.responseText);
|
||||
} else console.error ("ajax "+x.status)
|
||||
}
|
||||
x.send (body);
|
||||
var x = new XMLHttpRequest ();
|
||||
x.open (method, uri, false);
|
||||
x.setRequestHeader ('Accept', 'text/plain');
|
||||
x.setRequestHeader ('Accept', 'text/html');
|
||||
x.setRequestHeader ("Content-Type", "application/x-ww-form-urlencoded; charset=UTF-8");
|
||||
x.onreadystatechange = function (y) {
|
||||
if (x.status == 200) {
|
||||
if (fn) fn (x.responseText);
|
||||
} else console.error ("ajax "+x.status)
|
||||
}
|
||||
x.send (body);
|
||||
}
|
||||
|
||||
r2.assemble = function (offset, opcode, fn) {
|
||||
@ -48,135 +55,236 @@ r2.assemble = function (offset, opcode, fn) {
|
||||
|
||||
r2.disassemble = function (offset, bytes, fn) {
|
||||
var off = offset? "@"+offset:'';
|
||||
var str = 'pi 1@b:'+bytes+off;
|
||||
var str = 'pi @b:'+bytes+off;
|
||||
r2.cmd (str, fn);
|
||||
}
|
||||
}
|
||||
|
||||
r2.get_disasm = function (offset, length, cb) {
|
||||
// TODO: honor offset and length
|
||||
r2.cmd ("b 512;pd", cb);
|
||||
}
|
||||
|
||||
r2.config_set = function (fn) {
|
||||
// TODO
|
||||
// TODO
|
||||
}
|
||||
|
||||
r2.config_get = function (fn) {
|
||||
// TODO
|
||||
// TODO
|
||||
}
|
||||
|
||||
r2.set_flag_space = function (ns, fn) {
|
||||
// TODO
|
||||
r2.cmd ("fs ", fn);
|
||||
r2.cmd ("fs "+ns, fn);
|
||||
}
|
||||
|
||||
r2.set_flag_space = function (ns, fn) {
|
||||
r2.cmd ("fs "+ns, fn);
|
||||
}
|
||||
|
||||
r2.get_flags = function (fn) {
|
||||
r2.cmd ("fj", fn);
|
||||
r2.cmd ("fj", function (x) {
|
||||
if (x) x = JSON.parse (x);
|
||||
fn (x);
|
||||
});
|
||||
}
|
||||
|
||||
r2.get_opcodes = function (off, n, cb) {
|
||||
r2.cmd ("pdj @"+off+"!"+n, function (json) {
|
||||
var o = JSON.parse (json);
|
||||
cb (o);
|
||||
});
|
||||
r2.cmd ("pdj @"+off+"!"+n, function (json) {
|
||||
var o = JSON.parse (json);
|
||||
cb (o);
|
||||
});
|
||||
}
|
||||
|
||||
r2.get_bytes = function (off, n, cb) {
|
||||
r2.cmd ("pcj @"+off+"!"+n, function (json) {
|
||||
var o = JSON.parse (json);
|
||||
cb (o);
|
||||
});
|
||||
r2.cmd ("pcj @"+off+"!"+n, function (json) {
|
||||
var o = JSON.parse (json);
|
||||
cb (o);
|
||||
});
|
||||
}
|
||||
|
||||
r2.get_info = function (cb) {
|
||||
r2.cmd ("ij", function (json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
r2.cmd ("ij", function (json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
}
|
||||
r2.bin_imports = function (cb) {
|
||||
r2.cmd ("iij", function (json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
r2.cmd ("iij", function (json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
}
|
||||
|
||||
r2.bin_symbols = function (cb) {
|
||||
r2.cmd ("isj", function (json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
r2.cmd ("isj", function (json) {
|
||||
cb (JSON.parse (json));
|
||||
});
|
||||
}
|
||||
|
||||
r2.bin_sections = function (cb) {
|
||||
r2.cmd ("iSj", function (json) {
|
||||
var o = JSON.parse (json);
|
||||
cb (o);
|
||||
});
|
||||
r2.cmd ("iSj", function (json) {
|
||||
var o = JSON.parse (json);
|
||||
cb (o);
|
||||
});
|
||||
}
|
||||
|
||||
r2.cmd = function (c, cb) {
|
||||
Ajax ('GET', r2.root+"/cmd/"+encodeURI (c), '', function (x) {
|
||||
if (cb) cb (x);
|
||||
});
|
||||
Ajax ('GET', r2.root+"/cmd/"+encodeURI (c), '', function (x) {
|
||||
if (cb) cb (x);
|
||||
});
|
||||
}
|
||||
|
||||
r2.alive = function (cb) {
|
||||
r2.cmd ("b", function (o) {
|
||||
var ret = false;
|
||||
if (o && o.length () > 0)
|
||||
ret = true;
|
||||
if (cb) cb (o);
|
||||
});
|
||||
r2.cmd ("b", function (o) {
|
||||
var ret = false;
|
||||
if (o && o.length () > 0)
|
||||
ret = true;
|
||||
if (cb) cb (o);
|
||||
});
|
||||
}
|
||||
|
||||
r2.get_logger = function (obj) {
|
||||
if (typeof (obj) != "object")
|
||||
obj = {};
|
||||
obj.last = 0;
|
||||
obj.events = {};
|
||||
obj.interval = null;
|
||||
r2.cmd ("ll", function (x) {
|
||||
obj.last = +x;
|
||||
});
|
||||
obj.load = function (cb) {
|
||||
r2.cmd ("lj "+(obj.last+1), function (ret) {
|
||||
var json = JSON.parse (ret);
|
||||
if (cb) cb (json);
|
||||
});
|
||||
}
|
||||
obj.clear = function (cb) {
|
||||
// XXX: fix l-N
|
||||
r2.cmd ("l-", cb); //+obj.last, cb);
|
||||
}
|
||||
obj.send = function (msg, cb) {
|
||||
r2.cmd ("l "+msg, cb);
|
||||
}
|
||||
obj.refresh = function (cb) {
|
||||
obj.load (function (ret) {
|
||||
//obj.last = 0;
|
||||
for (var i = 0; i< ret.length; i++) {
|
||||
var message = ret[i];
|
||||
obj.events["message"] ({
|
||||
"id": message[0],
|
||||
"text": message[1]
|
||||
});
|
||||
if (message[0] > obj.last)
|
||||
obj.last = message[0];
|
||||
}
|
||||
if (cb) cb ();
|
||||
});
|
||||
}
|
||||
obj.autorefresh = function (n) {
|
||||
if (!n) {
|
||||
if (obj.interval)
|
||||
obj.interval.stop ();
|
||||
return;
|
||||
}
|
||||
function to() {
|
||||
obj.refresh (function () {
|
||||
//obj.clear ();
|
||||
});
|
||||
setTimeout (to, n*1000);
|
||||
return true;
|
||||
}
|
||||
obj.interval = setTimeout (to, n*1000);
|
||||
}
|
||||
obj.on = function (ev, cb) {
|
||||
obj.events[ev] = cb;
|
||||
return obj;
|
||||
}
|
||||
return obj;
|
||||
if (typeof (obj) != "object")
|
||||
obj = {};
|
||||
obj.last = 0;
|
||||
obj.events = {};
|
||||
obj.interval = null;
|
||||
r2.cmd ("ll", function (x) {
|
||||
obj.last = +x;
|
||||
});
|
||||
obj.load = function (cb) {
|
||||
r2.cmd ("lj "+(obj.last+1), function (ret) {
|
||||
var json = JSON.parse (ret);
|
||||
if (cb) cb (json);
|
||||
});
|
||||
}
|
||||
obj.clear = function (cb) {
|
||||
// XXX: fix l-N
|
||||
r2.cmd ("l-", cb); //+obj.last, cb);
|
||||
}
|
||||
obj.send = function (msg, cb) {
|
||||
r2.cmd ("l "+msg, cb);
|
||||
}
|
||||
obj.refresh = function (cb) {
|
||||
obj.load (function (ret) {
|
||||
//obj.last = 0;
|
||||
for (var i = 0; i< ret.length; i++) {
|
||||
var message = ret[i];
|
||||
obj.events["message"] ({
|
||||
"id": message[0],
|
||||
"text": message[1]
|
||||
});
|
||||
if (message[0] > obj.last)
|
||||
obj.last = message[0];
|
||||
}
|
||||
if (cb) cb ();
|
||||
});
|
||||
}
|
||||
obj.autorefresh = function (n) {
|
||||
if (!n) {
|
||||
if (obj.interval)
|
||||
obj.interval.stop ();
|
||||
return;
|
||||
}
|
||||
function to() {
|
||||
obj.refresh (function () {
|
||||
//obj.clear ();
|
||||
});
|
||||
setTimeout (to, n*1000);
|
||||
return true;
|
||||
}
|
||||
obj.interval = setTimeout (to, n*1000);
|
||||
}
|
||||
obj.on = function (ev, cb) {
|
||||
obj.events[ev] = cb;
|
||||
return obj;
|
||||
}
|
||||
return obj;
|
||||
}
|
||||
|
||||
r2.filter_asm = function (x, display) {
|
||||
var curoff = backward? prev_curoff: next_curoff;;
|
||||
var lastoff = backward? prev_lastoff: next_lastoff;;
|
||||
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]*)/);
|
||||
if (a && a.length>0) {
|
||||
lastoff = a[0].replace (/:/g, "");
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (display == "afl") {
|
||||
//hasmore (false);
|
||||
var z = "";
|
||||
for (var i=0;i<lines.length;i++) {
|
||||
var row = lines[i].replace (/\ +/g," ").split (/ /g);
|
||||
z += row[0]+ " "+row[3]+"\n";
|
||||
}
|
||||
x = z;
|
||||
} else
|
||||
if (display[0] == 'f') {
|
||||
//hasmore (false);
|
||||
if (display[1] == 's') {
|
||||
var z = "";
|
||||
for (var i=0; i<lines.length; i++) {
|
||||
var row = lines[i].replace (/\ +/g," ").split (/ /g);
|
||||
var mark = row[1]=='*'? '*': ' ';
|
||||
var space = row[2]? row[2]: row[1];
|
||||
if (!space) continue;
|
||||
z += row[0]+ " "+mark+" <a href=\"javascript:runcmd('fs "+
|
||||
space+"')\">"+space+"</a>\n";
|
||||
}
|
||||
x = z;
|
||||
} else {
|
||||
}
|
||||
} else
|
||||
if (display[0] == "i") {
|
||||
//hasmore (false);
|
||||
if (display[1]) {
|
||||
var z = "";
|
||||
for (var i=0;i<lines.length;i++) {
|
||||
var elems = lines[i].split (/ /g);
|
||||
var name = "";
|
||||
var addr = "";
|
||||
for (var j=0;j<elems.length;j++) {
|
||||
var kv = elems[j].split (/=/);
|
||||
if (kv[0] == "addr") addr = kv[1];
|
||||
if (kv[0] == "name") name = kv[1];
|
||||
if (kv[0] == "string") name = kv[1];
|
||||
}
|
||||
z += addr+ " "+name+"\n";
|
||||
}
|
||||
x = z;
|
||||
}
|
||||
} //else hasmore (true);
|
||||
|
||||
function haveDisasm(x) {
|
||||
if (x[0]=='p' && x[1]=='d') return true;
|
||||
if (x.indexOf (";pd") != -1) return true;
|
||||
return false;
|
||||
}
|
||||
if (haveDisasm (display)) {
|
||||
x = x.replace (/function:/g,"<span style=color:red>function:</span>");
|
||||
x = x.replace (/;(\s+)/g, ";");
|
||||
x = x.replace (/;(.*)/g, "// <span style='color:red'>$1</span>");
|
||||
x = x.replace (/(bl|call)/g, "<b style='color:green'>call</b>");
|
||||
x = x.replace (/(jmp|bne|beq|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:orange'>$1</b>");
|
||||
x = x.replace (/(hlt|leave|retn|ret)/g, "<b style='color:red'>$1</b>");
|
||||
x = x.replace (/(add|sub|mul|div|shl|shr|and|not|xor|inc|dec|sar|sal)/g, "<b style='color:orange'>$1</b>");
|
||||
x = x.replace (/(push|pop)/g, "<b style='color:magenta'>$1</b>");
|
||||
x = x.replace (/(test|cmp)/g, "<b style='color:green'>$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 (/0x([a-zA-Z0-9]*)/g, "<a href='javascript:r2ui.seek(\"0x$1\")'>0x$1</a>");
|
||||
// registers
|
||||
if (backward) {
|
||||
prev_curoff = curoff;
|
||||
prev_lastoff = lastoff;
|
||||
} else {
|
||||
next_curoff = curoff;
|
||||
next_lastoff = lastoff;
|
||||
if (!prev_curoff)
|
||||
prev_curoff = next_curoff;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
@ -3,7 +3,10 @@ enyo.kind ({
|
||||
classes: "onyx onyx-toolbar",
|
||||
kind: "Control",
|
||||
style: "width:25px",
|
||||
ra: null,
|
||||
components: [
|
||||
{kind: "FittableColumns", components: [
|
||||
{kind: "onyx.Button", content: "[", ontap: "closeSidebar", style: "padding:8px;margin-right:8px"},
|
||||
{kind: "onyx.MenuDecorator", onSelect: "itemSelected", components: [
|
||||
{content: "List elements"},
|
||||
{kind: "onyx.Menu", components: [
|
||||
@ -25,6 +28,7 @@ enyo.kind ({
|
||||
{tag: "h3", style:"background-color:red",name: "msg", fit:true, active: true, ontap: "rowTap"}
|
||||
]}
|
||||
]}
|
||||
]}
|
||||
],
|
||||
rowTap: function () {
|
||||
/* do something here */
|
||||
@ -32,6 +36,7 @@ enyo.kind ({
|
||||
create: function() {
|
||||
this.inherited (arguments);
|
||||
this.$.list.setCount (3);
|
||||
this.$.list.refresh();
|
||||
},
|
||||
data: [],
|
||||
setupItem: function (inSender, inIndex) {
|
||||
@ -48,8 +53,12 @@ enyo.kind ({
|
||||
// trycatch here or wtf
|
||||
self.data = JSON.parse (flags);
|
||||
self.$.list.setCount (self.data.length);
|
||||
self.$.list.refresh();
|
||||
});
|
||||
break;
|
||||
}
|
||||
},
|
||||
closeSidebar: function() {
|
||||
this.ra.setIndex (1);
|
||||
}
|
||||
});
|
||||
|
10
shlr/www/enyo/js/search.js
Normal file
10
shlr/www/enyo/js/search.js
Normal file
@ -0,0 +1,10 @@
|
||||
enyo.kind ({
|
||||
name: "Search",
|
||||
kind: "Scroller",
|
||||
style: "background-color:#303030",
|
||||
components: [
|
||||
{tag: "center", components: [
|
||||
{tag: "h1", style: "color:#f0f0f0", content: "TODO: Search"},
|
||||
]}
|
||||
]
|
||||
});
|
Loading…
Reference in New Issue
Block a user