Zygisk injector (#1)

* fix x86

* add lsplt

* transplant from zygisk

* api v4

Signed-off-by: 5ec1cff <ewtqyqyewtqyqy@gmail.com>

* Remove redundant logs

Signed-off-by: 5ec1cff <ewtqyqyewtqyqy@gmail.com>

---------

Signed-off-by: 5ec1cff <ewtqyqyewtqyqy@gmail.com>
This commit is contained in:
5ec1cff
2023-01-31 15:03:01 +08:00
committed by GitHub
parent 50a50a8d39
commit b8678720fb
28 changed files with 2476 additions and 22 deletions

View File

@@ -27,7 +27,7 @@ namespace zygiskd {
}
bool PingHeartbeat() {
LOGD("Daemon socket: %s", kZygiskSocket);
LOGD("Daemon socket: %s", kZygiskSocket.data());
auto fd = Connect(5);
if (fd == -1) {
PLOGE("Connect to zygiskd");
@@ -58,14 +58,44 @@ namespace zygiskd {
size_t len = socket_utils::read_usize(fd);
for (size_t i = 0; i < len; i++) {
std::string name = socket_utils::read_string(fd);
UniqueFd module_fd = socket_utils::recv_fd(fd);
int module_fd = socket_utils::recv_fd(fd);
auto handle = DlopenMem(module_fd, RTLD_NOW);
if (handle == nullptr) {
LOGW("Failed to dlopen module %s: %s", name.data(), dlerror());
continue;
}
modules.emplace_back(name, handle);
modules.emplace_back(i, name, handle);
}
return modules;
}
UniqueFd ConnectCompanion(size_t index) {
auto fd = Connect(1);
if (fd == -1) {
PLOGE("ConnectCompanion");
return -1;
}
socket_utils::write_u8(fd, (uint8_t) SocketAction::RequestCompanionSocket);
socket_utils::write_usize(fd, index);
if (socket_utils::read_u8(fd) == 1) {
return fd;
} else {
return -1;
}
}
UniqueFd GetModuleDir(size_t index) {
auto fd = Connect(1);
if (fd == -1) {
PLOGE("GetModuleDir");
return -1;
}
socket_utils::write_u8(fd, (uint8_t) SocketAction::GetModuleDir);
socket_utils::write_usize(fd, index);
if (socket_utils::read_u8(fd) == 1) {
return fd;
} else {
return -1;
}
}
}