You've already forked Zygisk-Assistant
mirror of
https://github.com/snake-4/Zygisk-Assistant.git
synced 2025-09-06 06:37:02 +00:00
Added prop hiding
This commit is contained in:
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -4,3 +4,6 @@
|
||||
[submodule "module/jni/libcxx"]
|
||||
path = module/jni/libcxx
|
||||
url = https://github.com/topjohnwu/libcxx.git
|
||||
[submodule "module/jni/system_properties"]
|
||||
path = module/jni/system_properties
|
||||
url = https://github.com/topjohnwu/system_properties
|
||||
|
||||
@@ -4,8 +4,9 @@ include $(CLEAR_VARS)
|
||||
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include $(LOCAL_PATH)/elfio
|
||||
LOCAL_MODULE := zygisk
|
||||
LOCAL_SRC_FILES := utils.cpp map_parser.cpp mountinfo_parser.cpp modules.cpp main.cpp
|
||||
LOCAL_STATIC_LIBRARIES := libcxx
|
||||
LOCAL_STATIC_LIBRARIES := libcxx libsystemproperties
|
||||
LOCAL_LDLIBS := -llog
|
||||
include $(BUILD_SHARED_LIBRARY)
|
||||
|
||||
include jni/libcxx/Android.mk
|
||||
include jni/libcxx/Android.mk
|
||||
include jni/system_properties/Android.mk
|
||||
@@ -3,3 +3,4 @@
|
||||
void doUnmount();
|
||||
void doRemount();
|
||||
void doHideZygisk();
|
||||
void doMrProp();
|
||||
|
||||
@@ -113,9 +113,8 @@ public:
|
||||
LOGD("Invoking the companion was successful.");
|
||||
else
|
||||
{
|
||||
LOGW("Invoking the companion failed. Performing operations in Zygote context!");
|
||||
LOGW("Invoking the companion failed. Functionality will be limited in Zygote context!");
|
||||
doUnmount();
|
||||
doRemount();
|
||||
}
|
||||
|
||||
doHideZygisk();
|
||||
@@ -165,6 +164,7 @@ void zygisk_companion_handler(int fd)
|
||||
{
|
||||
doUnmount();
|
||||
doRemount();
|
||||
doMrProp();
|
||||
}));
|
||||
}();
|
||||
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
#include <string>
|
||||
#include <string_view>
|
||||
#include <set>
|
||||
#include <atomic>
|
||||
#include <unordered_map>
|
||||
#include <cstdint>
|
||||
#include <sys/mount.h>
|
||||
#include <elfio/elfio.hpp>
|
||||
|
||||
// These includes are from the system_properties submodule, not NDK!
|
||||
#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
|
||||
#include <api/system_properties.h>
|
||||
#include <api/_system_properties.h>
|
||||
#include <system_properties/prop_info.h>
|
||||
|
||||
#include "zygisk.hpp"
|
||||
#include "logging.hpp"
|
||||
#include "map_parser.hpp"
|
||||
@@ -45,7 +53,7 @@ static bool shouldUnmount(const mountinfo_entry_t &mount, const mountinfo_root_r
|
||||
if (type == "overlay")
|
||||
{
|
||||
const auto &options = mount.getSuperOptions();
|
||||
|
||||
|
||||
if (options.contains("lowerdir") && options.at("lowerdir").starts_with("/data/adb"))
|
||||
return true;
|
||||
|
||||
@@ -159,3 +167,53 @@ void doHideZygisk()
|
||||
LOGD("libnativebridge.so had_error was reset.");
|
||||
}
|
||||
}
|
||||
|
||||
void doMrProp()
|
||||
{
|
||||
static bool isInitialized = false;
|
||||
static int resetCount = 0;
|
||||
if (!isInitialized)
|
||||
{
|
||||
isInitialized = __system_properties_init() == 0;
|
||||
}
|
||||
|
||||
if (!isInitialized)
|
||||
{
|
||||
LOGE("Could not initialize system_properties!");
|
||||
return;
|
||||
}
|
||||
|
||||
int ret = __system_property_foreach(
|
||||
[](const prop_info *pi, void *)
|
||||
{
|
||||
if (std::string_view(pi->name).starts_with("ro.") && !pi->is_long())
|
||||
{
|
||||
auto serial = std::atomic_load_explicit(&pi->serial, std::memory_order_relaxed);
|
||||
|
||||
// Well this is a bit dangerous
|
||||
bool shouldReset = (serial & 0xFF) != 0;
|
||||
auto length = strlen(pi->value);
|
||||
|
||||
if (!shouldReset)
|
||||
{
|
||||
for (size_t i = length; i < PROP_VALUE_MAX; i++)
|
||||
{
|
||||
if (pi->value[i] != 0)
|
||||
{
|
||||
shouldReset = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldReset)
|
||||
{
|
||||
resetCount++;
|
||||
__system_property_update(const_cast<prop_info *>(pi), pi->value, length);
|
||||
}
|
||||
}
|
||||
},
|
||||
nullptr);
|
||||
|
||||
LOGD("__system_property_foreach returned %d. resetCount=%d", ret, resetCount);
|
||||
}
|
||||
1
module/jni/system_properties
Submodule
1
module/jni/system_properties
Submodule
Submodule module/jni/system_properties added at e1a3e77d23
Reference in New Issue
Block a user