add: zygiskd C99 APatch support

This commit adds support for zygiskd C99 to recognize APatch rooted devices.
This commit is contained in:
ThePedroo
2024-08-15 22:42:47 -03:00
parent 19d2a1758e
commit c1e45e9af6
13 changed files with 484 additions and 210 deletions

View File

@@ -4,6 +4,7 @@
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <sys/wait.h>
#include <sys/un.h>
#include <errno.h>
@@ -280,3 +281,37 @@ ssize_t read_string(int fd, char *str, size_t len) {
return read_bytes;
}
bool exec_command(char *buf, size_t len, const char *file, char *const argv[]) {
int link[2];
pid_t pid;
if (pipe(link) == -1) {
LOGE("pipe: %s\n", strerror(errno));
return false;
}
if ((pid = fork()) == -1) {
LOGE("fork: %s\n", strerror(errno));
return false;
}
if (pid == 0) {
dup2(link[1], STDOUT_FILENO);
close(link[0]);
close(link[1]);
execv(file, argv);
} else {
close(link[1]);
int nbytes = read(link[0], buf, len);
buf[nbytes] = '\0';
wait(NULL);
}
return true;
}