mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-04-26 07:20:46 +00:00
64 lines
1.4 KiB
C++
64 lines
1.4 KiB
C++
#pragma once
|
|
|
|
#include <pthread.h>
|
|
#include <poll.h>
|
|
#include <string>
|
|
#include <limits>
|
|
#include <atomic>
|
|
#include <functional>
|
|
|
|
#include "socket.hpp"
|
|
#include "../core-rs.hpp"
|
|
|
|
#define AID_ROOT 0
|
|
#define AID_SHELL 2000
|
|
#define AID_USER_OFFSET 100000
|
|
|
|
#define to_app_id(uid) (uid % AID_USER_OFFSET)
|
|
#define to_user_id(uid) (uid / AID_USER_OFFSET)
|
|
|
|
// Return codes for daemon
|
|
enum class RespondCode : int {
|
|
ERROR = -1,
|
|
OK = 0,
|
|
ROOT_REQUIRED,
|
|
ACCESS_DENIED,
|
|
END
|
|
};
|
|
|
|
extern std::string native_bridge;
|
|
|
|
int connect_daemon(int req, bool create = false);
|
|
void unlock_blocks();
|
|
|
|
// Poll control
|
|
using poll_callback = void(*)(pollfd*);
|
|
void register_poll(const pollfd *pfd, poll_callback callback);
|
|
void unregister_poll(int fd, bool auto_close);
|
|
void clear_poll();
|
|
|
|
// Thread pool
|
|
void init_thread_pool();
|
|
void exec_task(std::function<void()> &&task);
|
|
|
|
// Daemon handlers
|
|
void denylist_handler(int client, const sock_cred *cred);
|
|
void su_daemon_handler(int client, const sock_cred *cred);
|
|
|
|
// Module stuffs
|
|
void disable_modules();
|
|
void remove_modules();
|
|
|
|
// Scripting
|
|
void exec_script(const char *script);
|
|
void clear_pkg(const char *pkg, int user_id);
|
|
[[noreturn]] void install_module(const char *file);
|
|
|
|
// Denylist
|
|
extern std::atomic<bool> denylist_enforced;
|
|
int denylist_cli(int argc, char **argv);
|
|
void initialize_denylist();
|
|
void scan_deny_apps();
|
|
bool is_deny_target(int uid, std::string_view process);
|
|
void revert_unmount(int pid = -1) noexcept;
|