def searchStructure(self, structType='sslsnoop.ctypes_openssh.session_state'): ''' return size of structure and list of addresses and values ) ''' from haystack import abouchet import ctypes #import sslsnoop #? #self.mapping.unmmap() # DEBUG stop at the first instance, lazy me instances = abouchet.searchIn(structType, mappings=self.mappings, targetMappings=[self.mapping], maxNum=1) if len(instances) > 0: log.debug('received %d struct of size %d'%(len(instances),len(instances[0][0]))) # init graphical element resultsViewer = searchinfoview.SearchInfoView(self.scene, QtCore.Qt.green, withDetails=True, parent=self.tab_search_structures) for value, addr in instances: offset = addr - self.mapping.start #instanceList.append(widgets.Structure( offset, value, color=QtCore.Qt.green, scene=self.scene)) log.debug('the value is an %s'%type(value) ) resultsViewer.addResult( offset, value, color=QtCore.Qt.green) # fill the scene log.debug('Found %d instances'%(len(instances)) ) ## make the toolbox title and add the widget searchName = 'Results for %s'%(structType) self.tab_search_structures.addItem(resultsViewer, searchName) nb = self.tab_search_structures.count() ##self.tab_search_structures.setItemEnabled(nb-1, True) return instances
def search_regexp(self, regexp, searchName, color=QtCore.Qt.black): reSearcher = signature.RegexpSearcher(self.mapping, regexp) # add a entry into the tabView on the right so we can play with it more easily resultsViewer = searchinfoview.SearchInfoView(self.scene, color, parent=self.tab_search_structures) res=[] for addr, value in reSearcher: offset = addr-self.mapping.start # add item to viewer + graphicsScene it = resultsViewer.addResult( offset, value, color) res.append(it) self.tab_search_structures.addItem(resultsViewer, searchName) nb = self.tab_search_structures.count() self.tab_search_structures.setItemEnabled(nb-1, True) # resize #self.tab_search_structures return res