You've already forked ReZygisk
mirror of
https://github.com/PerformanC/ReZygisk.git
synced 2025-09-06 06:37:01 +00:00
add: additional information to ptrace command
This commit adds more information to the ptrace command to allow better integration with external features.
This commit is contained in:
@@ -165,6 +165,60 @@ namespace zygiskd {
|
|||||||
|
|
||||||
info->pid = socket_utils::read_u32(fd);
|
info->pid = socket_utils::read_u32(fd);
|
||||||
|
|
||||||
|
info->modules = (struct zygote_modules *)malloc(sizeof(struct zygote_modules));
|
||||||
|
if (info->modules == NULL) {
|
||||||
|
info->modules->modules_count = 0;
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
info->modules->modules_count = socket_utils::read_usize(fd);
|
||||||
|
|
||||||
|
if (info->modules->modules_count == 0) {
|
||||||
|
info->modules->modules = NULL;
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
info->modules->modules = (char **)malloc(sizeof(char *) * info->modules->modules_count);
|
||||||
|
if (info->modules->modules == NULL) {
|
||||||
|
free(info->modules);
|
||||||
|
info->modules = NULL;
|
||||||
|
info->modules->modules_count = 0;
|
||||||
|
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (size_t i = 0; i < info->modules->modules_count; i++) {
|
||||||
|
/* INFO by ThePedroo: Ugly solution to read with std::string existance (temporary) */
|
||||||
|
std::string name = socket_utils::read_string(fd);
|
||||||
|
|
||||||
|
char module_path[PATH_MAX];
|
||||||
|
snprintf(module_path, sizeof(module_path), "/data/adb/modules/%s/module.prop", name.c_str());
|
||||||
|
|
||||||
|
FILE *module_prop = fopen(module_path, "r");
|
||||||
|
if (module_prop == NULL) {
|
||||||
|
info->modules->modules[i] = strdup(name.c_str());
|
||||||
|
} else {
|
||||||
|
char line[1024];
|
||||||
|
while (fgets(line, sizeof(line), module_prop) != NULL) {
|
||||||
|
if (strncmp(line, "name=", 5) == 0) {
|
||||||
|
info->modules->modules[i] = strndup(line + 5, strlen(line) - 6);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fclose(module_prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
close(fd);
|
close(fd);
|
||||||
} else info->running = false;
|
} else info->running = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,6 +42,11 @@ private:
|
|||||||
Fd fd_ = -1;
|
Fd fd_ = -1;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct zygote_modules {
|
||||||
|
char **modules;
|
||||||
|
size_t modules_count;
|
||||||
|
};
|
||||||
|
|
||||||
enum zygote_root_impl {
|
enum zygote_root_impl {
|
||||||
ZYGOTE_ROOT_IMPL_NONE,
|
ZYGOTE_ROOT_IMPL_NONE,
|
||||||
ZYGOTE_ROOT_IMPL_APATCH,
|
ZYGOTE_ROOT_IMPL_APATCH,
|
||||||
@@ -50,6 +55,7 @@ enum zygote_root_impl {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct zygote_info {
|
struct zygote_info {
|
||||||
|
struct zygote_modules *modules;
|
||||||
enum zygote_root_impl root_impl;
|
enum zygote_root_impl root_impl;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
bool running;
|
bool running;
|
||||||
|
|||||||
@@ -82,7 +82,52 @@ int main(int argc, char **argv) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Is the daemon running: %s\n", info.running ? "yes" : "no");
|
#ifdef __LP64__
|
||||||
|
printf("Daemon64 running: %d\n", status64.daemon_running);
|
||||||
|
printf("Zygote64 injected: %s\n", status64.zygote_injected ? "yes" : "no");
|
||||||
|
#else
|
||||||
|
printf("Daemon32 running: %s\n", status32.daemon_running ? "yes" : "no");
|
||||||
|
printf("Zygote32 injected: %s\n", status32.zygote_injected ? "yes" : "no");
|
||||||
|
#endif
|
||||||
|
|
||||||
|
switch (tracing_state) {
|
||||||
|
case TRACING: {
|
||||||
|
printf("Tracing state: TRACING\n");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STOPPING: {
|
||||||
|
printf("Tracing state: STOPPING\n");
|
||||||
|
printf("Stop reason: %s\n", monitor_stop_reason);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STOPPED: {
|
||||||
|
printf("Tracing state: STOPPED\n");
|
||||||
|
printf("Stop reason: %s\n", monitor_stop_reason);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case EXITING: {
|
||||||
|
printf("Tracing state: EXITING\n");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (info.modules->modules_count != 0) {
|
||||||
|
printf("Modules: %zu\n", info.modules->modules_count);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < info.modules->modules_count; i++) {
|
||||||
|
printf(" - %s\n", info.modules->modules[i]);
|
||||||
|
|
||||||
|
free(info.modules->modules[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(info.modules->modules);
|
||||||
|
} else {
|
||||||
|
printf("Modules: N/A\n");
|
||||||
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -22,14 +22,7 @@
|
|||||||
|
|
||||||
static void updateStatus();
|
static void updateStatus();
|
||||||
|
|
||||||
enum TracingState {
|
char monitor_stop_reason[32];
|
||||||
TRACING = 1,
|
|
||||||
STOPPING,
|
|
||||||
STOPPED,
|
|
||||||
EXITING
|
|
||||||
};
|
|
||||||
|
|
||||||
static char monitor_stop_reason[32];
|
|
||||||
|
|
||||||
constexpr char SOCKET_NAME[] = "init_monitor";
|
constexpr char SOCKET_NAME[] = "init_monitor";
|
||||||
|
|
||||||
@@ -110,20 +103,11 @@ struct EventLoop {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
static TracingState tracing_state = TRACING;
|
TracingState tracing_state = TRACING;
|
||||||
static char prop_path[PATH_MAX];
|
static char prop_path[PATH_MAX];
|
||||||
|
|
||||||
struct Status {
|
Status status64;
|
||||||
bool supported = false;
|
Status status32;
|
||||||
bool zygote_injected = false;
|
|
||||||
bool daemon_running = false;
|
|
||||||
pid_t daemon_pid = -1;
|
|
||||||
char *daemon_info;
|
|
||||||
char *daemon_error_info;
|
|
||||||
};
|
|
||||||
|
|
||||||
static Status status64;
|
|
||||||
static Status status32;
|
|
||||||
|
|
||||||
struct SocketHandler : public EventHandler {
|
struct SocketHandler : public EventHandler {
|
||||||
int sock_fd_;
|
int sock_fd_;
|
||||||
|
|||||||
@@ -3,6 +3,29 @@
|
|||||||
|
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
|
extern char monitor_stop_reason[32];
|
||||||
|
|
||||||
|
enum TracingState {
|
||||||
|
TRACING = 1,
|
||||||
|
STOPPING,
|
||||||
|
STOPPED,
|
||||||
|
EXITING
|
||||||
|
};
|
||||||
|
|
||||||
|
extern TracingState tracing_state;
|
||||||
|
|
||||||
|
struct Status {
|
||||||
|
bool supported = false;
|
||||||
|
bool zygote_injected = false;
|
||||||
|
bool daemon_running = false;
|
||||||
|
pid_t daemon_pid = -1;
|
||||||
|
char *daemon_info;
|
||||||
|
char *daemon_error_info;
|
||||||
|
};
|
||||||
|
|
||||||
|
extern Status status64;
|
||||||
|
extern Status status32;
|
||||||
|
|
||||||
void init_monitor();
|
void init_monitor();
|
||||||
|
|
||||||
bool trace_zygote(int pid);
|
bool trace_zygote(int pid);
|
||||||
|
|||||||
@@ -283,6 +283,12 @@ fn handle_daemon_action(
|
|||||||
|
|
||||||
let pid = unsafe { libc::getpid() };
|
let pid = unsafe { libc::getpid() };
|
||||||
stream.write_u32(pid as u32)?;
|
stream.write_u32(pid as u32)?;
|
||||||
|
|
||||||
|
stream.write_usize(context.modules.len())?;
|
||||||
|
|
||||||
|
for module in context.modules.iter() {
|
||||||
|
stream.write_string(&module.name)?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
DaemonSocketAction::ReadModules => {
|
DaemonSocketAction::ReadModules => {
|
||||||
stream.write_usize(context.modules.len())?;
|
stream.write_usize(context.modules.len())?;
|
||||||
|
|||||||
Reference in New Issue
Block a user