Esempio n. 1
0
  /**
   * Inserts hooks into a single code item.
   *
   * @param hooks
   * @param classData
   * @param code
   */
  private void hookReferences(HookMap hooks, ClassDataItem classData, CodeItem code) {
    if (code == null) {
      return;
    }

    Instruction[] instructions = code.getInstructions();
    for (int index = 0; index < instructions.length; index++) {
      Instruction i = instructions[index];

      if (i instanceof InstructionWithReference) {
        InstructionWithReference inst = (InstructionWithReference) i;

        HookItem oldTarget = HookItem.getInstance(inst.getReferencedItem());

        if (!hooks.containsKey(oldTarget)) {
          continue;
        }

        Item newTarget = hooks.get(oldTarget);

        inst.referencedItem = newTarget;

        if (newTarget instanceof MethodIdItem) {
          // Need to update the invoke type if it changed
          updateInvokeType(inst, (MethodIdItem) newTarget);
        }
      }
    }
  }
  @Override
  public Set<DexType> introducedTypes() {
    InstructionWithReference i = (InstructionWithReference) instruction;

    Set<DexType> types = new HashSet<DexType>();
    types.add(new DexType((TypeIdItem) i.getReferencedItem()));
    return types;
  }