From 00e18cf3b63f3a7a33587c332584f5b6b93896a9 Mon Sep 17 00:00:00 2001 From: Jim Wu Date: Mon, 6 Apr 2020 15:01:18 +0800 Subject: [PATCH] Add switch to disable hidden api bypass link #387 --- edxp-core/src/main/cpp/main/src/config_manager.cpp | 6 ++++++ edxp-core/src/main/cpp/main/src/config_manager.h | 3 +++ edxp-core/src/main/cpp/main/src/native_hook.cpp | 4 +++- 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/edxp-core/src/main/cpp/main/src/config_manager.cpp b/edxp-core/src/main/cpp/main/src/config_manager.cpp index 3bf8c3653..8e3cf37a4 100644 --- a/edxp-core/src/main/cpp/main/src/config_manager.cpp +++ b/edxp-core/src/main/cpp/main/src/config_manager.cpp @@ -88,6 +88,7 @@ namespace edxp { deopt_boot_image_enabled_ = access(GetConfigPath("deoptbootimage").c_str(), F_OK) == 0; resources_hook_enabled_ = access(GetConfigPath("disable_resources").c_str(), F_OK) != 0; no_module_log_enabled_ = access(GetConfigPath("disable_modules_log").c_str(), F_OK) == 0; + hidden_api_bypass_enabled_ = access(GetConfigPath("disable_hidden_api_bypass").c_str(), F_OK) != 0; // use_white_list snapshot use_white_list_snapshot_ = access(use_whitelist_path_.c_str(), F_OK) == 0; @@ -98,6 +99,7 @@ namespace edxp { LOGI(" resources hook: %s", BoolToString(resources_hook_enabled_)); LOGI(" deopt boot image: %s", BoolToString(deopt_boot_image_enabled_)); LOGI(" no module log: %s", BoolToString(no_module_log_enabled_)); + LOGI(" hidden api bypass: %s", BoolToString(hidden_api_bypass_enabled_)); if (black_white_list_enabled_) { SnapshotBlackWhiteList(); } @@ -183,6 +185,10 @@ namespace edxp { return deopt_boot_image_enabled_; } + ALWAYS_INLINE bool ConfigManager::IsHiddenAPIBypassEnabled() const { + return hidden_api_bypass_enabled_; + } + ALWAYS_INLINE std::string ConfigManager::GetInstallerPackageName() const { return installer_pkg_name_; } 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 db2023fd0..f1b9faf16 100644 --- a/edxp-core/src/main/cpp/main/src/config_manager.h +++ b/edxp-core/src/main/cpp/main/src/config_manager.h @@ -32,6 +32,8 @@ namespace edxp { bool IsNoModuleLogEnabled() const; + bool IsHiddenAPIBypassEnabled() const; + std::string GetInstallerPackageName() const; std::string GetXposedPropPath() const; @@ -46,6 +48,7 @@ namespace edxp { bool IsAppNeedHook(const std::string &app_data_dir); + bool hidden_api_bypass_enabled_ = false; private: inline static ConfigManager *instance_; uid_t last_user_ = false; diff --git a/edxp-core/src/main/cpp/main/src/native_hook.cpp b/edxp-core/src/main/cpp/main/src/native_hook.cpp index 4028971b6..4e42a99ab 100644 --- a/edxp-core/src/main/cpp/main/src/native_hook.cpp +++ b/edxp-core/src/main/cpp/main/src/native_hook.cpp @@ -83,7 +83,9 @@ namespace edxp { if (art_hooks_installed) { return; } - art::hidden_api::DisableHiddenApi(art_handle, hook_func); + if (ConfigManager::GetInstance() -> IsHiddenAPIBypassEnabled()) { + art::hidden_api::DisableHiddenApi(art_handle, hook_func); + } art::Runtime::Setup(art_handle, hook_func); art::gc::Heap::Setup(art_handle, hook_func); art::ClassLinker::Setup(art_handle, hook_func);