Magisk/native/jni/zygisk/zygisk.hpp

49 lines
1.2 KiB
C++
Raw Normal View History

#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>
#define INJECT_ENV_1 "MAGISK_INJ_1"
#define INJECT_ENV_2 "MAGISK_INJ_2"
2021-08-18 10:44:32 +00:00
enum : int {
ZYGISK_SETUP,
2021-10-13 11:52:02 +00:00
ZYGISK_GET_INFO,
2021-08-19 11:55:17 +00:00
ZYGISK_UNMOUNT,
2021-08-21 10:52:59 +00:00
ZYGISK_GET_LOG_PIPE,
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__)
#else
#define ZLOGD(...) LOGD("zygisk32: " __VA_ARGS__)
#define ZLOGE(...) LOGE("zygisk32: " __VA_ARGS__)
#define ZLOGI(...) LOGI("zygisk32: " __VA_ARGS__)
#endif
// Unmap all pages matching the name
void unmap_all(const char *name);
// 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-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-09-18 09:38:53 +00:00
struct AppInfo {
bool is_magisk_app;
bool on_denylist;
};
2021-01-08 08:53:24 +00:00
void self_unload();
void hook_functions();
bool unhook_functions();
2021-10-13 11:52:02 +00:00
std::vector<int> remote_get_info(int uid, const char *process, AppInfo *info);
2021-08-19 11:55:17 +00:00
int remote_request_unmount();