You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
improve: CLI and code (#3)
This commit improves the CLI of ReZygisk, allowing the use of important information like PID of the daemons. Also improves the code of the loaders ptracer.
This commit is contained in:
@@ -18,10 +18,11 @@ namespace zygiskd {
|
||||
|
||||
int Connect(uint8_t retry) {
|
||||
int fd = socket(PF_UNIX, SOCK_STREAM | SOCK_CLOEXEC, 0);
|
||||
struct sockaddr_un addr{
|
||||
.sun_family = AF_UNIX,
|
||||
.sun_path={0},
|
||||
struct sockaddr_un addr = {
|
||||
.sun_family = AF_UNIX,
|
||||
.sun_path = { 0 },
|
||||
};
|
||||
|
||||
auto socket_path = TMP_PATH + kCPSocketName;
|
||||
strcpy(addr.sun_path, socket_path.c_str());
|
||||
socklen_t socklen = sizeof(addr);
|
||||
@@ -67,6 +68,7 @@ namespace zygiskd {
|
||||
}
|
||||
socket_utils::write_u8(fd, (uint8_t) SocketAction::GetProcessFlags);
|
||||
socket_utils::write_u32(fd, uid);
|
||||
|
||||
return socket_utils::read_u32(fd);
|
||||
}
|
||||
|
||||
@@ -139,4 +141,29 @@ namespace zygiskd {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void GetInfo(struct zygote_info *info) {
|
||||
/* TODO: Optimize and avoid re-connect twice here */
|
||||
int fd = Connect(1);
|
||||
|
||||
if (fd != -1) {
|
||||
info->running = true;
|
||||
|
||||
socket_utils::write_u8(fd, (uint8_t) SocketAction::GetInfo);
|
||||
|
||||
int flags = socket_utils::read_u32(fd);
|
||||
|
||||
if (flags & (1 << 29)) {
|
||||
info->root_impl = ZYGOTE_ROOT_IMPL_KERNELSU;
|
||||
} else if (flags & (1 << 30)) {
|
||||
info->root_impl = ZYGOTE_ROOT_IMPL_MAGISK;
|
||||
} else {
|
||||
info->root_impl = ZYGOTE_ROOT_IMPL_NONE;
|
||||
}
|
||||
|
||||
info->pid = socket_utils::read_u32(fd);
|
||||
|
||||
close(fd);
|
||||
} else info->running = false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user