mirror of
https://github.com/radareorg/radare2.git
synced 2024-12-27 16:07:54 +00:00
allow rename functions in main offset
This commit is contained in:
parent
e0d7e3271d
commit
836b4625e1
File diff suppressed because one or more lines are too long
@ -812,7 +812,7 @@ function has_scrollbar(divnode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function on_scroll(event) {
|
function on_scroll(event) {
|
||||||
if (r2ui._dis.display == "flat") {
|
if (r2ui._dis.display == "flatDISABLED") {
|
||||||
var scroll_offset = null;
|
var scroll_offset = null;
|
||||||
var top_offset = null;
|
var top_offset = null;
|
||||||
var addr = null;
|
var addr = null;
|
||||||
@ -830,6 +830,7 @@ function on_scroll(event) {
|
|||||||
if (has_scrollbar($('#center_panel')[0])) {
|
if (has_scrollbar($('#center_panel')[0])) {
|
||||||
if (scroll_offset === 0 ) {
|
if (scroll_offset === 0 ) {
|
||||||
$("#center_panel").scroll(null);
|
$("#center_panel").scroll(null);
|
||||||
|
// console.log("Scroll en top", scroll_offset, top_offset)
|
||||||
addr = "0x" + r2ui._dis.instructions[0].offset.toString(16);
|
addr = "0x" + r2ui._dis.instructions[0].offset.toString(16);
|
||||||
r2.get_disasm_before(addr, 100, function(x) {
|
r2.get_disasm_before(addr, 100, function(x) {
|
||||||
r2ui._dis.instructions = x.concat(r2ui._dis.instructions);
|
r2ui._dis.instructions = x.concat(r2ui._dis.instructions);
|
||||||
@ -842,6 +843,7 @@ function on_scroll(event) {
|
|||||||
}
|
}
|
||||||
if (scroll_offset > top_offset) {
|
if (scroll_offset > top_offset) {
|
||||||
$("#center_panel").scroll(null);
|
$("#center_panel").scroll(null);
|
||||||
|
// console.log("Scroll en top", scroll_offset, top_offset)
|
||||||
addr = "0x" + r2ui._dis.instructions[r2ui._dis.instructions.length-1].offset.toString(16);
|
addr = "0x" + r2ui._dis.instructions[r2ui._dis.instructions.length-1].offset.toString(16);
|
||||||
r2.get_disasm_after(addr, 100, function(x) {
|
r2.get_disasm_after(addr, 100, function(x) {
|
||||||
r2ui._dis.instructions = r2ui._dis.instructions.slice(0, -1).concat(x);
|
r2ui._dis.instructions = r2ui._dis.instructions.slice(0, -1).concat(x);
|
||||||
|
@ -315,7 +315,15 @@ enyo.kind ({
|
|||||||
if (this.renaming !== null && this.rbox.value.length > 0) {
|
if (this.renaming !== null && this.rbox.value.length > 0) {
|
||||||
if ($(this.selected).hasClass('insaddr')) {
|
if ($(this.selected).hasClass('insaddr')) {
|
||||||
var old_value = get_offset_flag(r2ui._dis.selected_offset);
|
var old_value = get_offset_flag(r2ui._dis.selected_offset);
|
||||||
rename(r2ui._dis.selected_offset, old_value, this.rbox.value, "offsets");
|
var type = "offsets";
|
||||||
|
r2.cmdj("afij @ " + r2ui._dis.selected_offset, function(x) {
|
||||||
|
if (x !== null && x !== undefined) {
|
||||||
|
if ("0x" + x[0].offset.toString(16) === r2ui._dis.selected_offset) {
|
||||||
|
type = "functions";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
rename(r2ui._dis.selected_offset, old_value, this.rbox.value, type);
|
||||||
} else if ($(this.selected).hasClass('faddr')) {
|
} else if ($(this.selected).hasClass('faddr')) {
|
||||||
if ($(this.selected).hasClass('fvar'))
|
if ($(this.selected).hasClass('fvar'))
|
||||||
r2.cmd("afvn " + r2ui._dis.renameOldValue + " " + r2ui._dis.rbox.value + " @ " + r2ui._dis.selected_offset, function(x){});
|
r2.cmd("afvn " + r2ui._dis.renameOldValue + " " + r2ui._dis.rbox.value + " @ " + r2ui._dis.selected_offset, function(x){});
|
||||||
@ -559,8 +567,8 @@ enyo.kind ({
|
|||||||
// for (var k in colors)
|
// for (var k in colors)
|
||||||
// if (block[k])
|
// if (block[k])
|
||||||
// count++;
|
// count++;
|
||||||
// count++; // avoid 0div wtf
|
// count++; // avoid 0div wtf
|
||||||
// if (count==1) break;
|
// if (count==1) break;
|
||||||
// var h = HEIGHT / count;
|
// var h = HEIGHT / count;
|
||||||
// for (var k in colors) {
|
// for (var k in colors) {
|
||||||
// var color = colors[k];
|
// var color = colors[k];
|
||||||
@ -576,7 +584,7 @@ enyo.kind ({
|
|||||||
// }
|
// }
|
||||||
// c += "<td onclick='r2ui.seek("+off+",true)' title='"+off
|
// c += "<td onclick='r2ui.seek("+off+",true)' title='"+off
|
||||||
// + "' style='height:"+HEIGHT+"px' "
|
// + "' style='height:"+HEIGHT+"px' "
|
||||||
// + "width=15px>"+r+"</td>";
|
// + "width=15px>"+r+"</td>";
|
||||||
// }
|
// }
|
||||||
// c += "</tr></table>";
|
// c += "</tr></table>";
|
||||||
// self.$.colorbar.setContent (c);
|
// self.$.colorbar.setContent (c);
|
||||||
|
@ -72,7 +72,15 @@ DisasmPanel.prototype.handleInputTextChange = function() {
|
|||||||
if (this.renaming !== null && this.rbox.value.length > 0) {
|
if (this.renaming !== null && this.rbox.value.length > 0) {
|
||||||
if ($(this.selected).hasClass('insaddr')) {
|
if ($(this.selected).hasClass('insaddr')) {
|
||||||
var old_value = get_offset_flag(r2ui._dis.selected_offset);
|
var old_value = get_offset_flag(r2ui._dis.selected_offset);
|
||||||
rename(r2ui._dis.selected_offset, old_value, this.rbox.value, "offsets");
|
var type = "offsets";
|
||||||
|
r2.cmdj("afij @ " + r2ui._dis.selected_offset, function(x) {
|
||||||
|
if (x !== null && x !== undefined) {
|
||||||
|
if ("0x" + x[0].offset.toString(16) === r2ui._dis.selected_offset) {
|
||||||
|
type = "functions";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
rename(r2ui._dis.selected_offset, old_value, this.rbox.value, type);
|
||||||
} else if ($(this.selected).hasClass('faddr')) {
|
} else if ($(this.selected).hasClass('faddr')) {
|
||||||
if ($(this.selected).hasClass('fvar'))
|
if ($(this.selected).hasClass('fvar'))
|
||||||
r2.cmd("afvn " + r2ui._dis.renameOldValue + " " + r2ui._dis.rbox.value + " @ " + r2ui._dis.selected_offset, function(x){});
|
r2.cmd("afvn " + r2ui._dis.renameOldValue + " " + r2ui._dis.rbox.value + " @ " + r2ui._dis.selected_offset, function(x){});
|
||||||
|
@ -15,48 +15,48 @@ $(document).ready( function() {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Layout
|
// Layout
|
||||||
myLayout = $('body').layout({
|
myLayout = $('body').layout({
|
||||||
west__size: 200,
|
west__size: 200,
|
||||||
east__size: 200,
|
east__size: 200,
|
||||||
south__size: 200,
|
south__size: 200,
|
||||||
north__resizable: false,
|
north__resizable: false,
|
||||||
center__onresize: function () {if (r2ui._dis.display == "graph" && r2ui._dis.minimap) update_minimap();},
|
center__onresize: function () {if (r2ui._dis.display == "graph" && r2ui._dis.minimap) update_minimap();},
|
||||||
west__onresize: $.layout.callbacks.resizePaneAccordions,
|
west__onresize: $.layout.callbacks.resizePaneAccordions,
|
||||||
east__onresize: $.layout.callbacks.resizePaneAccordions
|
east__onresize: $.layout.callbacks.resizePaneAccordions
|
||||||
});
|
});
|
||||||
// myLayout.disableClosable("north", true);
|
// myLayout.disableClosable("north", true);
|
||||||
$("#accordion1").accordion({ heightStyle: "fill" });
|
$("#accordion1").accordion({ heightStyle: "fill" });
|
||||||
$("#accordion2").accordion({ heightStyle: "fill" });
|
$("#accordion2").accordion({ heightStyle: "fill" });
|
||||||
|
|
||||||
// Boot r2 analysis, settings, ....
|
// Boot r2 analysis, settings, ....
|
||||||
r2.update_flags();
|
r2.update_flags();
|
||||||
r2.analAll();
|
r2.analAll();
|
||||||
r2.load_mmap();
|
r2.load_mmap();
|
||||||
r2ui.load_colors();
|
r2ui.load_colors();
|
||||||
r2.load_settings();
|
r2.load_settings();
|
||||||
load_binary_details();
|
load_binary_details();
|
||||||
|
|
||||||
// Create panels
|
// Create panels
|
||||||
var disasm_panel = new DisasmPanel();
|
var disasm_panel = new DisasmPanel();
|
||||||
var hex_panel = new HexPanel();
|
var hex_panel = new HexPanel();
|
||||||
var entropy_panel = new EntropyPanel();
|
var entropy_panel = new EntropyPanel();
|
||||||
var strings_panel = new StringsPanel();
|
var strings_panel = new StringsPanel();
|
||||||
var settings_panel = new SettingsPanel();
|
var settings_panel = new SettingsPanel();
|
||||||
var projects_panel = new ProjectsPanel();
|
var projects_panel = new ProjectsPanel();
|
||||||
r2ui._ent = entropy_panel;
|
r2ui._ent = entropy_panel;
|
||||||
r2ui._dis = disasm_panel;
|
r2ui._dis = disasm_panel;
|
||||||
r2ui._str = strings_panel;
|
r2ui._str = strings_panel;
|
||||||
r2ui._set = settings_panel;
|
r2ui._set = settings_panel;
|
||||||
r2ui._hex = hex_panel;
|
r2ui._hex = hex_panel;
|
||||||
r2ui._prj = projects_panel;
|
r2ui._prj = projects_panel;
|
||||||
|
|
||||||
// For enyo compatibility
|
// For enyo compatibility
|
||||||
r2ui.ra = {};
|
r2ui.ra = {};
|
||||||
r2ui.mp = {};
|
r2ui.mp = {};
|
||||||
r2ui.ra.getIndex = function() {};
|
r2ui.ra.getIndex = function() {};
|
||||||
r2ui.ra.setIndex = function() {};
|
r2ui.ra.setIndex = function() {};
|
||||||
r2ui.mp.openPage = function() {};
|
r2ui.mp.openPage = function() {};
|
||||||
|
|
||||||
var console_history = [];
|
var console_history = [];
|
||||||
var console_history_idx = 0;
|
var console_history_idx = 0;
|
||||||
@ -231,7 +231,7 @@ $(document).ready( function() {
|
|||||||
do_jumpto(address);
|
do_jumpto(address);
|
||||||
}
|
}
|
||||||
switch (ui.cmd) {
|
switch (ui.cmd) {
|
||||||
case "goto": do_goto(); break;
|
case "goto": do_goto(); break;
|
||||||
case "comment": do_comment(target); break;
|
case "comment": do_comment(target); break;
|
||||||
case "rename": do_rename(target, event); break;
|
case "rename": do_rename(target, event); break;
|
||||||
case "define": do_define(target); break;
|
case "define": do_define(target); break;
|
||||||
@ -267,9 +267,9 @@ $(document).ready( function() {
|
|||||||
$(document).dblclick(handleDoubleClick);
|
$(document).dblclick(handleDoubleClick);
|
||||||
|
|
||||||
// Show disasm panel and seek to entrypoint
|
// Show disasm panel and seek to entrypoint
|
||||||
disasm_panel.display_flat();
|
disasm_panel.display_flat();
|
||||||
r2ui.seek(disasm_panel.base,true);
|
r2ui.seek(disasm_panel.base,true);
|
||||||
scroll_to_element(r2ui._dis.selected);
|
scroll_to_element(r2ui._dis.selected);
|
||||||
|
|
||||||
$("#center_panel").scroll(on_scroll);
|
$("#center_panel").scroll(on_scroll);
|
||||||
|
|
||||||
@ -298,7 +298,7 @@ function scroll_to_last_offset() {
|
|||||||
|
|
||||||
// key handler
|
// key handler
|
||||||
function handleKeypress(inEvent) {
|
function handleKeypress(inEvent) {
|
||||||
var keynum = inEvent.keyCode || inEvent.charCode || inEvent.which || 0;
|
var keynum = inEvent.keyCode || inEvent.charCode || inEvent.which || 0;
|
||||||
var key = String.fromCharCode(keynum);
|
var key = String.fromCharCode(keynum);
|
||||||
// console.log(key);
|
// console.log(key);
|
||||||
if ($(inEvent.target).prop("tagName") === "INPUT") {
|
if ($(inEvent.target).prop("tagName") === "INPUT") {
|
||||||
@ -307,22 +307,22 @@ function handleKeypress(inEvent) {
|
|||||||
|
|
||||||
if (r2ui._dis.renaming !== null) return;
|
if (r2ui._dis.renaming !== null) return;
|
||||||
|
|
||||||
// Spacebar Switch flat and graph views
|
// Spacebar Switch flat and graph views
|
||||||
if (key === ' ') {
|
if (key === ' ') {
|
||||||
do_switchview();
|
do_switchview();
|
||||||
inEvent.preventDefault();
|
inEvent.preventDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (key === 'm' && r2ui._dis.display == "graph") toggle_minimap();
|
if (key === 'm' && r2ui._dis.display == "graph") toggle_minimap();
|
||||||
|
|
||||||
// h Seek to previous address in history
|
// h Seek to previous address in history
|
||||||
if (key === 'h') do_jumpto(r2ui.history_prev());
|
if (key === 'h') do_jumpto(r2ui.history_prev());
|
||||||
|
|
||||||
// l Seek to next address in history
|
// l Seek to next address in history
|
||||||
if (key === 'l') do_jumpto(r2ui.history_next());
|
if (key === 'l') do_jumpto(r2ui.history_next());
|
||||||
|
|
||||||
// j Seek to next Instruction
|
// j Seek to next Instruction
|
||||||
if (key === 'j') {
|
if (key === 'j') {
|
||||||
var get_more_instructions = false;
|
var get_more_instructions = false;
|
||||||
if ($(r2ui._dis.selected).hasClass("insaddr")) {
|
if ($(r2ui._dis.selected).hasClass("insaddr")) {
|
||||||
var next_instruction;
|
var next_instruction;
|
||||||
@ -350,9 +350,9 @@ function handleKeypress(inEvent) {
|
|||||||
rehighlight_iaddress(address);
|
rehighlight_iaddress(address);
|
||||||
scroll_to_address(address);
|
scroll_to_address(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// k Seek to previous instruction
|
// k Seek to previous instruction
|
||||||
if (key === 'k') {
|
if (key === 'k') {
|
||||||
var get_more_instructions = false;
|
var get_more_instructions = false;
|
||||||
if ($(r2ui._dis.selected).hasClass("insaddr")) {
|
if ($(r2ui._dis.selected).hasClass("insaddr")) {
|
||||||
var prev_instruction;
|
var prev_instruction;
|
||||||
@ -378,41 +378,41 @@ function handleKeypress(inEvent) {
|
|||||||
rehighlight_iaddress(address);
|
rehighlight_iaddress(address);
|
||||||
scroll_to_address(address);
|
scroll_to_address(address);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// c Define function
|
// c Define function
|
||||||
if (key === 'c') do_define(r2ui._dis.selected);
|
if (key === 'c') do_define(r2ui._dis.selected);
|
||||||
|
|
||||||
// u Clear function metadata
|
// u Clear function metadata
|
||||||
if (key === 'u') do_undefine(r2ui._dis.selected);
|
if (key === 'u') do_undefine(r2ui._dis.selected);
|
||||||
|
|
||||||
// g Go to address
|
// g Go to address
|
||||||
if (key === 'g') do_jumpto(prompt('Go to'));
|
if (key === 'g') do_jumpto(prompt('Go to'));
|
||||||
|
|
||||||
// ; Add comment
|
// ; Add comment
|
||||||
if (key === ';') do_comment(r2ui._dis.selected);
|
if (key === ';') do_comment(r2ui._dis.selected);
|
||||||
|
|
||||||
// n Rename
|
// n Rename
|
||||||
if (key === 'n') do_rename(r2ui._dis.selected, inEvent);
|
if (key === 'n') do_rename(r2ui._dis.selected, inEvent);
|
||||||
|
|
||||||
if (key === 'R') do_randomcolors();
|
if (key === 'R') do_randomcolors();
|
||||||
|
|
||||||
// esc
|
// esc
|
||||||
if (keynum === 27) {
|
if (keynum === 27) {
|
||||||
// Esc belongs to renaming
|
// Esc belongs to renaming
|
||||||
if(r2ui._dis.renaming !== null) {
|
if(r2ui._dis.renaming !== null) {
|
||||||
r2ui._dis.renaming.innerHTML = r2ui._dis.renameOldValue;
|
r2ui._dis.renaming.innerHTML = r2ui._dis.renameOldValue;
|
||||||
r2ui._dis.renaming = null;
|
r2ui._dis.renaming = null;
|
||||||
} else {
|
} else {
|
||||||
// go back in history
|
// go back in history
|
||||||
var addr = r2ui.history_prev();
|
var addr = r2ui.history_prev();
|
||||||
if (addr !== undefined && addr !== null) r2ui.seek(addr, false);
|
if (addr !== undefined && addr !== null) r2ui.seek(addr, false);
|
||||||
scroll_to_address(addr);
|
scroll_to_address(addr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// enter
|
// enter
|
||||||
if (keynum === 13) {
|
if (keynum === 13) {
|
||||||
r2ui._dis.goToAddress();
|
r2ui._dis.goToAddress();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_switchview() {
|
function do_switchview() {
|
||||||
@ -429,14 +429,14 @@ function do_jumpto(address) {
|
|||||||
var element = $('.insaddr.addr_' + address);
|
var element = $('.insaddr.addr_' + address);
|
||||||
if (element.length > 0) {
|
if (element.length > 0) {
|
||||||
r2ui.history_push(address);
|
r2ui.history_push(address);
|
||||||
r2ui._dis.selected = element;
|
r2ui._dis.selected = element[0];
|
||||||
r2ui._dis.selected_offset = address;
|
r2ui._dis.selected_offset = address;
|
||||||
render_history();
|
render_history();
|
||||||
} else {
|
} else {
|
||||||
r2ui.seek(address, true);
|
r2ui.seek(address, true);
|
||||||
}
|
}
|
||||||
rehighlight_iaddress(r2ui._dis.tmp_address);
|
rehighlight_iaddress(address);
|
||||||
scroll_to_address(r2ui._dis.tmp_address);
|
scroll_to_address(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
function do_rename(element, inEvent) {
|
function do_rename(element, inEvent) {
|
||||||
|
@ -9,9 +9,8 @@ StringsPanel.prototype.render = function() {
|
|||||||
var data = [];
|
var data = [];
|
||||||
for (var i in strings) {
|
for (var i in strings) {
|
||||||
var f = strings[i];
|
var f = strings[i];
|
||||||
f.string = decodeURI (f.string);
|
|
||||||
var fd = {
|
var fd = {
|
||||||
label: decodeURIComponent(f.string),
|
label: atob(f.string),
|
||||||
children: [
|
children: [
|
||||||
{label: "vaddr: " + "0x" + f.vaddr.toString(16)},
|
{label: "vaddr: " + "0x" + f.vaddr.toString(16)},
|
||||||
{label: "paddr: " + "0x" + f.paddr.toString(16)},
|
{label: "paddr: " + "0x" + f.paddr.toString(16)},
|
||||||
|
Loading…
Reference in New Issue
Block a user