Example #1
0
  /**
   * Insert hooks into all code in the wrapped DexFile.
   *
   * @param hooks Description of what references to hook, and with what.
   */
  public void hookReferences(HookMap hooks) {
    for (ClassDataItem classData : mDexFile.ClassDataSection.getItems()) {
      for (EncodedMethod method : classData.getDirectMethods()) {
        CodeItem code = method.codeItem;

        hookReferences(hooks, classData, code);
      }

      for (EncodedMethod method : classData.getVirtualMethods()) {
        CodeItem code = method.codeItem;

        hookReferences(hooks, classData, code);
      }
    }
  }
Example #2
0
  /**
   * Insert hooks into the specified CodeItems.
   *
   * @param hooks Description of what references to hook, and with what.
   * @param codeItems Collection containing all CodeItem objects where hooks should be placed.
   */
  public void hookReferences(HookMap hooks, Collection<Item> codeItems) {
    for (ClassDataItem classData : mDexFile.ClassDataSection.getItems()) {
      for (EncodedMethod method : classData.getDirectMethods()) {
        CodeItem code = method.codeItem;

        if (!codeItems.contains(code)) {
          continue;
        }

        hookReferences(hooks, classData, code);
      }

      for (EncodedMethod method : classData.getVirtualMethods()) {
        CodeItem code = method.codeItem;

        if (!codeItems.contains(code)) {
          continue;
        }

        hookReferences(hooks, classData, code);
      }
    }
  }