def copy_bytes(): """ Copy selected bytes to clipboard """ if using_ida7api: start = idc.read_selection_start() end = idc.read_selection_end() if idaapi.BADADDR in (start, end): ea = idc.here() start = idaapi.get_item_head(ea) end = idaapi.get_item_end(ea) # # reference https://stackoverflow.com/questions/6624453/whats-the-correct-way-to-convert-bytes-to-a-hex-string-in-python-3 data = idc.get_bytes(start, end - start).hex() print("Bytes copied: %s" % data) copy_to_clip(data) else: start = idc.SelStart() end = idc.SelEnd() if idaapi.BADADDR in (start, end): ea = idc.here() start = idaapi.get_item_head(ea) end = idaapi.get_item_end(ea) # reference https://stackoverflow.com/questions/6624453/whats-the-correct-way-to-convert-bytes-to-a-hex-string-in-python-3 # not work in ida7.5 python3.7.7 # data = idc.GetManyBytes(start, end-start).encode('hex') data = idc.GetManyBytes(start, end - start).hex() print("Bytes copied: %s" % data) copy_to_clip(data) return
def get_selection(): start = idc.SelStart() end = idc.SelEnd() if idaapi.BADADDR in (start, end): ea = idc.here() start = idaapi.get_item_head(ea) end = idaapi.get_item_end(ea) return start, end
def get_selection(always=True): start = idc.SelStart() end = idc.SelEnd() if idaapi.BADADDR in (start, end): if not always: raise exceptions.SarkNoSelection() ea = idc.here() start = idaapi.get_item_head(ea) end = idaapi.get_item_end(ea) return Selection(start, end)
def get_selection(always=True): start = idc.SelStart() end = idc.SelEnd() if idaapi.BADADDR in (start, end): if not always: raise exceptions.SarkNoSelection() ea = idc.here() start = idaapi.get_item_head(ea) end = idaapi.get_item_end(ea) return Selection(start, end)
def _build_metadata(self): """ Collect node metadata from the underlying database. """ current_address = self.address node_end = self.address + self.size # # loop through the node's entire range and count its instructions # NOTE: we are assuming that every defined 'head' is an instruction # while current_address < node_end: instruction_size = idaapi.get_item_end(current_address) - current_address self.instructions.append(current_address) current_address += instruction_size # save the number of instructions in this block self.instruction_count = len(self.instructions)
def _ida_cache_node(self, _): """ Collect node metadata from the underlying database. """ current_address = self.address node_end = self.address + self.size # # loop through the node's entire address range and count its # instructions. Note that we are assuming that every defined # 'head' (in IDA) is an instruction # while current_address < node_end: instruction_size = get_item_end(current_address) - current_address self.instructions[current_address] = instruction_size current_address += instruction_size # the source of the outward edge self.edge_out = current_address - instruction_size # save the number of instructions in this block self.instruction_count = len(self.instructions)
def get_next_insn_ea (ea, n): current_ea = ea for m in range(0, n): current_ea = idaapi.get_item_end (current_ea) return current_ea
def get_next_insn_ea(ea, n): current_ea = ea for m in range(0, n): current_ea = idaapi.get_item_end(current_ea) return current_ea