Java Code Examples for ghidra.program.model.listing.Instruction#getOpObjects()
The following examples show how to use
ghidra.program.model.listing.Instruction#getOpObjects() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EquateDB.java From ghidra with Apache License 2.0 | 6 votes |
private short findScalarOpIndex(Instruction instr) { short opIndex = -1; long value = record.getLongValue(EquateDBAdapter.VALUE_COL); int numOperands = instr.getNumOperands(); for (short i = 0; i < numOperands; i++) { for (Object obj : instr.getOpObjects(i)) { if (obj instanceof Scalar) { if (((Scalar) obj).getValue() != value) { continue; } if (opIndex >= 0) { return -1; // non-unique scalar operand value - can't identify operand } opIndex = i; } } } return opIndex; }
Example 2
Source File: ScalarOperandListingHover.java From ghidra with Apache License 2.0 | 5 votes |
private Object getOperand(OperandFieldLocation loc, Instruction instruction) { int opIndex = loc.getOperandIndex(); Object[] operands = instruction.getOpObjects(opIndex); if (operands.length == 1) { return operands[0]; } InstructionPrototype prototype = instruction.getPrototype(); List<Object> list = prototype.getOpRepresentationList(opIndex, instruction.getInstructionContext()); if (list == null) { return null; } return list.get(loc.getSubOperandIndex()); }
Example 3
Source File: Lab5Script.java From ghidra with Apache License 2.0 | 5 votes |
@Override public void run() throws Exception { Instruction instruction = getFirstInstruction(); while (instruction != null) { if (monitor.isCancelled()) { break; } if (instruction.getNumOperands() != 2) { continue; } Object[] opObjects0 = instruction.getOpObjects(0); if (opObjects0.length != 1 || !(opObjects0[0] instanceof Register)) { continue; } Object[] opObjects1 = instruction.getOpObjects(1); if (opObjects1.length != 1 || !(opObjects1[0] instanceof Scalar)) { continue; } Register register = (Register) opObjects0[0]; Scalar scalar = (Scalar) opObjects1[0]; String comment = "[" + register.getName() + "]=[" + scalar.toString(16, false, false, "", "") + "]"; setEOLComment(instruction.getMinAddress(), comment); instruction = getInstructionAfter(instruction); } }