def __call__(self): new_ranges = {r[0]: r for r in self.sreg_ranges} old_ranges = {r[0]: r for r in SgrChanged.get_sreg_ranges(self.rg)} start_eas = sorted( set(list(new_ranges.keys()) + list(old_ranges.keys()))) for start_ea in start_eas: new_range = new_ranges.get(start_ea, None) old_range = old_ranges.get(start_ea, None) if new_range and not old_range: _, __, val, tag = new_range ida_segregs.split_sreg_range(start_ea, self.rg, val, tag, True) if not new_range and old_range: ida_segregs.del_sreg_range(start_ea, self.rg) if new_range and old_range: _, __, new_val, new_tag = new_range _, __, old_val, old_tag = old_range if new_val != old_val or new_tag != old_tag: ida_segregs.split_sreg_range(start_ea, self.rg, new_val, new_tag, True) ida_kernwin.request_refresh(ida_kernwin.IWID_SEGREGS)
def load_file(li, neflags, format): flags = ida_idp.SETPROC_LOADER_NON_FATAL | ida_idp.SETPROC_LOADER ida_idp.set_processor_type("arm", flags) header = parse_header(li) offset = header.header_size while True: li.seek(offset) if li.read(1) != b'\x00': break offset += 1 length = header.content_size - (offset - header.header_size) seg = ida_segment.segment_t() seg.start_ea = header.base_address seg.end_ea = seg.start_ea + length seg.bitness = 1 ida_segment.add_segm_ex(seg, "ROM", "CODE", 0) li.file2base(offset, seg.start_ea, seg.end_ea - 1, 0) ida_segregs.split_sreg_range(seg.start_ea, ida_idp.str2reg("T"), 1, ida_segregs.SR_user) return 1