mirror of
https://github.com/geohot/qira
synced 2025-03-14 11:03:08 +03:00
static2 refactoring is happening:
This commit is contained in:
parent
83bec7480f
commit
bd70c940e6
@ -118,6 +118,7 @@ class Program:
|
||||
|
||||
# init static
|
||||
self.static = static2.Static(self.program)
|
||||
self.static.process()
|
||||
|
||||
# no traces yet
|
||||
self.traces = {}
|
||||
@ -291,6 +292,8 @@ class Program:
|
||||
thumb_flag = d[0]
|
||||
if thumb_flag == 't':
|
||||
thumb = True
|
||||
# override the arch since it's thumb
|
||||
self.static[addr]['arch'] = "thumb"
|
||||
elif thumb_flag == 'n':
|
||||
thumb = False
|
||||
else:
|
||||
@ -301,12 +304,12 @@ class Program:
|
||||
inst = d[d.rfind(" ")+5:]
|
||||
else:
|
||||
inst = d[d.find(":")+3:]
|
||||
self.static[addr]['instruction'] = inst
|
||||
if thumb:
|
||||
self.static[addr]['arch'] = "thumb"
|
||||
else:
|
||||
self.static[addr]['arch'] = "thumb"
|
||||
cnt += 1
|
||||
|
||||
#self.static[addr]['instruction'] = inst
|
||||
|
||||
# trigger disasm
|
||||
d = self.static[addr]['instruction']
|
||||
#print addr, inst
|
||||
#sys.stdout.write("%d..." % cnt); sys.stdout.flush()
|
||||
|
||||
|
@ -278,7 +278,7 @@ def getinstructions(forknum, clnum, clstart, clend):
|
||||
else:
|
||||
rret = rret[0]
|
||||
|
||||
rret['instruction'] = program.static[rret['address']]['instruction']
|
||||
rret['instruction'] = str(program.static[rret['address']]['instruction'])
|
||||
|
||||
if 'name' in program.static[rret['address']]:
|
||||
#print "setting name"
|
||||
@ -370,6 +370,8 @@ def getnames(addrs):
|
||||
send[ghex(addr)] = ret[addr]['name']
|
||||
emit('names', send)
|
||||
|
||||
|
||||
# TODO: this is a shitty function
|
||||
@app.route('/gettagsa', methods=["POST"])
|
||||
@socket_method
|
||||
def gettagsa():
|
||||
@ -387,6 +389,26 @@ def gettagsa():
|
||||
ret.append(rret)
|
||||
return json.dumps(ret)
|
||||
|
||||
@socketio.on('getstaticview', namespace='/qira')
|
||||
@socket_method
|
||||
def getstaticview(haddr, flat, flatrange):
|
||||
fxn = program.static[fhex(haddr)]['function']
|
||||
if fxn == None:
|
||||
return
|
||||
|
||||
blocks = []
|
||||
for b in fxn.blocks:
|
||||
bb = []
|
||||
for i in sorted(b.addresses):
|
||||
bbb = {'address': ghex(i)}
|
||||
bbb['comment'] = program.static[i]['comment']
|
||||
bbb['instruction'] = str(program.static[i]['instruction'])
|
||||
bbb['dests'] = map(lambda (x,y): (ghex(x), y), program.static[i]['instruction'].dests())
|
||||
bb.append(bbb)
|
||||
blocks.append(bb)
|
||||
|
||||
emit('function', {'blocks': blocks})
|
||||
|
||||
@socketio.on('gotoname', namespace='/qira')
|
||||
@socket_method
|
||||
def gotoname(name):
|
||||
@ -429,7 +451,6 @@ def serve(path):
|
||||
return Response(dat, mimetype="text/html")
|
||||
|
||||
|
||||
|
||||
# must go at the bottom
|
||||
def run_server(largs, lprogram):
|
||||
global args
|
||||
|
@ -73,6 +73,8 @@ class Tags:
|
||||
return None
|
||||
|
||||
def __setitem__(self, tag, val):
|
||||
if tag == "instruction" and type(val) == str:
|
||||
raise Exception("instructions shouldn't be strings")
|
||||
if tag == "name":
|
||||
# name can change by adding underscores
|
||||
val = self.static.set_name(self.address, val)
|
||||
@ -193,6 +195,13 @@ class Static:
|
||||
def add_memory_chunk(self, address, dat):
|
||||
self.base_memory[(address, address+len(dat))] = dat
|
||||
|
||||
def process(self):
|
||||
recursive.make_function_at(self, self['entry'])
|
||||
main = self.get_address_by_name("main")
|
||||
if main != None:
|
||||
recursive.make_function_at(self, main)
|
||||
print "*** found %d functions" % len(self['functions'])
|
||||
|
||||
|
||||
# *** STATIC TEST STUFF ***
|
||||
|
||||
|
@ -35,6 +35,11 @@ function display_flat(addrs) {
|
||||
$("#staticpanel").html(idump);
|
||||
}
|
||||
|
||||
function on_function(fxn) { DS("function");
|
||||
var graph = new Graph();
|
||||
p(fxn);
|
||||
} stream.on('function', on_function);
|
||||
|
||||
function on_tags(addrs, fxn) { DS("tags");
|
||||
if (!fxn) {
|
||||
display_flat(addrs);
|
||||
|
Loading…
x
Reference in New Issue
Block a user