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( [x.to_list() for x in 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(self)
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 = [x for x in self.items[start:stop] if x.enabled] else: base = 0 enabled_items = [x for x in self.items if x.enabled] offsets = set([x.offset for x in 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 range(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 = [x for x in enabled_items if x.offset == offset] 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