You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
show loaded modules
This commit is contained in:
@@ -26,6 +26,7 @@ pub const PATH_CP_BIN64: &str = "bin/zygisk-cp64";
|
||||
pub const PATH_PT_BIN32: &str = "bin/zygisk-ptracer32";
|
||||
pub const PATH_PT_BIN64: &str = "bin/zygisk-ptracer64";
|
||||
pub const ZYGOTE_INJECTED: i32 = lp_select!(5, 4);
|
||||
pub const DAEMON_SET_INFO: i32 = lp_select!(7, 6);
|
||||
|
||||
pub const MAX_RESTART_COUNT: i32 = 5;
|
||||
|
||||
|
||||
@@ -203,10 +203,13 @@ pub fn unix_listener_from_path(path: &str) -> Result<UnixListener> {
|
||||
}
|
||||
|
||||
pub fn unix_datagram_sendto_abstract(path: &str, buf: &[u8]) -> Result<()> {
|
||||
// FIXME: shall we set create context every time?
|
||||
set_socket_create_context(get_current_attr()?.as_str())?;
|
||||
let addr = SocketAddrUnix::new_abstract_name(path.as_bytes())?;
|
||||
let socket = socket(AddressFamily::UNIX, SocketType::DGRAM, None)?;
|
||||
connect_unix(&socket, &addr)?;
|
||||
sendto_unix(socket, buf, SendFlags::empty(), &addr)?;
|
||||
set_socket_create_context("u:r:zygote:s0")?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
@@ -32,11 +32,26 @@ struct Context {
|
||||
|
||||
pub fn main() -> Result<()> {
|
||||
log::info!("Welcome to Zygisk Next ({}) !", constants::ZKSU_VERSION);
|
||||
let magic_path = std::env::var("MAGIC")?;
|
||||
let controller_path = format!("init_monitor{}", magic_path);
|
||||
log::info!("socket path {}", controller_path);
|
||||
|
||||
let arch = get_arch()?;
|
||||
log::debug!("Daemon architecture: {arch}");
|
||||
let modules = load_modules(arch)?;
|
||||
|
||||
{
|
||||
let module_names: Vec<_> = modules.iter()
|
||||
.map(|m| m.name.as_str()).collect();
|
||||
let module_info = format!("loaded {} module(s):{}", modules.len(), module_names.join(","));
|
||||
let mut msg = Vec::<u8>::new();
|
||||
msg.extend_from_slice(&constants::DAEMON_SET_INFO.to_le_bytes());
|
||||
msg.extend_from_slice(&(module_info.len() as u32 + 1).to_le_bytes());
|
||||
msg.extend_from_slice(module_info.as_bytes());
|
||||
msg.extend_from_slice(&[0u8]);
|
||||
utils::unix_datagram_sendto_abstract(controller_path.as_str(), msg.as_slice()).expect("failed to send info");
|
||||
}
|
||||
|
||||
let context = Context {
|
||||
modules,
|
||||
};
|
||||
@@ -50,13 +65,8 @@ pub fn main() -> Result<()> {
|
||||
log::trace!("New daemon action {:?}", action);
|
||||
match action {
|
||||
DaemonSocketAction::PingHeartbeat => {
|
||||
utils::set_socket_create_context(utils::get_current_attr()?.as_str())?;
|
||||
let magic_path = std::env::var("MAGIC")?;
|
||||
let socket_path = format!("init_monitor{}", magic_path);
|
||||
log::info!("socket path {}", socket_path);
|
||||
let value = constants::ZYGOTE_INJECTED;
|
||||
utils::unix_datagram_sendto_abstract(socket_path.as_str(), &value.to_le_bytes())?;
|
||||
utils::set_socket_create_context("u:r:zygote:s0")?;
|
||||
utils::unix_datagram_sendto_abstract(controller_path.as_str(), &value.to_le_bytes())?;
|
||||
}
|
||||
DaemonSocketAction::ZygoteRestart => {
|
||||
info!("Zygote restarted, clean up companions");
|
||||
|
||||
Reference in New Issue
Block a user