com.pnfsoftware.jeb.core.units.code.android.ir.IDInstruction |
dexdec
IR instruction object. Each intermediate representation instruction has:
- an opcode: refer to DOpcodeType
- zero, one, or two operands, of type IDElement
- an offset (in the IR)
- a size
IR CFGs consist of basic blocks made of IR instructions. An IDMethodContext
references it
IR CFG. IR instructions can also be created via the createXxx
methods of the context
object.
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract void |
adjustSize(int delta)
Adjust this instruction's IR size.
| ||||||||||
abstract IDInstruction |
copy(DCopyOptions opt)
Copy this element.
| ||||||||||
abstract void |
copyBaseFields(IDInstruction sourceInsn)
Copy all base fields, that is all fields but the opcode and operands of the source
instruction to this instruction.
| ||||||||||
abstract int |
countUsedIdentifier(IDVar var)
This method is deprecated.
use
countUsedVariable(IDVar) instead
| ||||||||||
abstract int |
countUsedVariable(IDVar var)
Count the number of times the provided variable is used (read) by this instruction.
| ||||||||||
abstract IDInstruction |
duplicate()
Deep copy of this instruction.
| ||||||||||
abstract IDInstruction |
duplicateForReplacement(IDInstruction replacedInsn)
Duplicate this instruction with the intent to replace the source instruction.
| ||||||||||
abstract IDInstruction | duplicateWithOffsetAndSize(long offset, int size) | ||||||||||
abstract Integer |
evaluate(Map<Integer, IDImm> varmap)
Convenience method: evaluate the IR instruction using the provided set a variable values.
| ||||||||||
abstract IDExpression | getAssignDestination() | ||||||||||
abstract IDExpression | getAssignSource() | ||||||||||
abstract int | getBranchTarget() | ||||||||||
abstract IDMethodContext |
getContext()
Retrieve the IR method context to which this instruction belongs.
| ||||||||||
abstract IDVar |
getDefinedIdentifier()
This method is deprecated.
use
getDefinedVariable() instead
| ||||||||||
abstract IDVar |
getDefinedVariable()
Get the identifier defined (written) by this method, if there is one.
| ||||||||||
abstract IDInvokeInfo | getInvokeData() | ||||||||||
abstract IDPredicate |
getJcondCondition()
Get the condition predicate (if the instruction is a JCOND).
| ||||||||||
abstract long |
getOffset()
IR offsets are 32-bit integers; they can be safely cast to int.
| ||||||||||
abstract long |
getOffsetEnd()
Retrieve the end offset (exclusive) of this instruction
| ||||||||||
abstract DOpcodeType |
getOpcode()
Get this instruction opcode.
| ||||||||||
abstract IDElement |
getOperand1()
Get the first operand.
| ||||||||||
abstract IDElement |
getOperand2()
Get the second operand.
| ||||||||||
abstract IDExpression | getReturnExpression() | ||||||||||
abstract IDSwitchData | getSwitchData() | ||||||||||
abstract IDExpression | getSwitchExpression() | ||||||||||
abstract IDExpression | getThrowExpression() | ||||||||||
abstract List<IDVar> |
getUsedIdentifiers()
This method is deprecated.
use
getUsedVariables() instead
| ||||||||||
abstract List<IDVar> |
getUsedVariables()
Get the variables used (read) by this instruction.
| ||||||||||
abstract boolean |
hasRightSideSideEffects(boolean includeCanThrow)
This method is deprecated.
this method is deprecated, you may want to use
hasUseSideEffects(boolean) instead.
| ||||||||||
abstract boolean |
hasUseSideEffects(boolean includeCanThrow)
Determine whether the used components of the statement may have side-effects.
| ||||||||||
abstract boolean | isAssign() | ||||||||||
abstract boolean | isAssignFromVar(int wantedVarId) | ||||||||||
abstract boolean | isAssignFromVar() | ||||||||||
abstract boolean | isAssignFromVarToVar(int wantedSrcVarId, int wantedDstVarId) | ||||||||||
abstract boolean | isAssignFromVarToVar() | ||||||||||
abstract boolean | isAssignToVar() | ||||||||||
abstract boolean | isAssignToVar(int wantedVarId) | ||||||||||
abstract boolean | isInvoke() | ||||||||||
abstract boolean | isJcond() | ||||||||||
abstract boolean | isJcondOrSwitch() | ||||||||||
abstract boolean | isJump() | ||||||||||
abstract boolean | isJumpOrJcond() | ||||||||||
abstract boolean | isMonitorEnter() | ||||||||||
abstract boolean | isMonitorExit() | ||||||||||
abstract boolean | isNop() | ||||||||||
abstract boolean | isReturn() | ||||||||||
abstract boolean | isStoreException() | ||||||||||
abstract boolean | isSwitch() | ||||||||||
abstract boolean | isSwitchOnInt() | ||||||||||
abstract boolean | isSwitchOnString() | ||||||||||
abstract boolean | isThrow() | ||||||||||
abstract void |
morph(DOpcodeType opcode, IDElement opnd1, IDElement opnd2)
This dangerous method allows changing an IR instruction into a different one, while keeping
metadata (e.g.
| ||||||||||
abstract int |
replaceDefinedVariable(IDVar var, IDExpression repl)
Replace the variable defined by this statement (if there is any).
| ||||||||||
abstract int |
replaceUsedIdentifier(IDVar var, IDExpression repl)
This method is deprecated.
use
replaceUsedVariable(IDVar, IDExpression) instead
| ||||||||||
abstract int |
replaceUsedVariable(IDVar var, IDExpression repl)
Deep replace all matching used variables of this instruction.
| ||||||||||
abstract IDExpression | setAssignDestination(IDExpression dst) | ||||||||||
abstract IDExpression | setAssignSource(IDExpression src) | ||||||||||
abstract int |
setBranchTarget(int offset)
Update the branch target for unconditional and conditional jumps only.
| ||||||||||
abstract IDMethodContext |
setContext(IDMethodContext ctx)
Update the instruction context.
| ||||||||||
abstract IDPredicate | setJcondCondition(IDPredicate cond) | ||||||||||
abstract void |
setOffset(long offset)
Set this instruction's IR offset.
| ||||||||||
abstract void |
setOpcode(DOpcodeType opcode)
Change the instruction opcode.
| ||||||||||
abstract void |
setOperand1(IDElement opnd)
Change the instruction first operand.
| ||||||||||
abstract void |
setOperand2(IDElement opnd)
Change the instruction second operand.
| ||||||||||
abstract IDExpression | setReturnExpression(IDExpression exp) | ||||||||||
abstract void |
setSize(int size)
Set this instruction's IR size.
| ||||||||||
abstract IDSwitchData | setSwitchData(IDSwitchData swdata) | ||||||||||
abstract IDExpression | setSwitchExpression(IDExpression exp) | ||||||||||
abstract IDExpression | setThrowExpression(IDExpression exp) | ||||||||||
abstract void |
transformJcondToAssign(IDVar dst)
Transform a conditional jump instruction to a conditional-predicate assignment.
| ||||||||||
abstract void |
transformJcondToJump()
Transform a conditional jump instruction to a jump.
| ||||||||||
abstract boolean |
transformSwitchToJcond()
Transform a single-case switch into a conditional jump.
| ||||||||||
abstract void |
transformToJump(IDTarget target)
Transform any instruction to a jump, and update the jump target.
| ||||||||||
abstract void |
transformToJump(int offset)
Transform any instruction to a jump, and update the jump target.
| ||||||||||
abstract void |
transformToNop()
Transform any instruction to a NOP.
| ||||||||||
abstract int |
updateTargets(Map<Integer, Integer> oldToNewOffsets)
Update the targets of a branching instruction.
| ||||||||||
abstract int |
updateTargets(Map<Integer, Integer> oldToNewOffsets, boolean failOnMissedEntry)
Update the targets of a branching instruction.
| ||||||||||
abstract void |
verify()
Verify this instruction.
| ||||||||||
abstract boolean |
visitInstruction(IDVisitor visitor, boolean skipAssignmentDestination)
Visit this instruction and its constituents.
| ||||||||||
abstract boolean |
visitInstruction(IDVisitor visitor)
Visit this instruction and its constituents.
| ||||||||||
abstract boolean |
visitInstructionPostOrder(IDVisitor visitor, boolean skipAssignmentDestination)
Visit this instruction and its constituents.
| ||||||||||
abstract boolean |
visitInstructionPreOrder(IDVisitor visitor, boolean skipAssignmentDestination)
Visit this instruction and its constituents.
| ||||||||||
abstract IDInstruction |
withOffset(long offset)
Update the instruction offset.
| ||||||||||
abstract IDInstruction |
withSize(int size)
Update the instruction size.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Adjust this instruction's IR size. Dangerous method. Make sure to ensure CFG consistency if this instruction is part of a CFG.
delta | added to the current size
|
---|
Copy this element. This operation can be seen as a custom duplication; the resulting element may not be of the same type as this element.
opt | optional; if one is provided, onDup(IDExpression) will be
tried first to create a copy |
---|
Copy all base fields, that is all fields but the opcode and operands of the source instruction to this instruction.
Count the number of times the provided variable is used (read) by this instruction.
Example (ASSIGN opcode): x = y * (y + z)
=> x is not used; y is used twice; z is used
once
Deep copy of this instruction.
Duplicate this instruction with the intent to replace the source instruction. The offset and size of the source instruction are copied over to the newly created instruction.
Convenience method: evaluate the IR instruction using the provided set a variable values.
varmap | a map of variable values to be used when evaluating the expression (this map
will not be modified after evaluation of the instruction; for full-control of the
emulation, use evaluate(IDState) instead of this method) |
---|
DexDecEvaluationException |
---|
Retrieve the IR method context to which this instruction belongs. The method context holds
all information regarding a current method decompilation. It is also a factory to create more
IDInstruction
objects.
Get the identifier defined (written) by this method, if there is one. Only
IR_ASSIGN
and IR_STORE_EXCEPTION
may define (write)
identifiers.
is an invocation
Get the condition predicate (if the instruction is a JCOND).
IR offsets are 32-bit integers; they can be safely cast to int.
Retrieve the end offset (exclusive) of this instruction
Get the first operand. May be null if the opcode does not specify one. Refer to
getOpcode()
and DOpcodeType
.
Get the second operand. May be null if the opcode does not specify one. Refer to
getOpcode()
and DOpcodeType
.
Get the variables used (read) by this instruction.
z = x + (y * x)
would return [y, x, x]
.
This method is deprecated.
this method is deprecated, you may want to use
hasUseSideEffects(boolean)
instead.
Determine whether the right-side of assignment statements may have side-effects.
This method is not fail-safe, it works on a best-effort basis. Refer to
hasSideEffects(IDMethodContext, boolean)
for more information.@return
Determine whether the used components of the statement may have side-effects.
This method is not fail-safe, it works on a best-effort basis. Refer to
hasSideEffects(IDMethodContext, boolean)
for more information.
invocation
(call, new,
new-array, alloc-object)
store-exception
(special opcode)
This dangerous method allows changing an IR instruction into a different one, while keeping
metadata (e.g. offset, size, etc.) intact. If possible, use one of the transformXxx
instructions instead.
opcode | new opcode |
---|---|
opnd1 | new operand 1 (if any) - refer to DOpcodeType 's type for operand type |
opnd2 | new operand 2 (if any) - refer to DOpcodeType 's type for operand type
|
Replace the variable defined by this statement (if there is any).
var | target variable to be replaced |
---|---|
repl | expression that will replace the variable |
Deep replace all matching used variables of this instruction. The replacement expression is duplicated to avoid reuse. Defined identifiers (if any) are not replaced.
var | target variable to be replaced |
---|---|
repl | expression that will replace the variable |
Update the branch target for unconditional and conditional jumps only. This function fails for all other opcodes, including switches.
offset | the new offset |
---|
Update the instruction context. It is important to update the context when transferring the instructions from a CFG (from context A) to another CFG (of contextB).
ctx | new context |
---|
Set this instruction's IR offset. Dangerous method. Make sure to ensure CFG consistency if this instruction is part of a CFG.
Change the instruction opcode. This method is dangerous. Instruction operands may require an update as well.
Change the instruction first operand. This method is dangerous. Other instruction attributes may require an update as well.
Change the instruction second operand. This method is dangerous. Other instruction attributes may require an update as well.
Set this instruction's IR size. Dangerous method. Make sure to ensure CFG consistency if this instruction is part of a CFG.
size | new size |
---|
Transform a conditional jump instruction to a conditional-predicate assignment. It is the caller's responsibility to verify that the instruction is a JCOND.
IF pred GOTO target ==> dst = pred
dst | the destination operand for the predicate |
---|
Transform a conditional jump instruction to a jump. It is the caller's responsibility to verify that the instruction is a JCOND.
IF pred GOTO target ==> GOTO target
Transform a single-case switch into a conditional jump.
SWITCH(VAR) { CASE X: GOTO target; } // fall-through => IF VAR==X GOTO target; // fall-through
Transform any instruction to a jump, and update the jump target.
target | a target |
---|
Transform any instruction to a jump, and update the jump target.
offset | target offset |
---|
Transform any instruction to a NOP.
Update the targets of a branching instruction. This method has no effect on IR opcodes other
than JUMP
, JCOND
, and SWITCH
.
oldToNewOffsets | a map of current IR offsets to new IR offsets |
---|
Update the targets of a branching instruction. This method has no effect on IR opcodes other
than JUMP
, JCOND
, and SWITCH
.
oldToNewOffsets | a map of current IR offsets to new IR offsets |
---|---|
failOnMissedEntry | if true, the method will raise if a (current) branch target cannot be mapped to a new target (i.e., if there is no entry for a branch target in the map) |
Verify this instruction.
Currently, this method verifies that the instruction operands match the current opcode
specifications (see DOpcodeType
).
IllegalStateException | throw on error |
---|
Visit this instruction and its constituents. The visit is made depth-first, pre-order, and
parents are recorded. (Refer to IVisitResults
for details.)
Same as visitInstructionPreOrder
. Replacements must be reported (refer to
visitDepthPre(IDVisitor)
for details).
visitor | visitor object |
---|---|
skipAssignmentDestination | true to skip visiting the destination of
IR_ASSIGN or IR_STORE_EXCEPTION |
DVisitResults
when visiting an element
Visit this instruction and its constituents. The visit is made depth-first, pre-order, and
parents are recorded. (Refer to IVisitResults
for details.)
Same as visitInstructionPreOrder
. Replacements must be reported (refer to
visitDepthPre(IDVisitor)
for details).
visitor | visitor object |
---|
DVisitResults
when visiting an element
Visit this instruction and its constituents. The visit is made depth-first, post-order, and
parents are recorded. (Refer to IVisitResults
for details.)
Replacements need not be reported.
visitor | visitor object |
---|---|
skipAssignmentDestination | true to skip visiting the destination of
IR_ASSIGN or IR_STORE_EXCEPTION |
DVisitResults
when visiting an element
Visit this instruction and its constituents. The visit is made depth-first, pre-order, and
parents are recorded. (Refer to IVisitResults
for details.)
Replacements must be reported (refer to visitDepthPre(IDVisitor)
for
details).
visitor | visitor object |
---|---|
skipAssignmentDestination | true to skip visiting the destination of
IR_ASSIGN or IR_STORE_EXCEPTION |
DVisitResults
when visiting an element
Update the instruction offset.
offset | new offset |
---|
Update the instruction size.
size | new size |
---|