PAGalaxyLab/YAHFA

support android 12 better.

WindySha opened this issue · 9 comments

OFFSET_classlinker_in_Runtime should be 472 + 8 in the newest android 12 version.

I think the better way to get classlinker address is the relative offset of JavaVMExt address which is easy to get by JNI.
In an art::Runtime instance, whether android 11 or android 12, the offset is 3 pointer size.

ClassLinker* class_linker_;

SignalCatcher* signal_catcher_;

std::unique_ptr<jni::JniIdManager> jni_id_manager_;

std::unique_ptr<JavaVMExt> java_vm_;
rk700 commented

I think the better way to get classlinker address is the relative offset of JavaVMExt address which is easy to get by JNI. In an art::Runtime instance, whether android 11 or android 12, the offset is 3 pointer size.

ClassLinker* class_linker_;

SignalCatcher* signal_catcher_;

std::unique_ptr<jni::JniIdManager> jni_id_manager_;

std::unique_ptr<JavaVMExt> java_vm_;

Thanks! That's a good idea. I just pushed a new commit for it: 9cea98b

@rk700
Not actually true: https://android.googlesource.com/platform/art/+/4dcac3629ea5925e47b522073f3c49420e998911

diff --git [a/runtime/runtime.h](https://android.googlesource.com/platform/art/+/48fb9f43a81fa0cab09ed4a4f3d478c1a0ecbe9e/runtime/runtime.h) [b/runtime/runtime.h](https://android.googlesource.com/platform/art/+/4dcac3629ea5925e47b522073f3c49420e998911/runtime/runtime.h)
index 2dd022e..0c99cf9 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -107,6 +107,7 @@
 struct RuntimeArgumentMap;
 class RuntimeCallbacks;
 class SignalCatcher;
+class SmallIrtAllocator;
 class StackOverflowHandler;
 class SuspensionHandler;
 class ThreadList;
@@ -324,6 +325,10 @@
     return class_linker_;
   }
 
+  SmallIrtAllocator* GetSmallIrtAllocator() const {
+    return small_irt_allocator_;
+  }
+
   jni::JniIdManager* GetJniIdManager() const {
     return jni_id_manager_.get();
   }
@@ -1198,6 +1203,8 @@
 
   SignalCatcher* signal_catcher_;
 
+  SmallIrtAllocator* small_irt_allocator_;
+
   std::unique_ptr<jni::JniIdManager> jni_id_manager_;
 
   std::unique_ptr<JavaVMExt> java_vm_;

@rk700 Not actually true: https://android.googlesource.com/platform/art/+/4dcac3629ea5925e47b522073f3c49420e998911

diff --git [a/runtime/runtime.h](https://android.googlesource.com/platform/art/+/48fb9f43a81fa0cab09ed4a4f3d478c1a0ecbe9e/runtime/runtime.h) [b/runtime/runtime.h](https://android.googlesource.com/platform/art/+/4dcac3629ea5925e47b522073f3c49420e998911/runtime/runtime.h)
index 2dd022e..0c99cf9 100644
--- a/runtime/runtime.h
+++ b/runtime/runtime.h
@@ -107,6 +107,7 @@
 struct RuntimeArgumentMap;
 class RuntimeCallbacks;
 class SignalCatcher;
+class SmallIrtAllocator;
 class StackOverflowHandler;
 class SuspensionHandler;
 class ThreadList;
@@ -324,6 +325,10 @@
     return class_linker_;
   }
 
+  SmallIrtAllocator* GetSmallIrtAllocator() const {
+    return small_irt_allocator_;
+  }
+
   jni::JniIdManager* GetJniIdManager() const {
     return jni_id_manager_.get();
   }
@@ -1198,6 +1203,8 @@
 
   SignalCatcher* signal_catcher_;
 
+  SmallIrtAllocator* small_irt_allocator_;
+
   std::unique_ptr<jni::JniIdManager> jni_id_manager_;
 
   std::unique_ptr<JavaVMExt> java_vm_;

Excuse my ignorance, when will this change take effect, in Android 13 or with Android12 update?

rk700 commented

So the distance between classlinker and javavm is increased by 1 pointer right?

I think you are right. And I think we can try to dlsym some symbols added in this commit (just like canyie/pine@34dc23e) to detect if the rom merged this commit.

是的,我用小米6刷过12系统测试过,获取到的是错误的值。不过也有其他12系统刷机包,获取到的是正确的值。另外安卓13测试过,也是错误的

另外安卓13也保留32位环境

是的,我用小米6刷过12系统测试过,获取到的是错误的值。不过也有其他12系统刷机包,获取到的是正确的值。另外安卓13测试过,也是错误的

安卓12L与13已经合并此修改。安卓12除主分支外我没有发现合并修改,不知道是否有遗漏。这可能是第三方系统直接使用master分支构建的原因。