2021-01-07 06:21:17 +00:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <stdint.h>
|
2021-01-08 13:25:44 +00:00
|
|
|
#include <jni.h>
|
2021-10-13 11:52:02 +00:00
|
|
|
#include <vector>
|
2022-02-12 15:43:36 +00:00
|
|
|
#include <daemon.hpp>
|
2021-01-07 06:21:17 +00:00
|
|
|
|
2022-02-06 08:27:31 +00:00
|
|
|
#define MAGISKTMP_ENV "MAGISKTMP"
|
2021-01-07 06:21:17 +00:00
|
|
|
|
2022-06-09 04:29:38 +00:00
|
|
|
#define HIJACK_BIN64 "/system/bin/appwidget"
|
|
|
|
#define HIJACK_BIN32 "/system/bin/bu"
|
2022-06-01 08:50:42 +00:00
|
|
|
|
2022-03-01 10:13:18 +00:00
|
|
|
namespace ZygiskRequest {
|
|
|
|
enum : int {
|
2022-02-12 15:43:36 +00:00
|
|
|
SETUP,
|
|
|
|
GET_INFO,
|
|
|
|
GET_LOG_PIPE,
|
|
|
|
CONNECT_COMPANION,
|
|
|
|
GET_MODDIR,
|
|
|
|
PASSTHROUGH,
|
|
|
|
END
|
2021-08-18 10:44:32 +00:00
|
|
|
};
|
2022-03-01 10:13:18 +00:00
|
|
|
}
|
2021-08-18 10:44:32 +00:00
|
|
|
|
2021-10-14 09:13:23 +00:00
|
|
|
#if defined(__LP64__)
|
|
|
|
#define ZLOGD(...) LOGD("zygisk64: " __VA_ARGS__)
|
|
|
|
#define ZLOGE(...) LOGE("zygisk64: " __VA_ARGS__)
|
|
|
|
#define ZLOGI(...) LOGI("zygisk64: " __VA_ARGS__)
|
2022-06-01 08:50:42 +00:00
|
|
|
#define HIJACK_BIN HIJACK_BIN64
|
2021-10-14 09:13:23 +00:00
|
|
|
#else
|
|
|
|
#define ZLOGD(...) LOGD("zygisk32: " __VA_ARGS__)
|
|
|
|
#define ZLOGE(...) LOGE("zygisk32: " __VA_ARGS__)
|
|
|
|
#define ZLOGI(...) LOGI("zygisk32: " __VA_ARGS__)
|
2022-06-01 08:50:42 +00:00
|
|
|
#define HIJACK_BIN HIJACK_BIN32
|
2021-10-14 09:13:23 +00:00
|
|
|
#endif
|
|
|
|
|
2021-01-07 06:21:17 +00:00
|
|
|
// Unmap all pages matching the name
|
|
|
|
void unmap_all(const char *name);
|
|
|
|
|
2021-09-23 02:14:05 +00:00
|
|
|
// Remap all matching pages with anonymous pages
|
|
|
|
void remap_all(const char *name);
|
|
|
|
|
2021-08-11 07:00:21 +00:00
|
|
|
// Get library name + offset (from start of ELF), given function address
|
|
|
|
uintptr_t get_function_off(int pid, uintptr_t addr, char *lib);
|
2021-01-07 06:21:17 +00:00
|
|
|
|
2021-08-11 07:00:21 +00:00
|
|
|
// Get function address, given library name + offset
|
|
|
|
uintptr_t get_function_addr(int pid, const char *lib, uintptr_t off);
|
2021-01-08 08:53:24 +00:00
|
|
|
|
2021-11-07 21:05:44 +00:00
|
|
|
extern void *self_handle;
|
|
|
|
|
2021-01-08 08:53:24 +00:00
|
|
|
void hook_functions();
|
2022-01-21 12:43:27 +00:00
|
|
|
int remote_get_info(int uid, const char *process, uint32_t *flags, std::vector<int> &fds);
|
2022-02-12 15:43:36 +00:00
|
|
|
|
2022-03-01 10:13:18 +00:00
|
|
|
inline int zygisk_request(int req) {
|
|
|
|
int fd = connect_daemon(MainRequest::ZYGISK);
|
2022-08-07 12:09:46 +00:00
|
|
|
if (fd < 0) return fd;
|
2022-03-01 10:13:18 +00:00
|
|
|
write_int(fd, req);
|
2022-02-12 15:43:36 +00:00
|
|
|
return fd;
|
|
|
|
}
|