rirud must be used in onModuleLoaded
This commit is contained in:
parent
1e629a92de
commit
fcd4b15496
|
|
@ -120,10 +120,8 @@ namespace art {
|
|||
HOOK_FUNC(FixupStaticTrampolines,
|
||||
"_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__ &&
|
||||
access(edxp::kLibSandHookNativePath.c_str(), F_OK) == -1) {
|
||||
edxp::Context::GetInstance()->GetVariant() != edxp::Variant::SANDHOOK) {
|
||||
LOGD("Not sandhook, installing _ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
|
||||
HOOK_FUNC(ShouldUseInterpreterEntrypoint,
|
||||
"_ZN3art11ClassLinker30ShouldUseInterpreterEntrypointEPNS_9ArtMethodEPKv");
|
||||
|
|
|
|||
|
|
@ -85,8 +85,8 @@ namespace edxp {
|
|||
namespace fs = std::filesystem;
|
||||
|
||||
fs::path ConfigManager::RetrieveBaseConfigPath() const {
|
||||
if (auto misc_path = GetMiscPath(); !misc_path.empty()) {
|
||||
return misc_path / std::to_string(user_);
|
||||
if (!misc_path_.empty()) {
|
||||
return misc_path_ / std::to_string(user_);
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
|
|
@ -259,7 +259,7 @@ namespace edxp {
|
|||
if (base_config_path_.empty()) return false;
|
||||
try {
|
||||
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::permissions(base_config_path_,
|
||||
fs::perms::owner_all | fs::perms::group_all | fs::perms::others_exec);
|
||||
|
|
@ -330,32 +330,22 @@ namespace edxp {
|
|||
}
|
||||
}
|
||||
|
||||
auto ConfigManager::GetMiscPath() -> decltype(misc_path_) {
|
||||
if (misc_path_.empty()) {
|
||||
fs::path misc_path("/data/adb/edxp/misc_path");
|
||||
try {
|
||||
RirudSocket rirud_socket{};
|
||||
auto path = rirud_socket.ReadFile(misc_path);
|
||||
path.erase(std::find_if(path.rbegin(), path.rend(), [](unsigned char ch) {
|
||||
return !std::isspace(ch);
|
||||
}).base(), path.end());
|
||||
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()) {
|
||||
void ConfigManager::Init(){
|
||||
fs::path misc_path("/data/adb/edxp/misc_path");
|
||||
try {
|
||||
RirudSocket rirud_socket{};
|
||||
auto path = rirud_socket.ReadFile(misc_path);
|
||||
path.erase(std::find_if(path.rbegin(), path.rend(), [](unsigned char ch) {
|
||||
return !std::isspace(ch);
|
||||
}).base(), path.end());
|
||||
misc_path_ = fs::path("/data/misc") / path;
|
||||
std::transform(kXposedInjectDexPath.begin(), kXposedInjectDexPath.end(),
|
||||
std::back_inserter(inject_dex_paths_),
|
||||
[](auto i) {
|
||||
return GetFrameworkPath(i);
|
||||
});
|
||||
} catch (const RirudSocket::RirudSocketException &e) {
|
||||
LOGE("%s", e.what());
|
||||
}
|
||||
return inject_dex_paths_;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -26,6 +26,8 @@ namespace edxp {
|
|||
};
|
||||
|
||||
public:
|
||||
static void Init();
|
||||
|
||||
inline static ConfigManager *GetInstance() {
|
||||
return instances_[current_user].get();
|
||||
}
|
||||
|
|
@ -34,10 +36,11 @@ namespace edxp {
|
|||
|
||||
inline static void SetCurrentUser(uid_t user) {
|
||||
if (auto instance = instances_.find(user);
|
||||
instance == instances_.end() || !instance->second) {
|
||||
instance == instances_.end() || !instance->second) {
|
||||
instances_[user] = std::make_unique<ConfigManager>(user);
|
||||
} else if(instance->second->NeedUpdateConfig()) {
|
||||
instances_[user] = std::make_unique<ConfigManager>(user, instance->second->IsInitialized());
|
||||
} else if (instance->second->NeedUpdateConfig()) {
|
||||
instances_[user] = std::make_unique<ConfigManager>(user,
|
||||
instance->second->IsInitialized());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -48,20 +51,20 @@ namespace edxp {
|
|||
// Always true now
|
||||
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 = {}) {
|
||||
return GetMiscPath() / "framework" / suffix;
|
||||
return misc_path_ / "framework" / suffix;
|
||||
}
|
||||
|
||||
inline auto GetXposedPropPath() const { return GetFrameworkPath(kXposedPropName); }
|
||||
|
|
@ -74,7 +77,7 @@ namespace edxp {
|
|||
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 {
|
||||
return base_config_path_ / "prefs" / pkg_name;
|
||||
|
|
@ -90,6 +93,7 @@ namespace edxp {
|
|||
|
||||
void EnsurePermission(const std::string &pkg_name, uid_t uid) const;
|
||||
|
||||
static const auto &GetInjectDexPaths() { return inject_dex_paths_; };
|
||||
|
||||
private:
|
||||
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 const bool use_prot_storage_ = GetAndroidApiLevel() >= __ANDROID_API_N__;
|
||||
|
||||
static decltype(misc_path_) GetMiscPath();
|
||||
|
||||
const uid_t user_;
|
||||
const std::filesystem::path data_path_prefix_;
|
||||
const std::filesystem::path base_config_path_;
|
||||
|
|
@ -117,7 +119,7 @@ namespace edxp {
|
|||
|
||||
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);
|
||||
|
||||
|
|
@ -132,12 +134,10 @@ namespace edxp {
|
|||
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 &, bool&&);
|
||||
|
||||
friend std::unique_ptr<ConfigManager> std::make_unique<ConfigManager>(uid_t &, bool &&);
|
||||
|
||||
std::filesystem::path RetrieveBaseConfigPath() const;
|
||||
|
||||
public:
|
||||
static decltype(inject_dex_paths_) GetInjectDexPaths();
|
||||
};
|
||||
|
||||
} // namespace edxp
|
||||
|
|
|
|||
|
|
@ -22,9 +22,10 @@
|
|||
#pragma clang diagnostic ignored "-Wunused-value"
|
||||
|
||||
namespace edxp {
|
||||
// TODO exclude unrelated processes
|
||||
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) {
|
||||
|
|
|
|||
|
|
@ -52,6 +52,8 @@ RirudSocket::RirudSocket() {
|
|||
socklen_t socklen = sizeof(sa_family_t) + strlen(addr.sun_path + 1) + 1;
|
||||
|
||||
if (connect(fd_, reinterpret_cast<struct sockaddr *>(&addr), socklen) == -1) {
|
||||
close(fd_);
|
||||
fd_ = -1;
|
||||
throw RirudSocketException(strerror(errno));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue