mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-01 05:55:26 +00:00
ff7ac582f0
Co-authored-by: topjohnwu <topjohnwu@gmail.com>
50 lines
1.4 KiB
C++
50 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <stdint.h>
|
|
#include <jni.h>
|
|
#include <vector>
|
|
|
|
#define INJECT_ENV_1 "MAGISK_INJ_1"
|
|
#define INJECT_ENV_2 "MAGISK_INJ_2"
|
|
#define MAGISKFD_ENV "MAGISKFD"
|
|
#define MAGISKTMP_ENV "MAGISKTMP"
|
|
|
|
enum : int {
|
|
ZYGISK_SETUP,
|
|
ZYGISK_GET_INFO,
|
|
ZYGISK_GET_LOG_PIPE,
|
|
ZYGISK_CONNECT_COMPANION,
|
|
ZYGISK_GET_MODDIR,
|
|
};
|
|
|
|
#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
|
|
|
|
// Find the memory address + size of the pages matching name + inode
|
|
std::pair<void*, size_t> find_map_range(const char *name, unsigned long inode);
|
|
|
|
// 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);
|
|
|
|
// Get library name + offset (from start of ELF), given function address
|
|
uintptr_t get_function_off(int pid, uintptr_t addr, char *lib);
|
|
|
|
// Get function address, given library name + offset
|
|
uintptr_t get_function_addr(int pid, const char *lib, uintptr_t off);
|
|
|
|
extern void *self_handle;
|
|
|
|
void hook_functions();
|
|
int remote_get_info(int uid, const char *process, uint32_t *flags, std::vector<int> &fds);
|
|
int remote_request_unmount();
|