From 836b4625e1159deca85028434a9bc9f0f90af57e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alvaro=20Mun=CC=83oz?= Date: Mon, 9 Feb 2015 01:44:27 +0100 Subject: [PATCH] allow rename functions in main offset --- shlr/www/enyo/index.js | 6 +- shlr/www/enyo/js/disasm.js | 4 +- shlr/www/enyo/js/disassembler.js | 16 +++- shlr/www/p/lib/js/disasm_panel.js | 10 ++- shlr/www/p/lib/js/main.js | 138 ++++++++++++++--------------- shlr/www/p/lib/js/strings_panel.js | 3 +- 6 files changed, 97 insertions(+), 80 deletions(-) diff --git a/shlr/www/enyo/index.js b/shlr/www/enyo/index.js index a5495bba85..eaff82f953 100644 --- a/shlr/www/enyo/index.js +++ b/shlr/www/enyo/index.js @@ -1,6 +1,6 @@ -enyo.kind({name:"About",kind:"Scroller",style:"background-color:#303030",components:[{tag:"center",components:[{tag:"h1",style:"color:#f0f0f0",content:"r2wui"},{kind:"Image",src:"icon.png"},{tag:"h3",style:"color:#707070;margin-bottom:50px",content:"the web frontend for radare2"},{tag:"h2",style:"color:#a0a0a0",content:"author: pancake 2013-2014"},{tag:"h2",style:"color:#a0a0a0",content:"version: ???",name:"vertext"},{tag:"h2",style:"color:#a0a0a0",content:"revision: ???",name:"revtext"}]}],create:function(){this.inherited(arguments);(function(me){setTimeout(function(){r2.cmd("?V",function(v){var version=v.split(" ")[0];var revision=v.split(" ")[2];me.$.vertext.setContent("version: "+version);me.$.revtext.setContent("revision: "+revision)})},1e3)})(this)}});enyo.kind({name:"Assembler",kind:"Scroller",classes:"r2panel",style:"background-color:#c0c0c0;",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:"font",content:"opcode",classes:"r2ui-input",style:"width:64px;font-weight:bold"},{kind:"Input",value:"",style:"width:60%",onkeydown:"assembleOpcode",attributes:{autocapitalize:"off"},name:"opcode"}]},{kind:"onyx.InputDecorator",classes:"r2ui-input",components:[{tag:"font",content:"bytes",classes:"r2ui-input",style:"width:64px;font-weight:bold"},{kind:"Input",value:"",style:"width:120px",onkeydown:"assembleOpcode",attributes:{autocapitalize:"off"},name:"bytes"}]},{kind:"onyx.InputDecorator",classes:"r2ui-input",components:[{tag:"font",content:"offset",classes:"r2ui-input",style:"width:64px;font-weight:bold"},{kind:"Input",value:"entry0",style:"width:120px",onkeydown:"assembleOpcode",attributes:{autocapitalize:"off"},name:"offset"}]}]}]},{tag:"form",style:"margin-top:8px;margin-left:8px",attributes:{action:"javascript:#"},components:[{tag:"h2",content:"Calculator"},{kind:"onyx.InputDecorator",classes:"r2ui-input",components:[{tag:"font",name:"value",content:"0",classes:"r2ui-input",style:"width:200px;font-weight:bold"},{kind:"Input",name:"ivalue",value:"0",style:"width:300",onkeydown:"calculateValue",attributes:{autocapitalize:"off"}}]}]}],calculateValue:function(inSender,inEvent){if(inEvent.keyCode===13){var v=this.$.value;var val=inSender.getValue();v.setContent("...");r2.cmd("?v "+val,function(x){v.setContent(x)})}},assembleOpcode:function(inSender,inEvent){if(inEvent.keyCode===13){var arg=inSender.getValue();var off=this.$.offset.getValue();switch(inSender.name){case"opcode":var hex=this.$.bytes;r2.assemble(off,arg,function(bytes){hex.setValue(bytes)});break;case"bytes":var op=this.$.opcode;r2.disassemble(off,arg,function(x){op.setValue(x)});break;case"offset":break}}}});var Config={keys:{1:"this.setIndex(0)",2:"this.setIndex(1)",3:"this.setIndex(2)"}};enyo.kind({name:"Console",kind:"Scroller",classes:"r2panel",style:"background-color:#c0c0c0;padding-left:7px",components:[{tag:"form",attributes:{action:"javascript:#"},components:[{kind:"FittableRows",fit:true,classes:"fittable-sample-shadow",components:[{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"}]}]}],runCommand:function(inSender,inEvent){if(inEvent.keyCode===13){var cmd=this.$.input.getValue();this.$.input.setValue("");(function(out){r2.cmd(cmd,function(x){out.setContent(x)})})(this.$.output)}}});enyo.kind({name:"Debugger",kind:"Scroller",style:"background-color:#303030",components:[{tag:"center",components:[{tag:"h1",style:"color:#f0f0f0",content:"TODO: Debugger"}]}]});var BBGraph=function(){this.vertices={};this.edges=[];this.elements=[];this.links=[];this.fcn_offset=0;joint.shapes.html={};joint.shapes.html.Element=joint.shapes.basic.Rect.extend({defaults:joint.util.deepSupplement({type:"html.Element",attrs:{rect:{stroke:r2ui.colors[".ec_gui_border"],fill:r2ui.colors[".ec_gui_alt_background"]}}},joint.shapes.basic.Rect.prototype.defaults)});joint.shapes.html.ElementView=joint.dia.ElementView.extend({initialize:function(){_.bindAll(this,"updateBox");joint.dia.ElementView.prototype.initialize.apply(this,arguments);this.$box=$(_.template(this.model.get("html"))());this.$box.find("input").on("mousedown click",function(evt){evt.stopPropagation()});this.model.on("change",this.updateBox,this);this.updateBox()},render:function(){joint.dia.ElementView.prototype.render.apply(this,arguments);this.paper.$el.prepend(this.$box);this.updateBox();return this},updateBox:function(event){var bbox=this.model.getBBox();this.$box.css({width:bbox.width+2,height:bbox.height,left:bbox.x-1,top:bbox.y+7})}})};BBGraph.prototype.addVertex=function(addr,vlen,dom){if(this.vertices[addr]===undefined){this.vertices[addr]={};this.vertices[addr].parents=[];this.vertices[addr].children=[];if(vlen===undefined){this.vertices[addr].len=1;var dom=document.createElement("div");dom.id="bb_"+addr;dom.className="basicblock enyo-selectable ec_gui_background ec_gui_border";dom.innerHTML="
0x"+addr.toString(16)+"
";this.vertices[addr].rendered=dom}}if(vlen!==undefined){this.vertices[addr].len=vlen;this.vertices[addr].rendered=dom}};BBGraph.prototype.addEdge=function(v1,v2,color){this.addVertex(v1);this.addVertex(v2);this.edges.push({from:v1,to:v2,color:color});this.vertices[v1].children.push(v2);this.vertices[v2].parents.push(v1)};BBGraph.prototype.makeElement=function(addr,width,height,html){this.elements.push(new joint.shapes.html.Element({id:String(addr),size:{width:width,height:height},html:html}))};BBGraph.prototype.makeLink=function(v1,v2,color){this.links.push(new joint.dia.Link({source:{id:String(v1)},target:{id:String(v2)},attrs:{".marker-target":{d:"M 4 0 L 0 2 L 4 4 z",fill:color,stroke:color},".connection":{"stroke-width":1,stroke:color}},smooth:true}))};BBGraph.prototype.render=function(){var name=Object.keys(this.vertices).toString();var outergbox=document.createElement("div");outergbox.id="outergbox";var bbcanvas=document.getElementById("canvas");var gbox=document.createElement("div");gbox.id="gbox";gbox.className=name;outergbox.appendChild(gbox);bbcanvas.appendChild(outergbox);for(var addr in this.vertices){var r=this.vertices[addr].rendered;if(r!==undefined){gbox.appendChild(r);this.makeElement(addr,r.offsetWidth,r.offsetHeight,r.outerHTML)}}for(var j=0;j");var items=this.elements.concat(this.links);var width=$("#center_panel").width();var graph=new joint.dia.Graph;var paper=new joint.dia.Paper({el:$("#canvas"),gridSize:1,width:2e3,height:6e3,model:graph});var minimap_width=200;var minimap_heigh=200;$("#minimap").html("");$("#minimap").html("");var minimap=new joint.dia.Paper({el:$("#minimap"),gridSize:1,width:minimap_width,height:minimap_heigh,model:graph});graph.resetCells(items);joint.layout.DirectedGraph.layout(graph);r2ui.graph=graph;reposition_graph();$("#minimap .basicblock").remove();graph.getCell("minimap_area").attr({rect:{stroke:"transparent"}});var svg_width=$("#canvas svg")[0].getBBox().width;var svg_height=$("#canvas svg")[0].getBBox().height;paper.setDimensions(svg_width+500,svg_height+500);var ws=Math.ceil(svg_width/minimap_width);var hs=Math.ceil(svg_height/minimap_heigh);var scale=1/Math.max(ws,hs);var delta=0;if(hs>ws)delta=minimap_width/2-svg_width*scale/2;minimap.scale(scale);minimap.setOrigin(delta,0);if($("#radareApp_mp").length){$("#minimap").css("left",$("#main_panel").width()-minimap_width-$("#main_panel").position().left);$("#minimap").css("top",$("#center_panel").position().top);$("#main_panel").bind("scroll",update_minimap)}else if($("#main_panel").length){$("#minimap").css("left",$("#main_panel").width()-minimap_width);$("#minimap").css("top",$("#center_panel").position().top-40);$("#center_panel").bind("scroll",update_minimap)}paper.on("cell:pointerup",function(cellview,evt,x,y){var model=cellview.model;var bbox=model.attributes.position;var id=String(model.prop("id"));if(model!==undefined&&id!=="minimap_area"){var color=null;var bb=r2ui.get_fcn_BB(r2ui.current_fcn_offset,id);if(bb!==undefined&&bb!==null){if(bb.x!=String(bbox.x)||bb.y!=String(bbox.y)){bb.x=bbox.x;bb.y=bbox.y;r2ui.update_fcn_BB(r2ui.current_fcn_offset,id,bb)}}else if(bb!==undefined&&bb!==null){r2ui.update_fcn_BB(r2ui.current_fcn_offset,id,{x:bbox.x,y:bbox.y})}}});if(r2ui._dis.minimap){update_minimap();$("#minimap_area").draggable({containment:"parent",stop:function(event,ui){var delta_x=ui.position.left/scale;var delta_y=ui.position.top/scale;if(delta_x<0)delta_x=0;if(delta_y<0)delta_y=0;if($("#radareApp_mp").length)$("#main_panel").scrollTo({top:delta_y,left:delta_x-delta/scale});else $("#center_panel").scrollTo({top:delta_y,left:delta_x-delta/scale})}})}else{$("#minimap").hide()}};function toggle_minimap(){if(r2ui._dis.minimap){r2ui._dis.minimap=false;r2ui.seek(r2ui._dis.selected_offset,false);$("#minimap").hide()}else{r2ui._dis.minimap=true;r2ui.seek(r2ui._dis.selected_offset,false);$("#minimap").show()}}function update_minimap(){if(r2ui._dis.minimap&&$("#canvas svg").length){var minimap_width=200;var minimap_height=200;var svg_width=$("#canvas svg")[0].getBBox().width;var svg_height=$("#canvas svg")[0].getBBox().height;var ws=Math.ceil(svg_width/minimap_width);var hs=Math.ceil(svg_height/minimap_height);var scale=1/Math.max(ws,hs);var delta=0;if(hs>ws)delta=minimap_width/2-svg_width*scale/2;var el=null;if($("#radareApp_mp").length){el=$("#main_panel")}else if($("#main_panel").length){el=$("#center_panel")}if(el.scrollTop()0){graph.addEdge(addr,bb.fail,"red");if(bb.jump>0){graph.addEdge(addr,bb.jump,"green")}}else if(bb.jump>0){graph.addEdge(addr,bb.jump,"blue")}}graph.render();var element=$("#canvas svg g .element");element.on("mousedown",function(event){flag=0});element.on("mousemove",function(event){flag=1});element.on("mouseup",function(event){if(flag===0){var id=event.target.parentNode.parentNode.parentNode.getAttribute("model-id");if(id!=="minimap_area"){var color=null;var bb=r2ui.get_fcn_BB(r2ui.current_fcn_offset,id);if(bb!==undefined&&bb!==null){if(bb.color==="red")bb.color=r2ui.colors[".ec_gui_alt_background"];else bb.color="red"}else{bb={x:"null",y:"null",color:"red"}}r2ui.update_fcn_BB(r2ui.current_fcn_offset,id,bb);reposition_graph()}}});return true}function render_instructions(instructions){var outergbox=document.createElement("div");outergbox.id="outergbox";var flatcanvas=document.getElementById("canvas");flatcanvas.innerHTML="";var gbox=document.createElement("div");gbox.id="gbox";gbox.className="ec_gui_background";outergbox.appendChild(gbox);flatcanvas.appendChild(outergbox);var flatcanvas_rect=getOffsetRect(flatcanvas);var asm_lines=r2.settings["asm.lines"];var asm_offset=r2.settings["asm.offset"];var accumulated_heigth=flatcanvas_rect.top;var lines=[];var targets={};var first_address=instructions[0].offset;var last_address=instructions[instructions.length-1].offset;for(var i in instructions){var ins=instructions[i];if((ins.type=="jmp"||ins.type=="cjmp")&&ins.jump!==undefined&&ins.jump!==null){var line={};line.from=ins.offset;if(last_addressins.jump){line.to_end=false;line.to=first_address}else{line.to_end=true;line.to=ins.jump}if(ins.type=="jmp"){line.color=r2ui.colors[".ec_flow"];line.dashed=false}else if(ins.type=="cjmp"){line.color=r2ui.colors[".ec_gui_cflow"];line.dashed=true}line.to_start=true;lines[lines.length]=line;if(targets[line.to]===undefined){targets[line.to]=0}}if(ins.comment===undefined||ins.comment===null)ins.comment="";else{ins.comment=atob(ins.comment)}var dom=document.createElement("div");if(asm_lines)dom.className="instructionbox enyo-selectable lines";else dom.className="instructionbox";dom.style.top=accumulated_heigth+"px";dom.innerHTML=html_for_instruction(ins);gbox.appendChild(dom);var instruction_rect=getOffsetRect(dom);var instruction_heigth=instruction_rect.bottom-instruction_rect.top;accumulated_heigth+=instruction_heigth}if(asm_lines){var canvas=document.createElement("canvas");canvas.width=500;canvas.height=accumulated_heigth;canvas.id="linecanvas";canvas.setAttribute("tabindex","1");canvas.setAttribute("style","outline: none;");gbox.appendChild(canvas);var ctx=canvas.getContext("2d");if(!ctx.setLineDash){ctx.setLineDash=function(){}}var num_targets=countProperties(targets);var num_assigned_paths=0;var lines_width=100;for(var l in lines){var line=lines[l];var from="0x"+line.from.toString(16);var to="0x"+line.to.toString(16);if(targets[line.to]===0){targets[line.to]=(num_targets-num_assigned_paths-1)*(90/(num_targets+1));num_assigned_paths+=1}var from_element=get_element_by_address(from);var to_element=get_element_by_address(to);if(from_element!==null&&from_element!==undefined&&to_element!==undefined&&to_element!==null){var x=targets[line.to];var from_rect=getOffsetRect(from_element);var y0=(from_rect.top+from_rect.bottom)/2;var to_rect=getOffsetRect(to_element);var y1=(to_rect.top+to_rect.bottom)/2;if(line.to==instructions[0].offset){y1=0}ctx.beginPath();ctx.moveTo(x,y0);ctx.lineTo(x,y1);ctx.strokeStyle=line.color;if(line.dashed)ctx.setLineDash([2,3]);ctx.stroke();if(line.to_start){ctx.beginPath();ctx.moveTo(x,y0);ctx.lineTo(lines_width-5,y0);ctx.strokeStyle=line.color;if(line.dashed)ctx.setLineDash([2,3]);ctx.stroke();ctx.beginPath();ctx.arc(lines_width-5-2,y0,2,0,2*Math.PI,false);ctx.fillStyle=line.color;ctx.fill()}if(line.to_end){ctx.beginPath();ctx.moveTo(x,y1);ctx.lineTo(lines_width-5,y1);ctx.strokeStyle=line.color;if(line.dashed)ctx.setLineDash([2,3]);ctx.stroke();ctx.beginPath();ctx.moveTo(lines_width-5,y1);ctx.lineTo(lines_width-10,y1-5);ctx.lineTo(lines_width-10,y1+5);ctx.lineWidth=1;ctx.fillStyle=line.color;ctx.fill()}}}}if(!asm_offset){var elements=document.getElementsByClassName("insaddr");for(var j in elements){if(elements[j].style)elements[j].style.display="none"}}}function getOffsetRect(elem){var box=elem.getBoundingClientRect();var offset=$("#gbox").offset().top;var top=box.top-offset;var bottom=box.bottom-offset;return{top:Math.round(top),bottom:Math.round(bottom)}}function countProperties(obj){var count=0;for(var prop in obj){if(obj.hasOwnProperty(prop)){++count}}return count}function toBoolean(str){if(str==="true")return true;else if(str==="false")return false;else return undefined}function html_for_instruction(ins){var idump='
';var offset="0x"+ins.offset.toString(16);var address=offset;var asm_flags=r2.settings["asm.flags"];var asm_bytes=r2.settings["asm.bytes"];var asm_xrefs=r2.settings["asm.xrefs"];var asm_cmtright=r2.settings["asm.cmtright"];if(offset==="0x"+ins.fcn_addr.toString(16)){if(r2ui._dis.display=="flat")idump+='
; -----------------------------------------------------------
';r2.cmdj("afij "+offset,function(x){if(x!==null&&x!==undefined&&x.length>0)idump+='
(fcn) '+x[0].name+"
"});r2.cmdj("afvj @ "+offset,function(x){var fvars=[];for(var i in x){idump+='
; '+x[i].kind+" "+x[i].type+" "+escapeHTML(x[i].name)+" @ "+x[i].ref+"
";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+='
; '+x[i].kind+" "+x[i].type+" "+escapeHTML(x[i].name)+" @ "+x[i].ref+"
";args[args.length]={name:x[i].name,id:address_canonicalize(offset)+"_"+x[i].ref}}r2.argMap[ins.fcn_addr]=args})}if(asm_flags){var flags;if(ins.flags!==undefined&&ins.flags!==null){flags=ins.flags.join(";")}else{flags=r2.get_flag_names(address_canonicalize(offset)).join(";")}if(flags!==""&&flags!==undefined&&flags!==null)idump+='
;-- '+escapeHTML(flags)+":
"}if(ins.comment&&!asm_cmtright){idump+='
; '+escapeHTML(ins.comment)+"
"}if(asm_xrefs){if(ins.xrefs!==undefined&&ins.xrefs!==null&&ins.xrefs.length>0){var xrefs="";for(var i in ins.xrefs){var xref=ins.xrefs[i];var name="";var xrefoffset="0x"+xref.addr.toString(16);if(r2.get_flag_names(address_canonicalize(xrefoffset)).length>0)name=" ("+r2.get_flag_names(address_canonicalize(xrefoffset)).join(";")+")";idump+='
; '+xref.type.toUpperCase()+" XREF from "+''+xrefoffset+" "+name+"
"}}}idump+=''+address+" ";if(asm_bytes){if(ins.bytes!==undefined&&ins.bytes!==null&&ins.bytes!==""){var dorep=function(a){if(a=="00")return'00';if(a=="ff")return'ff';if(a=="7f")return'7f'};var bytes=ins.bytes.replace(new RegExp("(00)|(ff)|(7f)","g"),dorep);idump+=''+bytes+" "}}var opcode=highlight_instruction(ins.opcode,true);if(r2.varMap[ins.fcn_addr]!==null&&r2.varMap[ins.fcn_addr]!==undefined&&r2.varMap[ins.fcn_addr].length>0||r2.argMap[ins.fcn_addr]!==null&&r2.argMap[ins.fcn_addr]!==undefined&&r2.argMap[ins.fcn_addr].length>0){for(var i in r2.varMap[ins.fcn_addr]){var var_name=r2.varMap[ins.fcn_addr][i].name;var var_id=r2.varMap[ins.fcn_addr][i].id;opcode=opcode.replace(var_name,""+escapeHTML(var_name)+"")}for(var i in r2.argMap[ins.fcn_addr]){var arg_name=r2.argMap[ins.fcn_addr][i];var arg_id=r2.argMap[ins.fcn_addr][i].id;opcode=opcode.replace(arg_name,""+escapeHTML(var_name)+"")}}if(ins.type!==undefined&&ins.type!==null){if(contains(math,ins.type))ins.type="math";if(contains(bin,ins.type))ins.type="bin";if(ins.type=="ill")ins.type="invalid";if(ins.type=="null")ins.type="invalid";if(ins.type=="undefined")ins.type="invalid";if(ins.type=="ujmp")ins.type="jmp";if(ins.type=="upush")ins.type="push";if(ins.type=="upop")ins.type="pop";if(ins.type=="ucall")ins.type="call";if(ins.type=="lea")ins.type="mov";idump+='
'+opcode+"
"}else{idump+='
'+opcode+"
"}if(ins.comment&&asm_cmtright){idump+=' ; '+escapeHTML(ins.comment)+""}idump+="
";return idump}var math=["add","sub","mul","imul","div","idiv","neg","adc","sbb","inc","dec",".byte"];var bin=["xor","and","or","not"];var regs=["EAX","ECX","EDX","EBX","ESP","EBP","ESI","EDI","EIP","RAX","RCX","RDX","RBX","RSP","RBP","RSI","RDI","R0","R1","R2","R3","R4","R5","R6","R7","R8","R9","R10","R11","R12","R13","R14","R15","RIP"];var escapeHTML=function(){"use strict";var chr={'"':""","&":"&","<":"<",">":">"};return function(text){return text.replace(/[\"&<>]/g,function(a){return chr[a]})}}();function highlight_instruction(line,instruction){if(line===undefined)return"undefined";if(instruction===undefined)instruction=true;var ret=escapeHTML(line);var re="(0x[0123456789abcdef]+)";var reps={};if(instruction){for(var i in regs){var rep=''+regs[i]+"";reps[regs[i]]=rep;rep=''+regs[i].toLowerCase()+"";reps[regs[i].toLowerCase()]=rep}for(i in reps){re+="|("+i+")"}}function dorep(a){if(a.substr(0,2)=="0x"){var syms=r2.get_flag_names(address_canonicalize(a));for(var i in syms){if(syms[i].indexOf("sym.imp.")){return""+syms[i]+""}if(syms[i].indexOf("fcn.")){return""+syms[i]+""}}var cl=get_data_type(a);if(cl===""){return""+a+""}else if(cl==="datainstruction"){return""+a+""}else if(cl==="datamemory"){return""+a+""}}else{return reps[a]}}return ret.replace(new RegExp(re,"g"),dorep)}function hex2(a){if(a===undefined)return"__";var ret=a.toString(16);if(ret.length==1)return"0"+ret;return ret}function hex(a){if(a===undefined){return""}else{if(a<0)a+=4294967296;return"0x"+a.toString(16)}}function get_data_type(v,more){var a=r2.get_address_type(v);if(a==="")return"";else{if(more!==undefined){return"data"+a+" addr addr_"+v}else{return"data"+a}}}function fnum(a){return parseInt(a,10)}function get_address_from_class(t,type){if(type===undefined)type="addr";var prefix=type+"_";var l=t.className.split(" ").filter(function(x){return x.substr(0,prefix.length)==type+"_"});if(l.length!=1)return undefined;return l[0].split("_")[1].split(" ")[0]}function rehighlight_iaddress(address,prefix){if(prefix===undefined)prefix="addr";$(".autohighlighti").removeClass("autohighlighti");$("."+prefix+"_"+address).addClass("autohighlighti");if(prefix==="addr")r2.cmd("s "+address,function(){})}function rehighlight_id(eid){$(".autohighlighti").removeClass("autohighlighti");$("#"+eid).addClass("autohighlighti")}function get_element_by_address(address){var elements=$(".insaddr.addr_"+address);if(elements.length===1)return elements[0];else return null}Element.prototype.documentOffsetTop=function(){return this.offsetTop+(this.offsetParent?this.offsetParent.documentOffsetTop():0)};function scroll_to_address(address){var elements=$(".insaddr.addr_"+address);var top=elements[0].documentOffsetTop()-window.innerHeight/2;top=Math.max(0,top);$("#main_panel").scrollTo({top:top,left:0})}function has_scrollbar(divnode){if(divnode.scrollHeight>divnode.clientHeight)return true;return false}function on_scroll(event){if(r2ui._dis.display=="flat"){var scroll_offset=null;var top_offset=null;var addr=null;if($("#radareApp_mp").length){scroll_offset=$("#main_panel").scrollTop();top_offset=$("#gbox").height()-$("#main_panel").height()-10;container_element=$("#center_panel")}else{scroll_offset=$("#center_panel").scrollTop();top_offset=$("#gbox").height()-$("#center_panel").height()-10;container_element=$("#disasm_tab")}if(has_scrollbar($("#center_panel")[0])){if(scroll_offset===0){$("#center_panel").scroll(null);addr="0x"+r2ui._dis.instructions[0].offset.toString(16);r2.get_disasm_before(addr,100,function(x){r2ui._dis.instructions=x.concat(r2ui._dis.instructions)});container_element.html("
");render_instructions(r2ui._dis.instructions);scroll_to_address(addr);rehighlight_iaddress(r2ui._dis.selected_offset);$("#center_panel").scroll(on_scroll)}if(scroll_offset>top_offset){$("#center_panel").scroll(null);addr="0x"+r2ui._dis.instructions[r2ui._dis.instructions.length-1].offset.toString(16);r2.get_disasm_after(addr,100,function(x){r2ui._dis.instructions=r2ui._dis.instructions.slice(0,-1).concat(x)});container_element.html("
");render_instructions(r2ui._dis.instructions);scroll_to_address(addr);rehighlight_iaddress(r2ui._dis.selected_offset);$("#center_panel").scroll(on_scroll)}}}}function scroll_to_element(element){var top=element.documentOffsetTop()-window.innerHeight/2;top=Math.max(0,top);$("#main_panel").scrollTo({top:top,left:0})}function rename(offset,old_value,new_value,space){if(space===undefined)space="functions";if(space=="functions"){r2.cmdj("pdfj @ "+offset,function(x){if(x!==null&&x!==undefined){if("0x"+x.addr.toString(16)===offset){r2.cmd("afn "+new_value+" "+offset,function(){r2.update_flags();return})}}})}if(new_value!==""&&old_value!==""){var cmd="fs "+space+";fr "+old_value+" "+new_value;r2.cmd(cmd,function(){})}else if(new_value===""&&old_value!==""){var cmd="fs "+space+";f-@"+offset;r2.cmd(cmd,function(){})}else if(new_value!==""&&old_value===""){var cmd="fs "+space+";f "+new_value+" @ "+offset;r2.cmd(cmd,function(){})}r2.update_flags()}function address_canonicalize(s){s=s.substr(2);while(s.substr(0,1)=="0")s=s.substr(1);s="0x"+s;s=s.toLowerCase();return s}function contains(a,obj){for(var i=0;i
"+"",style:"margin-right:5px;width:100%;height:100%"},{kind:enyo.Signals,onkeypress:"handleKeyPress"},{name:"menuPopup",kind:"onyx.Popup",floating:true,onHide:"hideContextMenu",onShow:"showContextMenu",style:"padding: 0px;",style:"padding: 10px",components:[{name:"menu",kind:"onyx.MenuDecorator",onSelect:"itemSelected",components:[{content:"Show menu"},{kind:"onyx.Menu",name:"contextMenu",components:[{content:"rename",value:"rename"},{content:"comment",value:"comment"},{content:"switch view",value:"do_switchview"},{content:"random colors",value:"do_randomcolors"}]}]}]}],handlers:{ontap:"handleTap",onhold:"handleHold",ondblclick:"handleDoubleClick",onTransitionFinish:"handleTransitionFinish"},handleTransitionFinish:function(){if(r2ui._dis.display=="graph"&&r2ui._dis.minimap)update_minimap()},itemSelected:function(inSender,inEvent){if(inEvent.originator.content){var itemContent=inEvent.originator.content;if(itemContent=="rename"){this.do_rename(this.selected,inEvent)}else if(itemContent=="comment"){this.do_comment(this.selected_offset)}else if(itemContent=="random colors"){do_randomcolors()}else if(itemContent=="switch view"){this.switch_view()}}this.$.menuPopup.hide()},handleHold:function(inSender,inEvent){this.handleTap(inSender,inEvent);if(typeof inEvent.target.className==="string"&&(inEvent.target.className.indexOf(" addr ")>-1||inEvent.target.className.indexOf(" faddr ")>-1)){var address=get_address_from_class(inEvent.target);this.selected=inEvent.target;this.selected_offset=address;rehighlight_iaddress(address);this.showContextMenu(inEvent.pageY,inEvent.pageX)}},showContextMenu:function(inSender,inEvent){if(parseFloat(inSender)==parseInt(inSender)&&!isNaN(inSender)&&parseFloat(inEvent)==parseInt(inEvent)&&!isNaN(inEvent)){this.$.menuPopup.addStyles("top:"+inSender+"px; left:"+inEvent+"px;padding:0px;");this.$.menuPopup.show();this.$.menuPopup.children[0].children[0].hide();this.$.menuPopup.children[0].children[1].show();this.$.menuPopup.render()}},hideContextMenu:function(inSender,inEvent){},handleDoubleClick:function(inSender,inEvent){if(inEvent.target.className.indexOf(" addr ")>-1&&inEvent.target.className.indexOf("insaddr")===-1){this.handleTap(inSender,inEvent);this.goToAddress()}},handleKeyPress:function(inSender,inEvent){var keynum=inEvent.keyCode||inEvent.charCode||inEvent.which||0;var key=String.fromCharCode(keynum);if(key==="?"){r2ui.mp.show_popup()}if(key===" "){this.switch_view()}if(key==="h"){var addr=r2ui.history_prev(); -if(addr!==undefined&&addr!==null)r2ui.seek(addr,false)}if(key==="l"){var addr=r2ui.history_next();if(addr!==undefined&&addr!==null)r2ui.seek(addr,false)}if(key==="m"&&r2ui._dis.display=="graph")toggle_minimap();if(key==="j"){var get_more_instructions=false;if($(this.selected).hasClass("insaddr")){var next_instruction;if(this.display=="flat"){next_instruction=$(this.selected).closest(".instructionbox").next().find(".insaddr")[0];if($("#gbox .instructionbox").index($(this.selected).closest(".instructionbox")[0])>$("#gbox .instructionbox").length-10)get_more_instructions=true}if(this.display=="graph"){var next_instruction=$(this.selected).closest(".instruction").next().find(".insaddr")[0];if(next_instruction===undefined||next_instruction===null){next_instruction=$(this.selected).closest(".basicblock").next().find(".insaddr")[0]}}var address=get_address_from_class(next_instruction);if(get_more_instructions){r2ui.seek(address,false)}else{r2ui.history_push(address);this.selected=next_instruction;this.selected_offset=address}rehighlight_iaddress(address);scroll_to_address(address)}}if(key==="k"){var get_more_instructions=false;if($(this.selected).hasClass("insaddr")){var prev_instruction;if(this.display=="flat"){prev_instruction=$(this.selected).closest(".instructionbox").prev().find(".insaddr")[0];if($("#gbox .instructionbox").index($(this.selected).closest(".instructionbox")[0])<10)get_more_instructions=true}if(this.display=="graph"){var prev_instruction=$(this.selected).closest(".instruction").prev().find(".insaddr")[0];if(prev_instruction===undefined||prev_instruction===null){prev_instruction=$(this.selected).closest(".basicblock").prev().find(".insaddr").last()[0]}}var address=get_address_from_class(prev_instruction);if(get_more_instructions){r2ui.seek(address,false)}else{r2ui.history_push(address);this.selected=prev_instruction;this.selected_offset=address}rehighlight_iaddress(address);scroll_to_address(address)}}if(key==="c"){var msg=prompt("Function name?");r2.cmd("af "+msg,function(){r2.update_flags();r2ui.seek("$$",false)})}if(key==="d"){r2.cmd("af-",function(){r2.update_flags();r2ui.seek("$$",false)})}if(key==="g"){r2ui.opendis(prompt("Go to"))}if(key===";"){this.do_comment(this.selected_offset)}if(key==="n"){this.do_rename(this.selected,inEvent)}if(key==="R")do_randomcolors();if(keynum===27){if(this.renaming!==null){this.renaming.innerHTML=this.renameOldValue;this.renaming=null}else{var addr=r2ui.history_prev();if(addr!==undefined&&addr!==null)r2ui.seek(addr,false)}}if(keynum===13){this.goToAddress()}},handleTap:function(inSender,inEvent){if(typeof inEvent.target.className==="string"){if(inEvent.target.className.indexOf(" addr ")>-1){var address=get_address_from_class(inEvent.target);rehighlight_iaddress(address);this.selected=inEvent.target;this.selected_offset=address;if($(inEvent.target).hasClass("insaddr")){r2ui.history_push(address);var get_more_instructions=false;var next_instruction;var prev_instruction;var address=get_address_from_class(inEvent.target);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);document.getElementById("canvas").focus()}}}else if($(inEvent.target).hasClass("fvar")||$(inEvent.target).hasClass("farg")){var eid=null;var address=get_address_from_class(inEvent.target,"faddr");r2ui._dis.selected=inEvent.target;r2ui._dis.selected_offset=address;var classes=inEvent.target.className.split(" ");for(var j in classes){var klass=classes[j];if(klass.indexOf("id_")===0)eid=klass.substring(3)}if(eid!==null)rehighlight_iaddress(eid,"id")}}},goToAddress:function(){if(this.renaming===null&&this.selected!==null&&this.selected.className.indexOf(" addr ")-1){var address=get_address_from_class(this.selected);if(this.selected.className.indexOf("ec_dataoffset")>-1){r2ui.openpage(address,2);return}if(address!==undefined&&address!==null){address=address_canonicalize(address);if(this.display==="flat"){r2ui.seek(address,true)}else{r2.cmdj("pdfj",function(x){if(x!==null&&x!==undefined){var ops=x.ops;var found=false;for(var i in ops){if(ops[i].offset===parseInt(address,16)){found=true}}if(found){r2ui.seek_in_graph(address,true)}else{r2ui.seek(address,true)}}})}}}},handleInputTextChange:function(){if(this.renaming!==null&&this.rbox.value.length>0){if($(this.selected).hasClass("insaddr")){var old_value=get_offset_flag(r2ui._dis.selected_offset);rename(r2ui._dis.selected_offset,old_value,this.rbox.value,"offsets")}else if($(this.selected).hasClass("faddr")){if($(this.selected).hasClass("fvar"))r2.cmd("afvn "+r2ui._dis.renameOldValue+" "+r2ui._dis.rbox.value+" @ "+r2ui._dis.selected_offset,function(x){});else if($(this.selected).hasClass("farg"))r2.cmd("afan "+r2ui._dis.renameOldValue+" "+r2ui._dis.rbox.value+" @ "+r2ui._dis.selected_offset,function(x){})}else{var old_value=r2ui._dis.renameOldValue;if(old_value.indexOf("0x")===0)old_value="";rename(r2ui._dis.selected_offset,old_value,r2ui._dis.rbox.value,"*")}var instruction;if(this.display=="flat")instruction=$(this.selected).closest(".instructionbox").find(".insaddr")[0];if(this.display=="graph")instruction=$(this.selected).closest(".instruction").find(".insaddr")[0];this.renaming=null;var address=get_address_from_class(instruction);r2ui.seek(address,false);scroll_to_address(address)}},min:0,max:0,block:512,base:"entry0",display:"flat",selected:null,renaming:null,renameOldValue:"",rbox:null,minimap:true,console_history:[],console_history_idx:0,instructions:[],do_comment:function(address){r2.cmd("CC- "+" @ "+address+";CC "+prompt("Comment")+" @ "+address);r2ui.seek(address,false);scroll_to_address(address)},do_rename:function(element,inEvent){if(this.renaming===null&&this.selected!==null&&this.selected.className.indexOf(" addr ")>-1){var address=get_address_from_class(this.selected);this.renaming=this.selected;this.renameOldValue=this.selected.innerHTML;this.rbox=document.createElement("input");this.rbox.setAttribute("type","text");this.rbox.setAttribute("id","rename");this.rbox.setAttribute("style","border-width: 0;padding: 0;");this.rbox.setAttribute("onChange","handleInputTextChange()");if(this.selected.className.indexOf("insaddr")>-1){var value=get_offset_flag(address);this.rbox.setAttribute("value",value);this.rbox.setSelectionRange(value.length,value.length)}else{this.rbox.setAttribute("value",this.renameOldValue);this.rbox.setSelectionRange(this.renameOldValue.length,this.renameOldValue.length)}this.renaming.innerHTML="";this.renaming.appendChild(this.rbox);setTimeout("r2ui._dis.rbox.focus();",200)}else if(this.renaming===null&&element!==null&&$(element).hasClass("faddr")){var address=get_address_from_class(element,"faddr");this.selected=element;this.selected_offset=address;this.renaming=element;this.renameOldValue=element.innerText;this.rbox=document.createElement("input");this.rbox.setAttribute("type","text");this.rbox.setAttribute("id","rename");this.rbox.setAttribute("style","border-width: 0;padding: 0;");this.rbox.setAttribute("onChange","handleInputTextChange()");this.rbox.setAttribute("value",this.renameOldValue);this.rbox.setSelectionRange(this.renameOldValue.length,this.renameOldValue.length);this.renaming.innerHTML="";this.renaming.appendChild(r2ui._dis.rbox);setTimeout("r2ui._dis.rbox.focus();",200)}},switch_view:function(){if(this.display==="flat")this.display_graph();else this.display_flat();var addr=r2ui.history_last();if(addr!==undefined&&addr!==null)r2ui.seek(addr,false)},display_graph:function(){this.display="graph";$("#main_panel").removeClass("ec_gui_background");$("#main_panel").addClass("ec_gui_alt_background")},display_flat:function(){this.display="flat";$("#main_panel.ui-layout-pane").removeClass("ec_gui_alt_background");$("#main_panel.ui-layout-pane").addClass("ec_gui_background")},seek:function(addr,scroll){var error=false;if(this.display==="graph"){this.$.minimap.show();$("#center_panel").html("");r2.cmd("agj "+addr,function(x){$("#center_panel").html("
");if(render_graph(x)===false)error=true})}if(error)this.display_flat();if(this.display==="flat"){$("#main_panel").scroll(on_scroll);this.$.minimap.hide();this.min=this.max=0;r2.get_disasm_before_after(addr,-100,100,function(x){$("#center_panel").html("
");r2ui._dis.instructions=x;render_instructions(r2ui._dis.instructions)})}this.selected=get_element_by_address(addr);this.selected_offset=addr;rehighlight_iaddress(addr);if(scroll===undefined||scroll===true){scroll_to_address(addr)}},create:function(){this.inherited(arguments);this.base="entry0";r2ui._dis=this;r2.update_flags();r2.analAll();r2.load_mmap();r2ui.load_colors()},resizeHandler:function(){this.inherited(arguments);if(r2ui._dis.display=="graph"&&r2ui._dis.minimap)update_minimap()},rendered:function(){this.inherited(arguments);myLayout=$("#radareApp_mp_panels_pageDisassembler_panel").layout({south__size:200});this.display_flat();r2ui.seek(this.base,true);var console_history=this.console_history;var console_history_idx=this.console_history_idx;$("#command").keypress(function(inEvent){var key=inEvent.keyCode||inEvent.charCode||inEvent.which||0;if(key===13){var cmd=inEvent.target.value.trim();var reloadUI=cmd=="";console_history[console_history.length]=cmd;console_history_idx+=1;if(cmd!=""){r2.cmd(inColor(cmd),function(x){var old_value=$("#cmd_output").text();$("#cmd_output").html(old_value+"\n> "+cmd+"\n"+x);$("#cmd_output").scrollTo($("#cmd_output")[0].scrollHeight)});if(cmd.indexOf("s ")===0){r2ui.history_push(r2ui._dis.selected_offset)}}inEvent.target.value="";if(reloadUI){r2.load_settings();r2ui.load_colors();r2ui.seek("$$",false);scroll_to_element(r2ui._dis.selected)}}});$("#command").keydown(function(inEvent){var key=inEvent.keyCode||inEvent.charCode||inEvent.which||0;if(key===40){console_history_idx++;if(console_history_idx>console_history.length-1)console_history_idx=console_history.length;inEvent.target.value=console_history[console_history_idx]===undefined?"":console_history[console_history_idx]}if(key===38){console_history_idx--;if(console_history_idx<0)console_history_idx=0;inEvent.target.value=console_history[console_history_idx]===undefined?"":console_history[console_history_idx]}})}});function docss(x){return""+x+""}enyo.kind({name:"DisassemblerOld",kind:"Scroller",tag:"div",style:"margin:0px;background-color:#c0c0c0",data:null,components:[{tag:"div",allowHtml:true,classes:"colorbar",name:"colorbar"},{tag:"br"},{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"}],min:0,max:0,block:512,base:"entry0",less:function(){var self=this;var text=this.$.text;this.min+=this.block;r2.get_disasm(this.base+"-"+this.min,this.block,function(x){x=docss(r2.filter_asm(x,"pd"));var oldy=r2ui._dis.getScrollBounds().height;text.setContent("
"+x+text.getContent()+"
");var newy=r2ui._dis.getScrollBounds().height;r2ui._dis.scrollTo(0,newy-oldy)})},more:function(){var text=this.$.text;this.max+=this.block;r2.get_disasm(this.base+"+"+this.max,this.block,function(x){x=docss(r2.filter_asm(x,"pd"));text.setContent("
"+text.getContent()+x+"
")})},seek:function(addr){var text=this.$.text;this.base=addr;this.min=this.max=0;r2.get_disasm(addr,this.block,function(x){x=docss(r2.filter_asm(x,"pd"));text.setContent("
"+x+"
")});this.scrollTo(0,0)},create:function(){this.inherited(arguments);var text=this.$.text;r2.cmd("e asm.lineswidth = 20",function(x){});this.seek("entry0");r2ui._dis=this;r2ui.history_push("entry0")},colorbar_create:function(){var self=this;r2.cmd("pvj 24",function(x){try{var y=JSON.parse(x)}catch(e){alert(e);return}console.log(y);var c=""+"";var colors={flags:"#c0c0c0",comments:"yellow",functions:"#5050f0",strings:"orange"};var off="";var WIDTH="100%";var HEIGHT=16;for(var i=0;i";var count=0;for(var k in colors)if(block[k])count++;count++;if(count==1)break;var h=HEIGHT/count;for(var k in colors){var color=colors[k];if(block[k])r+=""}r+="
____
";off="0x"+block.offset.toString(16)}else{off="0x"+(y.from+y.blocksize*i).toString(16)}c+=""+r+""}c+="";self.$.colorbar.setContent(c)})}});enyo.kind({name:"Graph",kind:"Scroller",style:"background-color:#c0c0c0",components:[{tag:"h2",content:"Open graph",style:"margin-left:10px;"},{kind:"Group",classes:"enyo-border-box group",defaultKind:"onyx.Button",components:[{content:"Basic blocks",classes:"onyx-dark menu-button",ontap:"openGraphBB"},{content:"Callgraph",classes:"onyx-dark menu-button",ontap:"openGraphCG"}]}],openGraphBB:function(){window.open("/graph/","_self")},openGraphCG:function(){window.open("/d3/","_self")}});function docss(x){return""+x+""}enyo.kind({name:"Hexdump",kind:"Scroller",tag:"div",style:"margin:0px;background-color:#c0c0c0;color:black",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:"..",style:"margin-left:5px;color:black"},{tag:"div",content:"v",classes:"moreless",ontap:"more"}],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=css(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=docss(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=docss(r2.filter_asm(x,"px"));text.setContent("
"+x+"
")});this.colorbar_create()},create:function(){this.inherited(arguments);var text=this.$.text;this.seek("entry0");r2ui._hex=this;this.colorbar_create()},setupItem:function(inSender,inIndex){this.$.msg.setContent(this.data[inIndex.index]);return true},colorbar_create:function(){var self=this;r2.cmd("pvj",function(x){try{var y=JSON.parse(x)}catch(e){alert(e);return}var c="";var colors={flags:"#c0c0c0",comments:"yellow",functions:"#5050f0",strings:"orange"};var off="";var WIDTH=10;var HEIGHT=30;for(var i=0;i ";if(block.offset){var r="
";var count=0;for(var k in colors){if(block[k])count++}count++;if(count==1)break;var h=HEIGHT/count;for(var k in colors){var color=colors[k];if(block[k])r+=""}r+="
 
";off="0x"+block.offset.toString(16)}else{off="0x"+(y.from+y.blocksize*i).toString(16)}c+=""+r+""}c+="";self.$.colorbar.setContent(c)})}});if(function(a,b){function c(a){var b=a.length,c=fb.type(a);return fb.isWindow(a)?!1:1===a.nodeType&&b?!0:"array"===c||"function"!==c&&(0===b||"number"==typeof b&&b>0&&b-1 in a)}function d(a){var b=ob[a]={};return fb.each(a.match(hb)||[],function(a,c){b[c]=!0}),b}function e(){Object.defineProperty(this.cache={},0,{get:function(){return{}}}),this.expando=fb.expando+Math.random()}function f(a,c,d){var e;if(d===b&&1===a.nodeType)if(e="data-"+c.replace(sb,"-$1").toLowerCase(),d=a.getAttribute(e),"string"==typeof d){try{d="true"===d?!0:"false"===d?!1:"null"===d?null:+d+""===d?+d:rb.test(d)?JSON.parse(d):d}catch(f){}pb.set(a,c,d)}else d=b;return d}function g(){return!0}function h(){return!1}function i(){try{return T.activeElement}catch(a){}}function j(a,b){for(;(a=a[b])&&1!==a.nodeType;);return a}function k(a,b,c){if(fb.isFunction(b))return fb.grep(a,function(a,d){return!!b.call(a,d,a)!==c});if(b.nodeType)return fb.grep(a,function(a){return a===b!==c});if("string"==typeof b){if(Cb.test(b))return fb.filter(b,a,c);b=fb.filter(b,a)}return fb.grep(a,function(a){return bb.call(b,a)>=0!==c})}function l(a,b){return fb.nodeName(a,"table")&&fb.nodeName(1===b.nodeType?b:b.firstChild,"tr")?a.getElementsByTagName("tbody")[0]||a.appendChild(a.ownerDocument.createElement("tbody")):a}function m(a){return a.type=(null!==a.getAttribute("type"))+"/"+a.type,a}function n(a){var b=Nb.exec(a.type);return b?a.type=b[1]:a.removeAttribute("type"),a}function o(a,b){for(var c=a.length,d=0;c>d;d++)qb.set(a[d],"globalEval",!b||qb.get(b[d],"globalEval"))}function p(a,b){var c,d,e,f,g,h,i,j;if(1===b.nodeType){if(qb.hasData(a)&&(f=qb.access(a),g=qb.set(b,f),j=f.events)){delete g.handle,g.events={};for(e in j)for(c=0,d=j[e].length;d>c;c++)fb.event.add(b,e,j[e][c])}pb.hasData(a)&&(h=pb.access(a),i=fb.extend({},h),pb.set(b,i))}}function q(a,c){var d=a.getElementsByTagName?a.getElementsByTagName(c||"*"):a.querySelectorAll?a.querySelectorAll(c||"*"):[];return c===b||c&&fb.nodeName(a,c)?fb.merge([a],d):d}function r(a,b){var c=b.nodeName.toLowerCase();"input"===c&&Kb.test(a.type)?b.checked=a.checked:("input"===c||"textarea"===c)&&(b.defaultValue=a.defaultValue)}function s(a,b){if(b in a)return b;for(var c=b.charAt(0).toUpperCase()+b.slice(1),d=b,e=_b.length;e--;)if(b=_b[e]+c,b in a)return b;return d}function t(a,b){return a=b||a,"none"===fb.css(a,"display")||!fb.contains(a.ownerDocument,a)}function u(b){return a.getComputedStyle(b,null)}function v(a,b){for(var c,d,e,f=[],g=0,h=a.length;h>g;g++)d=a[g],d.style&&(f[g]=qb.get(d,"olddisplay"),c=d.style.display,b?(f[g]||"none"!==c||(d.style.display=""),""===d.style.display&&t(d)&&(f[g]=qb.access(d,"olddisplay",z(d.nodeName)))):f[g]||(e=t(d),(c&&"none"!==c||!e)&&qb.set(d,"olddisplay",e?c:fb.css(d,"display"))));for(g=0;h>g;g++)d=a[g],d.style&&(b&&"none"!==d.style.display&&""!==d.style.display||(d.style.display=b?f[g]||"":"none"));return a}function w(a,b,c){var d=Ub.exec(b);return d?Math.max(0,d[1]-(c||0))+(d[2]||"px"):b}function x(a,b,c,d,e){for(var f=c===(d?"border":"content")?4:"width"===b?1:0,g=0;4>f;f+=2)"margin"===c&&(g+=fb.css(a,c+$b[f],!0,e)),d?("content"===c&&(g-=fb.css(a,"padding"+$b[f],!0,e)),"margin"!==c&&(g-=fb.css(a,"border"+$b[f]+"Width",!0,e))):(g+=fb.css(a,"padding"+$b[f],!0,e),"padding"!==c&&(g+=fb.css(a,"border"+$b[f]+"Width",!0,e)));return g}function y(a,b,c){var d=!0,e="width"===b?a.offsetWidth:a.offsetHeight,f=u(a),g=fb.support.boxSizing&&"border-box"===fb.css(a,"boxSizing",!1,f);if(0>=e||null==e){if(e=Qb(a,b,f),(0>e||null==e)&&(e=a.style[b]),Vb.test(e))return e;d=g&&(fb.support.boxSizingReliable||e===a.style[b]),e=parseFloat(e)||0}return e+x(a,b,c||(g?"border":"content"),d,f)+"px"}function z(a){var b=T,c=Xb[a];return c||(c=A(a,b),"none"!==c&&c||(Rb=(Rb||fb("