Class AbstractGraphReorganizer<InsnType extends ILocatedInstruction>

java.lang.Object
com.pnfsoftware.jeb.core.units.code.android.controlflow.AbstractGraphReorganizer<InsnType>

public abstract class AbstractGraphReorganizer<InsnType extends ILocatedInstruction> extends Object
Facility for CFG graph nodes reordering and graph address shifting.
  • Constructor Details

    • AbstractGraphReorganizer

      public AbstractGraphReorganizer(CFG<InsnType> cfg)
  • Method Details

    • reorder

      public CFG<InsnType> reorder(int[] newOrder)
      Parameters:
      newOrder - an array of 0-based indices from 0 to n-1; providing [0, 1, ..., n-1] does nothing
      Returns:
      a reordered CFG; null if the provided order was the original order
    • shift

      public void shift(int shsize)
      Shift the CFG 'downward', ie, all addresses. This method works in-place; no new CFG is created (unlike reorder(int[])).
      Parameters:
      shsize - a strictly positive value; else the method will throw
    • getReorganizedCfg

      public CFG<InsnType> getReorganizedCfg()
      Retrieve a CFG reorganized by reorder(int[]).
      Returns:
    • getConversionMap

      public Map<Long,Long> getConversionMap()
      Retrieve a map holding the old offsets to their corresponding new offsets, in the reorganized CFG.
      Returns:
    • canFallthrough

      protected abstract boolean canFallthrough(InsnType insn)
      Determine if the provided instruction is a flow breaker that falls-through (or may, if it's a conditional branch) into the first instruction of the next block.
      Parameters:
      insn -
      Returns:
    • updateInstructionOffset

      protected abstract InsnType updateInstructionOffset(InsnType insn, long insnOffset)
      Update or copy the provided instruction and set its offset. It is up to the implementation to decide whether instructions should be copied (consequence: the original CFG may be fully preserved, at the cost of speed and resources) or reused.
      Parameters:
      insn - original instruction
      insnOffset - new offset
      Returns:
      the provided instruction (updated), or a new (copy) of the instruction with the provided offset
    • createTrampoline

      protected abstract InsnType createTrampoline(long insnOffset, long tempTarget)
      Parameters:
      insnOffset -
      tempTarget -
      Returns:
    • createNop

      protected abstract InsnType createNop(long insnOffset, int insnSize)
      Parameters:
      insnOffset -
      insnSize -
      Returns:
    • updateTrampolineTarget

      protected abstract void updateTrampolineTarget(InsnType insn, long target)
      Parameters:
      insn - must be a trampoline instruction
      target -
    • hasTargets

      protected abstract boolean hasTargets(InsnType insn)
      Determine whether the instruction has targets that may be updated.
      Parameters:
      insn -
      Returns:
    • updateTargets

      protected abstract void updateTargets(InsnType insn, Map<Long,Long> map)
      Parameters:
      insn -
      map -