MCPcopy Create free account
hub / github.com/Vector35/binaryninja-api / get_instruction_info

Method get_instruction_info

python/examples/nes.py:485–506  ·  view source on GitHub ↗
(self, data:bytes, addr:int)

Source from the content-addressed store, hash-verified

483 return instr, operand, length, value
484
485 def get_instruction_info(self, data:bytes, addr:int) -> Optional[InstructionInfo]:
486 result = M6502.decode_instruction(data, addr)
487 if result is None:
488 return None
489 instr, operand, length, _ = result
490 assert length is not None
491 result = InstructionInfo()
492 result.length = length
493 if instr == "jmp":
494 if operand == ADDR:
495 result.add_branch(BranchType.UnconditionalBranch, struct.unpack("<H", data[1:3])[0])
496 else:
497 result.add_branch(BranchType.UnresolvedBranch)
498 elif instr == "jsr":
499 result.add_branch(BranchType.CallDestination, struct.unpack("<H", data[1:3])[0])
500 elif instr in ["rti", "rts"]:
501 result.add_branch(BranchType.FunctionReturn)
502 if instr in ["bcc", "bcs", "beq", "bmi", "bne", "bpl", "bvc", "bvs"]:
503 dest = (addr + 2 + struct.unpack("b", data[1:2])[0]) & 0xffff
504 result.add_branch(BranchType.TrueBranch, dest)
505 result.add_branch(BranchType.FalseBranch, addr + 2)
506 return result
507
508 def get_instruction_text(self, data: bytes, addr: int) -> Optional[Tuple[List[InstructionTextToken], int]]:
509 result = M6502.decode_instruction(data, addr)

Callers 3

liftFunction · 0.45
find_jump_tableFunction · 0.45
populate_nodesMethod · 0.45

Calls 3

add_branchMethod · 0.95
InstructionInfoClass · 0.90
decode_instructionMethod · 0.80

Tested by 1

liftFunction · 0.36