Support preview sdk
This commit is contained in:
parent
be5aeb4981
commit
7a9b966ec7
|
|
@ -116,6 +116,10 @@ namespace yahfa {
|
||||||
switch (sdkVersion) {
|
switch (sdkVersion) {
|
||||||
default:
|
default:
|
||||||
LOGE("not compatible with SDK %d", sdkVersion);
|
LOGE("not compatible with SDK %d", sdkVersion);
|
||||||
|
case __ANDROID_API_FUTURE__:
|
||||||
|
// fallthrough
|
||||||
|
case __ANDROID_API_T__:
|
||||||
|
case 32: // stupid Google
|
||||||
case __ANDROID_API_S__:
|
case __ANDROID_API_S__:
|
||||||
OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod =
|
OFFSET_entry_point_from_quick_compiled_code_in_ArtMethod =
|
||||||
roundUpToPtrSize(4 * 3 + 2 * 2) + pointer_size;
|
roundUpToPtrSize(4 * 3 + 2 * 2) + pointer_size;
|
||||||
|
|
@ -194,8 +198,8 @@ namespace yahfa {
|
||||||
env->NewGlobalRef(hook); // keep a global ref so that the hook method would not be GCed
|
env->NewGlobalRef(hook); // keep a global ref so that the hook method would not be GCed
|
||||||
if (backup) env->NewGlobalRef(backup);
|
if (backup) env->NewGlobalRef(backup);
|
||||||
return JNI_TRUE;
|
return JNI_TRUE;
|
||||||
} else {
|
|
||||||
return JNI_FALSE;
|
|
||||||
}
|
}
|
||||||
|
return JNI_FALSE;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,8 @@ namespace art {
|
||||||
bool, ShouldUseInterpreterEntrypoint, (void * art_method,
|
bool, ShouldUseInterpreterEntrypoint, (void * art_method,
|
||||||
const void *quick_code), {
|
const void *quick_code), {
|
||||||
if (quick_code != nullptr &&
|
if (quick_code != nullptr &&
|
||||||
(lspd::isHooked(art_method) || lspd::IsMethodPending(art_method))) [[unlikely]] {
|
(lspd::isHooked(art_method) ||
|
||||||
|
lspd::IsMethodPending(art_method))) [[unlikely]] {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return backup(art_method, quick_code);
|
return backup(art_method, quick_code);
|
||||||
|
|
@ -110,49 +111,8 @@ namespace art {
|
||||||
// @ApiSensitive(Level.MIDDLE)
|
// @ApiSensitive(Level.MIDDLE)
|
||||||
inline static void Setup(const SandHook::ElfImg &handle) {
|
inline static void Setup(const SandHook::ElfImg &handle) {
|
||||||
int api_level = lspd::GetAndroidApiLevel();
|
int api_level = lspd::GetAndroidApiLevel();
|
||||||
size_t OFFSET_classlinker; // Get offset from art::Runtime::RunRootClinits() call in IDA
|
|
||||||
switch (api_level) {
|
|
||||||
case __ANDROID_API_O__:
|
|
||||||
[[fallthrough]];
|
|
||||||
case __ANDROID_API_O_MR1__:
|
|
||||||
if constexpr(lspd::is64) {
|
|
||||||
OFFSET_classlinker = 464;
|
|
||||||
} else {
|
|
||||||
OFFSET_classlinker = 284;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case __ANDROID_API_P__:
|
|
||||||
if constexpr(lspd::is64) {
|
|
||||||
OFFSET_classlinker = 528;
|
|
||||||
} else {
|
|
||||||
OFFSET_classlinker = 336;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case __ANDROID_API_Q__:
|
|
||||||
if constexpr(lspd::is64) {
|
|
||||||
OFFSET_classlinker = 480;
|
|
||||||
} else {
|
|
||||||
OFFSET_classlinker = 280;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
LOGE("No valid offset for art::Runtime::class_linker_ found. Using Android R.");
|
|
||||||
[[fallthrough]];
|
|
||||||
case __ANDROID_API_R__:
|
|
||||||
case __ANDROID_API_S__:
|
|
||||||
if constexpr(lspd::is64) {
|
|
||||||
OFFSET_classlinker = 472;
|
|
||||||
} else {
|
|
||||||
OFFSET_classlinker = 276;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
void *thiz = *reinterpret_cast<void **>(
|
instance_ = new ClassLinker(nullptr); // make it nullptr
|
||||||
reinterpret_cast<uintptr_t>(Runtime::Current()->Get()) + OFFSET_classlinker);
|
|
||||||
// ClassLinker* GetClassLinker() but inlined
|
|
||||||
LOGD("Classlinker object: %p", thiz);
|
|
||||||
instance_ = new ClassLinker(thiz);
|
|
||||||
|
|
||||||
RETRIEVE_MEM_FUNC_SYMBOL(SetEntryPointsToInterpreter,
|
RETRIEVE_MEM_FUNC_SYMBOL(SetEntryPointsToInterpreter,
|
||||||
"_ZNK3art11ClassLinker27SetEntryPointsToInterpreterEPNS_9ArtMethodE");
|
"_ZNK3art11ClassLinker27SetEntryPointsToInterpreterEPNS_9ArtMethodE");
|
||||||
|
|
@ -186,13 +146,12 @@ namespace art {
|
||||||
LOGD("MakeInitializedClassesVisiblyInitialized start, thiz=%p, self=%p", thiz_, self);
|
LOGD("MakeInitializedClassesVisiblyInitialized start, thiz=%p, self=%p", thiz_, self);
|
||||||
if (thiz_) [[likely]]
|
if (thiz_) [[likely]]
|
||||||
MakeInitializedClassesVisiblyInitialized(thiz_, self, wait);
|
MakeInitializedClassesVisiblyInitialized(thiz_, self, wait);
|
||||||
|
else LOGW("Classlinker is nullptr");
|
||||||
}
|
}
|
||||||
|
|
||||||
[[gnu::always_inline]]
|
[[gnu::always_inline]]
|
||||||
void SetEntryPointsToInterpreter(void *art_method) const {
|
void SetEntryPointsToInterpreter(void *art_method) const {
|
||||||
LOGD("SetEntryPointsToInterpreter start, thiz=%p, art_method=%p", thiz_, art_method);
|
SetEntryPointsToInterpreter(thiz_, art_method);
|
||||||
if (thiz_) [[likely]]
|
|
||||||
SetEntryPointsToInterpreter(thiz_, art_method);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,9 @@ namespace lspd {
|
||||||
static int32_t api_level = []() {
|
static int32_t api_level = []() {
|
||||||
char prop_value[PROP_VALUE_MAX];
|
char prop_value[PROP_VALUE_MAX];
|
||||||
__system_property_get("ro.build.version.sdk", prop_value);
|
__system_property_get("ro.build.version.sdk", prop_value);
|
||||||
return atoi(prop_value);
|
int base = atoi(prop_value);
|
||||||
|
__system_property_get("ro.build.version.preview_sdk", prop_value);
|
||||||
|
return base + atoi(prop_value);
|
||||||
}();
|
}();
|
||||||
return api_level;
|
return api_level;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue