``get_instruction_info`` returns an InstructionInfo object for the instruction at the given virtual address ``addr`` with data ``data``. .. note:: The instruction info object should always set the InstructionInfo.length to the instruction length, \ and the branches of the proper types shou
(self, data: bytes, addr: int)
| 2353 | return CoreArchitecture._from_cache(handle=result), new_addr.value |
| 2354 | |
| 2355 | def get_instruction_info(self, data: bytes, addr: int) -> Optional[InstructionInfo]: |
| 2356 | """ |
| 2357 | ``get_instruction_info`` returns an InstructionInfo object for the instruction at the given virtual address |
| 2358 | ``addr`` with data ``data``. |
| 2359 | |
| 2360 | .. note:: The instruction info object should always set the InstructionInfo.length to the instruction length, \ |
| 2361 | and the branches of the proper types should be added if the instruction is a branch. |
| 2362 | |
| 2363 | :param bytes data: a maximum of max_instruction_length bytes from the binary at virtual address ``addr`` |
| 2364 | :param int addr: virtual address of bytes in ``data`` |
| 2365 | :return: the InstructionInfo for the current instruction |
| 2366 | :rtype: InstructionInfo |
| 2367 | """ |
| 2368 | info = core.BNInstructionInfo() |
| 2369 | buf = (ctypes.c_ubyte * len(data))() |
| 2370 | ctypes.memmove(buf, data, len(data)) |
| 2371 | if not core.BNGetInstructionInfo(self.handle, buf, addr, len(data), info): |
| 2372 | return None |
| 2373 | result = InstructionInfo() |
| 2374 | result.length = info.length |
| 2375 | result.arch_transition_by_target_addr = info.archTransitionByTargetAddr |
| 2376 | result.branch_delay = info.delaySlots |
| 2377 | for i in range(0, info.branchCount): |
| 2378 | target = info.branchTarget[i] |
| 2379 | if info.branchArch[i]: |
| 2380 | arch = CoreArchitecture._from_cache(info.branchArch[i]) |
| 2381 | else: |
| 2382 | arch = None |
| 2383 | result.add_branch(BranchType(info.branchType[i]), target, arch) |
| 2384 | return result |
| 2385 | |
| 2386 | def get_instruction_text(self, data: bytes, addr: int) -> Optional[Tuple[List['function.InstructionTextToken'], int]]: |
| 2387 | """ |
nothing calls this directly
no test coverage detected