You've already forked ZygiskNext
mirror of
https://github.com/Dr-TSNG/ZygiskNext.git
synced 2025-08-27 23:46:34 +00:00
use /debug_ramdisk
This commit is contained in:
@@ -17,13 +17,15 @@ pub const MAX_LOG_LEVEL: LevelFilter = LevelFilter::Trace;
|
||||
pub const MAX_LOG_LEVEL: LevelFilter = LevelFilter::Info;
|
||||
|
||||
|
||||
pub const PATH_CP_NAME: &str = lp_select!("/cp32.sock", "/cp64.sock");
|
||||
|
||||
pub const PATH_MODULES_DIR: &str = "..";
|
||||
pub const PATH_MODULE_PROP: &str = "module.prop";
|
||||
pub const ZYGOTE_INJECTED: i32 = lp_select!(5, 4);
|
||||
pub const DAEMON_SET_INFO: i32 = lp_select!(7, 6);
|
||||
pub const DAEMON_SET_ERROR_INFO: i32 = lp_select!(9, 8);
|
||||
pub const TMP_DIR: &str = "/debug_ramdisk/zygisksu";
|
||||
pub const CONTROLLER_SOCKET: &str = concatcp!(TMP_DIR, "/init_monitor");
|
||||
pub const PATH_CP_NAME: &str = concatcp!(TMP_DIR, lp_select!("/cp32.sock", "/cp64.sock"));
|
||||
|
||||
pub const MAX_RESTART_COUNT: i32 = 5;
|
||||
|
||||
|
||||
@@ -202,10 +202,10 @@ pub fn unix_listener_from_path(path: &str) -> Result<UnixListener> {
|
||||
Ok(UnixListener::from(socket))
|
||||
}
|
||||
|
||||
pub fn unix_datagram_sendto_abstract(path: &str, buf: &[u8]) -> Result<()> {
|
||||
pub fn unix_datagram_sendto(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 addr = SocketAddrUnix::new(path.as_bytes())?;
|
||||
let socket = socket(AddressFamily::UNIX, SocketType::DGRAM, None)?;
|
||||
connect_unix(&socket, &addr)?;
|
||||
sendto_unix(socket, buf, SendFlags::empty(), &addr)?;
|
||||
|
||||
@@ -32,9 +32,6 @@ 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}");
|
||||
@@ -57,7 +54,7 @@ pub fn main() -> Result<()> {
|
||||
msg.extend_from_slice(&(info.len() as u32 + 1).to_le_bytes());
|
||||
msg.extend_from_slice(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");
|
||||
utils::unix_datagram_sendto(constants::CONTROLLER_SOCKET, msg.as_slice()).expect("failed to send info");
|
||||
}
|
||||
|
||||
let context = Context {
|
||||
@@ -74,7 +71,7 @@ pub fn main() -> Result<()> {
|
||||
match action {
|
||||
DaemonSocketAction::PingHeartbeat => {
|
||||
let value = constants::ZYGOTE_INJECTED;
|
||||
utils::unix_datagram_sendto_abstract(controller_path.as_str(), &value.to_le_bytes())?;
|
||||
utils::unix_datagram_sendto(constants::CONTROLLER_SOCKET, &value.to_le_bytes())?;
|
||||
}
|
||||
DaemonSocketAction::ZygoteRestart => {
|
||||
info!("Zygote restarted, clean up companions");
|
||||
@@ -166,10 +163,7 @@ fn create_library_fd(so_path: &PathBuf) -> Result<OwnedFd> {
|
||||
|
||||
fn create_daemon_socket() -> Result<UnixListener> {
|
||||
utils::set_socket_create_context("u:r:zygote:s0")?;
|
||||
let magic_path = std::env::var("MAGIC_PATH")?;
|
||||
let socket_path = magic_path + constants::PATH_CP_NAME;
|
||||
log::debug!("Daemon socket: {}", socket_path);
|
||||
let listener = utils::unix_listener_from_path(&socket_path)?;
|
||||
let listener = utils::unix_listener_from_path(constants::PATH_CP_NAME)?;
|
||||
Ok(listener)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user