コード例 #1
0
ファイル: HookTool.java プロジェクト: ponysen/ponify
    public void addClassTreeHook(HookClass origin, HookClass to) {
      addSuperclassHook(origin, to);

      Set<HookClass> superclassHookSet = new HashSet<HookClass>();
      superclassHookSet.add(origin);

      for (ClassDefItem classDef : mDexFile.ClassDefsSection.getItems()) {
        HookClass superclass = new HookClass(classDef.getSuperclass());

        if (superclassHookSet.contains(superclass)) {
          TypeIdItem classType = classDef.getClassType();
          HookClass newHook = new HookClass(classType);
          superclassHookSet.add(newHook);
          mHooks.put(newHook, classType);
        }
      }

      HookClass[] superclassHooks = superclassHookSet.toArray(new HookClass[0]);

      HashSet<EncodedMethod> newClassMethods = getClassMethodsMap().get(to);

      if (newClassMethods != null) {
        for (EncodedMethod newVirtual : newClassMethods) {
          if (newVirtual.isDirect()) {
            continue;
          }

          for (HookClass superclass : superclassHooks) {
            HookMethod deadMethod = new HookMethod(newVirtual.method);
            deadMethod.mClasspath = superclass.mClasspath;
            mDead.add(deadMethod);
          }
        }
      }
    }
コード例 #2
0
ファイル: HookTool.java プロジェクト: ponysen/ponify
  private void initClassMaps() {
    mClasses = new HashMap<HookClass, TypeIdItem>();
    mClassMethods = new HashMap<HookClass, HashSet<EncodedMethod>>();
    mSubclasses = new HashMap<String, Set<String>>();

    for (ClassDefItem item : mDexFile.ClassDefsSection.getItems()) {
      TypeIdItem classType = item.getClassType();
      HookClass classHook = new HookClass(classType);
      mClasses.put(classHook, classType);

      String superclassType = item.getSuperclass().getTypeDescriptor();
      Set<String> subclassSet = mSubclasses.get(superclassType);

      if (subclassSet == null) {
        subclassSet = new TreeSet<String>();
        mSubclasses.put(superclassType, subclassSet);
      }

      subclassSet.add(classType.getTypeDescriptor());

      ClassDataItem classData = item.getClassData();

      if (classData == null) {
        continue;
      }

      HashSet<EncodedMethod> classMethods = new HashSet<EncodedMethod>();

      for (EncodedMethod method : classData.getDirectMethods()) {
        classMethods.add(method);
      }

      for (EncodedMethod method : classData.getVirtualMethods()) {
        classMethods.add(method);
      }

      mClassMethods.put(classHook, classMethods);
    }
  }
コード例 #3
0
ファイル: HookTool.java プロジェクト: ponysen/ponify
 public void hookSuperclasses(HookMap hooks) {
   for (ClassDefItem classDef : mDexFile.ClassDefsSection.getItems()) {
     hookSuperclass(hooks, classDef);
   }
 }