Fix Sandhook

This commit is contained in:
kotori0 2020-11-06 23:57:45 +08:00 committed by solohsu
parent 5fc9d64971
commit 045fbe3346
4 changed files with 19 additions and 16 deletions

View File

@ -21,8 +21,13 @@ public class XposedInstallerHooker {
final String xposedAppClass = LEGACY_INSTALLER_PACKAGE_NAME + ".XposedApp";
final Class InstallZipUtil = XposedHelpers.findClass(LEGACY_INSTALLER_PACKAGE_NAME
+ ".util.InstallZipUtil", classLoader);
XposedHelpers.findAndHookMethod(xposedAppClass, classLoader, "getActiveXposedVersion",
XC_MethodReplacement.returnConstant(XposedBridge.getXposedVersion()));
XposedHelpers.findAndHookMethod(xposedAppClass, classLoader, "getActiveXposedVersion", new XC_MethodHook() {
@Override
protected void afterHookedMethod(MethodHookParam param) throws Throwable {
Utils.logD("after getActiveXposedVersion...");
param.setResult(XposedBridge.getXposedVersion());
}
});
XposedHelpers.findAndHookMethod(xposedAppClass, classLoader,
"reloadXposedProp", new XC_MethodHook() {
@Override

View File

@ -167,11 +167,16 @@ afterEvaluate {
}
}
def libPathRelease = "${buildDir}/intermediates/cmake/${variantLowered}/obj"
def exclude_list = ["riru.sh"]
if(backendLowered == "yahfa") {
exclude_list.add("system/lib/libsandhook-native.so")
exclude_list.add("system/lib64/libsandhook-native.so")
}
doLast {
copy {
from "${projectDir}/template_override"
into zipPathMagiskRelease
exclude 'riru.sh'
exclude exclude_list
}
copy {
from "${projectDir}/template_override"

View File

@ -6,6 +6,7 @@
#include <art/runtime/mirror/class.h>
#include <android-base/strings.h>
#include "runtime.h"
#include "config.h"
#include "jni_env_ext.h"
#include "edxp_context.h"
#include "jni/edxp_pending_hooks.h"
@ -84,7 +85,11 @@ namespace art {
HOOK_FUNC(FixupStaticTrampolines,
"_ZN3art11ClassLinker22FixupStaticTrampolinesENS_6ObjPtrINS_6mirror5ClassEEE");
if (GetAndroidApiLevel() >= __ANDROID_API_R__) {
// Sandhook will hook ShouldUseInterpreterEntrypoint, so we just skip
// edxp::Context::GetInstance()->GetVariant() will not work here, so we use smh dirty hack
if (GetAndroidApiLevel() >= __ANDROID_API_R__ && access(edxp::kLibSandHookNativePath.c_str(), F_OK) == -1) {
LOGD("Not sandhook, installing _ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
HOOK_FUNC(ShouldUseInterpreterEntrypoint,
"_ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
}

View File

@ -30,18 +30,6 @@ namespace edxp {
void InstallFwkHooks(void *fwk_handle);
bool InstallLinkerHooks(const char *linker_path);
CREATE_HOOK_STUB_ENTRIES(void *, mydlopen, const char *file_name, int flags,
const void *ext_info,
const void *caller) {
void *handle = mydlopenBackup(file_name, flags, ext_info, caller);
if (file_name != nullptr && std::string(file_name).find(kLibArtName) != std::string::npos) {
InstallArtHooks(handle);
}
return handle;
}
void InstallInlineHooks() {
if (installed) {
LOGI("Inline hooks have been installed, skip");