def main(): binNaviProxy = StandAlone.getPluginInterface() binNaviProxy.databaseManager.addDatabase("","com.mysql.jdbc.Driver","localhost","BINNAVI1","binnavi","binnavi",False,False) db=binNaviProxy.databaseManager.databases[0] db.connect() db.load() mods=db.getModules() ### initiate dialogBox to setect the module that should be used. ###################################################### frame = JFrame('BinNavi Module Selector',layout=BorderLayout(), defaultCloseOperation = JFrame.EXIT_ON_CLOSE, size = (1500, 800) ) frame2 = JFrame('Function Selector',layout=BorderLayout(), defaultCloseOperation = JFrame.EXIT_ON_CLOSE, size = (30, 30) ) frame2.setFocusableWindowState(False) frame2.setFocusable(False) frame2.setAlwaysOnTop(False) #convert the module list into the string to be used in the TextBox. textTemp = map((lambda x,y:"[%d]%s"%(x,y)),range(len(mods)),mods) textStr=''.join(textTemp) tx=JTextArea(textStr) tx.setLineWrap(True); tx.setWrapStyleWord(True); frame.add(tx,BorderLayout.PAGE_START) frame.visible = True modInd = JOptionPane.showInputDialog(frame2, "Enter the index of the chosen module", "Module selector"); #Open the module returned by the index bfname=mods[int(modInd)] # this modules correxponds to the chosen module bfname.load() funcViews=bfname.views #textTemp2 = ["[%d]%s"%(i,j) for i in range(len(funcViews)) for j in funcViews] textTemp2=map((lambda x,y:"[%d]%s"%(x,y.toString()[5:18])),range(len(funcViews)),funcViews) textStr1=''.join(textTemp2) ## remove the older text from the frame view frame.remove(tx) frame.update(frame.getGraphics()) frame.visible = False ## create a new textArea with the string made from all the functions' name txStr=JTextArea(textStr1) #tx.setsrcollOffset(20) txStr.setLineWrap(True); txStr.setWrapStyleWord(True); frame.add(txStr,BorderLayout.PAGE_START) frame.update(frame.getGraphics()) frame.visible = True funcInd = JOptionPane.showInputDialog(frame2, "Enter the index of the function", "Function selector"); ###################################################### bffunc=bfname.views[int(funcInd)] #this is the view of the buildfname function bffunc.load() frame2.setVisible(False) dispose(frame2) bfReil=bffunc.getReilCode() # this is the REIL code of the function bfReilGraph=bfReil.getGraph() instGraph = InstructionGraph.create(bfReilGraph) time.clock() results=doAnalysis(instGraph) totalTime=time.clock() #print "resultsLen", len([r for r in results]) print "**** printing results *******\n" print "Total time:", totalTime, '\n' numNode=0 for n in instGraph: numNode+=numNode nIn=list(results.getState(n).inVal) nIn.sort(key=itemgetter(0)) nOut=list(results.getState(n).out) nOut.sort(key=itemgetter(0)) print '@@ ',n.getInstruction(),'\n' print '\t In', nIn, '\n' print '\t OUT', nOut, '\n' print '\t memory: ',results.getState(n).memoryWritten, '\n' print "++++ Total instructions: %d +++++\n"%numNode #finally close the view of the function bffunc.close() #print bffunc.isLoaded() #junky=raw_input("function closed. enter any charater") print "Done! Closing the module selector window" frame.setVisible(False) dispose(frame)
### initiate dialogBox to setect the module that should be used. ###################################################### frame = JFrame('BinNavi Module Selector',layout=BorderLayout(), defaultCloseOperation = JFrame.EXIT_ON_CLOSE, size = (1500, 800) ) frame2 = JFrame('Function Selector',layout=BorderLayout(), defaultCloseOperation = JFrame.EXIT_ON_CLOSE, size = (30, 30) ) frame2.setFocusableWindowState(False) frame2.setFocusable(False) frame2.setAlwaysOnTop(False) #convert the module list into the string to be used in the TextBox. textTemp = map((lambda x,y:"[%d]%s"%(x,y)),range(len(mods)),mods) textStr=''.join(textTemp) tx=JTextArea(textStr) tx.setLineWrap(True); tx.setWrapStyleWord(True); frame.add(tx,BorderLayout.PAGE_START) frame.visible = True modInd = JOptionPane.showInputDialog(frame2, "Enter the index of the chosen module", "Module selector"); #Open the module returned by the index bfname=mods[int(modInd)] # this modules correxponds to the chosen module