mirror of
https://github.com/radareorg/radare2.git
synced 2025-01-13 17:20:46 +00:00
uncomplete webui work
This commit is contained in:
parent
ebf85b56cb
commit
4654501740
File diff suppressed because one or more lines are too long
@ -573,26 +573,28 @@ function html_for_instruction(ins) {
|
||||
|
||||
if (offset === "0x"+ins.fcn_addr.toString(16)) {
|
||||
if (r2ui._dis.display == "flat") idump += '<div class="ec_flow">; -----------------------------------------------------------</div>';
|
||||
r2.cmdj("afij " + offset, function(x){
|
||||
if (x !== null && x !== undefined && x.length > 0)
|
||||
idump += '<div class="ec_fname">(fcn) ' + x[0].name + '</div>';
|
||||
});
|
||||
r2.cmdj("afvj @ " + offset, function(x){
|
||||
var fvars = [];
|
||||
for (var i in x) {
|
||||
idump += '<div class="ec_flag">; ' + x[i].kind + " " + x[i].type + " <span class='fvar id_" + address_canonicalize(offset) + "_" + x[i].ref + " ec_prompt faddr faddr_" + address_canonicalize(offset) + "'>" + escapeHTML(x[i].name) + "</span> @ " + x[i].ref + '</div>';
|
||||
fvars[fvars.length] = {name: x[i].name, id: address_canonicalize(offset) + "_" + x[i].ref};
|
||||
}
|
||||
r2.varMap[ins.fcn_addr] = fvars;
|
||||
});
|
||||
r2.cmdj("afaj @ " + offset, function(x){
|
||||
var args = [];
|
||||
for (var i in x) {
|
||||
idump += '<div class="ec_flag">; ' + x[i].kind + " " + x[i].type + " <span class='farg id_" + address_canonicalize(offset) + "_" + x[i].ref + " ec_prompt faddr faddr_" + address_canonicalize(offset) + "'>" + escapeHTML(x[i].name) + "</span> @ " + x[i].ref + '</div>';
|
||||
args[args.length] = {name: x[i].name, id: address_canonicalize(offset) + "_" + x[i].ref};
|
||||
}
|
||||
r2.argMap[ins.fcn_addr] = args;
|
||||
var results;
|
||||
var cmd = "afij " + offset + ";afvj " + offset + ";afaj " + offset;
|
||||
r2.cmd(cmd, function(x){
|
||||
results = x.split("\n");
|
||||
});
|
||||
var info = JSON.parse(results[0]);
|
||||
if (info !== null && info !== undefined && info.length > 0)
|
||||
idump += '<div class="ec_fname">(fcn) ' + info[0].name + '</div>';
|
||||
var vars = JSON.parse(results[1]);
|
||||
var fvars = [];
|
||||
for (var i in vars) {
|
||||
idump += '<div class="ec_flag">; ' + vars[i].kind + " " + results[1][i].type + " <span class='fvar id_" + address_canonicalize(offset) + "_" + results[1][i].ref + " ec_prompt faddr faddr_" + address_canonicalize(offset) + "'>" + escapeHTML(results[1][i].name) + "</span> @ " + results[1][i].ref + '</div>';
|
||||
fvars[fvars.length] = {name: results[1][i].name, id: address_canonicalize(offset) + "_" + results[1][i].ref};
|
||||
}
|
||||
r2.varMap[ins.fcn_addr] = fvars;
|
||||
var args = JSON.parse(results[2]);
|
||||
var fargs = [];
|
||||
for (var i in args) {
|
||||
idump += '<div class="ec_flag">; ' + args[i].kind + " " + args[i].type + " <span class='farg id_" + address_canonicalize(offset) + "_" + args[i].ref + " ec_prompt faddr faddr_" + address_canonicalize(offset) + "'>" + escapeHTML(args[i].name) + "</span> @ " + args[i].ref + '</div>';
|
||||
fargs[fargs.length] = {name: args[i].name, id: address_canonicalize(offset) + "_" + args[i].ref};
|
||||
}
|
||||
r2.argMap[ins.fcn_addr] = fargs;
|
||||
}
|
||||
if (asm_flags) {
|
||||
var flags;
|
||||
@ -820,10 +822,11 @@ function has_scrollbar(divnode) {
|
||||
}
|
||||
|
||||
function on_scroll(event) {
|
||||
// console.log($(event.target).scrollTop());
|
||||
if (!r2ui._dis.scrolling) {
|
||||
var enyo = $("#radareApp").length ? true : false;
|
||||
var panel_disas = false;
|
||||
if (!enyo) panel_disas =$( "#main_panel" ).tabs( "option", "active" ) == 0? true : false;
|
||||
if (!enyo) panel_disas = $("#main_panel").tabs("option", "active") === 0 ? true : false;
|
||||
r2ui._dis.scrolling = true;
|
||||
if (r2ui._dis.display == "flat" && (enyo || panel_disas)) {
|
||||
var scroll_offset = null;
|
||||
@ -849,8 +852,7 @@ function on_scroll(event) {
|
||||
render_instructions(r2ui._dis.instructions);
|
||||
scroll_to_address(addr);
|
||||
rehighlight_iaddress(r2ui._dis.selected_offset);
|
||||
}
|
||||
if (scroll_offset > top_offset) {
|
||||
} else if (scroll_offset > top_offset) {
|
||||
// console.log("Scroll en top", scroll_offset, top_offset)
|
||||
addr = "0x" + r2ui._dis.instructions[r2ui._dis.instructions.length-1].offset.toString(16);
|
||||
r2.get_disasm_after(addr, 100, function(x) {
|
||||
@ -864,6 +866,7 @@ function on_scroll(event) {
|
||||
}
|
||||
}
|
||||
r2ui._dis.scrolling = false;
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@ -1022,3 +1025,9 @@ function inColor(x) {
|
||||
return "e scr.color=true;"+x+";e scr.color=false";
|
||||
}
|
||||
|
||||
function save_project_notes() {
|
||||
if ($("#pnotes").val() === r2ui.project_notes) {
|
||||
console.log("Saving " + r2ui.project_notes);
|
||||
r2.cmd("Pnj " + btoa(r2ui.project_notes));
|
||||
}
|
||||
}
|
@ -97,8 +97,7 @@ enyo.kind ({
|
||||
var key = String.fromCharCode(keynum);
|
||||
// console.log(key);
|
||||
|
||||
var ctrlDown = evt.ctrlKey||evt.metaKey; // Mac support
|
||||
if (ctrlDown && evt.altKey) return true;
|
||||
if (inEvent.ctrlKey||inEvent.metaKey) return true;
|
||||
|
||||
// show help
|
||||
if (key === '?') {
|
||||
|
@ -100,6 +100,8 @@ r2ui.update_fcn_BB = function(fcn_offset, bb_offset, bbinfo) {
|
||||
r2ui.basic_blocks[bb_offset] = bbinfo;
|
||||
}
|
||||
};
|
||||
|
||||
r2ui.project_notes = "";
|
||||
r2ui.current_fcn_offset = null;
|
||||
r2ui.graph = null;
|
||||
r2ui.console_lang = "r2";
|
||||
@ -172,6 +174,7 @@ r2ui.prev_instruction = function() {
|
||||
}
|
||||
|
||||
r2ui.seek = function (addr, push, scroll) {
|
||||
if (addr === undefined) return;
|
||||
// Resolve flag in case we dont have an address
|
||||
if (addr.indexOf("0x") === 0) {
|
||||
addr = address_canonicalize(addr);
|
||||
|
@ -103,6 +103,10 @@
|
||||
<div id="information"></div>
|
||||
<h3 id="sections_label">Sections</h3>
|
||||
<div id="sections"></div>
|
||||
<h3 id="notes_label">Project Notes</h3>
|
||||
<div id="notes">
|
||||
<textarea id="pnotes" style="width:100%;height:100%;"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -11,7 +11,7 @@ HexPanel.prototype.seek = function(addr, scroll) {
|
||||
this.min = this.max = 0;
|
||||
r2.cmd (inColor("px " + this.block + "@" + addr), function (x) {
|
||||
x = render_hexdump(x);
|
||||
$("#hex_tab").html("<div style='overflow: scroll;padding-left: 30px;'><pre id='hexdump' style='color:rgb(127,127,127);''>" + x + "</pre></div>");
|
||||
$("#hex_tab").html("<div style='padding-left: 30px;'><pre id='hexdump' style='color:rgb(127,127,127);''>" + x + "</pre></div>");
|
||||
});
|
||||
};
|
||||
HexPanel.prototype.scrollTo = function(x,y) {
|
||||
|
@ -273,17 +273,37 @@ $(document).ready( function() {
|
||||
r2ui.seek(disasm_panel.base,true);
|
||||
scroll_to_element(r2ui._dis.selected);
|
||||
|
||||
// Infinite scroll
|
||||
$("#center_panel").scroll(on_scroll);
|
||||
|
||||
// Project notes
|
||||
r2.cmdj("Pnj", function(x){
|
||||
// TODO: Handle when project does not exist
|
||||
// TODO: remove keyhandlers from pnotes
|
||||
if (x !== null) {
|
||||
console.log(x);
|
||||
var notes = atob(x);
|
||||
$("#pnotes").html(notes);
|
||||
}
|
||||
});
|
||||
$("#pnotes").bind("keydown", function(x) {
|
||||
r2ui.project_notes = $("#pnotes").val();
|
||||
setTimeout("save_project_notes();", 3000);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
function scroll_to_element(element) {
|
||||
if (element === undefined) return;
|
||||
var top = Math.max(0,element.documentOffsetTop() - ( window.innerHeight / 2 ));
|
||||
$('#center_panel').scrollTo(top, {axis: 'y'});
|
||||
r2ui._dis.scroll_offset = top;
|
||||
}
|
||||
|
||||
function scroll_to_address(address) {
|
||||
if (address === undefined) return;
|
||||
var elements = $(".insaddr.addr_" + address);
|
||||
var top = elements[0].documentOffsetTop() - ( window.innerHeight / 2 );
|
||||
top = Math.max(0,top);
|
||||
@ -304,8 +324,7 @@ function handleKeypress(inEvent) {
|
||||
var key = String.fromCharCode(keynum);
|
||||
// console.log(key);
|
||||
|
||||
var ctrlDown = evt.ctrlKey||evt.metaKey; // Mac support
|
||||
if (ctrlDown && evt.altKey) return true;
|
||||
if (inEvent.ctrlKey||inEvent.metaKey) return true;
|
||||
|
||||
if ($(inEvent.target).prop("tagName") === "INPUT") {
|
||||
return;
|
||||
@ -544,48 +563,55 @@ function do_define(element) {
|
||||
}
|
||||
|
||||
function handleClick(inEvent) {
|
||||
if ($(inEvent.target).hasClass('addr')) {
|
||||
var address = get_address_from_class(inEvent.target);
|
||||
r2ui._dis.selected = inEvent.target;
|
||||
r2ui._dis.selected_offset = address;
|
||||
rehighlight_iaddress(address);
|
||||
// If instruction address, add address to history
|
||||
if ($(inEvent.target).hasClass('insaddr')) {
|
||||
r2ui.history_push(address);
|
||||
render_history();
|
||||
|
||||
var get_more_instructions = false;
|
||||
var next_instruction;
|
||||
var prev_instruction;
|
||||
var address;
|
||||
if (r2ui._dis.display == "flat") {
|
||||
next_instruction = $(r2ui._dis.selected).closest(".instructionbox").next().find('.insaddr')[0];
|
||||
if ($("#gbox .instructionbox").index( $(r2ui._dis.selected).closest(".instructionbox")[0]) > $("#gbox .instructionbox").length - 10) {
|
||||
get_more_instructions = true;
|
||||
address = get_address_from_class(next_instruction);
|
||||
}
|
||||
prev_instruction = $(r2ui._dis.selected).closest(".instructionbox").prev().find('.insaddr')[0];
|
||||
if ($("#gbox .instructionbox").index( $(r2ui._dis.selected).closest(".instructionbox")[0]) < 10) {
|
||||
get_more_instructions = true;
|
||||
address = get_address_from_class(prev_instruction);
|
||||
}
|
||||
}
|
||||
if (r2ui._dis.display == "graph") {
|
||||
var next_instruction = $(r2ui._dis.selected).closest(".instruction").next().find('.insaddr')[0];
|
||||
if (next_instruction === undefined || next_instruction === null) {
|
||||
next_instruction = $(r2ui._dis.selected).closest(".basicblock").next().find('.insaddr')[0];
|
||||
}
|
||||
var prev_instruction = $(r2ui._dis.selected).closest(".instruction").prev().find('.insaddr')[0];
|
||||
if (prev_instruction === undefined || prev_instruction === null) {
|
||||
prev_instruction = $(r2ui._dis.selected).closest(".basicblock").prev().find('.insaddr').last()[0];
|
||||
}
|
||||
}
|
||||
if (get_more_instructions) {
|
||||
r2ui.seek(address, false);
|
||||
if ($(inEvent.target).hasClass('addr')) {
|
||||
if ($(inEvent.target).hasClass('history')) {
|
||||
var idx = inEvent.target.className.split(" ").filter(function(x) { return x.substr(0,"history_idx_".length) == "history_idx_"; });
|
||||
idx = String(idx).split("_")[2];
|
||||
r2ui.history_idx = idx;
|
||||
do_jumpto(r2ui.history[idx]);
|
||||
}
|
||||
// If instruction address, add address to history
|
||||
else if ($(inEvent.target).hasClass('insaddr')) {
|
||||
var address = get_address_from_class(inEvent.target);
|
||||
r2ui._dis.selected = inEvent.target;
|
||||
r2ui._dis.selected_offset = address;
|
||||
rehighlight_iaddress(address);
|
||||
scroll_to_address(address);
|
||||
|
||||
r2ui.history_push(address);
|
||||
render_history();
|
||||
var get_more_instructions = false;
|
||||
var next_instruction;
|
||||
var prev_instruction;
|
||||
var address;
|
||||
if (r2ui._dis.display == "flat") {
|
||||
next_instruction = $(r2ui._dis.selected).closest(".instructionbox").next().find('.insaddr')[0];
|
||||
if ($("#gbox .instructionbox").index( $(r2ui._dis.selected).closest(".instructionbox")[0]) > $("#gbox .instructionbox").length - 10) {
|
||||
get_more_instructions = true;
|
||||
address = get_address_from_class(next_instruction);
|
||||
}
|
||||
prev_instruction = $(r2ui._dis.selected).closest(".instructionbox").prev().find('.insaddr')[0];
|
||||
if ($("#gbox .instructionbox").index( $(r2ui._dis.selected).closest(".instructionbox")[0]) < 10) {
|
||||
get_more_instructions = true;
|
||||
address = get_address_from_class(prev_instruction);
|
||||
}
|
||||
}
|
||||
if (r2ui._dis.display == "graph") {
|
||||
var next_instruction = $(r2ui._dis.selected).closest(".instruction").next().find('.insaddr')[0];
|
||||
if (next_instruction === undefined || next_instruction === null) {
|
||||
next_instruction = $(r2ui._dis.selected).closest(".basicblock").next().find('.insaddr')[0];
|
||||
}
|
||||
var prev_instruction = $(r2ui._dis.selected).closest(".instruction").prev().find('.insaddr')[0];
|
||||
if (prev_instruction === undefined || prev_instruction === null) {
|
||||
prev_instruction = $(r2ui._dis.selected).closest(".basicblock").prev().find('.insaddr').last()[0];
|
||||
}
|
||||
}
|
||||
if (get_more_instructions) {
|
||||
r2ui.seek(address, false);
|
||||
rehighlight_iaddress(address);
|
||||
scroll_to_address(address);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($(inEvent.target).hasClass('fvar') || $(inEvent.target).hasClass('farg')) {
|
||||
var eid = null;
|
||||
var address = get_address_from_class(inEvent.target, "faddr");
|
||||
@ -784,8 +810,8 @@ function render_history(){
|
||||
var flag = r2.get_flag_names(r2ui.history[i]);
|
||||
if (flag.length > 0) flag = flag[0];
|
||||
else flag = r2ui.history[i];
|
||||
if (i == r2ui.history_idx - 1) html += " > <span class='history history_idx addr addr_" + r2ui.history[i] + "'>" + flag + "</span>";
|
||||
else html += " > <span class='history addr addr_" + r2ui.history[i] + "'>" + flag + "</span>";
|
||||
if (i == r2ui.history_idx - 1) html += " > <span class='history history_idx addr addr_" + r2ui.history[i] + " history_idx_" + i + "'>" + flag + "</span>";
|
||||
else html += " > <span class='history addr addr_" + r2ui.history[i] + " history_idx_" + i + "'>" + flag + "</span>";
|
||||
}
|
||||
}
|
||||
html += "</div>";
|
||||
|
Loading…
x
Reference in New Issue
Block a user