def __init__(self, items, temp_struct, virtual_table): MyChoose.__init__( self, items, "Select Virtual Function", [["Address", 10], ["Name", 15], ["Declaration", 45]], 13) self.popup_names = ["Scan All", "-", "Scan", "-"] self.__temp_struct = temp_struct self.__virtual_table = virtual_table
def activated(self, index): # Double click on offset, opens window with variables if index.column() == 0: item = self.items[index.row()] scanned_variables = list(item.scanned_variables) variable_chooser = MyChoose( map(lambda x: x.to_list(), scanned_variables), "Select Variable", [["Origin", 4], ["Function name", 25], ["Variable name", 25], ["Expression address", 10]] ) row = variable_chooser.Show(modal=True) if row != -1: idaapi.open_pseudocode(scanned_variables[row].expression_address, 0) # Double click on type. If type is virtual table than opens windows with virtual methods elif index.column() == 1: self.items[index.row()].activate()
def get_recognized_shape(self, start=0, stop=-1): if not self.items: return None result = [] if stop != -1: base = self.items[start].offset enabled_items = filter(lambda x: x.enabled, self.items[start:stop]) else: base = 0 enabled_items = filter(lambda x: x.enabled, self.items) offsets = set(map(lambda x: x.offset, enabled_items)) if not enabled_items: return min_size = enabled_items[-1].offset + enabled_items[-1].size - base tinfo = idaapi.tinfo_t() for ordinal in xrange(1, idaapi.get_ordinal_qty(idaapi.cvar.idati)): tinfo.get_numbered_type(idaapi.cvar.idati, ordinal) if tinfo.is_udt() and tinfo.get_size() >= min_size: is_found = False for offset in offsets: is_found = False items = filter(lambda x: x.offset == offset, enabled_items) potential_members = Helper.get_fields_at_offset( tinfo, offset - base) for item in items: for potential_member in potential_members: if item.type_equals_to(potential_member): is_found = True break if is_found: break if not is_found: break if is_found: result.append((ordinal, idaapi.tinfo_t(tinfo))) chooser = MyChoose( [[str(x), "0x{0:08X}".format(y.get_size()), y.dstr()] for x, y in result], "Select Structure", [["Ordinal", 5], ["Size", 10], ["Structure name", 50]]) idx = chooser.Show(modal=True) if idx != -1: return result[idx][1] return None
def show_virtual_functions(self): function_chooser = MyChoose([ function.get_information() for function in self.virtual_functions ], "Select Virtual Function", [["Address", 10], ["Name", 15], ["Declaration", 45]], 13) function_chooser.OnGetIcon = lambda n: 32 if self.virtual_functions[ n].visited else 160 function_chooser.OnGetLineAttr = \ lambda n: [0xd9d9d9, 0x0] if self.virtual_functions[n].visited else [0xffffff, 0x0] # Very nasty, but have no time to make nice QT window instead Ida Choose2 menu. # This function creates menu "Scan All" function_chooser.popup_names = ["Scan All", "-", "Scan", "-"] function_chooser.OnInsertLine = self.scan_virtual_functions function_chooser.OnEditLine = self.scan_virtual_function idx = function_chooser.Show(True) if idx != -1: self.virtual_functions[idx].visited = True idaapi.open_pseudocode(int(self.virtual_functions[idx]), 1)