diff --git a/edxp-core/src/main/cpp/main/include/config.h b/edxp-core/src/main/cpp/main/include/config.h index 772cfb48c..edec0a8a8 100644 --- a/edxp-core/src/main/cpp/main/include/config.h +++ b/edxp-core/src/main/cpp/main/include/config.h @@ -36,13 +36,11 @@ 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 kLibBasePath = LP_SELECT("/system/lib/"s, "/system/lib64/"s); static const auto kLibArtLegacyPath = kLibBasePath + kLibArtName; - static const auto kLibSandHookPath = kLibBasePath + kLibSandHookName; static const auto kLibFwPath = kLibBasePath + kLibFwName; inline constexpr const char *const BoolToString(bool b) { diff --git a/edxp-core/src/main/cpp/main/src/config_manager.h b/edxp-core/src/main/cpp/main/src/config_manager.h index c350877d5..9b3130182 100644 --- a/edxp-core/src/main/cpp/main/src/config_manager.h +++ b/edxp-core/src/main/cpp/main/src/config_manager.h @@ -60,16 +60,21 @@ namespace edxp { inline const auto &GetInstallerPackageName() const { return installer_pkg_name_; } - inline const auto &GetLibSandHookName() const { return kLibSandHookName; } - inline const auto &GetDataPathPrefix() const { return data_path_prefix_; } - inline static const auto &GetMiscPath() {return misc_path_;} + inline static const auto &GetMiscPath() { return misc_path_; } inline static auto GetFrameworkPath(const std::string &suffix = {}) { return misc_path_ / "framework" / suffix; } + inline static auto GetLibSandHookName() { + if constexpr(edxp::is64) + return GetFrameworkPath("lib64/libsandhook.edxp.so"); + else + return GetFrameworkPath("lib/libsandhook.edxp.so"); + } + inline auto GetXposedPropPath() const { return GetFrameworkPath(kXposedPropName); } inline auto GetConfigPath(const std::string &suffix = {}) const { @@ -98,7 +103,7 @@ namespace edxp { static const auto &GetInjectDexPaths() { return inject_dex_paths_; }; - bool IsInstaller(const std::string& pkg_name) const { + bool IsInstaller(const std::string &pkg_name) const { return pkg_name == installer_pkg_name_ || pkg_name == kPrimaryInstallerPkgName; } diff --git a/edxp-core/src/main/cpp/main/src/edxp_context.cpp b/edxp-core/src/main/cpp/main/src/edxp_context.cpp index 86e294e71..8f4bb7517 100644 --- a/edxp-core/src/main/cpp/main/src/edxp_context.cpp +++ b/edxp-core/src/main/cpp/main/src/edxp_context.cpp @@ -141,7 +141,7 @@ namespace edxp { if (variant_ == SANDHOOK) { //for SandHook variant - ScopedDlHandle sandhook_handle(kLibSandHookPath.c_str()); + ScopedDlHandle sandhook_handle(ConfigManager::GetLibSandHookName().c_str()); if (!sandhook_handle.IsValid()) { return; } diff --git a/edxp-core/template_override/customize.sh b/edxp-core/template_override/customize.sh index 05940f9f0..8e1e9d81b 100644 --- a/edxp-core/template_override/customize.sh +++ b/edxp-core/template_override/customize.sh @@ -213,30 +213,20 @@ ui_print "- ${LANG_CUST_INST_COPY_LIB}" rm -rf "/data/misc/$MISC_PATH/framework" mv "${MODPATH}/system/framework" "/data/misc/$MISC_PATH/framework" -set_perm_recursive /data/misc/$MISC_PATH/framework root root 0755 0644 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}" - -mv "${MODPATH}/system/lib/libriru_edxp.so" "${MODPATH}/system/lib/${LIB_RIRU_EDXP}" -if [[ "${IS64BIT}" == true ]]; then - mv "${MODPATH}/system/lib64/libriru_edxp.so" "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}" -fi if [[ "${VARIANTS}" == "SandHook" ]]; then - mv "${MODPATH}/system/lib/libsandhook.edxp.so" "${MODPATH}/system/lib/${LIB_SANDHOOK_EDXP}" - if [[ "${IS64BIT}" == true ]]; then - mv "${MODPATH}/system/lib64/libsandhook.edxp.so" "${MODPATH}/system/lib64/${LIB_SANDHOOK_EDXP}" - fi + mkdir -p "/data/misc/$MISC_PATH/framework/lib" + mv "${MODPATH}/system/lib/libsandhook.edxp.so" "/data/misc/$MISC_PATH/framework/lib/libsandhook.edxp.so" + if [ "$IS64BIT" = true ]; then + mkdir -p "/data/misc/$MISC_PATH/framework/lib64" + mv "${MODPATH}/system/lib64/libsandhook.edxp.so" "/data/misc/$MISC_PATH/framework/lib64/libsandhook.edxp.so" + fi fi +set_perm_recursive /data/misc/$MISC_PATH/framework root root 0755 0644 "u:object_r:magisk_file:s0" || abortC "! ${LANG_CUST_ERR_PERM}" -ui_print "- ${LANG_CUST_INST_RAND_LIB_1}" -ui_print " - ${LANG_CUST_INST_RAND_LIB_2}" -ui_print " - ${LANG_CUST_INST_RAND_LIB_3}" -sed -i 's:libriru_edxp.so:'"${LIB_RIRU_EDXP}"':g' "${MODPATH}/system/lib/${LIB_RIRU_EDXP}" -sed -i 's:libsandhook.edxp.so:'"${LIB_SANDHOOK_EDXP}"':g' "${MODPATH}/system/lib/${LIB_RIRU_EDXP}" - -ui_print " - ${LANG_CUST_INST_RAND_LIB_4}" +mv "${MODPATH}/system/lib/libriru_edxp.so" "${MODPATH}/system/lib/${LIB_RIRU_EDXP}" if [[ "${IS64BIT}" == true ]]; then - sed -i 's:libriru_edxp.so:'"${LIB_RIRU_EDXP}"':g' "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}" - sed -i 's:libsandhook.edxp.so:'"${LIB_SANDHOOK_EDXP}"':g' "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}" + mv "${MODPATH}/system/lib64/libriru_edxp.so" "${MODPATH}/system/lib64/${LIB_RIRU_EDXP}" fi ui_print "- ${LANG_CUST_INST_REM_OLDCONF}" diff --git a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/config/SandHookProvider.java b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/config/SandHookProvider.java index e45ce9c0b..318fac6fe 100644 --- a/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/config/SandHookProvider.java +++ b/edxp-sandhook/src/main/java/com/elderdrivers/riru/edxp/sandhook/config/SandHookProvider.java @@ -16,6 +16,8 @@ import de.robv.android.xposed.XposedBridge; +import static com.elderdrivers.riru.edxp.util.ClassUtils.shouldDelayHook; + public class SandHookProvider extends BaseHookProvider { @Override public void hookMethod(Member method, XposedBridge.AdditionalHookInfo additionalInfo) { @@ -50,7 +52,7 @@ public Object invokeOriginalMethod(Member method, long methodId, Object thisObje @Override public Member findMethodNative(Member hookMethod) { - return hookMethod; + return shouldDelayHook(hookMethod) ? null : hookMethod; } @Override diff --git a/sandhook-hooklib/src/main/java/com/swift/sandhook/SandHook.java b/sandhook-hooklib/src/main/java/com/swift/sandhook/SandHook.java index 231e236b4..071616f61 100644 --- a/sandhook-hooklib/src/main/java/com/swift/sandhook/SandHook.java +++ b/sandhook-hooklib/src/main/java/com/swift/sandhook/SandHook.java @@ -95,8 +95,6 @@ public static synchronized void hook(HookWrapper.HookEntity entity) throws HookE if (SandHookConfig.delayHook && PendingHookHandler.canWork() && ClassStatusUtils.isStaticAndNoInited(entity.target)) { PendingHookHandler.addPendingHook(entity); return; - } else if (entity.initClass) { - resolveStaticMethod(target); } resolveStaticMethod(backup);