diff --git a/app/src/main/java/io/github/lsposed/manager/ConfigManager.java b/app/src/main/java/io/github/lsposed/manager/ConfigManager.java index 8ca537f2..ff24299c 100644 --- a/app/src/main/java/io/github/lsposed/manager/ConfigManager.java +++ b/app/src/main/java/io/github/lsposed/manager/ConfigManager.java @@ -163,37 +163,6 @@ public class ConfigManager { } } - public static int getVariant() { - try { - return LSPosedManagerServiceClient.getVariant(); - } catch (RemoteException | NullPointerException e) { - Log.e(App.TAG, Log.getStackTraceString(e)); - return 1; - } - } - - public static String getVariantString() { - int variant = getVariant(); - switch (variant) { - case 1: - return "YAHFA"; - case 2: - return "SandHook"; - default: - return "Unknown"; - } - } - - public static boolean setVariant(int variant) { - try { - LSPosedManagerServiceClient.setVariant(variant); - return true; - } catch (RemoteException | NullPointerException e) { - Log.e(App.TAG, Log.getStackTraceString(e)); - return false; - } - } - public static boolean isPermissive() { try { return LSPosedManagerServiceClient.isPermissive(); diff --git a/app/src/main/java/io/github/lsposed/manager/receivers/LSPosedManagerServiceClient.java b/app/src/main/java/io/github/lsposed/manager/receivers/LSPosedManagerServiceClient.java index f7d5121a..c46370cf 100644 --- a/app/src/main/java/io/github/lsposed/manager/receivers/LSPosedManagerServiceClient.java +++ b/app/src/main/java/io/github/lsposed/manager/receivers/LSPosedManagerServiceClient.java @@ -115,16 +115,6 @@ public class LSPosedManagerServiceClient { service.setVerboseLog(enabled); } - public static int getVariant() throws RemoteException, NullPointerException { - ensureService(); - return service.getVariant(); - } - - public static void setVariant(int variant) throws RemoteException, NullPointerException { - ensureService(); - service.setVariant(variant); - } - public static boolean isPermissive() throws RemoteException, NullPointerException { ensureService(); return service.isPermissive(); diff --git a/app/src/main/java/io/github/lsposed/manager/ui/activity/MainActivity.java b/app/src/main/java/io/github/lsposed/manager/ui/activity/MainActivity.java index d9afc721..c80e0a97 100644 --- a/app/src/main/java/io/github/lsposed/manager/ui/activity/MainActivity.java +++ b/app/src/main/java/io/github/lsposed/manager/ui/activity/MainActivity.java @@ -92,7 +92,7 @@ public class MainActivity extends BaseActivity { String installXposedVersion = ConfigManager.getXposedVersionName(); int cardBackgroundColor; if (installXposedVersion != null) { - binding.statusTitle.setText(getString(R.string.Activated, ConfigManager.getVariantString())); + binding.statusTitle.setText(getString(R.string.Activated, "YAHFA")); if (!ConfigManager.isPermissive()) { if (Helpers.currentHoliday == Helpers.Holidays.LUNARNEWYEAR) { cardBackgroundColor = 0xfff05654; diff --git a/build.gradle.kts b/build.gradle.kts index 77b2fcf0..806f66f4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -41,7 +41,7 @@ val commitCount = Git(repo).log().add(refId).call().count() val defaultManagerPackageName by extra("io.github.lsposed.manager") val verCode by extra(commitCount + 4200) -val verName by extra("v1.2.2") +val verName by extra("v1.3.0") val androidTargetSdkVersion by extra(30) val androidMinSdkVersion by extra(27) val androidBuildToolsVersion by extra("30.0.3") diff --git a/core/build.gradle.kts b/core/build.gradle.kts index e96a433b..36d86f27 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -66,7 +66,6 @@ val verName: String by rootProject.extra dependencies { implementation("dev.rikka.ndk:riru:10") implementation("com.android.tools.build:apksig:4.1.2") - implementation(project(":sandhook-hooklib")) compileOnly(project(":hiddenapi-stubs")) compileOnly("androidx.annotation:annotation:1.1.0") implementation(project(":interface")) diff --git a/core/src/main/aidl/io/github/lsposed/lspd/service/ILSPApplicationService.aidl b/core/src/main/aidl/io/github/lsposed/lspd/service/ILSPApplicationService.aidl index a08db967..e878961d 100644 --- a/core/src/main/aidl/io/github/lsposed/lspd/service/ILSPApplicationService.aidl +++ b/core/src/main/aidl/io/github/lsposed/lspd/service/ILSPApplicationService.aidl @@ -5,8 +5,6 @@ interface ILSPApplicationService { IBinder requestManagerBinder() = 3; - int getVariant() = 4; - boolean isResourcesHookEnabled() = 5; String[] getModulesList(String processName) = 6; diff --git a/core/src/main/cpp/external/CMakeLists.txt b/core/src/main/cpp/external/CMakeLists.txt index b0ce1505..85f9b4da 100644 --- a/core/src/main/cpp/external/CMakeLists.txt +++ b/core/src/main/cpp/external/CMakeLists.txt @@ -15,8 +15,5 @@ add_subdirectory(Dobby) target_include_directories(dobby PUBLIC Dobby/include) target_include_directories(dobby PUBLIC Dobby/builtin-plugin/BionicLinkerRestriction) -add_subdirectory(SandHook) -target_include_directories(sandhook.lspd PUBLIC SandHook) - add_subdirectory(DexBuilder) target_include_directories(dex_builder PUBLIC DexBuilder) diff --git a/core/src/main/cpp/external/SandHook/CMakeLists.txt b/core/src/main/cpp/external/SandHook/CMakeLists.txt deleted file mode 100644 index e5bb4ba5..00000000 --- a/core/src/main/cpp/external/SandHook/CMakeLists.txt +++ /dev/null @@ -1,36 +0,0 @@ -cmake_minimum_required(VERSION 3.4.1) -project(sandhook.lspd) - -ENABLE_LANGUAGE(ASM) - -add_definitions(-std=c++11) - -if (${CMAKE_ANDROID_ARCH_ABI} STREQUAL armeabi-v7a OR ${CMAKE_ANDROID_ARCH_ABI} STREQUAL arm64-v8a) -set(${PROJECT_NAME}_SOURCES - sandhook.cpp - trampoline/trampoline.cpp - trampoline/trampoline_manager.cpp - utils/dlfcn_nougat.cpp - utils/hide_api.cpp - utils/utils.cpp - utils/offset.cpp - utils/elf_util.cpp - casts/cast_art_method.cpp - casts/cast_compiler_options.cpp - art/art_method.cpp - art/art_compiler_options.cpp - art/art_classlinker.cpp - trampoline/arch/arm32.S - trampoline/arch/arm64.S - inst/insts_arm32.cpp - inst/insts_arm64.cpp - nativehook/native_hook.cpp - ) -else() - set(${PROJECT_NAME}_SOURCES dummy.cpp) -endif() -add_library(${PROJECT_NAME} - STATIC - ${${PROJECT_NAME}_SOURCES}) - -target_link_libraries(${PROJECT_NAME} log) \ No newline at end of file diff --git a/core/src/main/cpp/external/SandHook/art/art_classlinker.cpp b/core/src/main/cpp/external/SandHook/art/art_classlinker.cpp deleted file mode 100644 index d54f50f2..00000000 --- a/core/src/main/cpp/external/SandHook/art/art_classlinker.cpp +++ /dev/null @@ -1,9 +0,0 @@ -// -// Created by 双草酸酯 on 11/27/20. -// -#include "../includes/art_classlinker.h" - -using namespace art; -void ClassLinker::MakeInitializedClassesVisiblyInitialized(void* self, bool wait) { - -} \ No newline at end of file diff --git a/core/src/main/cpp/external/SandHook/art/art_compiler_options.cpp b/core/src/main/cpp/external/SandHook/art/art_compiler_options.cpp deleted file mode 100644 index eaab2044..00000000 --- a/core/src/main/cpp/external/SandHook/art/art_compiler_options.cpp +++ /dev/null @@ -1,25 +0,0 @@ -// -// Created by 甘尧 on 2019/2/24. -// - -#include "../includes/art_compiler_options.h" -#include "../includes/cast_compiler_options.h" -#include "../includes/hide_api.h" - -using namespace SandHook; -using namespace art; - -extern int SDK_INT; - -size_t CompilerOptions::getInlineMaxCodeUnits() { - if (SDK_INT < ANDROID_N) - return 0; - return CastCompilerOptions::inlineMaxCodeUnits->get(this); -} - -bool CompilerOptions::setInlineMaxCodeUnits(size_t units) { - if (SDK_INT < ANDROID_N) - return false; - CastCompilerOptions::inlineMaxCodeUnits->set(this, units); - return true; -} diff --git a/core/src/main/cpp/external/SandHook/art/art_method.cpp b/core/src/main/cpp/external/SandHook/art/art_method.cpp deleted file mode 100644 index e1de698d..00000000 --- a/core/src/main/cpp/external/SandHook/art/art_method.cpp +++ /dev/null @@ -1,197 +0,0 @@ -// -// Created by swift on 2019/2/3. -// -#include -#include "../includes/art_method.h" -#include "../includes/cast_art_method.h" -#include "../includes/hide_api.h" -#include "../includes/utils.h" - -extern int SDK_INT; -extern bool DEBUG; - -using namespace art::mirror; -using namespace SandHook; - -// Non-intrinsics: Caches whether we can use fast-path in the interpreter invokes. -// Intrinsics: These bits are part of the intrinsic ordinal. -static constexpr uint32_t kAccFastInterpreterToInterpreterInvoke = 0x40000000; // method. - -void ArtMethod::tryDisableInline() { - if (SDK_INT < ANDROID_O) - return; - uint32_t accessFlag = getAccessFlags(); - accessFlag &= ~ 0x08000000; - setAccessFlags(accessFlag); -} - -void ArtMethod::disableInterpreterForO() { - /*if (SDK_INT >= ANDROID_O && SDK_INT < ANDROID_R && DEBUG) { - setNative(); - }*/ -} - -void ArtMethod::disableFastInterpreterForQ() { - if (SDK_INT < ANDROID_Q) - return; - uint32_t accessFlag = getAccessFlags(); - accessFlag &= ~kAccFastInterpreterToInterpreterInvoke; - setAccessFlags(accessFlag); -} - -void ArtMethod::disableCompilable() { - if (SDK_INT < ANDROID_N) - return; - uint32_t accessFlag = getAccessFlags(); - if (SDK_INT >= ANDROID_O2) { - accessFlag |= 0x02000000; - accessFlag |= 0x00800000; - } else { - accessFlag |= 0x01000000; - } - setAccessFlags(accessFlag); -} - -bool ArtMethod::isAbstract() { - uint32_t accessFlags = getAccessFlags(); - return ((accessFlags & 0x0400) != 0); -} - -bool ArtMethod::isNative() { - uint32_t accessFlags = getAccessFlags(); - return ((accessFlags & 0x0100) != 0); -} - -bool ArtMethod::isStatic() { - uint32_t accessFlags = getAccessFlags(); - return ((accessFlags & 0x0008) != 0); -} - -bool ArtMethod::isCompiled() { - return getQuickCodeEntry() != CastArtMethod::quickToInterpreterBridge && - getQuickCodeEntry() != CastArtMethod::genericJniStub; -} - -bool ArtMethod::isThumbCode() { - #if defined(__arm__) - return (reinterpret_cast(getQuickCodeEntry()) & 0x1) == 0x1; - #else - return false; - #endif -} - -void ArtMethod::setAccessFlags(uint32_t flags) { - CastArtMethod::accessFlag->set(this, flags); -} - -void ArtMethod::setPrivate() { - uint32_t accessFlag = getAccessFlags(); - accessFlag &= ~ 0x0001; - accessFlag &= ~ 0x0004; - accessFlag |= 0x0002; - setAccessFlags(accessFlag); -} - -void ArtMethod::setStatic() { - uint32_t accessFlag = getAccessFlags(); - accessFlag |= 0x0008; - setAccessFlags(accessFlag); -}; - - -void ArtMethod::setNative() { - uint32_t accessFlag = getAccessFlags(); - accessFlag |= 0x0100; - setAccessFlags(accessFlag); -} - -uint32_t ArtMethod::getAccessFlags() { - return CastArtMethod::accessFlag->get(this); -} - -uint32_t ArtMethod::getDexMethodIndex() { - return CastArtMethod::dexMethodIndex->get(this); -} - -void* ArtMethod::getQuickCodeEntry() { - return CastArtMethod::entryPointQuickCompiled->get(this); -} - -void* ArtMethod::getInterpreterCodeEntry() { - return CastArtMethod::entryPointFromInterpreter->get(this); -} - -GCRoot ArtMethod::getDeclaringClass() { - return CastArtMethod::declaringClass->get(this); -} - -uint16_t ArtMethod::getHotnessCount() { - return CastArtMethod::hotnessCount->get(this); -} - -void ArtMethod::setQuickCodeEntry(void *entry) { - CastArtMethod::entryPointQuickCompiled->set(this, entry); -} - -void ArtMethod::setJniCodeEntry(void *entry) { - CastArtMethod::entryPointFromJNI->set(this, entry); -} - -void ArtMethod::setInterpreterCodeEntry(void *entry) { - CastArtMethod::entryPointFromInterpreter->set(this, entry); -} - -void ArtMethod::setDexCacheResolveList(void *list) { - CastArtMethod::dexCacheResolvedMethods->set(this, list); -} - -void ArtMethod::setDexCacheResolveItem(uint32_t index, void* item) { - CastArtMethod::dexCacheResolvedMethods->setElement(this, index, item); -} - -void ArtMethod::setDeclaringClass(GCRoot classPtr) { - CastArtMethod::declaringClass->set(this, classPtr); -} - -void ArtMethod::setHotnessCount(uint16_t count) { - CastArtMethod::hotnessCount->set(this, count); -} - -bool ArtMethod::compile(JNIEnv* env) { - if (isCompiled()) - return true; - //some unknown error when trigger jit for jni method manually - if (isNative()) - return false; - Size threadId = getAddressFromJavaByCallMethod(env, "com/swift/sandhook/SandHook", "getThreadId"); - if (threadId == 0) - return false; - return compileMethod(this, reinterpret_cast(threadId)) && isCompiled(); -} - -bool ArtMethod::deCompile() { - if (!isCompiled()) - return true; - if ((isNative() && CastArtMethod::canGetJniBridge) || (!isNative() && CastArtMethod::canGetInterpreterBridge)) { - setQuickCodeEntry(isNative() ? CastArtMethod::genericJniStub : CastArtMethod::quickToInterpreterBridge); - if (SDK_INT < ANDROID_N) { - //TODO SetEntryPointFromInterpreterCode - } - flushCache(); - return true; - } else { - return false; - } -} - -void ArtMethod::flushCache() { -// flushCacheExt(reinterpret_cast(this), size()); -} - -void ArtMethod::backup(ArtMethod *backup) { - memcpy(backup, this, size()); -} - -Size ArtMethod::size() { - return CastArtMethod::size; -} diff --git a/core/src/main/cpp/external/SandHook/casts/cast_art_method.cpp b/core/src/main/cpp/external/SandHook/casts/cast_art_method.cpp deleted file mode 100644 index b67d70ed..00000000 --- a/core/src/main/cpp/external/SandHook/casts/cast_art_method.cpp +++ /dev/null @@ -1,290 +0,0 @@ -// -// Created by swift on 2019/2/3. -// - -#include "../includes/cast_art_method.h" -#include "../includes/utils.h" -#include "../includes/never_call.h" -#include "../includes/log.h" - -extern int SDK_INT; - -namespace SandHook { - - class CastDexCacheResolvedMethods : public ArrayMember { - protected: - Size calOffset(JNIEnv *jniEnv, art::mirror::ArtMethod *p) override { - if (SDK_INT >= ANDROID_P) - return getParentSize() + 1; - int offset = 0; - Size addr = getAddressFromJava(jniEnv, "com/swift/sandhook/SandHookMethodResolver", - "resolvedMethodsAddress"); - if (addr != 0) { - offset = findOffset(p, getParentSize(), 2, addr); - if (offset >= 0) { - return static_cast(offset); - } - } - if (SDK_INT == ANDROID_M) { - return 4; - } else if (SDK_INT >= ANDROID_L && SDK_INT <= ANDROID_L2) { - return 4 * 3; - } - return getParentSize() + 1; - } - - public: - Size arrayStart(mirror::ArtMethod *parent) override { - void *p = IMember::get(parent); - if (SDK_INT <= ANDROID_M) { - return reinterpret_cast(p) + 4 * 3; - } else { - return reinterpret_cast(p); - } - } - - }; - - class CastEntryPointFormInterpreter : public IMember { - protected: - Size calOffset(JNIEnv *jniEnv, art::mirror::ArtMethod *p) override { - if (SDK_INT == ANDROID_L2) { - return RoundUpToPtrSize(4 * 7 + 4 * 2); - } else if (SDK_INT == ANDROID_M) { - return getParentSize() - 3 * BYTE_POINT; - } else if (SDK_INT <= ANDROID_L) { - Size addr = getAddressFromJava(jniEnv, "com/swift/sandhook/SandHookMethodResolver", - "entryPointFromInterpreter"); - int offset = 0; - if (addr != 0) { - offset = findOffset(p, getParentSize(), 2, addr); - if (offset >= 0) { - return static_cast(offset); - } - } - return getParentSize() - 4 * 8 - 4 * 4; - } - else - return getParentSize() + 1; - } - }; - - class CastEntryPointQuickCompiled : public IMember { - protected: - Size calOffset(JNIEnv *jniEnv, art::mirror::ArtMethod *p) override { - if (SDK_INT >= ANDROID_M) { - return getParentSize() - BYTE_POINT; - } else if (SDK_INT <= ANDROID_L) { - Size addr = getAddressFromJava(jniEnv, "com/swift/sandhook/SandHookMethodResolver", - "entryPointFromCompiledCode"); - int offset = 0; - if (addr != 0) { - offset = findOffset(p, getParentSize(), 2, addr); - if (offset >= 0) { - return static_cast(offset); - } - } - return getParentSize() - 4 - 2 * BYTE_POINT; - } else { - return CastArtMethod::entryPointFromInterpreter->getOffset() + 2 * BYTE_POINT; - } - } - }; - - class CastEntryPointFromJni : public IMember { - protected: - Size calOffset(JNIEnv *jniEnv, art::mirror::ArtMethod *p) override { - Size jniAddr = reinterpret_cast(Java_com_swift_sandhook_ClassNeverCall_neverCallNative); - int offset = findOffset(p, getParentSize(), 2, jniAddr); - if (offset >= 0) { - return static_cast(offset); - } - if (SDK_INT >= ANDROID_L2 && SDK_INT <= ANDROID_N) { - return getParentSize() - 2 * BYTE_POINT; - } else { - return getParentSize() - 8 * 2 - 4 * 4; - } - } - }; - - - class CastAccessFlag : public IMember { - protected: - Size calOffset(JNIEnv *jniEnv, art::mirror::ArtMethod *p) override { - uint32_t accessFlag = getIntFromJava(jniEnv, "com/swift/sandhook/SandHook", - "testAccessFlag"); - if (accessFlag == 0) { - accessFlag = 524313; - //kAccPublicApi - if (SDK_INT >= ANDROID_Q) { - accessFlag |= 0x10000000; - } - } - int offset = findOffset(p, getParentSize(), 2, accessFlag); - if (offset < 0) { - if (SDK_INT >= ANDROID_N) { - return 4; - } else if (SDK_INT == ANDROID_L2) { - return 20; - } else if (SDK_INT == ANDROID_L) { - return 56; - } else { - return getParentSize() + 1; - } - } else { - return static_cast(offset); - } - } - }; - - class CastShadowClass : public IMember { - protected: - Size calOffset(JNIEnv *jniEnv, mirror::ArtMethod *p) override { - if (SDK_INT < ANDROID_N) - return getParentSize() + 1; - return 0; - } - }; - - - class CastDexMethodIndex : public IMember { - protected: - Size calOffset(JNIEnv *jniEnv, art::mirror::ArtMethod *p) override { - if (SDK_INT >= ANDROID_P) { - return CastArtMethod::accessFlag->getOffset() - + CastArtMethod::accessFlag->size() - + sizeof(uint32_t); - } - int offset = 0; - jint index = getIntFromJava(jniEnv, "com/swift/sandhook/SandHookMethodResolver", - "dexMethodIndex"); - if (index != 0) { - offset = findOffset(p, getParentSize(), 2, static_cast(index)); - if (offset >= 0) { - return static_cast(offset); - } - } - return getParentSize() + 1; - } - }; - - class CastHotnessCount : public IMember { - protected: - Size calOffset(JNIEnv *jniEnv, mirror::ArtMethod *p) override { - if (SDK_INT <= ANDROID_N) - return getParentSize() + 1; - return CastArtMethod::dexMethodIndex->getOffset() - + CastArtMethod::dexMethodIndex->size() - + sizeof(uint16_t); - } - }; - - - void CastArtMethod::init(JNIEnv *env) { - //init ArtMethodSize - jclass sizeTestClass = env->FindClass("com/swift/sandhook/ArtMethodSizeTest"); - jobject artMethod1 = getMethodObject(env, "com.swift.sandhook.ArtMethodSizeTest", "method1"); - jobject artMethod2 = getMethodObject(env, "com.swift.sandhook.ArtMethodSizeTest", "method2"); - - env->CallStaticVoidMethod(sizeTestClass, env->FromReflectedMethod(artMethod1)); - - std::atomic_thread_fence(std::memory_order_acquire); - - art::mirror::ArtMethod *m1 = getArtMethod(env, artMethod1); - art::mirror::ArtMethod *m2 = getArtMethod(env, artMethod2); - - size = m2 - m1; - - //init Members - - accessFlag = new CastAccessFlag(); - accessFlag->init(env, m1, size); - - entryPointFromInterpreter = new CastEntryPointFormInterpreter(); - entryPointFromInterpreter->init(env, m1, size); - - entryPointQuickCompiled = new CastEntryPointQuickCompiled(); - entryPointQuickCompiled->init(env, m1, size); - - dexMethodIndex = new CastDexMethodIndex(); - dexMethodIndex->init(env, m1, size); - - dexCacheResolvedMethods = new CastDexCacheResolvedMethods(); - dexCacheResolvedMethods->init(env, m1, size); - - declaringClass = new CastShadowClass(); - declaringClass->init(env, m1, size); - - - hotnessCount = new CastHotnessCount(); - hotnessCount->init(env, m1, size); - - auto neverCallTestClass = "com.swift.sandhook.ClassNeverCall"; - - art::mirror::ArtMethod *neverCall = getArtMethod(env, getMethodObject(env, - neverCallTestClass, - "neverCall")); - art::mirror::ArtMethod *neverCall2 = getArtMethod(env, getMethodObject(env, - neverCallTestClass, - "neverCall2")); - - bool beAot = entryPointQuickCompiled->get(neverCall) != entryPointQuickCompiled->get(neverCall2); - if (beAot) { - quickToInterpreterBridge = getInterpreterBridge(false); - if (quickToInterpreterBridge == nullptr) { - quickToInterpreterBridge = entryPointQuickCompiled->get(neverCall); - canGetInterpreterBridge = false; - } - } else { - quickToInterpreterBridge = entryPointQuickCompiled->get(neverCall); - } - - - art::mirror::ArtMethod *neverCallNative = getArtMethod(env, getMethodObject(env, - neverCallTestClass, - "neverCallNative")); - art::mirror::ArtMethod *neverCallNative2 = getArtMethod(env, getMethodObject(env, - neverCallTestClass, - "neverCallNative2")); - - beAot = entryPointQuickCompiled->get(neverCallNative) != entryPointQuickCompiled->get(neverCallNative2); - if (beAot) { - genericJniStub = getInterpreterBridge(true); - if (genericJniStub == nullptr) { - genericJniStub = entryPointQuickCompiled->get(neverCallNative); - canGetJniBridge = false; - } - } else { - genericJniStub = entryPointQuickCompiled->get(neverCallNative); - } - - entryPointFromJNI = new CastEntryPointFromJni(); - entryPointFromJNI->init(env, neverCallNative, size); - - art::mirror::ArtMethod *neverCallStatic = getArtMethod(env, getMethodObject(env, - neverCallTestClass, - "neverCallStatic")); - staticResolveStub = entryPointQuickCompiled->get(neverCallStatic); - - } - - void CastArtMethod::copy(art::mirror::ArtMethod *from, art::mirror::ArtMethod *to) { - memcpy(to, from, size); - } - - Size CastArtMethod::size = 0; - IMember *CastArtMethod::entryPointQuickCompiled = nullptr; - IMember *CastArtMethod::entryPointFromInterpreter = nullptr; - IMember *CastArtMethod::entryPointFromJNI = nullptr; - ArrayMember *CastArtMethod::dexCacheResolvedMethods = nullptr; - IMember *CastArtMethod::dexMethodIndex = nullptr; - IMember *CastArtMethod::accessFlag = nullptr; - IMember *CastArtMethod::declaringClass = nullptr; - IMember *CastArtMethod::hotnessCount = nullptr; - void *CastArtMethod::quickToInterpreterBridge = nullptr; - void *CastArtMethod::genericJniStub = nullptr; - void *CastArtMethod::staticResolveStub = nullptr; - bool CastArtMethod::canGetInterpreterBridge = true; - bool CastArtMethod::canGetJniBridge = true; - -} \ No newline at end of file diff --git a/core/src/main/cpp/external/SandHook/casts/cast_compiler_options.cpp b/core/src/main/cpp/external/SandHook/casts/cast_compiler_options.cpp deleted file mode 100644 index 60944962..00000000 --- a/core/src/main/cpp/external/SandHook/casts/cast_compiler_options.cpp +++ /dev/null @@ -1,35 +0,0 @@ -// -// Created by 甘尧 on 2019/2/24. -// - -#include "../includes/cast_compiler_options.h" -#include "../includes/hide_api.h" - -extern int SDK_INT; - -namespace SandHook { - - - class CastInlineMaxCodeUnits : public IMember { - protected: - Size calOffset(JNIEnv *jniEnv, art::CompilerOptions *p) override { - if (SDK_INT < ANDROID_N) - return getParentSize() + 1; - if (SDK_INT >= ANDROID_Q) { - return BYTE_POINT + 3 * sizeof(size_t); - } - if (SDK_INT >= ANDROID_O) { - return BYTE_POINT + 5 * sizeof(size_t); - } else { - return BYTE_POINT + 6 * sizeof(size_t); - } - } - }; - - void CastCompilerOptions::init(JNIEnv *jniEnv) { - inlineMaxCodeUnits->init(jniEnv, nullptr, sizeof(art::CompilerOptions)); - } - - IMember* CastCompilerOptions::inlineMaxCodeUnits = new CastInlineMaxCodeUnits(); - -} diff --git a/core/src/main/cpp/external/SandHook/dummy.cpp b/core/src/main/cpp/external/SandHook/dummy.cpp deleted file mode 100644 index 8d299843..00000000 --- a/core/src/main/cpp/external/SandHook/dummy.cpp +++ /dev/null @@ -1,10 +0,0 @@ -// -// Created by Kotori0 on 2021/1/30. -// -#include "sandhook.h" -#include "includes/log.h" - -bool JNI_Load_Ex(JNIEnv* env, jclass classSandHook, jclass classNeverCall) { - LOGE("Sandhook: Unsupported platform."); - return false; -} \ No newline at end of file diff --git a/core/src/main/cpp/external/SandHook/includes/arch.h b/core/src/main/cpp/external/SandHook/includes/arch.h deleted file mode 100644 index cbc52ccc..00000000 --- a/core/src/main/cpp/external/SandHook/includes/arch.h +++ /dev/null @@ -1,49 +0,0 @@ -// -// Created by 甘尧 on 2019/1/12. -// - -#ifndef SANDHOOK_ARCH_H -#define SANDHOOK_ARCH_H - -#define BYTE_POINT sizeof(void*) - -typedef size_t Size; - -//32bit -#if defined(__i386__) || defined(__arm__) -//64bit -#elif defined(__aarch64__) || defined(__x86_64__) -#else -#endif - -#if defined(__arm__) -static void clearCacheArm32(char* begin, char *end) -{ - const int syscall = 0xf0002; - __asm __volatile ( - "mov r0, %0\n" - "mov r1, %1\n" - "mov r3, %2\n" - "mov r2, #0x0\n" - "svc 0x00000000\n" - : - : "r" (begin), "r" (end), "r" (syscall) - : "r0", "r1", "r3" - ); -} -#endif - -#define ANDROID_K 19 -#define ANDROID_L 21 -#define ANDROID_L2 22 -#define ANDROID_M 23 -#define ANDROID_N 24 -#define ANDROID_N2 25 -#define ANDROID_O 26 -#define ANDROID_O2 27 -#define ANDROID_P 28 -#define ANDROID_Q 29 -#define ANDROID_R 30 -#define ANDROID_S 31 - -#endif //SANDHOOK_ARCH_H \ No newline at end of file diff --git a/core/src/main/cpp/external/SandHook/includes/arch_base.h b/core/src/main/cpp/external/SandHook/includes/arch_base.h deleted file mode 100644 index 34c05938..00000000 --- a/core/src/main/cpp/external/SandHook/includes/arch_base.h +++ /dev/null @@ -1,34 +0,0 @@ -// -// Created by SwiftGan on 2019/1/17. -// - -#ifndef SANDHOOK_BASE_H -#define SANDHOOK_BASE_H - -#define FUNCTION_START(x) \ -.text; \ -.align 4; \ -.global x; \ -x: \ - -#define FUNCTION_START_T(x) \ -.syntax unified; \ -.text; \ -.align 4; \ -.thumb; \ -.thumb_func; \ -.global x; \ -x: \ - -#define FUNCTION_END(x) .size x, .-x - -#define REPLACEMENT_HOOK_TRAMPOLINE replacement_hook_trampoline -#define INLINE_HOOK_TRAMPOLINE inline_hook_trampoline -#define DIRECT_JUMP_TRAMPOLINE direct_jump_trampoline -#define CALL_ORIGIN_TRAMPOLINE call_origin_trampoline - -#define INLINE_HOOK_TRAMPOLINE_T inline_hook_trampoline_t -#define DIRECT_JUMP_TRAMPOLINE_T direct_jump_trampoline_t -#define CALL_ORIGIN_TRAMPOLINE_T call_origin_trampoline_t - -#endif //SANDHOOK_BASE_H diff --git a/core/src/main/cpp/external/SandHook/includes/art_classlinker.h b/core/src/main/cpp/external/SandHook/includes/art_classlinker.h deleted file mode 100644 index 18eaccd2..00000000 --- a/core/src/main/cpp/external/SandHook/includes/art_classlinker.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// Created by 双草酸酯 on 11/27/20. -// - -#ifndef SANDHOOK_ART_CLASSLINKER_H -#define SANDHOOK_ART_CLASSLINKER_H - -#endif //SANDHOOK_ART_CLASSLINKER_H -namespace art { -class ClassLinker { -public: - void MakeInitializedClassesVisiblyInitialized(void* self, bool wait); -}; -} \ No newline at end of file diff --git a/core/src/main/cpp/external/SandHook/includes/art_collector_type.h b/core/src/main/cpp/external/SandHook/includes/art_collector_type.h deleted file mode 100644 index 3de50771..00000000 --- a/core/src/main/cpp/external/SandHook/includes/art_collector_type.h +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2013 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_GC_COLLECTOR_TYPE_H_ -#define ART_RUNTIME_GC_COLLECTOR_TYPE_H_ - -#include - -namespace art { - namespace gc { - -// Which types of collections are able to be performed. - enum CollectorType { - // No collector selected. - kCollectorTypeNone, - // Non concurrent mark-sweep. - kCollectorTypeMS, - // Concurrent mark-sweep. - kCollectorTypeCMS, - // Semi-space / mark-sweep hybrid, enables compaction. - kCollectorTypeSS, - // Heap trimming collector, doesn't do any actual collecting. - kCollectorTypeHeapTrim, - // A (mostly) concurrent copying collector. - kCollectorTypeCC, - // The background compaction of the concurrent copying collector. - kCollectorTypeCCBackground, - // Instrumentation critical section fake collector. - kCollectorTypeInstrumentation, - // Fake collector for adding or removing application image spaces. - kCollectorTypeAddRemoveAppImageSpace, - // Fake collector used to implement exclusion between GC and debugger. - kCollectorTypeDebugger, - // A homogeneous space compaction collector used in background transition - // when both foreground and background collector are CMS. - kCollectorTypeHomogeneousSpaceCompact, - // Class linker fake collector. - kCollectorTypeClassLinker, - // JIT Code cache fake collector. - kCollectorTypeJitCodeCache, - // Hprof fake collector. - kCollectorTypeHprof, - // Fake collector for installing/removing a system-weak holder. - kCollectorTypeAddRemoveSystemWeakHolder, - // Fake collector type for GetObjectsAllocated - kCollectorTypeGetObjectsAllocated, - // Fake collector type for ScopedGCCriticalSection - kCollectorTypeCriticalSection, - }; - } // namespace gc -} // namespace art - -#endif // ART_RUNTIME_GC_COLLECTOR_TYPE_H_ diff --git a/core/src/main/cpp/external/SandHook/includes/art_compiler_options.h b/core/src/main/cpp/external/SandHook/includes/art_compiler_options.h deleted file mode 100644 index 0a462353..00000000 --- a/core/src/main/cpp/external/SandHook/includes/art_compiler_options.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// Created by 甘尧 on 2019/2/23. -// - -#ifndef ART_COMPILER_OPTIONS_H -#define ART_COMPILER_OPTIONS_H - -#include - -namespace art { - class CompilerOptions { - public: - void* compiler_filter_; - size_t huge_method_threshold_; - size_t large_method_threshold_; - size_t small_method_threshold_; - size_t tiny_method_threshold_; - size_t num_dex_methods_threshold_; - size_t inline_depth_limit_; - size_t inline_max_code_units_; - - size_t getInlineMaxCodeUnits(); - bool setInlineMaxCodeUnits(size_t units); - - }; -} - -#endif //ART_COMPILER_OPTIONS_H diff --git a/core/src/main/cpp/external/SandHook/includes/art_gc_cause.h b/core/src/main/cpp/external/SandHook/includes/art_gc_cause.h deleted file mode 100644 index a039cc0d..00000000 --- a/core/src/main/cpp/external/SandHook/includes/art_gc_cause.h +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_RUNTIME_GC_GC_CAUSE_H_ -#define ART_RUNTIME_GC_GC_CAUSE_H_ - -#include - -namespace art { - namespace gc { - -// What caused the GC? - enum GcCause { - // Invalid GC cause used as a placeholder. - kGcCauseNone, - // GC triggered by a failed allocation. Thread doing allocation is blocked waiting for GC before - // retrying allocation. - kGcCauseForAlloc, - // A background GC trying to ensure there is free memory ahead of allocations. - kGcCauseBackground, - // An explicit System.gc() call. - kGcCauseExplicit, - // GC triggered for a native allocation when NativeAllocationGcWatermark is exceeded. - // (This may be a blocking GC depending on whether we run a non-concurrent collector). - kGcCauseForNativeAlloc, - // GC triggered for a collector transition. - kGcCauseCollectorTransition, - // Not a real GC cause, used when we disable moving GC (currently for GetPrimitiveArrayCritical). - kGcCauseDisableMovingGc, - // Not a real GC cause, used when we trim the heap. - kGcCauseTrim, - // Not a real GC cause, used to implement exclusion between GC and instrumentation. - kGcCauseInstrumentation, - // Not a real GC cause, used to add or remove app image spaces. - kGcCauseAddRemoveAppImageSpace, - // Not a real GC cause, used to implement exclusion between GC and debugger. - kGcCauseDebugger, - // GC triggered for background transition when both foreground and background collector are CMS. - kGcCauseHomogeneousSpaceCompact, - // Class linker cause, used to guard filling art methods with special values. - kGcCauseClassLinker, - // Not a real GC cause, used to implement exclusion between code cache metadata and GC. - kGcCauseJitCodeCache, - // Not a real GC cause, used to add or remove system-weak holders. - kGcCauseAddRemoveSystemWeakHolder, - // Not a real GC cause, used to prevent hprof running in the middle of GC. - kGcCauseHprof, - // Not a real GC cause, used to prevent GetObjectsAllocated running in the middle of GC. - kGcCauseGetObjectsAllocated, - // GC cause for the profile saver. - kGcCauseProfileSaver, - // GC cause for running an empty checkpoint. - kGcCauseRunEmptyCheckpoint, - }; - } // namespace gc -} // namespace art - -#endif // ART_RUNTIME_GC_GC_CAUSE_H_ diff --git a/core/src/main/cpp/external/SandHook/includes/art_jit.h b/core/src/main/cpp/external/SandHook/includes/art_jit.h deleted file mode 100644 index c59f48cf..00000000 --- a/core/src/main/cpp/external/SandHook/includes/art_jit.h +++ /dev/null @@ -1,28 +0,0 @@ -// -// Created by 甘尧 on 2019/2/23. -// - -#ifndef SANDHOOK_ART_JIT_H -#define SANDHOOK_ART_JIT_H - -namespace art { - namespace jit { - - //7.0 - 9.0 - class JitCompiler { - public: - virtual ~JitCompiler(); - std::unique_ptr compilerOptions; - }; - - class Jit { - public: - //void* getCompilerOptions(); - }; - - - - }; -} - -#endif //SANDHOOK_ART_JIT_H diff --git a/core/src/main/cpp/external/SandHook/includes/art_method.h b/core/src/main/cpp/external/SandHook/includes/art_method.h deleted file mode 100644 index 58fb8ec4..00000000 --- a/core/src/main/cpp/external/SandHook/includes/art_method.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Copyright (c) 2011 The Android Open Source Project - * Copyright (c) 2015, alipay.com - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef ART_H -#define ART_H - -#include -#include "arch.h" - -//7.0 - 10.0 -#define GCRoot uint32_t - -namespace art { -namespace mirror { -class Object { -public: -}; -class Class: public Object { -public: -}; - -class ArtField { -public: -}; - -class ArtMethod { -public: - - bool isAbstract(); - bool isNative(); - bool isStatic(); - bool isCompiled(); - bool isThumbCode(); - - void setAccessFlags(uint32_t flags); - void disableCompilable(); - void tryDisableInline(); - void disableInterpreterForO(); - void disableFastInterpreterForQ(); - void setPrivate(); - void setStatic(); - void setNative(); - - void setQuickCodeEntry(void* entry); - void setJniCodeEntry(void* entry); - void setInterpreterCodeEntry(void* entry); - void setDexCacheResolveList(void* list); - void setDexCacheResolveItem(uint32_t index, void* item); - void setDeclaringClass(GCRoot classPtr); - void setHotnessCount(uint16_t count); - - void* getQuickCodeEntry(); - void* getInterpreterCodeEntry(); - uint32_t getAccessFlags(); - uint32_t getDexMethodIndex(); - GCRoot getDeclaringClass(); - uint16_t getHotnessCount(); - - bool compile(JNIEnv* env); - bool deCompile(); - void flushCache(); - void backup(ArtMethod* backup); - - static Size size(); - -}; - -} - -} - -#endif //ART_H diff --git a/core/src/main/cpp/external/SandHook/includes/art_runtime.h b/core/src/main/cpp/external/SandHook/includes/art_runtime.h deleted file mode 100644 index e27d68ae..00000000 --- a/core/src/main/cpp/external/SandHook/includes/art_runtime.h +++ /dev/null @@ -1,18 +0,0 @@ -// -// Created by 甘尧 on 2019/2/23. -// - -#ifndef SANDHOOK_ART_RUNTIME_H -#define SANDHOOK_ART_RUNTIME_H - -#include "art_jit.h" - -namespace art { - class Runtime { - - public: - jit::Jit* getJit(); - }; -} - -#endif //SANDHOOK_ART_RUNTIME_H diff --git a/core/src/main/cpp/external/SandHook/includes/cast.h b/core/src/main/cpp/external/SandHook/includes/cast.h deleted file mode 100644 index 6748c686..00000000 --- a/core/src/main/cpp/external/SandHook/includes/cast.h +++ /dev/null @@ -1,123 +0,0 @@ -// -// Created by 甘尧 on 2019/1/12. -// - - -#ifndef SANDHOOK_ICAST_H -#define SANDHOOK_ICAST_H - -#include -#include -#include -#include "arch.h" -#include "utils.h" - - -namespace SandHook { - - template - class cast { - public: - cast(T t) { - this->origin = t; - }; - - virtual Size getSize() { return sizeof(T); }; - - private: - T origin; - }; - - template - class IMember { - public: - - virtual void init(JNIEnv *jniEnv, PType* p, Size size) { - this->parentSize = size; - offset = calOffset(jniEnv, p); - } - - Size size() { - return sizeof(MType); - } - - virtual Size getOffset() { - return offset; - } - - virtual Size getParentSize() { - return parentSize; - } - - virtual MType get(PType* p) { - if (offset > parentSize) - return 0; - return *reinterpret_cast((Size)p + getOffset()); - }; - - virtual void set(PType* p, MType t) { - if (offset > parentSize) - return; - memcpy(reinterpret_cast((Size)p + getOffset()), &t, size()); - }; - - template - int findOffset(void *start, size_t len, size_t step, T value) { - - if (nullptr == start) { - return -1; - } - - for (int i = 0; i <= len; i += step) { - T current_value = *reinterpret_cast((size_t) start + i); - if (value == current_value) { - return i; - } - } - return -1; - } - - private: - Size offset = 0; - protected: - Size parentSize = 0; - virtual Size calOffset(JNIEnv *jniEnv, PType* p) = 0; - - }; - - template - class ArrayMember : public IMember { - public: - - virtual void init(JNIEnv *jniEnv, PType* p, Size parentSize) override { - IMember::init(jniEnv, p, parentSize); - elementSize = calElementSize(jniEnv, p); - } - - virtual Size getElementSize() { - return elementSize; - } - - virtual Size arrayStart(PType* parent) { - void* p = IMember::get(parent); - return reinterpret_cast(p); - } - - using IMember::getParentSize; - - virtual void setElement(PType* parent, int position, ElementType elementPoint) { - Size array = arrayStart(parent); - memcpy(reinterpret_cast(array + position * getElementSize()), &elementPoint, getElementSize()); - } - - private: - Size elementSize = 0; - protected: - virtual Size calElementSize(JNIEnv *jniEnv, PType* p) { - return sizeof(ElementType); - }; - }; - -} - -#endif //SANDHOOK_ICAST_H \ No newline at end of file diff --git a/core/src/main/cpp/external/SandHook/includes/cast_art_method.h b/core/src/main/cpp/external/SandHook/includes/cast_art_method.h deleted file mode 100644 index 1cdb37bb..00000000 --- a/core/src/main/cpp/external/SandHook/includes/cast_art_method.h +++ /dev/null @@ -1,39 +0,0 @@ -// -// Created by 甘尧 on 2019/1/12. -// - -#ifndef SANDHOOK_CAST_ART_METHOD_H -#define SANDHOOK_CAST_ART_METHOD_H - -#include "cast.h" -#include "trampoline_manager.h" - -namespace SandHook { - - class CastArtMethod { - public: - static Size size; - static IMember* entryPointQuickCompiled; - static IMember* entryPointFromInterpreter; - static IMember* entryPointFromJNI; - static ArrayMember* dexCacheResolvedMethods; - static IMember* dexMethodIndex; - static IMember* accessFlag; - static IMember* declaringClass; - static IMember* hotnessCount; - static void* quickToInterpreterBridge; - static void* genericJniStub; - static void* staticResolveStub; - static bool canGetJniBridge; - static bool canGetInterpreterBridge; - - static void init(JNIEnv *env); - static void copy(art::mirror::ArtMethod* from, art::mirror::ArtMethod* to); - - }; - -} - -#endif //SANDHOOK_CAST_ART_METHOD_H - - diff --git a/core/src/main/cpp/external/SandHook/includes/cast_compiler_options.h b/core/src/main/cpp/external/SandHook/includes/cast_compiler_options.h deleted file mode 100644 index 5b98a9d4..00000000 --- a/core/src/main/cpp/external/SandHook/includes/cast_compiler_options.h +++ /dev/null @@ -1,24 +0,0 @@ -// -// Created by 甘尧 on 2019/1/12. -// - -#ifndef SANDHOOK_CAST_COMPILER_OPTIONS_H -#define SANDHOOK_CAST_COMPILER_OPTIONS_H - -#include "cast.h" -#include "art_compiler_options.h" - -namespace SandHook { - - class CastCompilerOptions { - public: - static void init(JNIEnv *jniEnv); - static IMember* inlineMaxCodeUnits; - }; - - -} - -#endif //SANDHOOK_CAST_COMPILER_OPTIONS_H - - diff --git a/core/src/main/cpp/external/SandHook/includes/dlfcn_nougat.h b/core/src/main/cpp/external/SandHook/includes/dlfcn_nougat.h deleted file mode 100644 index 1fbaa5c4..00000000 --- a/core/src/main/cpp/external/SandHook/includes/dlfcn_nougat.h +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef DLFCN_NOUGAT_H -#define DLFCN_NOUGAT_H - -//see implementation in https://tech.meituan.com/2017/07/20/android-remote-debug.html -extern "C" { -int fake_dlclose(void *handle); - -void *fake_dlopen(const char *filename, int flags); - -void *fake_dlsym(void *handle, const char *name); - -const char *fake_dlerror(); - -void *getSymCompat(const char *filename, const char *name); -} - -#endif //DLFCN_NOUGAT_H diff --git a/core/src/main/cpp/external/SandHook/includes/elf_util.h b/core/src/main/cpp/external/SandHook/includes/elf_util.h deleted file mode 100644 index 79141764..00000000 --- a/core/src/main/cpp/external/SandHook/includes/elf_util.h +++ /dev/null @@ -1,72 +0,0 @@ -// -// Created by Swift Gan on 2019/3/14. -// -#ifndef SANDHOOK_ELF_UTIL_H -#define SANDHOOK_ELF_UTIL_H - -#include - -#if defined(__LP64__) -typedef Elf64_Ehdr Elf_Ehdr; -typedef Elf64_Shdr Elf_Shdr; -typedef Elf64_Addr Elf_Addr; -typedef Elf64_Dyn Elf_Dyn; -typedef Elf64_Rela Elf_Rela; -typedef Elf64_Sym Elf_Sym; -typedef Elf64_Off Elf_Off; - -#define ELF_R_SYM(i) ELF64_R_SYM(i) -#else -typedef Elf32_Ehdr Elf_Ehdr; -typedef Elf32_Shdr Elf_Shdr; -typedef Elf32_Addr Elf_Addr; -typedef Elf32_Dyn Elf_Dyn; -typedef Elf32_Rel Elf_Rela; -typedef Elf32_Sym Elf_Sym; -typedef Elf32_Off Elf_Off; - -#define ELF_R_SYM(i) ELF32_R_SYM(i) -#endif - -namespace SandHook { - - class ElfImg { - public: - - ElfImg(const char* elf); - - Elf_Addr getSymbOffset(const char* name); - - void* getModuleBase(const char* name); - - Elf_Addr getSymbAddress(const char* name); - - ~ElfImg(); - - private: - const char* elf = nullptr; - void* base = nullptr; - char* buffer = nullptr; - off_t size = 0; - off_t bias = -4396; - Elf_Ehdr* header = nullptr; - Elf_Shdr* section_header = nullptr; - Elf_Shdr* symtab = nullptr; - Elf_Shdr* strtab = nullptr; - Elf_Shdr* dynsym = nullptr; - Elf_Off dynsym_count = 0; - Elf_Sym* symtab_start = nullptr; - Elf_Sym* dynsym_start = nullptr; - Elf_Sym* strtab_start = nullptr; - Elf_Off symtab_count = 0; - Elf_Off symstr_offset = 0; - Elf_Off symstr_offset_for_symtab = 0; - Elf_Off symtab_offset = 0; - Elf_Off dynsym_offset = 0; - Elf_Off symtab_size = 0; - Elf_Off dynsym_size = 0; - }; - -} - -#endif //SANDHOOK_ELF_UTIL_H diff --git a/core/src/main/cpp/external/SandHook/includes/hide_api.h b/core/src/main/cpp/external/SandHook/includes/hide_api.h deleted file mode 100644 index e7966790..00000000 --- a/core/src/main/cpp/external/SandHook/includes/hide_api.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// Created by swift on 2019/1/21. -// - -#ifndef SANDHOOK_HIDE_API_H -#define SANDHOOK_HIDE_API_H - -#include -#include "dlfcn_nougat.h" -#include "dlfcn.h" -#include -#include "../includes/art_compiler_options.h" -#include "../includes/art_jit.h" -#include "../includes/art_method.h" - -#if defined(__aarch64__) -# define __get_tls() ({ void** __val; __asm__("mrs %0, tpidr_el0" : "=r"(__val)); __val; }) -#elif defined(__arm__) -# define __get_tls() ({ void** __val; __asm__("mrc p15, 0, %0, c13, c0, 3" : "=r"(__val)); __val; }) -#endif - -#define TLS_SLOT_ART_THREAD 7 - -using namespace art::mirror; - -extern "C" { - - void initHideApi(JNIEnv *env); - bool compileMethod(void *artMethod, void *thread); - - void suspendVM(void *); - void resumeVM(void *); - - bool canGetObject(); - jobject getJavaObject(JNIEnv* env, void* thread, void* address); - void *getCurrentThread(); - - art::jit::JitCompiler* getGlobalJitCompiler(); - - art::CompilerOptions* getCompilerOptions(art::jit::JitCompiler* compiler); - - art::CompilerOptions* getGlobalCompilerOptions(); - - bool disableJitInline(art::CompilerOptions* compilerOptions); - - void* getInterpreterBridge(bool isNative); - - bool replaceUpdateCompilerOptionsQ(); - - bool forceProcessProfiles(); - - bool hookClassInit(void(*callback)(void*)); - - JNIEnv *attachAndGetEvn(); - - ArtMethod* getArtMethod(JNIEnv *env, jobject method); -} - -#endif //SANDHOOK_HIDE_API_H diff --git a/core/src/main/cpp/external/SandHook/includes/inst.h b/core/src/main/cpp/external/SandHook/includes/inst.h deleted file mode 100644 index 70fd4846..00000000 --- a/core/src/main/cpp/external/SandHook/includes/inst.h +++ /dev/null @@ -1,122 +0,0 @@ -// -// Created by swift on 2019/2/3. -// - -#ifndef SANDHOOK_INST_VISTOR_H -#define SANDHOOK_INST_VISTOR_H - -#include -#include "arch.h" - -#define CASE(inst,mask,match,type) \ -if ((inst & mask) == match) { return type; } \ - -namespace SandHook { - - union Arm32Code { - uint32_t code; - struct { - uint32_t cond:4; - uint32_t empty:2; - uint32_t opcode:4; - uint32_t s:1; - uint32_t rn:4; - uint32_t rd:4; - uint32_t operand2:12; - } units; - }; - - union Arm16Code { - uint16_t code; - struct { - uint32_t cond:16; - } units; - }; - - enum InstArch { - ARM32 = 0, - Thumb16, - Thumb32, - Arm64, - X86, - X64 - }; - - enum class InstType_Thumb32 { - // BLX