Remove some traces left by LSPosed
1. Avoid changing `system.prop`: there is already no need to add system-wise `dex2oat` flags, since LSPosed provides a wrapper for it, see https://nullptr.icu/index.php/archives/53/ for detailed explanation; 2. Postpone initialization of LSPlant: initialization of `initInfo` during the `onLoad` Zygisk api will change the order of parsed files in memory, especially bring the item `libart.so` forward; 3. Close opened virtual map file: this should no longer be a problem after the second point is applied since it is no longer opened during `onLoad`, but let us close it as a good practice; 4. Remove /data/resource-cache mount: introduced in https://github.com/LSPosed/LSPosed/pull/1627, most likely designed to solve problems in early versions of root solutions and being reverted does not change the function of deamon since we will have to wait sufficient time in `waitSystemService` of `LSPosedService` manager. Of course, more tests are neeeded on different devices to see if parasitic notification manager will work as expected.
This commit is contained in:
parent
984bb1c8e5
commit
156c6ae855
|
|
@ -23,8 +23,6 @@ if [ $debug = "true" ]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
mount tmpfs -t tmpfs /data/resource-cache
|
||||
|
||||
if [ ! -S "/dev/socket/zygote" ]; then
|
||||
timeout 0.5 inotifyd - /dev/socket:near | while read -r line; do
|
||||
$debug && log -p v -t "LSPosed" "inotify: $line"
|
||||
|
|
|
|||
|
|
@ -1 +0,0 @@
|
|||
dalvik.vm.dex2oat-flags=--inline-max-code-units=0
|
||||
|
|
@ -40,7 +40,7 @@ class ZygiskModule : public zygisk::ModuleBase {
|
|||
void onLoad(zygisk::Api *api, JNIEnv *env) override {
|
||||
env_ = env;
|
||||
api_ = api;
|
||||
MagiskLoader::Init(api);
|
||||
MagiskLoader::Init();
|
||||
ConfigImpl::Init();
|
||||
}
|
||||
|
||||
|
|
@ -51,7 +51,7 @@ class ZygiskModule : public zygisk::ModuleBase {
|
|||
}
|
||||
|
||||
void postAppSpecialize(const zygisk::AppSpecializeArgs *args) override {
|
||||
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePost(env_, args->nice_name,
|
||||
MagiskLoader::GetInstance()->OnNativeForkAndSpecializePost(env_, api_, args->nice_name,
|
||||
args->app_data_dir);
|
||||
if (*allowUnload) api_->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
||||
}
|
||||
|
|
@ -69,7 +69,7 @@ class ZygiskModule : public zygisk::ModuleBase {
|
|||
env_->DeleteLocalRef(name);
|
||||
env_->DeleteLocalRef(process);
|
||||
}
|
||||
MagiskLoader::GetInstance()->OnNativeForkSystemServerPost(env_);
|
||||
MagiskLoader::GetInstance()->OnNativeForkSystemServerPost(env_, api_);
|
||||
if (*allowUnload) api_->setOption(zygisk::DLCLOSE_MODULE_LIBRARY);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -59,12 +59,12 @@ std::vector<MapInfo> MapInfo::Scan(std::string_view pid) {
|
|||
constexpr static auto kMapEntry = 7;
|
||||
std::vector<MapInfo> info;
|
||||
auto path = "/proc/" + std::string{pid} + "/maps";
|
||||
auto maps = std::unique_ptr<FILE, decltype(&fclose)>{fopen(path.c_str(), "r"), &fclose};
|
||||
auto maps = fopen(path.c_str(), "r");
|
||||
if (maps) {
|
||||
char *line = nullptr;
|
||||
size_t len = 0;
|
||||
ssize_t read;
|
||||
while ((read = getline(&line, &len, maps.get())) > 0) {
|
||||
while ((read = getline(&line, &len, maps)) > 0) {
|
||||
line[read - 1] = '\0';
|
||||
uintptr_t start = 0;
|
||||
uintptr_t end = 0;
|
||||
|
|
@ -89,10 +89,12 @@ std::vector<MapInfo> MapInfo::Scan(std::string_view pid) {
|
|||
}
|
||||
free(line);
|
||||
}
|
||||
fclose(maps);
|
||||
return info;
|
||||
}
|
||||
|
||||
void MagiskLoader::InitializeZygiskApi(zygisk::Api *api) {
|
||||
void MagiskLoader::InitializeLSPlant(zygisk::Api *api) {
|
||||
if (lsplant_initilized) return;
|
||||
std::vector<std::pair<const char *, void **>> plt_hook_saved = {};
|
||||
|
||||
const std::string libArtPath = GetArt()->name();
|
||||
|
|
@ -151,6 +153,7 @@ void MagiskLoader::InitializeZygiskApi(zygisk::Api *api) {
|
|||
.art_symbol_prefix_resolver =
|
||||
[](auto symbol) { return GetArt()->getSymbPrefixFirstAddress(symbol); },
|
||||
.is_plt_hook = true};
|
||||
lsplant_initilized = true;
|
||||
}
|
||||
|
||||
void MagiskLoader::LoadDex(JNIEnv *env, PreloadedDex &&dex) {
|
||||
|
|
@ -195,7 +198,7 @@ void MagiskLoader::OnNativeForkSystemServerPre(JNIEnv *env) {
|
|||
setAllowUnload(skip_);
|
||||
}
|
||||
|
||||
void MagiskLoader::OnNativeForkSystemServerPost(JNIEnv *env) {
|
||||
void MagiskLoader::OnNativeForkSystemServerPost(JNIEnv *env, zygisk::Api *api) {
|
||||
if (!skip_) {
|
||||
auto *instance = Service::instance();
|
||||
auto system_server_binder = instance->RequestSystemServerBinder(env);
|
||||
|
|
@ -218,6 +221,7 @@ void MagiskLoader::OnNativeForkSystemServerPost(JNIEnv *env) {
|
|||
instance->HookBridge(*this, env);
|
||||
|
||||
// always inject into system server
|
||||
InitializeLSPlant(api);
|
||||
InitArtHooker(env, initInfo);
|
||||
InitHooks(env);
|
||||
SetupEntryClass(env);
|
||||
|
|
@ -272,7 +276,8 @@ void MagiskLoader::OnNativeForkAndSpecializePre(JNIEnv *env, jint uid, jintArray
|
|||
setAllowUnload(skip_);
|
||||
}
|
||||
|
||||
void MagiskLoader::OnNativeForkAndSpecializePost(JNIEnv *env, jstring nice_name, jstring app_dir) {
|
||||
void MagiskLoader::OnNativeForkAndSpecializePost(JNIEnv *env, zygisk::Api *api, jstring nice_name,
|
||||
jstring app_dir) {
|
||||
const JUTFString process_name(env, nice_name);
|
||||
auto *instance = Service::instance();
|
||||
if (is_parasitic_manager) nice_name = JNI_NewStringUTF(env, "org.lsposed.manager").release();
|
||||
|
|
@ -284,6 +289,7 @@ void MagiskLoader::OnNativeForkAndSpecializePost(JNIEnv *env, jstring nice_name,
|
|||
ConfigBridge::GetInstance()->obfuscation_map(std::move(obfs_map));
|
||||
LoadDex(env, PreloadedDex(dex_fd, size));
|
||||
close(dex_fd);
|
||||
InitializeLSPlant(api);
|
||||
InitArtHooker(env, initInfo);
|
||||
InitHooks(env);
|
||||
SetupEntryClass(env);
|
||||
|
|
|
|||
|
|
@ -29,10 +29,7 @@
|
|||
namespace lspd {
|
||||
class MagiskLoader : public Context {
|
||||
public:
|
||||
inline static void Init(zygisk::Api *api) {
|
||||
instance_ = std::make_unique<MagiskLoader>();
|
||||
GetInstance()->InitializeZygiskApi(api);
|
||||
}
|
||||
inline static void Init() { instance_ = std::make_unique<MagiskLoader>(); }
|
||||
|
||||
inline static MagiskLoader *GetInstance() {
|
||||
return static_cast<MagiskLoader *>(instance_.get());
|
||||
|
|
@ -41,12 +38,13 @@ public:
|
|||
void OnNativeForkAndSpecializePre(JNIEnv *env, jint uid, jintArray &gids, jstring &nice_name,
|
||||
jboolean is_child_zygote, jstring app_data_dir);
|
||||
|
||||
void OnNativeForkAndSpecializePost(JNIEnv *env, jstring nice_name, jstring app_dir);
|
||||
|
||||
void OnNativeForkSystemServerPost(JNIEnv *env);
|
||||
void OnNativeForkAndSpecializePost(JNIEnv *env, zygisk::Api *api, jstring nice_name,
|
||||
jstring app_dir);
|
||||
|
||||
void OnNativeForkSystemServerPre(JNIEnv *env);
|
||||
|
||||
void OnNativeForkSystemServerPost(JNIEnv *env, zygisk::Api *api);
|
||||
|
||||
protected:
|
||||
void LoadDex(JNIEnv *env, PreloadedDex &&dex) override;
|
||||
|
||||
|
|
@ -54,9 +52,10 @@ protected:
|
|||
|
||||
private:
|
||||
bool skip_ = false;
|
||||
bool lsplant_initilized = false;
|
||||
lsplant::InitInfo initInfo;
|
||||
|
||||
void InitializeZygiskApi(zygisk::Api *api);
|
||||
void InitializeLSPlant(zygisk::Api *api);
|
||||
static void setAllowUnload(bool unload);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue