remove libsandhook-native.so
This commit is contained in:
parent
9c0a5d6abc
commit
f3fa952b25
|
|
@ -124,13 +124,8 @@ namespace art {
|
|||
HOOK_FUNC(FixupStaticTrampolines,
|
||||
"_ZN3art11ClassLinker22FixupStaticTrampolinesENS_6ObjPtrINS_6mirror5ClassEEE");
|
||||
|
||||
// Sandhook will hook ShouldUseInterpreterEntrypoint, so we just skip
|
||||
// edxp::Context::GetInstance()->GetVariant() will not work here, so we use smh dirty hack
|
||||
if (!edxp::path_exists(edxp::kLibSandHookNativePath)) {
|
||||
LOGD("Not sandhook, installing _ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
|
||||
HOOK_FUNC(ShouldUseInterpreterEntrypoint,
|
||||
"_ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
|
||||
}
|
||||
HOOK_FUNC(ShouldUseInterpreterEntrypoint,
|
||||
"_ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
|
||||
|
||||
// MakeInitializedClassesVisiblyInitialized will cause deadlock
|
||||
// IsQuickToInterpreterBridge cannot be hooked by Dobby yet
|
||||
|
|
|
|||
|
|
@ -37,15 +37,12 @@ inline constexpr bool is64 = Is64();
|
|||
static const auto kLibArtName = "libart.so"s;
|
||||
static const auto kLibFwName = "libandroidfw.so"s;
|
||||
static const auto kLibSandHookName = "libsandhook.edxp.so"s;
|
||||
static const auto kLibDlName = "libdl.so"s;
|
||||
static const auto kLibSandHookNativeName = "libsandhook-native.so"s;
|
||||
|
||||
static const auto kLibBasePath =
|
||||
LP_SELECT("/system/lib/"s,
|
||||
"/system/lib64/"s);
|
||||
static const auto kLibArtLegacyPath = kLibBasePath + kLibArtName;
|
||||
static const auto kLibSandHookPath = kLibBasePath + kLibSandHookName;
|
||||
static const auto kLibSandHookNativePath = kLibBasePath + kLibSandHookNativeName;
|
||||
static const auto kLibFwPath = kLibBasePath + kLibFwName;
|
||||
|
||||
inline constexpr const char *const BoolToString(bool b) {
|
||||
|
|
|
|||
|
|
@ -246,7 +246,6 @@ else
|
|||
ui_print "- Extracting arm libraries"
|
||||
extract "$ZIPFILE" 'system/lib/libriru_edxp.so' "$MODPATH"
|
||||
if [[ "${VARIANTS}" == "SandHook" ]]; then
|
||||
extract "$ZIPFILE" 'system/lib/libsandhook-native.so' "$MODPATH"
|
||||
extract "$ZIPFILE" 'system/lib/libsandhook.edxp.so' "$MODPATH"
|
||||
fi
|
||||
|
||||
|
|
@ -254,7 +253,6 @@ else
|
|||
ui_print "- Extracting arm64 libraries"
|
||||
extract "$ZIPFILE" 'system/lib64/libriru_edxp.so' "$MODPATH"
|
||||
if [[ "${VARIANTS}" == "SandHook" ]]; then
|
||||
extract "$ZIPFILE" 'system/lib64/libsandhook-native.so' "$MODPATH"
|
||||
extract "$ZIPFILE" 'system/lib64/libsandhook.edxp.so' "$MODPATH"
|
||||
fi
|
||||
fi
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -30,23 +30,9 @@ extern "C" {
|
|||
|
||||
void (*profileSaver_ForceProcessProfiles)() = nullptr;
|
||||
|
||||
//for Android R
|
||||
void *jniIdManager = nullptr;
|
||||
ArtMethod *(*origin_DecodeArtMethodId)(void *thiz, jmethodID jmethodId) = nullptr;
|
||||
ArtMethod *replace_DecodeArtMethodId(void *thiz, jmethodID jmethodId) {
|
||||
jniIdManager = thiz;
|
||||
return origin_DecodeArtMethodId(thiz, jmethodId);
|
||||
}
|
||||
jfieldID fieldArtMethod = nullptr;
|
||||
|
||||
bool (*origin_ShouldUseInterpreterEntrypoint)(ArtMethod *artMethod, const void* quick_code) = nullptr;
|
||||
bool replace_ShouldUseInterpreterEntrypoint(ArtMethod *artMethod, const void* quick_code) {
|
||||
if (SandHook::TrampolineManager::get().methodHooked(artMethod) && quick_code != nullptr) {
|
||||
return false;
|
||||
}
|
||||
return origin_ShouldUseInterpreterEntrypoint(artMethod, quick_code);
|
||||
}
|
||||
|
||||
// paths
|
||||
// paths
|
||||
const char* art_lib_path;
|
||||
const char* jit_lib_path;
|
||||
|
||||
|
|
@ -139,32 +125,9 @@ extern "C" {
|
|||
profileSaver_ForceProcessProfiles = reinterpret_cast<void (*)()>(getSymCompat(art_lib_path, "_ZN3art12ProfileSaver20ForceProcessProfilesEv"));
|
||||
}
|
||||
|
||||
//init native hook lib
|
||||
void* native_hook_handle = dlopen("libsandhook-native.so", RTLD_LAZY | RTLD_GLOBAL);
|
||||
if (native_hook_handle) {
|
||||
hook_native = reinterpret_cast<void *(*)(void *, void *)>(dlsym(native_hook_handle, "SandInlineHook"));
|
||||
} else {
|
||||
hook_native = reinterpret_cast<void *(*)(void *, void *)>(getSymCompat(
|
||||
"libsandhook-native.so", "SandInlineHook"));
|
||||
}
|
||||
|
||||
if (SDK_INT >= ANDROID_R && hook_native) {
|
||||
const char *symbol_decode_method = sizeof(void*) == 8 ? "_ZN3art3jni12JniIdManager15DecodeGenericIdINS_9ArtMethodEEEPT_m" : "_ZN3art3jni12JniIdManager15DecodeGenericIdINS_9ArtMethodEEEPT_j";
|
||||
void *decodeArtMethod = getSymCompat(art_lib_path, symbol_decode_method);
|
||||
if (art_lib_path != nullptr) {
|
||||
origin_DecodeArtMethodId = reinterpret_cast<ArtMethod *(*)(void *,
|
||||
jmethodID)>(hook_native(
|
||||
decodeArtMethod,
|
||||
reinterpret_cast<void *>(replace_DecodeArtMethodId)));
|
||||
}
|
||||
void *shouldUseInterpreterEntrypoint = getSymCompat(art_lib_path,
|
||||
"_ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
|
||||
if (shouldUseInterpreterEntrypoint != nullptr) {
|
||||
origin_ShouldUseInterpreterEntrypoint = reinterpret_cast<bool (*)(ArtMethod *,
|
||||
const void *)>(hook_native(
|
||||
shouldUseInterpreterEntrypoint,
|
||||
reinterpret_cast<void *>(replace_ShouldUseInterpreterEntrypoint)));
|
||||
}
|
||||
if (SDK_INT >=ANDROID_R) {
|
||||
auto classExecutable = env->FindClass("java/lang/reflect/Executable");
|
||||
fieldArtMethod = env->GetFieldID(classExecutable, "artMethod", "J");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -283,8 +246,7 @@ extern "C" {
|
|||
void fake_jit_update_options(void* handle) {
|
||||
//do nothing
|
||||
LOGW("android q: art request update compiler options");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
bool replaceUpdateCompilerOptionsQ() {
|
||||
if (SDK_INT < ANDROID_Q)
|
||||
|
|
@ -349,16 +311,10 @@ extern "C" {
|
|||
}
|
||||
|
||||
ArtMethod* getArtMethod(JNIEnv *env, jobject method) {
|
||||
jmethodID methodId = env->FromReflectedMethod(method);
|
||||
if (SDK_INT >= ANDROID_R && isIndexId(methodId)) {
|
||||
if (origin_DecodeArtMethodId == nullptr || jniIdManager == nullptr) {
|
||||
auto res = callStaticMethodAddr(env, "com/swift/sandhook/SandHook", "getArtMethod",
|
||||
"(Ljava/lang/reflect/Member;)J", method);
|
||||
return reinterpret_cast<ArtMethod *>(res);
|
||||
} else {
|
||||
return origin_DecodeArtMethodId(jniIdManager, methodId);
|
||||
}
|
||||
if (SDK_INT >= ANDROID_R) {
|
||||
return reinterpret_cast<ArtMethod *>(env->GetLongField(method, fieldArtMethod));
|
||||
} else {
|
||||
jmethodID methodId = env->FromReflectedMethod(method);
|
||||
return reinterpret_cast<ArtMethod *>(methodId);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,8 +95,6 @@ public class SandHook {
|
|||
if (SandHookConfig.delayHook && PendingHookHandler.canWork() && ClassStatusUtils.isStaticAndNoInited(entity.target)) {
|
||||
PendingHookHandler.addPendingHook(entity);
|
||||
return;
|
||||
} else if (entity.initClass) {
|
||||
resolveStaticMethod(target);
|
||||
}
|
||||
|
||||
resolveStaticMethod(backup);
|
||||
|
|
|
|||
Loading…
Reference in New Issue