mirror of
https://github.com/rizinorg/cutter.git
synced 2024-12-20 20:06:12 +00:00
commit
416ed82149
@ -20,21 +20,6 @@
|
|||||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/disasm.js"></script>
|
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/disasm.js"></script>
|
||||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/jquery-1.9.0.js"></script>
|
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/jquery-1.9.0.js"></script>
|
||||||
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/graph_panel.js"></script>
|
<script type="text/javascript" src="qrc:/graph/html/graph/lib/js/graph_panel.js"></script>
|
||||||
<script type="text/javascript">
|
|
||||||
function init(theme) {
|
|
||||||
// Load r2 settings (TODO: Do we need this?)
|
|
||||||
r2.load_settings();
|
|
||||||
|
|
||||||
// Initialize and render graph
|
|
||||||
r2ui.graph_panel = new GraphPanel();
|
|
||||||
if (r2ui.graph_panel != null) {
|
|
||||||
r2ui.graph_panel.seek(location.hash.substring(1));
|
|
||||||
r2ui.graph_panel.init_handlers();
|
|
||||||
if (theme == "dark") r2ui.graph_panel.render("dark");
|
|
||||||
else r2ui.graph_panel.render("light");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</head>
|
</head>
|
||||||
<body style="margin: 0px">
|
<body style="margin: 0px">
|
||||||
|
|
||||||
@ -44,6 +29,5 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
@ -4,6 +4,21 @@ SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformTo
|
|||||||
return toElement.getScreenCTM().inverse().multiply(this.getScreenCTM());
|
return toElement.getScreenCTM().inverse().multiply(this.getScreenCTM());
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function init_panel(theme) {
|
||||||
|
// Load r2 settings (TODO: Do we need this?)
|
||||||
|
r2.load_settings();
|
||||||
|
|
||||||
|
// Initialize and render graph
|
||||||
|
r2ui.graph_panel = new GraphPanel();
|
||||||
|
if (r2ui.graph_panel != null) {
|
||||||
|
r2ui.graph_panel.seek(location.hash.substring(1));
|
||||||
|
r2ui.graph_panel.init_handlers();
|
||||||
|
if (theme == "dark") r2ui.graph_panel.render("dark");
|
||||||
|
else r2ui.graph_panel.render("light");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// Basic Block Graph
|
// Basic Block Graph
|
||||||
var BBGraph = function () {
|
var BBGraph = function () {
|
||||||
this.vertices = {};
|
this.vertices = {};
|
||||||
@ -174,20 +189,11 @@ BBGraph.prototype.render = function() {
|
|||||||
if (hs > ws) delta = (minimap_width/2) - svg_width*scale/2;
|
if (hs > ws) delta = (minimap_width/2) - svg_width*scale/2;
|
||||||
minimap.scale(scale);
|
minimap.scale(scale);
|
||||||
minimap.setOrigin(delta,0);
|
minimap.setOrigin(delta,0);
|
||||||
// minimap.$el.css('pointer-events', 'none');
|
minimap.$el.css('pointer-events', 'none');
|
||||||
|
|
||||||
$("#minimap").css("left", $("#main_panel").width() - minimap_width);
|
$("#minimap").css("left", $("#main_panel").width() - minimap_width);
|
||||||
$("#minimap").css("top", $("#center_panel").position().top - 40);
|
$("#minimap").css("top", $("#center_panel").position().top - 40);
|
||||||
// $("#center_panel").bind('scroll', update_minimap);
|
|
||||||
// $("#main_panel").bind('scroll', update_minimap);
|
|
||||||
// $("#disasm_tab").bind('scroll', update_minimap);
|
|
||||||
// $("#minimap").bind('scroll', update_minimap);
|
|
||||||
// $("#canvas").bind('scroll', update_minimap);
|
|
||||||
document.addEventListener('scroll', function (event) {
|
document.addEventListener('scroll', function (event) {
|
||||||
//if (event.target.id === 'idOfUl') { // or any other filtering condition
|
if (event.target.id === 'main_panel') update_minimap();
|
||||||
console.log('scrolling', event.target);
|
|
||||||
update_minimap();
|
|
||||||
//}
|
|
||||||
}, true /*Capture event*/);
|
}, true /*Capture event*/);
|
||||||
|
|
||||||
paper.on( "cell:pointerup", function( cellview, evt, x, y) {
|
paper.on( "cell:pointerup", function( cellview, evt, x, y) {
|
||||||
@ -269,6 +275,8 @@ function update_minimap() {
|
|||||||
var left_offset = el.scrollLeft()*scale + delta;
|
var left_offset = el.scrollLeft()*scale + delta;
|
||||||
if (mma_width > minimap_width - left_offset) mma_width = minimap_width - left_offset;
|
if (mma_width > minimap_width - left_offset) mma_width = minimap_width - left_offset;
|
||||||
if (mma_height > minimap_height - top_offset) mma_height = minimap_height - top_offset;
|
if (mma_height > minimap_height - top_offset) mma_height = minimap_height - top_offset;
|
||||||
|
if (left_offset > minimap_width) left_offset = minimap_width
|
||||||
|
if (top_offset > minimap_height) top_offset = minimap_height;
|
||||||
$("#minimap_area").width(mma_width);
|
$("#minimap_area").width(mma_width);
|
||||||
$("#minimap_area").height(mma_height);
|
$("#minimap_area").height(mma_height);
|
||||||
$("#minimap_area").css("top", top_offset);
|
$("#minimap_area").css("top", top_offset);
|
||||||
|
@ -26,142 +26,11 @@ GraphPanel.prototype.init_handlers = function() {
|
|||||||
$(document).unbind("dblclick");
|
$(document).unbind("dblclick");
|
||||||
|
|
||||||
// Bind custom functions to mouse and key events
|
// Bind custom functions to mouse and key events
|
||||||
//$("#center_panel").scroll(on_scroll);
|
|
||||||
//$(document).keypress(handleKeypress);
|
//$(document).keypress(handleKeypress);
|
||||||
$(document).click(handleClick);
|
$(document).click(handleClick);
|
||||||
$(document).dblclick(handleDoubleClick);
|
$(document).dblclick(handleDoubleClick);
|
||||||
};
|
};
|
||||||
|
|
||||||
GraphPanel.prototype.init_context_menu = function() {
|
|
||||||
// Context menu for disas addresses:
|
|
||||||
$(document).contextmenu({
|
|
||||||
delegate: ".addr",
|
|
||||||
menu: [
|
|
||||||
{title: "jump to address<kbd>g</kbd>", cmd: "goto"},
|
|
||||||
{title: "rename<kbd>n</kbd>", cmd: "rename"},
|
|
||||||
{title: "add comment<kbd>;</kbd>", cmd: "comment"},
|
|
||||||
{title: "code<kbd>c</kbd>", cmd: "define"},
|
|
||||||
{title: "undefine<kbd>u</kbd>", cmd: "undefine"},
|
|
||||||
{title: "random colors<kbd>R</kbd>", cmd: "randomcolors"},
|
|
||||||
{title: "switch disasm/graph<kbd>s</kbd>", cmd: "switchview"}
|
|
||||||
],
|
|
||||||
preventSelect: true,
|
|
||||||
taphold: true,
|
|
||||||
preventContextMenuForPopup: true,
|
|
||||||
show: false,
|
|
||||||
position: function(event, ui){
|
|
||||||
return {my: "left+100 top-10", at: "left bottom", of: ui.target};
|
|
||||||
},
|
|
||||||
beforeOpen: function(event, ui) {
|
|
||||||
var address = get_address_from_class(ui.target[0]);
|
|
||||||
var xrefs_to = [];
|
|
||||||
var xrefs_from = [];
|
|
||||||
var xrefto_submenu = null;
|
|
||||||
var xreffrom_submenu = null;
|
|
||||||
var refs = [];
|
|
||||||
var addr = "";
|
|
||||||
var type = "";
|
|
||||||
r2.cmd("axf @" + address, function(x){
|
|
||||||
var lines = x.split('\n');
|
|
||||||
for (var l in lines) {
|
|
||||||
if (lines[l] !== "") xrefs_to[xrefs_to.length] = lines[l];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (xrefs_to.length > 0) {
|
|
||||||
$(document).contextmenu("showEntry", "xrefs_to", true);
|
|
||||||
refs = [];
|
|
||||||
for (var r in xrefs_to) {
|
|
||||||
addr = xrefs_to[r].split(' ')[1];
|
|
||||||
type = xrefs_to[r].split(' ')[0];
|
|
||||||
refs[refs.length] = {title: addr + "<kbd>" + type + "</kbd>", cmd: "jumpto_" + addr};
|
|
||||||
}
|
|
||||||
xrefto_submenu = {title: "xrefs to", children: refs};
|
|
||||||
}
|
|
||||||
r2.cmd("axt @" + address, function(x){
|
|
||||||
var lines = x.split('\n');
|
|
||||||
for (var l in lines) {
|
|
||||||
if (lines[l] !== "") xrefs_from[xrefs_from.length] = lines[l];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
if (xrefs_from.length > 0) {
|
|
||||||
$(document).contextmenu("showEntry", "xrefs_from", true);
|
|
||||||
refs = [];
|
|
||||||
for (var r in xrefs_from) {
|
|
||||||
addr = xrefs_from[r].split(' ')[1];
|
|
||||||
type = xrefs_from[r].split(' ')[0];
|
|
||||||
refs[refs.length] = {title: addr + "<kbd>" + type + "</kbd>", cmd: "jumpto_" + addr};
|
|
||||||
}
|
|
||||||
xreffrom_submenu = {title: "xrefs from", children: refs};
|
|
||||||
}
|
|
||||||
var menu = [
|
|
||||||
{title: "jump to address<kbd>g</kbd>", cmd: "goto"},
|
|
||||||
{title: "rename<kbd>n</kbd>", cmd: "rename"},
|
|
||||||
{title: "add comment<kbd>;</kbd>", cmd: "comment"},
|
|
||||||
{title: "code<kbd>c</kbd>", cmd: "define"},
|
|
||||||
{title: "undefine<kbd>u</kbd>", cmd: "undefine"},
|
|
||||||
{title: "random colors<kbd>R</kbd>", cmd: "randomcolors"},
|
|
||||||
{title: "switch disasm/graph<kbd>s</kbd>", cmd: "switchview"}
|
|
||||||
];
|
|
||||||
if (xreffrom_submenu !== null || xrefto_submenu !== null) {
|
|
||||||
if (xrefto_submenu !== null) menu[menu.length] = xrefto_submenu;
|
|
||||||
if (xreffrom_submenu !== null) menu[menu.length] = xreffrom_submenu;
|
|
||||||
}
|
|
||||||
$(document).contextmenu("replaceMenu", menu);
|
|
||||||
|
|
||||||
r2.cmdj("pdj 1 @" + address, function(x) {
|
|
||||||
if(x) {
|
|
||||||
if(x[0].fcn_addr == x[0].offset) {
|
|
||||||
$(document).contextmenu("showEntry", "define", false);
|
|
||||||
$(document).contextmenu("showEntry", "undefine", true);
|
|
||||||
} else {
|
|
||||||
$(document).contextmenu("showEntry", "define", true);
|
|
||||||
$(document).contextmenu("showEntry", "undefine", false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if (ui.target.hasClass('insaddr')) {
|
|
||||||
$(document).contextmenu("showEntry", "comment", true);
|
|
||||||
$(document).contextmenu("showEntry", "rename", true);
|
|
||||||
} else {
|
|
||||||
$(document).contextmenu("showEntry", "comment", false);
|
|
||||||
$(document).contextmenu("showEntry", "rename", true);
|
|
||||||
$(document).contextmenu("showEntry", "define", false);
|
|
||||||
$(document).contextmenu("showEntry", "undefine", false);
|
|
||||||
}
|
|
||||||
if (ui.target.hasClass('reloc') || ui.target.hasClass('symbol') || ui.target.hasClass('import')) {
|
|
||||||
$(document).contextmenu("showEntry", "comment", false);
|
|
||||||
$(document).contextmenu("showEntry", "rename", false);
|
|
||||||
$(document).contextmenu("showEntry", "define", false);
|
|
||||||
$(document).contextmenu("showEntry", "undefine", false);
|
|
||||||
}
|
|
||||||
// Context manu on disasm panel
|
|
||||||
if (!$.contains($("#disasm_tab")[0], ui.target[0])) {
|
|
||||||
$(document).contextmenu("showEntry", "switchview", false);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
select: function(event, ui) {
|
|
||||||
$(document).contextmenu("close");
|
|
||||||
var target = ui.target[0];
|
|
||||||
var address = get_address_from_class(target);
|
|
||||||
if (ui.cmd.indexOf("jumpto_") === 0) {
|
|
||||||
address = ui.cmd.substring(ui.cmd.indexOf("jumpto_") + 7);
|
|
||||||
do_jumpto(address);
|
|
||||||
}
|
|
||||||
switch (ui.cmd) {
|
|
||||||
case "goto": do_goto(); break;
|
|
||||||
case "comment": do_comment(target); break;
|
|
||||||
case "rename": do_rename(target, event); break;
|
|
||||||
case "define": do_define(target); break;
|
|
||||||
//case "undefine": do_undefine(target); break;
|
|
||||||
case "randomcolors": do_randomcolors(target); break;
|
|
||||||
//case "switchview": do_switchview(target); break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
GraphPanel.prototype.render = function(theme) {
|
GraphPanel.prototype.render = function(theme) {
|
||||||
|
|
||||||
// Set theme
|
// Set theme
|
||||||
|
@ -1561,9 +1561,9 @@ void MemoryWidget::create_graph(QString off)
|
|||||||
QSettings settings;
|
QSettings settings;
|
||||||
if (settings.value("dark").toBool())
|
if (settings.value("dark").toBool())
|
||||||
{
|
{
|
||||||
ui->graphWebView->page()->runJavaScript(QString("init('dark');"));
|
ui->graphWebView->page()->runJavaScript(QString("init_panel('dark');"));
|
||||||
} else {
|
} else {
|
||||||
ui->graphWebView->page()->runJavaScript(QString("init('light');"));
|
ui->graphWebView->page()->runJavaScript(QString("init_panel('light');"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user