separate error info and normal info of daemons

This commit is contained in:
5ec1cff
2023-12-12 12:35:13 +08:00
parent 370bb0863b
commit 056900406e
4 changed files with 33 additions and 10 deletions

View File

@@ -13,6 +13,8 @@ enum Command {
ZYGOTE32_INJECTED = 5, ZYGOTE32_INJECTED = 5,
DAEMON64_SET_INFO = 6, DAEMON64_SET_INFO = 6,
DAEMON32_SET_INFO = 7, DAEMON32_SET_INFO = 7,
DAEMON64_SET_ERROR_INFO = 8,
DAEMON32_SET_ERROR_INFO = 9,
}; };
void send_control_command(Command cmd); void send_control_command(Command cmd);

View File

@@ -121,6 +121,7 @@ struct Status {
bool daemon_running = false; bool daemon_running = false;
pid_t daemon_pid = -1; pid_t daemon_pid = -1;
std::string daemon_info; std::string daemon_info;
std::string daemon_error_info;
}; };
static Status status64; static Status status64;
@@ -246,6 +247,18 @@ struct SocketHandler : public EventHandler {
status32.daemon_info = std::string(msg.data); status32.daemon_info = std::string(msg.data);
updateStatus(); updateStatus();
break; break;
case DAEMON64_SET_ERROR_INFO:
LOGD("received daemon64 error info %s", msg.data);
status64.daemon_running = false;
status64.daemon_error_info = std::string(msg.data);
updateStatus();
break;
case DAEMON32_SET_ERROR_INFO:
LOGD("received daemon32 error info %s", msg.data);
status32.daemon_running = false;
status32.daemon_error_info = std::string(msg.data);
updateStatus();
break;
} }
} }
} }
@@ -385,8 +398,8 @@ public:
auto status_str = parse_status(status); \ auto status_str = parse_status(status); \
LOGW("daemon" #abi "pid %d exited: %s", pid, status_str.c_str()); \ LOGW("daemon" #abi "pid %d exited: %s", pid, status_str.c_str()); \
status##abi.daemon_running = false; \ status##abi.daemon_running = false; \
if (status##abi.daemon_info.empty()) { \ if (status##abi.daemon_error_info.empty()) { \
status##abi.daemon_info = status_str; \ status##abi.daemon_error_info = status_str; \
} \ } \
updateStatus(); \ updateStatus(); \
continue; \ continue; \
@@ -506,14 +519,20 @@ static void updateStatus() {
else if (status##suffix.zygote_injected) status_text += "😋injected,"; \ else if (status##suffix.zygote_injected) status_text += "😋injected,"; \
else status_text += "❌not injected,"; \ else status_text += "❌not injected,"; \
status_text += " daemon" #suffix ":"; \ status_text += " daemon" #suffix ":"; \
if (status##suffix.daemon_running) status_text += "😋running"; \ if (status##suffix.daemon_running) { \
else { \ status_text += "😋running"; \
if (!status##suffix.daemon_info.empty()) { \
status_text += "("; \
status_text += status##suffix.daemon_info; \
status_text += ")"; \
} \
} else { \
status_text += "❌crashed"; \ status_text += "❌crashed"; \
} \ if (!status##suffix.daemon_error_info.empty()) { \
if (!status##suffix.daemon_info.empty()) { \ status_text += "("; \
status_text += "("; \ status_text += status##suffix.daemon_error_info; \
status_text += status##suffix.daemon_info; \ status_text += ")"; \
status_text += ")"; \ } \
} \ } \
} }
WRITE_STATUS_ABI(64) WRITE_STATUS_ABI(64)

View File

@@ -27,6 +27,7 @@ pub const PATH_PT_BIN32: &str = "bin/zygisk-ptracer32";
pub const PATH_PT_BIN64: &str = "bin/zygisk-ptracer64"; pub const PATH_PT_BIN64: &str = "bin/zygisk-ptracer64";
pub const ZYGOTE_INJECTED: i32 = lp_select!(5, 4); pub const ZYGOTE_INJECTED: i32 = lp_select!(5, 4);
pub const DAEMON_SET_INFO: i32 = lp_select!(7, 6); pub const DAEMON_SET_INFO: i32 = lp_select!(7, 6);
pub const DAEMON_SET_ERROR_INFO: i32 = lp_select!(9, 8);
pub const MAX_RESTART_COUNT: i32 = 5; pub const MAX_RESTART_COUNT: i32 = 5;

View File

@@ -42,14 +42,15 @@ pub fn main() -> Result<()> {
{ {
let mut msg = Vec::<u8>::new(); let mut msg = Vec::<u8>::new();
msg.extend_from_slice(&constants::DAEMON_SET_INFO.to_le_bytes());
let info = match root_impl::get_impl() { let info = match root_impl::get_impl() {
root_impl::RootImpl::KernelSU | root_impl::RootImpl::Magisk => { root_impl::RootImpl::KernelSU | root_impl::RootImpl::Magisk => {
msg.extend_from_slice(&constants::DAEMON_SET_INFO.to_le_bytes());
let module_names: Vec<_> = modules.iter() let module_names: Vec<_> = modules.iter()
.map(|m| m.name.as_str()).collect(); .map(|m| m.name.as_str()).collect();
format!("Root: {:?},module({}): {}", root_impl::get_impl(), modules.len(), module_names.join(",")) format!("Root: {:?},module({}): {}", root_impl::get_impl(), modules.len(), module_names.join(","))
} }
_ => { _ => {
msg.extend_from_slice(&constants::DAEMON_SET_ERROR_INFO.to_le_bytes());
format!("Invalid root implementation: {:?}", root_impl::get_impl()) format!("Invalid root implementation: {:?}", root_impl::get_impl())
} }
}; };