rovo89 / android_art

Android ART with modifications for the Xposed framework.
Other
376 stars 212 forks source link

Xposed can works on Android 7 #61

Closed duoniduoni closed 7 years ago

duoniduoni commented 7 years ago

android_7 0_hookmethod_ok ![Uploading Android_7.0_hookMethod_OK.jpg…]()

In my options, there are three parts in Xposed(ART):

  1. Hook
  2. Remove optimizations(like inline、direct branching .......)
  3. redex2oat

frist : original xposed can set hook by watching ‘source code’,but we always have no chance to watch 'source code', we alawys watch 'decompile code' to set hook.

second : It is too hard to porting original xposed to Android 7, because Part 2 and Part 3; And it is useless if you have no chance to watch 'source code', so I remove the Part2 and Part 3, just porting Part 1 —— Hook to Android 7, it works !

I desire to consult with you @rovo89 .

Xposed gives a lot of help on my job , thank you @rovo89 !

PS : I am a chinese, my english is very poor ~ ^_^

rovo89 commented 7 years ago

I know that it's possible, I had a proof of concept for the easy cases months ago. But I don't have time to work on Xposed at the moment, that's why there's no progress. And I want to avoid removing optimizations and redexing this time to keep the original performance, which is quite hard, but I think it will be possible.

duoniduoni commented 7 years ago

thank you @rovo89

May I have the code how you proof of concept for the easy cases please ?

I have a question here :

void ArtMethod::VisitRoots(RootVisitorType& visitor, size_t pointer_size) {
  ArtMethod* interface_method = nullptr;
  mirror::Class* klass = declaring_class_.Read();
  if (LIKELY(klass != nullptr)) {
    if (UNLIKELY(klass->IsProxyClass())) {
      // For normal methods, dex cache shortcuts will be visited through the declaring class.
      // However, for proxies we need to keep the interface method alive, so we visit its roots.
      interface_method = mirror::DexCache::GetElementPtrSize(
          GetDexCacheResolvedMethods(pointer_size),
          GetDexMethodIndex(),
          pointer_size);
      DCHECK(interface_method != nullptr);
      DCHECK_EQ(interface_method,
                Runtime::Current()->GetClassLinker()->FindMethodForProxy(klass, this));
      interface_method->VisitRoots(visitor, pointer_size);
    }   
    visitor.VisitRoot(declaring_class_.AddressWithoutBarrier());
    // We know we don't have profiling information if the class hasn't been verified. Note
    // that this check also ensures the IsNative call can be made, as IsNative expects a fully
    // created class (and not a retired one).
    if (klass->IsVerified()) {
      // Runtime methods and native methods use the same field as the profiling info for
      // storing their own data (jni entrypoint for native methods, and ImtConflictTable for
      // some runtime methods).

      if (!IsNative() && !IsRuntimeMethod() && !IsXposedHookedMethod()) {
        ProfilingInfo* profiling_info = GetProfilingInfo(pointer_size);
        if (profiling_info != nullptr) {
          profiling_info->VisitRoots(visitor);
        }
      }   
    }   

    if (UNLIKELY(IsXposedHookedMethod())) {
      GetXposedOriginalMethod()->VisitRoots(visitor, pointer_size);
    }   
  }
}

I think it is right , but i am not very sure, I need your help, please!

duoniduoni commented 7 years ago

@rovo89

hello ?

rovo89 commented 7 years ago

I don't think I have that source code state anymore, and even if I had it, I wouldn't publish half-finished work, sorry.

duoniduoni commented 7 years ago

thank you @rovo89

duoniduoni commented 7 years ago

thank you @rovo89