rirud must be used in onModuleLoaded
This commit is contained in:
parent
1e629a92de
commit
fcd4b15496
|
|
@ -120,10 +120,8 @@ namespace art {
|
||||||
HOOK_FUNC(FixupStaticTrampolines,
|
HOOK_FUNC(FixupStaticTrampolines,
|
||||||
"_ZN3art11ClassLinker22FixupStaticTrampolinesENS_6ObjPtrINS_6mirror5ClassEEE");
|
"_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 (api_level >= __ANDROID_API_R__ &&
|
if (api_level >= __ANDROID_API_R__ &&
|
||||||
access(edxp::kLibSandHookNativePath.c_str(), F_OK) == -1) {
|
edxp::Context::GetInstance()->GetVariant() != edxp::Variant::SANDHOOK) {
|
||||||
LOGD("Not sandhook, installing _ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
|
LOGD("Not sandhook, installing _ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
|
||||||
HOOK_FUNC(ShouldUseInterpreterEntrypoint,
|
HOOK_FUNC(ShouldUseInterpreterEntrypoint,
|
||||||
"_ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
|
"_ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
|
||||||
|
|
|
||||||
|
|
@ -85,8 +85,8 @@ namespace edxp {
|
||||||
namespace fs = std::filesystem;
|
namespace fs = std::filesystem;
|
||||||
|
|
||||||
fs::path ConfigManager::RetrieveBaseConfigPath() const {
|
fs::path ConfigManager::RetrieveBaseConfigPath() const {
|
||||||
if (auto misc_path = GetMiscPath(); !misc_path.empty()) {
|
if (!misc_path_.empty()) {
|
||||||
return misc_path / std::to_string(user_);
|
return misc_path_ / std::to_string(user_);
|
||||||
} else {
|
} else {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
@ -259,7 +259,7 @@ namespace edxp {
|
||||||
if (base_config_path_.empty()) return false;
|
if (base_config_path_.empty()) return false;
|
||||||
try {
|
try {
|
||||||
fs::create_directories(base_config_path_);
|
fs::create_directories(base_config_path_);
|
||||||
fs::permissions(GetMiscPath(),
|
fs::permissions(misc_path_,
|
||||||
fs::perms::owner_all | fs::perms::group_all | fs::perms::others_exec);
|
fs::perms::owner_all | fs::perms::group_all | fs::perms::others_exec);
|
||||||
fs::permissions(base_config_path_,
|
fs::permissions(base_config_path_,
|
||||||
fs::perms::owner_all | fs::perms::group_all | fs::perms::others_exec);
|
fs::perms::owner_all | fs::perms::group_all | fs::perms::others_exec);
|
||||||
|
|
@ -330,8 +330,7 @@ namespace edxp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto ConfigManager::GetMiscPath() -> decltype(misc_path_) {
|
void ConfigManager::Init(){
|
||||||
if (misc_path_.empty()) {
|
|
||||||
fs::path misc_path("/data/adb/edxp/misc_path");
|
fs::path misc_path("/data/adb/edxp/misc_path");
|
||||||
try {
|
try {
|
||||||
RirudSocket rirud_socket{};
|
RirudSocket rirud_socket{};
|
||||||
|
|
@ -340,22 +339,13 @@ namespace edxp {
|
||||||
return !std::isspace(ch);
|
return !std::isspace(ch);
|
||||||
}).base(), path.end());
|
}).base(), path.end());
|
||||||
misc_path_ = fs::path("/data/misc") / path;
|
misc_path_ = fs::path("/data/misc") / path;
|
||||||
} catch (const RirudSocket::RirudSocketException &e) {
|
|
||||||
LOGE("%s", e.what());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return misc_path_;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto ConfigManager::GetInjectDexPaths() -> decltype(inject_dex_paths_) {
|
|
||||||
if (inject_dex_paths_.empty()) {
|
|
||||||
std::transform(kXposedInjectDexPath.begin(), kXposedInjectDexPath.end(),
|
std::transform(kXposedInjectDexPath.begin(), kXposedInjectDexPath.end(),
|
||||||
std::back_inserter(inject_dex_paths_),
|
std::back_inserter(inject_dex_paths_),
|
||||||
[](auto i) {
|
[](auto i) {
|
||||||
return GetFrameworkPath(i);
|
return GetFrameworkPath(i);
|
||||||
});
|
});
|
||||||
|
} catch (const RirudSocket::RirudSocketException &e) {
|
||||||
|
LOGE("%s", e.what());
|
||||||
}
|
}
|
||||||
return inject_dex_paths_;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -26,6 +26,8 @@ namespace edxp {
|
||||||
};
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
static void Init();
|
||||||
|
|
||||||
inline static ConfigManager *GetInstance() {
|
inline static ConfigManager *GetInstance() {
|
||||||
return instances_[current_user].get();
|
return instances_[current_user].get();
|
||||||
}
|
}
|
||||||
|
|
@ -36,8 +38,9 @@ namespace edxp {
|
||||||
if (auto instance = instances_.find(user);
|
if (auto instance = instances_.find(user);
|
||||||
instance == instances_.end() || !instance->second) {
|
instance == instances_.end() || !instance->second) {
|
||||||
instances_[user] = std::make_unique<ConfigManager>(user);
|
instances_[user] = std::make_unique<ConfigManager>(user);
|
||||||
} else if(instance->second->NeedUpdateConfig()) {
|
} else if (instance->second->NeedUpdateConfig()) {
|
||||||
instances_[user] = std::make_unique<ConfigManager>(user, instance->second->IsInitialized());
|
instances_[user] = std::make_unique<ConfigManager>(user,
|
||||||
|
instance->second->IsInitialized());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -48,20 +51,20 @@ namespace edxp {
|
||||||
// Always true now
|
// Always true now
|
||||||
inline auto IsBlackWhiteListEnabled() const { return true; }
|
inline auto IsBlackWhiteListEnabled() const { return true; }
|
||||||
|
|
||||||
inline auto IsResourcesHookEnabled() const { return resources_hook_enabled_; }
|
inline const auto &IsResourcesHookEnabled() const { return resources_hook_enabled_; }
|
||||||
|
|
||||||
inline auto IsDeoptBootImageEnabled() const { return deopt_boot_image_enabled_; }
|
inline const auto &IsDeoptBootImageEnabled() const { return deopt_boot_image_enabled_; }
|
||||||
|
|
||||||
inline auto IsNoModuleLogEnabled() const { return no_module_log_enabled_; }
|
inline const auto &IsNoModuleLogEnabled() const { return no_module_log_enabled_; }
|
||||||
|
|
||||||
inline auto GetInstallerPackageName() const { return installer_pkg_name_; }
|
inline const auto &GetInstallerPackageName() const { return installer_pkg_name_; }
|
||||||
|
|
||||||
inline auto GetLibSandHookName() const { return kLibSandHookName; }
|
inline const auto &GetLibSandHookName() const { return kLibSandHookName; }
|
||||||
|
|
||||||
inline auto GetDataPathPrefix() const { return data_path_prefix_; }
|
inline const auto &GetDataPathPrefix() const { return data_path_prefix_; }
|
||||||
|
|
||||||
inline static auto GetFrameworkPath(const std::string &suffix = {}) {
|
inline static auto GetFrameworkPath(const std::string &suffix = {}) {
|
||||||
return GetMiscPath() / "framework" / suffix;
|
return misc_path_ / "framework" / suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto GetXposedPropPath() const { return GetFrameworkPath(kXposedPropName); }
|
inline auto GetXposedPropPath() const { return GetFrameworkPath(kXposedPropName); }
|
||||||
|
|
@ -74,7 +77,7 @@ namespace edxp {
|
||||||
return base_config_path_ / "log" / suffix;
|
return base_config_path_ / "log" / suffix;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline auto GetBaseConfigPath() const { return base_config_path_; }
|
inline const auto &GetBaseConfigPath() const { return base_config_path_; }
|
||||||
|
|
||||||
inline auto GetPrefsPath(const std::string &pkg_name) const {
|
inline auto GetPrefsPath(const std::string &pkg_name) const {
|
||||||
return base_config_path_ / "prefs" / pkg_name;
|
return base_config_path_ / "prefs" / pkg_name;
|
||||||
|
|
@ -90,6 +93,7 @@ namespace edxp {
|
||||||
|
|
||||||
void EnsurePermission(const std::string &pkg_name, uid_t uid) const;
|
void EnsurePermission(const std::string &pkg_name, uid_t uid) const;
|
||||||
|
|
||||||
|
static const auto &GetInjectDexPaths() { return inject_dex_paths_; };
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline static std::unordered_map<uid_t, std::unique_ptr<ConfigManager>> instances_{};
|
inline static std::unordered_map<uid_t, std::unique_ptr<ConfigManager>> instances_{};
|
||||||
|
|
@ -98,8 +102,6 @@ namespace edxp {
|
||||||
inline static std::vector<std::filesystem::path> inject_dex_paths_;
|
inline static std::vector<std::filesystem::path> inject_dex_paths_;
|
||||||
inline static const bool use_prot_storage_ = GetAndroidApiLevel() >= __ANDROID_API_N__;
|
inline static const bool use_prot_storage_ = GetAndroidApiLevel() >= __ANDROID_API_N__;
|
||||||
|
|
||||||
static decltype(misc_path_) GetMiscPath();
|
|
||||||
|
|
||||||
const uid_t user_;
|
const uid_t user_;
|
||||||
const std::filesystem::path data_path_prefix_;
|
const std::filesystem::path data_path_prefix_;
|
||||||
const std::filesystem::path base_config_path_;
|
const std::filesystem::path base_config_path_;
|
||||||
|
|
@ -117,7 +119,7 @@ namespace edxp {
|
||||||
|
|
||||||
const std::filesystem::file_time_type last_write_time_;
|
const std::filesystem::file_time_type last_write_time_;
|
||||||
|
|
||||||
ConfigManager(uid_t uid, bool initialized=false);
|
ConfigManager(uid_t uid, bool initialized = false);
|
||||||
|
|
||||||
static std::unordered_set<std::string> GetAppList(const std::filesystem::path &dir);
|
static std::unordered_set<std::string> GetAppList(const std::filesystem::path &dir);
|
||||||
|
|
||||||
|
|
@ -132,12 +134,10 @@ namespace edxp {
|
||||||
bool InitConfigPath() const;
|
bool InitConfigPath() const;
|
||||||
|
|
||||||
friend std::unique_ptr<ConfigManager> std::make_unique<ConfigManager>(uid_t &);
|
friend std::unique_ptr<ConfigManager> std::make_unique<ConfigManager>(uid_t &);
|
||||||
friend std::unique_ptr<ConfigManager> std::make_unique<ConfigManager>(uid_t &, bool&&);
|
|
||||||
|
friend std::unique_ptr<ConfigManager> std::make_unique<ConfigManager>(uid_t &, bool &&);
|
||||||
|
|
||||||
std::filesystem::path RetrieveBaseConfigPath() const;
|
std::filesystem::path RetrieveBaseConfigPath() const;
|
||||||
|
|
||||||
public:
|
|
||||||
static decltype(inject_dex_paths_) GetInjectDexPaths();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace edxp
|
} // namespace edxp
|
||||||
|
|
|
||||||
|
|
@ -22,9 +22,10 @@
|
||||||
#pragma clang diagnostic ignored "-Wunused-value"
|
#pragma clang diagnostic ignored "-Wunused-value"
|
||||||
|
|
||||||
namespace edxp {
|
namespace edxp {
|
||||||
// TODO exclude unrelated processes
|
|
||||||
static void onModuleLoaded() {
|
static void onModuleLoaded() {
|
||||||
LOG(INFO) << "onModuleLoaded: welcome to EdXposed!";
|
LOGI("onModuleLoaded: welcome to EdXposed!");
|
||||||
|
// rirud must be used in onModuleLoaded
|
||||||
|
ConfigManager::Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
static int shouldSkipUid(int uid) {
|
static int shouldSkipUid(int uid) {
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,8 @@ RirudSocket::RirudSocket() {
|
||||||
socklen_t socklen = sizeof(sa_family_t) + strlen(addr.sun_path + 1) + 1;
|
socklen_t socklen = sizeof(sa_family_t) + strlen(addr.sun_path + 1) + 1;
|
||||||
|
|
||||||
if (connect(fd_, reinterpret_cast<struct sockaddr *>(&addr), socklen) == -1) {
|
if (connect(fd_, reinterpret_cast<struct sockaddr *>(&addr), socklen) == -1) {
|
||||||
|
close(fd_);
|
||||||
|
fd_ = -1;
|
||||||
throw RirudSocketException(strerror(errno));
|
throw RirudSocketException(strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue