Fix heap offset for all systems

This commit is contained in:
kotori0 2020-12-04 01:03:59 +08:00
parent d6c7570588
commit 1e9b307f54
1 changed files with 12 additions and 12 deletions

View File

@ -33,45 +33,45 @@ namespace art {
// @ApiSensitive(Level.MIDDLE)
static void Setup(void *handle, HookFunType hook_func) {
int api_level = edxp::GetAndroidApiLevel();
size_t OFFSET_classlinker; // Get offset from art::Runtime::RunRootClinits() call in IDA
size_t OFFSET_heap; // Get offset from art::Runtime::RunRootClinits() call in IDA
switch (api_level) {
case __ANDROID_API_O__:
[[fallthrough]];
case __ANDROID_API_O_MR1__:
if constexpr(edxp::is64) {
OFFSET_classlinker = 464;
OFFSET_heap = 0x180;
} else {
OFFSET_classlinker = 284;
OFFSET_heap = 0xF4;
}
break;
case __ANDROID_API_P__:
if constexpr(edxp::is64) {
OFFSET_classlinker = 528;
OFFSET_heap = 0x1C0;
} else {
OFFSET_classlinker = 336;
OFFSET_heap = 0x128;
}
break;
case __ANDROID_API_Q__:
if constexpr(edxp::is64) {
OFFSET_classlinker = 480;
OFFSET_heap = 0x190;
} else {
OFFSET_classlinker = 280;
OFFSET_heap = 0xF0;
}
break;
default:
LOGE("No valid offset for art::Runtime::class_linker_ found. Using Android R.");
LOGE("No valid offset for art::Runtime::heap_ found. Using Android R.");
[[fallthrough]];
case __ANDROID_API_R__:
if constexpr(edxp::is64) {
OFFSET_classlinker = 392;
OFFSET_heap = 392;
} else {
OFFSET_classlinker = 236;
OFFSET_heap = 236;
}
break;
}
void *thiz = *reinterpret_cast<void **>(
reinterpret_cast<size_t>(Runtime::Current()->Get()) + OFFSET_classlinker);
LOGD("HEAP object: %p", thiz);
reinterpret_cast<size_t>(Runtime::Current()->Get()) + OFFSET_heap);
LOGD("art::runtime::Heap object: %p", thiz);
instance_ = new Heap(thiz);
RETRIEVE_FUNC_SYMBOL(WaitForGcToComplete,
"_ZN3art2gc4Heap19WaitForGcToCompleteENS0_7GcCauseEPNS_6ThreadE");