Load libsqlite dynamically

This commit is contained in:
topjohnwu 2020-01-11 03:20:59 +08:00
parent 615ad0cc5a
commit b39f407596
11 changed files with 107 additions and 12758 deletions

View File

@ -13,6 +13,7 @@ LIBNANOPB := $(EXT_PATH)/nanopb
LIBSYSTEMPROPERTIES := jni/systemproperties/include
LIBUTILS := jni/utils/include
LIBMINCRYPT := $(EXT_PATH)/mincrypt/include
LIBXZ := $(EXT_PATH)/xz-embedded
########################
# Binaries
@ -22,11 +23,9 @@ ifdef B_MAGISK
include $(CLEAR_VARS)
LOCAL_MODULE := magisk
LOCAL_SHARED_LIBRARIES := libsqlite
LOCAL_STATIC_LIBRARIES := libnanopb libsystemproperties libutils
LOCAL_C_INCLUDES := \
jni/include \
$(EXT_PATH)/include \
$(LIBNANOPB) \
$(LIBSYSTEMPROPERTIES) \
$(LIBUTILS)
@ -98,9 +97,9 @@ ifdef BB_INIT
LOCAL_STATIC_LIBRARIES := libsepol libxz libutils
LOCAL_C_INCLUDES := \
jni/include \
$(EXT_PATH)/include \
out \
out/$(TARGET_ARCH_ABI) \
$(LIBXZ) \
$(LIBSEPOL) \
$(LIBUTILS)

View File

@ -3,6 +3,7 @@
#include <time.h>
#include <string.h>
#include <unistd.h>
#include <dlfcn.h>
#include <sys/stat.h>
#include <magisk.h>
@ -14,8 +15,93 @@
using namespace std;
typedef struct sqlite3 sqlite3;
static sqlite3 *mDB = nullptr;
// SQLite APIs
#define SQLITE_OPEN_READWRITE 0x00000002 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_CREATE 0x00000004 /* Ok for sqlite3_open_v2() */
#define SQLITE_OPEN_FULLMUTEX 0x00010000 /* Ok for sqlite3_open_v2() */
static int (*sqlite3_open_v2)(
const char *filename,
sqlite3 **ppDb,
int flags,
const char *zVfs);
static const char *(*sqlite3_errmsg)(sqlite3 *db);
static int (*sqlite3_close)(sqlite3 *db);
static void (*sqlite3_free)(void *v);
static int (*sqlite3_exec)(
sqlite3 *db,
const char *sql,
int (*callback)(void*, int, char**, char**),
void *v,
char **errmsg);
// Internal Android linker APIs
static void (*android_get_LD_LIBRARY_PATH)(char *buffer, size_t buffer_size);
static void (*android_update_LD_LIBRARY_PATH)(const char *ld_library_path);
#define DLERR(ptr) if (!(ptr)) { \
LOGE("db: %s\n", dlerror()); \
return false; \
}
#define DLOAD(handle, arg) {\
auto f = dlsym(handle, #arg); \
DLERR(f) \
*(void **) &(arg) = f; \
}
#if defined(__aarch64__) || defined(__x86_64__)
constexpr char apex_path[] = ":/apex/com.android.runtime/lib64";
#else
constexpr char apex_path[] = ":/apex/com.android.runtime/lib";
#endif
static int dl_init = 0;
static bool dload_sqlite() {
if (dl_init)
return dl_init > 0;
dl_init = -1;
auto sqlite = dlopen("libsqlite.so", RTLD_LAZY);
if (!sqlite) {
// Should only happen on Android 10+
auto dl = dlopen("libdl_android.so", RTLD_LAZY);
DLERR(dl);
DLOAD(dl, android_get_LD_LIBRARY_PATH);
DLOAD(dl, android_update_LD_LIBRARY_PATH);
// Inject APEX into LD_LIBRARY_PATH
char ld_path[4096];
android_get_LD_LIBRARY_PATH(ld_path, sizeof(ld_path));
int len = strlen(ld_path);
strcpy(ld_path + len, apex_path);
android_update_LD_LIBRARY_PATH(ld_path);
sqlite = dlopen("libsqlite.so", RTLD_LAZY);
// Revert LD_LIBRARY_PATH just in case
ld_path[len] = '\0';
android_update_LD_LIBRARY_PATH(ld_path);
}
DLERR(sqlite);
DLOAD(sqlite, sqlite3_open_v2);
DLOAD(sqlite, sqlite3_errmsg);
DLOAD(sqlite, sqlite3_close);
DLOAD(sqlite, sqlite3_exec);
DLOAD(sqlite, sqlite3_free);
dl_init = 1;
return true;
}
int db_strings::getKeyIdx(string_view key) const {
int idx = DB_STRING_NUM;
for (int i = 0; i < DB_STRING_NUM; ++i) {
@ -50,6 +136,9 @@ static int ver_cb(void *ver, int, char **data, char **) {
#define err_ret(e) if (e) return e;
static char *open_and_init_db(sqlite3 *&db) {
if (!dload_sqlite())
return strdup("Cannot load libsqlite.so");
int ret = sqlite3_open_v2(MAGISKDB, &db,
SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE | SQLITE_OPEN_FULLMUTEX, nullptr);
if (ret)
@ -304,3 +393,12 @@ void exec_sql(int client) {
write_int(client, 0);
db_err_cmd(err, return; );
}
bool db_err(char *e) {
if (e) {
LOGE("sqlite3_exec: %s\n", e);
sqlite3_free(e);
return true;
}
return false;
}

View File

@ -1,27 +1,9 @@
LOCAL_PATH := $(call my-dir)
ifdef B_MAGISK
# libsqlite.so (stub)
include $(CLEAR_VARS)
LOCAL_MODULE:= libsqlite
LOCAL_C_INCLUDES := $(EXT_PATH)/include
LOCAL_SRC_FILES := stubs/sqlite3_stub.c
include $(BUILD_SHARED_LIBRARY)
endif
# libselinux.so (stub)
#include $(CLEAR_VARS)
#LOCAL_MODULE:= libselinux
#LOCAL_C_INCLUDES := $(LIBSELINUX)
#LOCAL_SRC_FILES := stubs/selinux_stub.c
#include $(BUILD_SHARED_LIBRARY)
# libxz.a
include $(CLEAR_VARS)
LOCAL_MODULE:= libxz
LOCAL_C_INCLUDES := $(EXT_PATH)/include
LOCAL_C_INCLUDES := $(LIBXZ)
LOCAL_SRC_FILES := \
xz-embedded/xz_crc32.c \
xz-embedded/xz_dec_lzma2.c \
@ -83,7 +65,7 @@ include $(BUILD_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := liblzma
LOCAL_C_INCLUDES += \
$(EXT_PATH)/include/xz_config \
$(EXT_PATH)/xz_config \
$(EXT_PATH)/xz/src/common \
$(EXT_PATH)/xz/src/liblzma/api \
$(EXT_PATH)/xz/src/liblzma/check \

File diff suppressed because it is too large Load Diff

View File

@ -1,356 +0,0 @@
#include <stdbool.h>
#include <selinux/avc.h>
#include <selinux/context.h>
#include <selinux/get_context_list.h>
#include <selinux/get_default_type.h>
#include <selinux/label.h>
#include <selinux/restorecon.h>
#include <selinux/selinux.h>
int is_selinux_enabled(void) { return 0; }
int is_selinux_mls_enabled(void) { return 0; }
void freecon(char * con) { }
void freeconary(char ** con) { }
int getcon(char ** con) { return 0; }
int getcon_raw(char ** con) { return 0; }
int setcon(const char * con) { return 0; }
int setcon_raw(const char * con) { return 0; }
int getpidcon(pid_t pid, char ** con) { return 0; }
int getpidcon_raw(pid_t pid, char ** con) { return 0; }
int getprevcon(char ** con) { return 0; }
int getprevcon_raw(char ** con) { return 0; }
int getexeccon(char ** con) { return 0; }
int getexeccon_raw(char ** con) { return 0; }
int setexeccon(const char * con) { return 0; }
int setexeccon_raw(const char * con) { return 0; }
int getfscreatecon(char ** con) { return 0; }
int getfscreatecon_raw(char ** con) { return 0; }
int setfscreatecon(const char * context) { return 0; }
int setfscreatecon_raw(const char * context) { return 0; }
int getkeycreatecon(char ** con) { return 0; }
int getkeycreatecon_raw(char ** con) { return 0; }
int setkeycreatecon(const char * context) { return 0; }
int setkeycreatecon_raw(const char * context) { return 0; }
int getsockcreatecon(char ** con) { return 0; }
int getsockcreatecon_raw(char ** con) { return 0; }
int setsockcreatecon(const char * context) { return 0; }
int setsockcreatecon_raw(const char * context) { return 0; }
int getfilecon(const char *path, char ** con) { return 0; }
int getfilecon_raw(const char *path, char ** con) { return 0; }
int lgetfilecon(const char *path, char ** con) { return 0; }
int lgetfilecon_raw(const char *path, char ** con) { return 0; }
int fgetfilecon(int fd, char ** con) { return 0; }
int fgetfilecon_raw(int fd, char ** con) { return 0; }
int setfilecon(const char *path, const char * con) { return 0; }
int setfilecon_raw(const char *path, const char * con) { return 0; }
int lsetfilecon(const char *path, const char * con) { return 0; }
int lsetfilecon_raw(const char *path, const char * con) { return 0; }
int fsetfilecon(int fd, const char * con) { return 0; }
int fsetfilecon_raw(int fd, const char * con) { return 0; }
int getpeercon(int fd, char ** con) { return 0; }
int getpeercon_raw(int fd, char ** con) { return 0; }
void selinux_set_callback(int type, union selinux_callback cb) { }
int security_compute_av(const char * scon,
const char * tcon,
security_class_t tclass,
access_vector_t requested,
struct av_decision *avd) { return 0; }
int security_compute_av_raw(const char * scon,
const char * tcon,
security_class_t tclass,
access_vector_t requested,
struct av_decision *avd) { return 0; }
int security_compute_av_flags(const char * scon,
const char * tcon,
security_class_t tclass,
access_vector_t requested,
struct av_decision *avd) { return 0; }
int security_compute_av_flags_raw(const char * scon,
const char * tcon,
security_class_t tclass,
access_vector_t requested,
struct av_decision *avd) { return 0; }
int security_compute_create(const char * scon,
const char * tcon,
security_class_t tclass,
char ** newcon) { return 0; }
int security_compute_create_raw(const char * scon,
const char * tcon,
security_class_t tclass,
char ** newcon) { return 0; }
int security_compute_create_name(const char * scon,
const char * tcon,
security_class_t tclass,
const char *objname,
char ** newcon) { return 0; }
int security_compute_create_name_raw(const char * scon,
const char * tcon,
security_class_t tclass,
const char *objname,
char ** newcon) { return 0; }
int security_compute_relabel(const char * scon,
const char * tcon,
security_class_t tclass,
char ** newcon) { return 0; }
int security_compute_relabel_raw(const char * scon,
const char * tcon,
security_class_t tclass,
char ** newcon) { return 0; }
int security_compute_member(const char * scon,
const char * tcon,
security_class_t tclass,
char ** newcon) { return 0; }
int security_compute_member_raw(const char * scon,
const char * tcon,
security_class_t tclass,
char ** newcon) { return 0; }
int security_compute_user(const char * scon,
const char *username,
char *** con) { return 0; }
int security_compute_user_raw(const char * scon,
const char *username,
char *** con) { return 0; }
int security_load_policy(void *data, size_t len) { return 0; }
int security_get_initial_context(const char *name,
char ** con) { return 0; }
int security_get_initial_context_raw(const char *name,
char ** con) { return 0; }
int selinux_mkload_policy(int preservebools) { return 0; }
int selinux_init_load_policy(int *enforce) { return 0; }
int security_set_boolean_list(size_t boolcnt,
SELboolean * boollist, int permanent) { return 0; }
int security_load_booleans(char *path) { return 0; }
int security_check_context(const char * con) { return 0; }
int security_check_context_raw(const char * con) { return 0; }
int security_canonicalize_context(const char * con,
char ** canoncon) { return 0; }
int security_canonicalize_context_raw(const char * con,
char ** canoncon) { return 0; }
int security_getenforce(void) { return 0; }
int security_setenforce(int value) { return 0; }
int security_deny_unknown(void) { return 0; }
int security_disable(void) { return 0; }
int security_policyvers(void) { return 0; }
int security_get_boolean_names(char ***names, int *len) { return 0; }
int security_get_boolean_pending(const char *name) { return 0; }
int security_get_boolean_active(const char *name) { return 0; }
int security_set_boolean(const char *name, int value) { return 0; }
int security_commit_booleans(void) { return 0; }
int selinux_set_mapping(struct security_class_mapping *map) { return 0; }
security_class_t mode_to_security_class(mode_t mode) { return 0; }
security_class_t string_to_security_class(const char *name) { return 0; }
const char *security_class_to_string(security_class_t cls) { return 0; }
const char *security_av_perm_to_string(security_class_t tclass,
access_vector_t perm) { return 0; }
access_vector_t string_to_av_perm(security_class_t tclass,
const char *name) { return 0; }
int security_av_string(security_class_t tclass,
access_vector_t av, char **result) { return 0; }
void print_access_vector(security_class_t tclass, access_vector_t av) { }
void set_matchpathcon_printf(void (*f) (const char *fmt, ...)) { }
void set_matchpathcon_invalidcon(int (*f) (const char *path,
unsigned lineno,
char *context)) { }
void set_matchpathcon_canoncon(int (*f) (const char *path,
unsigned lineno,
char **context)) { }
void set_matchpathcon_flags(unsigned int flags) { }
int matchpathcon_init(const char *path) { return 0; }
int matchpathcon_init_prefix(const char *path, const char *prefix) { return 0; }
void matchpathcon_fini(void) { }
int realpath_not_final(const char *name, char *resolved_path) { return 0; }
int matchpathcon(const char *path,
mode_t mode, char ** con) { return 0; }
int matchpathcon_index(const char *path,
mode_t mode, char ** con) { return 0; }
int matchpathcon_filespec_add(ino_t ino, int specind, const char *file) { return 0; }
void matchpathcon_filespec_destroy(void) { }
void matchpathcon_filespec_eval(void) { }
void matchpathcon_checkmatches(char *str) { }
int matchmediacon(const char *media, char ** con) { return 0; }
int selinux_getenforcemode(int *enforce) { return 0; }
char *selinux_boolean_sub(const char *boolean_name) { return 0; }
int selinux_getpolicytype(char **policytype) { return 0; }
const char *selinux_policy_root(void) { return 0; }
int selinux_set_policy_root(const char *rootpath) { return 0; }
const char *selinux_current_policy_path(void) { return 0; }
const char *selinux_binary_policy_path(void) { return 0; }
const char *selinux_failsafe_context_path(void) { return 0; }
const char *selinux_removable_context_path(void) { return 0; }
const char *selinux_default_context_path(void) { return 0; }
const char *selinux_user_contexts_path(void) { return 0; }
const char *selinux_file_context_path(void) { return 0; }
const char *selinux_file_context_homedir_path(void) { return 0; }
const char *selinux_file_context_local_path(void) { return 0; }
const char *selinux_file_context_subs_path(void) { return 0; }
const char *selinux_file_context_subs_dist_path(void) { return 0; }
const char *selinux_homedir_context_path(void) { return 0; }
const char *selinux_media_context_path(void) { return 0; }
const char *selinux_virtual_domain_context_path(void) { return 0; }
const char *selinux_virtual_image_context_path(void) { return 0; }
const char *selinux_lxc_contexts_path(void) { return 0; }
const char *selinux_x_context_path(void) { return 0; }
const char *selinux_sepgsql_context_path(void) { return 0; }
const char *selinux_openrc_contexts_path(void) { return 0; }
const char *selinux_openssh_contexts_path(void) { return 0; }
const char *selinux_snapperd_contexts_path(void) { return 0; }
const char *selinux_systemd_contexts_path(void) { return 0; }
const char *selinux_contexts_path(void) { return 0; }
const char *selinux_securetty_types_path(void) { return 0; }
const char *selinux_booleans_subs_path(void) { return 0; }
const char *selinux_booleans_path(void) { return 0; }
const char *selinux_customizable_types_path(void) { return 0; }
const char *selinux_users_path(void) { return 0; }
const char *selinux_usersconf_path(void) { return 0; }
const char *selinux_translations_path(void) { return 0; }
const char *selinux_colors_path(void) { return 0; }
const char *selinux_netfilter_context_path(void) { return 0; }
const char *selinux_path(void) { return 0; }
int selinux_check_access(const char * scon, const char * tcon, const char *tclass, const char *perm, void *auditdata) { return 0; }
int selinux_check_passwd_access(access_vector_t requested) { return 0; }
int checkPasswdAccess(access_vector_t requested) { return 0; }
int selinux_check_securetty_context(const char * tty_context) { return 0; }
void set_selinuxmnt(const char *mnt) { }
int selinuxfs_exists(void) { return 0; }
void fini_selinuxmnt(void) {}
int setexecfilecon(const char *filename, const char *fallback_type) { return 0; }
#ifndef DISABLE_RPM
int rpm_execcon(unsigned int verified,
const char *filename,
char *const argv[], char *const envp[]) { return 0; }
#endif
int is_context_customizable(const char * scontext) { return 0; }
int selinux_trans_to_raw_context(const char * trans,
char ** rawp) { return 0; }
int selinux_raw_to_trans_context(const char * raw,
char ** transp) { return 0; }
int selinux_raw_context_to_color(const char * raw,
char **color_str) { return 0; }
int getseuserbyname(const char *linuxuser, char **seuser, char **level) { return 0; }
int getseuser(const char *username, const char *service,
char **r_seuser, char **r_level) { return 0; }
int selinux_file_context_cmp(const char * a,
const char * b) { return 0; }
int selinux_file_context_verify(const char *path, mode_t mode) { return 0; }
int selinux_lsetfilecon_default(const char *path) { return 0; }
void selinux_reset_config(void) { }
int avc_sid_to_context(security_id_t sid, char ** ctx) { return 0; }
int avc_sid_to_context_raw(security_id_t sid, char ** ctx) { return 0; }
int avc_context_to_sid(const char * ctx, security_id_t * sid) { return 0; }
int avc_context_to_sid_raw(const char * ctx, security_id_t * sid) { return 0; }
int sidget(security_id_t sid) { return 0; }
int sidput(security_id_t sid) { return 0; }
int avc_get_initial_sid(const char *name, security_id_t * sid) { return 0; }
int avc_init(const char *msgprefix,
const struct avc_memory_callback *mem_callbacks,
const struct avc_log_callback *log_callbacks,
const struct avc_thread_callback *thread_callbacks,
const struct avc_lock_callback *lock_callbacks) { return 0; }
int avc_open(struct selinux_opt *opts, unsigned nopts) { return 0; }
void avc_cleanup(void) { }
int avc_reset(void) { return 0; }
void avc_destroy(void) { }
int avc_has_perm_noaudit(security_id_t ssid,
security_id_t tsid,
security_class_t tclass,
access_vector_t requested,
struct avc_entry_ref *aeref, struct av_decision *avd) { return 0; }
int avc_has_perm(security_id_t ssid, security_id_t tsid,
security_class_t tclass, access_vector_t requested,
struct avc_entry_ref *aeref, void *auditdata) { return 0; }
void avc_audit(security_id_t ssid, security_id_t tsid,
security_class_t tclass, access_vector_t requested,
struct av_decision *avd, int result, void *auditdata) { }
int avc_compute_create(security_id_t ssid,
security_id_t tsid,
security_class_t tclass, security_id_t * newsid) { return 0; }
int avc_compute_member(security_id_t ssid,
security_id_t tsid,
security_class_t tclass, security_id_t * newsid) { return 0; }
int avc_add_callback(int (*callback)
(uint32_t event, security_id_t ssid,
security_id_t tsid, security_class_t tclass,
access_vector_t perms,
access_vector_t * out_retained),
uint32_t events, security_id_t ssid,
security_id_t tsid, security_class_t tclass,
access_vector_t perms) { return 0; }
void avc_cache_stats(struct avc_cache_stats *stats) { }
void avc_av_stats(void) { }
void avc_sid_stats(void) { }
int avc_netlink_open(int blocking) { return 0; }
void avc_netlink_loop(void) { }
void avc_netlink_close(void) { }
int avc_netlink_acquire_fd(void) { return 0; }
void avc_netlink_release_fd(void) { }
int avc_netlink_check_nb(void) { return 0; }
int selinux_status_open(int fallback) { return 0; }
void selinux_status_close(void) { }
int selinux_status_updated(void) { return 0; }
int selinux_status_getenforce(void) { return 0; }
int selinux_status_policyload(void) { return 0; }
int selinux_status_deny_unknown(void) { return 0; }
context_t context_new(const char *s) { return 0; }
char *context_str(context_t c) { return 0; }
void context_free(context_t c) { }
const char *context_type_get(context_t c) { return 0; }
const char *context_range_get(context_t c) { return 0; }
const char *context_role_get(context_t c) { return 0; }
const char *context_user_get(context_t c) { return 0; }
int context_type_set(context_t c, const char *s) { return 0; }
int context_range_set(context_t c, const char *s) { return 0; }
int context_role_set(context_t c, const char *s) { return 0; }
int context_user_set(context_t c, const char *s) { return 0; }
int get_ordered_context_list(const char *user,
char * fromcon,
char *** list) { return 0; }
int get_ordered_context_list_with_level(const char *user,
const char *level,
char * fromcon,
char *** list) { return 0; }
int get_default_context(const char *user,
char * fromcon,
char ** newcon) { return 0; }
int get_default_context_with_level(const char *user,
const char *level,
char * fromcon,
char ** newcon) { return 0; }
int get_default_context_with_role(const char *user,
const char *role,
char * fromcon,
char ** newcon) { return 0; }
int get_default_context_with_rolelevel(const char *user,
const char *role,
const char *level,
char * fromcon,
char ** newcon) { return 0; }
int query_user_context(char ** list,
char ** newcon) { return 0; }
int manual_user_enter_context(const char *user,
char ** newcon) { return 0; }
const char *selinux_default_type_path(void) { return 0; }
int get_default_type(const char *role, char **type) { return 0; }
struct selabel_handle *selabel_open(unsigned int backend,
const struct selinux_opt *opts,
unsigned nopts) { return 0; }
void selabel_close(struct selabel_handle *handle) { }
int selabel_lookup(struct selabel_handle *handle, char **con,
const char *key, int type) { return 0; }
int selabel_lookup_raw(struct selabel_handle *handle, char **con,
const char *key, int type) { return 0; }
bool selabel_partial_match(struct selabel_handle *handle, const char *key) { return 0; }
int selabel_lookup_best_match(struct selabel_handle *rec, char **con,
const char *key, const char **aliases, int type) { return 0; }
int selabel_lookup_best_match_raw(struct selabel_handle *rec, char **con,
const char *key, const char **aliases, int type) { return 0; }
int selabel_digest(struct selabel_handle *rec,
unsigned char **digest, size_t *digest_len,
char ***specfiles, size_t *num_specfiles) { return 0; }
void selabel_stats(struct selabel_handle *handle) { }
int selinux_restorecon(const char *pathname,
unsigned int restorecon_flags) { return 0; }
struct selabel_handle *selinux_restorecon_default_handle(void) { return 0; }
void selinux_restorecon_set_exclude_list(const char **exclude_list) { }
int selinux_restorecon_set_alt_rootpath(const char *alt_rootpath) { return 0; }
int selinux_restorecon_xattr(const char *pathname,
unsigned int xattr_flags,
struct dir_xattr ***xattr_list) { return 0; }

View File

@ -1,770 +0,0 @@
#include <sqlite3.h>
SQLITE_API SQLITE_EXTERN const char sqlite3_version[];
SQLITE_API const char *sqlite3_libversion(void) { return 0; }
SQLITE_API const char *sqlite3_sourceid(void) { return 0; }
SQLITE_API int sqlite3_libversion_number(void) { return 0; }
SQLITE_API int sqlite3_compileoption_used(const char *zOptName) { return 0; }
SQLITE_API const char *sqlite3_compileoption_get(int N) { return 0; }
SQLITE_API int sqlite3_threadsafe(void) { return 0; }
SQLITE_API int sqlite3_close(sqlite3 *db) { return 0; }
SQLITE_API int sqlite3_close_v2(sqlite3 *db) { return 0; }
SQLITE_API int sqlite3_exec(
sqlite3 *db,
const char *sql,
int (*callback)(void *v,int i,char**,char**),
void *v,
char **errmsg
) { return 0; }
SQLITE_API int sqlite3_initialize(void) { return 0; }
SQLITE_API int sqlite3_shutdown(void) { return 0; }
SQLITE_API int sqlite3_os_init(void) { return 0; }
SQLITE_API int sqlite3_os_end(void) { return 0; }
SQLITE_API int sqlite3_config(int i, ...) { return 0; }
SQLITE_API int sqlite3_db_config(sqlite3 *db, int op, ...) { return 0; }
SQLITE_API int sqlite3_extended_result_codes(sqlite3 *db, int onoff) { return 0; }
SQLITE_API sqlite3_int64 sqlite3_last_insert_rowid(sqlite3 *db) { return 0; }
SQLITE_API int sqlite3_changes(sqlite3 *db) { return 0; }
SQLITE_API int sqlite3_total_changes(sqlite3 *db) { return 0; }
SQLITE_API int sqlite3_complete(const char *sql) { return 0; }
SQLITE_API int sqlite3_complete16(const void *sql) { return 0; }
SQLITE_API int sqlite3_busy_handler(sqlite3 *db,int(*cb)(void *v,int i),void *v) { return 0; }
SQLITE_API int sqlite3_busy_timeout(sqlite3 *db, int ms) { return 0; }
SQLITE_API int sqlite3_get_table(
sqlite3 *db,
const char *zSql,
char ***pazResult,
int *pnRow,
int *pnColumn,
char **pzErrmsg
) { return 0; }
SQLITE_API char *sqlite3_mprintf(const char *s,...) { return 0; }
SQLITE_API char *sqlite3_vmprintf(const char *s, va_list va) { return 0; }
SQLITE_API char *sqlite3_snprintf(int i,char *s,const char *ss, ...) { return 0; }
SQLITE_API char *sqlite3_vsnprintf(int i,char *s,const char *ss, va_list va) { return 0; }
SQLITE_API void *sqlite3_malloc(int i) { return 0; }
SQLITE_API void *sqlite3_malloc64(sqlite3_uint64 u64) { return 0; }
SQLITE_API void *sqlite3_realloc(void *v, int i) { return 0; }
SQLITE_API void *sqlite3_realloc64(void *v, sqlite3_uint64 u64) { return 0; }
SQLITE_API sqlite3_uint64 sqlite3_msize(void *v) { return 0; }
SQLITE_API sqlite3_int64 sqlite3_memory_used(void) { return 0; }
SQLITE_API sqlite3_int64 sqlite3_memory_highwater(int resetFlag) { return 0; }
SQLITE_API int sqlite3_set_authorizer(
sqlite3 *db,
int (*xAuth)(void *v,int i,const char *s,const char *ss,const char *sss,const char*),
void *pUserData
) { return 0; }
SQLITE_API SQLITE_DEPRECATED void *sqlite3_trace(sqlite3 *db,
void(*xTrace)(void *v,const char*), void *v) { return 0; }
SQLITE_API SQLITE_DEPRECATED void *sqlite3_profile(sqlite3 *db,
void(*xProfile)(void *v,const char *s,sqlite3_uint64 u64), void *v) { return 0; }
SQLITE_API int sqlite3_trace_v2(
sqlite3 *db,
unsigned uMask,
int(*xCallback)(unsigned,void*,void*,void*),
void *pCtx
) { return 0; }
SQLITE_API int sqlite3_open(
const char *filename,
sqlite3 **ppDb
) { return 0; }
SQLITE_API int sqlite3_open16(
const void *filename,
sqlite3 **ppDb
) { return 0; }
SQLITE_API int sqlite3_open_v2(
const char *filename,
sqlite3 **ppDb,
int flags,
const char *zVfs
) { return 0; }
SQLITE_API const char *sqlite3_uri_parameter(const char *zFilename, const char *zParam) { return 0; }
SQLITE_API int sqlite3_uri_boolean(const char *zFile, const char *zParam, int bDefault) { return 0; }
SQLITE_API sqlite3_int64 sqlite3_uri_int64(const char *s, const char *ss, sqlite3_int64 i64) { return 0; }
SQLITE_API int sqlite3_errcode(sqlite3 *db) { return 0; }
SQLITE_API int sqlite3_extended_errcode(sqlite3 *db) { return 0; }
SQLITE_API const char *sqlite3_errmsg(sqlite3 *db) { return 0; }
SQLITE_API const void *sqlite3_errmsg16(sqlite3 *db) { return 0; }
SQLITE_API const char *sqlite3_errstr(int i) { return 0; }
SQLITE_API int sqlite3_limit(sqlite3 *db, int id, int newVal) { return 0; }
SQLITE_API int sqlite3_prepare(
sqlite3 *db,
const char *zSql,
int nByte,
sqlite3_stmt **ppStmt,
const char **pzTail
) { return 0; }
SQLITE_API int sqlite3_prepare_v2(
sqlite3 *db,
const char *zSql,
int nByte,
sqlite3_stmt **ppStmt,
const char **pzTail
) { return 0; }
SQLITE_API int sqlite3_prepare_v3(
sqlite3 *db,
const char *zSql,
int nByte,
unsigned int prepFlags,
sqlite3_stmt **ppStmt,
const char **pzTail
) { return 0; }
SQLITE_API int sqlite3_prepare16(
sqlite3 *db,
const void *zSql,
int nByte,
sqlite3_stmt **ppStmt,
const void **pzTail
) { return 0; }
SQLITE_API int sqlite3_prepare16_v2(
sqlite3 *db,
const void *zSql,
int nByte,
sqlite3_stmt **ppStmt,
const void **pzTail
) { return 0; }
SQLITE_API int sqlite3_prepare16_v3(
sqlite3 *db,
const void *zSql,
int nByte,
unsigned int prepFlags,
sqlite3_stmt **ppStmt,
const void **pzTail
) { return 0; }
SQLITE_API const char *sqlite3_sql(sqlite3_stmt *pStmt) { return 0; }
SQLITE_API char *sqlite3_expanded_sql(sqlite3_stmt *pStmt) { return 0; }
SQLITE_API int sqlite3_stmt_readonly(sqlite3_stmt *pStmt) { return 0; }
SQLITE_API int sqlite3_stmt_busy(sqlite3_stmt *stmt) { return 0; }
SQLITE_API int sqlite3_bind_blob(sqlite3_stmt *stmt, int i, const void *v, int n, void(*cb)(void*)) { return 0; }
SQLITE_API int sqlite3_bind_blob64(sqlite3_stmt *stmt, int i, const void *v, sqlite3_uint64 u64,
void(*cb)(void*)) { return 0; }
SQLITE_API int sqlite3_bind_double(sqlite3_stmt *stmt, int i, double df) { return 0; }
SQLITE_API int sqlite3_bind_int(sqlite3_stmt *stmt, int i, int ii) { return 0; }
SQLITE_API int sqlite3_bind_int64(sqlite3_stmt *stmt, int i, sqlite3_int64 i64) { return 0; }
SQLITE_API int sqlite3_bind_null(sqlite3_stmt *stmt, int i) { return 0; }
SQLITE_API int sqlite3_bind_text(sqlite3_stmt *stmt,int i,const char *s,int ii,void(*cb)(void*)) { return 0; }
SQLITE_API int sqlite3_bind_text16(sqlite3_stmt *stmt, int i, const void *v, int ii, void(*cb)(void*)) { return 0; }
SQLITE_API int sqlite3_bind_text64(sqlite3_stmt *stmt, int i, const char *s, sqlite3_uint64 u64,
void(*cb)(void*), unsigned char encoding) { return 0; }
SQLITE_API int sqlite3_bind_value(sqlite3_stmt *stmt, int i, const sqlite3_value *s_val) { return 0; }
SQLITE_API int sqlite3_bind_pointer(sqlite3_stmt *stmt, int i, void *v, const char *s,void(*cb)(void*)) { return 0; }
SQLITE_API int sqlite3_bind_zeroblob(sqlite3_stmt *stmt, int i, int n) { return 0; }
SQLITE_API int sqlite3_bind_zeroblob64(sqlite3_stmt *stmt, int i, sqlite3_uint64 u64) { return 0; }
SQLITE_API int sqlite3_bind_parameter_count(sqlite3_stmt *stmt) { return 0; }
SQLITE_API const char *sqlite3_bind_parameter_name(sqlite3_stmt *stmt, int i) { return 0; }
SQLITE_API int sqlite3_bind_parameter_index(sqlite3_stmt *stmt, const char *zName) { return 0; }
SQLITE_API int sqlite3_clear_bindings(sqlite3_stmt *stmt) { return 0; }
SQLITE_API int sqlite3_column_count(sqlite3_stmt *pStmt) { return 0; }
SQLITE_API const char *sqlite3_column_name(sqlite3_stmt *stmt, int N) { return 0; }
SQLITE_API const void *sqlite3_column_name16(sqlite3_stmt *stmt, int N) { return 0; }
SQLITE_API const char *sqlite3_column_database_name(sqlite3_stmt *stmt,int i) { return 0; }
SQLITE_API const void *sqlite3_column_database_name16(sqlite3_stmt *stmt,int i) { return 0; }
SQLITE_API const char *sqlite3_column_table_name(sqlite3_stmt *stmt,int i) { return 0; }
SQLITE_API const void *sqlite3_column_table_name16(sqlite3_stmt *stmt,int i) { return 0; }
SQLITE_API const char *sqlite3_column_origin_name(sqlite3_stmt *stmt,int i) { return 0; }
SQLITE_API const void *sqlite3_column_origin_name16(sqlite3_stmt *stmt,int i) { return 0; }
SQLITE_API const char *sqlite3_column_decltype(sqlite3_stmt *stmt,int i) { return 0; }
SQLITE_API const void *sqlite3_column_decltype16(sqlite3_stmt *stmt,int i) { return 0; }
SQLITE_API int sqlite3_step(sqlite3_stmt *stmt) { return 0; }
SQLITE_API int sqlite3_data_count(sqlite3_stmt *pStmt) { return 0; }
SQLITE_API const void *sqlite3_column_blob(sqlite3_stmt *stmt, int iCol) { return 0; }
SQLITE_API double sqlite3_column_double(sqlite3_stmt *stmt, int iCol) { return 0; }
SQLITE_API int sqlite3_column_int(sqlite3_stmt *stmt, int iCol) { return 0; }
SQLITE_API sqlite3_int64 sqlite3_column_int64(sqlite3_stmt *stmt, int iCol) { return 0; }
SQLITE_API const unsigned char *sqlite3_column_text(sqlite3_stmt *stmt, int iCol) { return 0; }
SQLITE_API const void *sqlite3_column_text16(sqlite3_stmt *stmt, int iCol) { return 0; }
SQLITE_API sqlite3_value *sqlite3_column_value(sqlite3_stmt *stmt, int iCol) { return 0; }
SQLITE_API int sqlite3_column_bytes(sqlite3_stmt *stmt, int iCol) { return 0; }
SQLITE_API int sqlite3_column_bytes16(sqlite3_stmt *stmt, int iCol) { return 0; }
SQLITE_API int sqlite3_column_type(sqlite3_stmt *stmt, int iCol) { return 0; }
SQLITE_API int sqlite3_finalize(sqlite3_stmt *pStmt) { return 0; }
SQLITE_API int sqlite3_reset(sqlite3_stmt *pStmt) { return 0; }
SQLITE_API int sqlite3_create_function(
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context *sctx,int i,sqlite3_value**),
void (*xStep)(sqlite3_context *sctx,int i,sqlite3_value**),
void (*xFinal)(sqlite3_context *sctx)
) { return 0; }
SQLITE_API int sqlite3_create_function16(
sqlite3 *db,
const void *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context *sctx,int i,sqlite3_value**),
void (*xStep)(sqlite3_context *sctx,int i,sqlite3_value**),
void (*xFinal)(sqlite3_context *sctx)
) { return 0; }
SQLITE_API int sqlite3_create_function_v2(
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xFunc)(sqlite3_context *sctx,int i,sqlite3_value**),
void (*xStep)(sqlite3_context *sctx,int i,sqlite3_value**),
void (*xFinal)(sqlite3_context *sctx),
void(*xDestroy)(void*)
) { return 0; }
SQLITE_API int sqlite3_create_window_function(
sqlite3 *db,
const char *zFunctionName,
int nArg,
int eTextRep,
void *pApp,
void (*xStep)(sqlite3_context *sctx,int i,sqlite3_value**),
void (*xFinal)(sqlite3_context *sctx),
void (*xValue)(sqlite3_context *sctx),
void (*xInverse)(sqlite3_context *sctx,int i,sqlite3_value**),
void(*xDestroy)(void*)
) { return 0; }
SQLITE_API SQLITE_DEPRECATED int sqlite3_aggregate_count(sqlite3_context *sctx) { return 0; }
SQLITE_API SQLITE_DEPRECATED int sqlite3_expired(sqlite3_stmt *stmt) { return 0; }
SQLITE_API SQLITE_DEPRECATED int sqlite3_transfer_bindings(sqlite3_stmt *stmt, sqlite3_stmt *stmt1) { return 0; }
SQLITE_API SQLITE_DEPRECATED int sqlite3_global_recover(void) { return 0; }
SQLITE_API SQLITE_DEPRECATED void sqlite3_thread_cleanup(void) { }
SQLITE_API SQLITE_DEPRECATED int sqlite3_memory_alarm(void(*cb)(void *v,sqlite3_int64,int i),
void *v,sqlite3_int64 i64) { return 0; }
SQLITE_API const void *sqlite3_value_blob(sqlite3_value *s_val) { return 0; }
SQLITE_API double sqlite3_value_double(sqlite3_value *s_val) { return 0; }
SQLITE_API int sqlite3_value_int(sqlite3_value *s_val) { return 0; }
SQLITE_API sqlite3_int64 sqlite3_value_int64(sqlite3_value *s_val) { return 0; }
SQLITE_API void *sqlite3_value_pointer(sqlite3_value *s_val, const char *s) { return 0; }
SQLITE_API const unsigned char *sqlite3_value_text(sqlite3_value *s_val) { return 0; }
SQLITE_API const void *sqlite3_value_text16(sqlite3_value *s_val) { return 0; }
SQLITE_API const void *sqlite3_value_text16le(sqlite3_value *s_val) { return 0; }
SQLITE_API const void *sqlite3_value_text16be(sqlite3_value *s_val) { return 0; }
SQLITE_API int sqlite3_value_bytes(sqlite3_value *s_val) { return 0; }
SQLITE_API int sqlite3_value_bytes16(sqlite3_value *s_val) { return 0; }
SQLITE_API int sqlite3_value_type(sqlite3_value *s_val) { return 0; }
SQLITE_API int sqlite3_value_numeric_type(sqlite3_value *s_val) { return 0; }
SQLITE_API int sqlite3_value_nochange(sqlite3_value *s_val) { return 0; }
SQLITE_API unsigned int sqlite3_value_subtype(sqlite3_value *s_val) { return 0; }
SQLITE_API sqlite3_value *sqlite3_value_dup(const sqlite3_value *s_val) { return 0; }
SQLITE_API void *sqlite3_aggregate_context(sqlite3_context *sctx, int nBytes) { return 0; }
SQLITE_API void *sqlite3_user_data(sqlite3_context *sctx) { return 0; }
SQLITE_API sqlite3 *sqlite3_context_db_handle(sqlite3_context *sctx) { return 0; }
SQLITE_API void *sqlite3_get_auxdata(sqlite3_context *sctx, int N) { return 0; }
SQLITE_API void sqlite3_result_blob64(sqlite3_context *sctx,const void *v,
sqlite3_uint64 u64,void(*cb)(void*)) { }
SQLITE_API void sqlite3_result_text64(sqlite3_context *sctx, const char *s,sqlite3_uint64 u64,
void(*cb)(void*), unsigned char encoding) { }
SQLITE_API int sqlite3_result_zeroblob64(sqlite3_context *sctx, sqlite3_uint64 n) { return 0; }
SQLITE_API int sqlite3_create_collation(
sqlite3 *db,
const char *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*)
) { return 0; }
SQLITE_API int sqlite3_create_collation_v2(
sqlite3 *db,
const char *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void *v,int i,const void*,int,const void*),
void(*xDestroy)(void*)
) { return 0; }
SQLITE_API int sqlite3_create_collation16(
sqlite3 *db,
const void *zName,
int eTextRep,
void *pArg,
int(*xCompare)(void*,int,const void*,int,const void*)
) { return 0; }
SQLITE_API int sqlite3_collation_needed(
sqlite3 *db,
void *v,
void(*cb)(void *v,sqlite3 *db,int eTextRep,const char*)
) { return 0; }
SQLITE_API int sqlite3_collation_needed16(
sqlite3 *db,
void *v,
void(*cb)(void *v,sqlite3 *db,int eTextRep,const void*)
) { return 0; }
SQLITE_API int sqlite3_key(
sqlite3 *db,
const void *pKey, int nKey
) { return 0; }
SQLITE_API int sqlite3_key_v2(
sqlite3 *db,
const char *zDbName,
const void *pKey, int nKey
) { return 0; }
SQLITE_API int sqlite3_rekey(
sqlite3 *db,
const void *pKey, int nKey
) { return 0; }
SQLITE_API int sqlite3_rekey_v2(
sqlite3 *db,
const char *zDbName,
const void *pKey, int nKey
) { return 0; }
SQLITE_API void sqlite3_activate_see(
const char *zPassPhrase
) { }
SQLITE_API void sqlite3_activate_cerod(
const char *zPassPhrase
) { }
SQLITE_API int sqlite3_sleep(int i) { return 0; }
SQLITE_API SQLITE_EXTERN char *sqlite3_temp_directory;
SQLITE_API SQLITE_EXTERN char *sqlite3_data_directory;
SQLITE_API int sqlite3_win32_set_directory(
unsigned long type,
void *zValue
) { return 0; }
SQLITE_API int sqlite3_win32_set_directory8(unsigned long type, const char *zValue) { return 0; }
SQLITE_API int sqlite3_win32_set_directory16(unsigned long type, const void *zValue) { return 0; }
SQLITE_API int sqlite3_get_autocommit(sqlite3 *db) { return 0; }
SQLITE_API sqlite3 *sqlite3_db_handle(sqlite3_stmt *stmt) { return 0; }
SQLITE_API const char *sqlite3_db_filename(sqlite3 *db, const char *zDbName) { return 0; }
SQLITE_API int sqlite3_db_readonly(sqlite3 *db, const char *zDbName) { return 0; }
SQLITE_API sqlite3_stmt *sqlite3_next_stmt(sqlite3 *pDb, sqlite3_stmt *pStmt) { return 0; }
SQLITE_API void *sqlite3_commit_hook(sqlite3 *db, int(*cb)(void*), void *v) { return 0; }
SQLITE_API void *sqlite3_rollback_hook(sqlite3 *db, void(*cb)(void *), void *v) { return 0; }
SQLITE_API void *sqlite3_update_hook(
sqlite3 *db,
void(*cb)(void *,int ,char const *,char const *,sqlite3_int64 i64),
void *v
) { return 0; }
SQLITE_API int sqlite3_enable_shared_cache(int i) { return 0; }
SQLITE_API int sqlite3_release_memory(int i) { return 0; }
SQLITE_API int sqlite3_db_release_memory(sqlite3 *db) { return 0; }
SQLITE_API sqlite3_int64 sqlite3_soft_heap_limit64(sqlite3_int64 N) { return 0; }
SQLITE_API SQLITE_DEPRECATED void sqlite3_soft_heap_limit(int N) { }
SQLITE_API int sqlite3_table_column_metadata(
sqlite3 *db,
const char *zDbName,
const char *zTableName,
const char *zColumnName,
char const **pzDataType,
char const **pzCollSeq,
int *pNotNull,
int *pPrimaryKey,
int *pAutoinc
) { return 0; }
SQLITE_API int sqlite3_load_extension(
sqlite3 *db,
const char *zFile,
const char *zProc,
char **pzErrMsg
) { return 0; }
SQLITE_API int sqlite3_enable_load_extension(sqlite3 *db, int onoff) { return 0; }
SQLITE_API int sqlite3_auto_extension(void(*xEntryPoint)(void)) { return 0; }
SQLITE_API int sqlite3_cancel_auto_extension(void(*xEntryPoint)(void)) { return 0; }
SQLITE_API int sqlite3_create_module(
sqlite3 *db,
const char *zName,
const sqlite3_module *p,
void *pClientData
) { return 0; }
SQLITE_API int sqlite3_create_module_v2(
sqlite3 *db,
const char *zName,
const sqlite3_module *p,
void *pClientData,
void(*xDestroy)(void*)
) { return 0; }
SQLITE_API int sqlite3_declare_vtab(sqlite3 *db, const char *zSQL) { return 0; }
SQLITE_API int sqlite3_overload_function(sqlite3 *db, const char *zFuncName, int nArg) { return 0; }
SQLITE_API int sqlite3_blob_open(
sqlite3 *db,
const char *zDb,
const char *zTable,
const char *zColumn,
sqlite3_int64 iRow,
int flags,
sqlite3_blob **ppBlob
) { return 0; }
SQLITE_API int sqlite3_blob_reopen(sqlite3_blob *ppBlob, sqlite3_int64 i64) { return 0; }
SQLITE_API int sqlite3_blob_close(sqlite3_blob *ppBlob) { return 0; }
SQLITE_API int sqlite3_blob_bytes(sqlite3_blob *ppBlob) { return 0; }
SQLITE_API int sqlite3_blob_read(sqlite3_blob *ppBlob, void *Z, int N, int iOffset) { return 0; }
SQLITE_API int sqlite3_blob_write(sqlite3_blob *ppBlob, const void *z, int n, int iOffset) { return 0; }
SQLITE_API sqlite3_vfs *sqlite3_vfs_find(const char *zVfsName) { return 0; }
SQLITE_API int sqlite3_vfs_register(sqlite3_vfs *s_vfs, int makeDflt) { return 0; }
SQLITE_API int sqlite3_vfs_unregister(sqlite3_vfs *s_vfs) { return 0; }
SQLITE_API sqlite3_mutex *sqlite3_mutex_alloc(int i) { return 0; }
SQLITE_API int sqlite3_mutex_try(sqlite3_mutex *smtx) { return 0; }
SQLITE_API int sqlite3_mutex_held(sqlite3_mutex *smtx) { return 0; }
SQLITE_API int sqlite3_mutex_notheld(sqlite3_mutex *smtx) { return 0; }
SQLITE_API sqlite3_mutex *sqlite3_db_mutex(sqlite3 *db) { return 0; }
SQLITE_API int sqlite3_file_control(sqlite3 *db, const char *zDbName, int op, void *v) { return 0; }
SQLITE_API int sqlite3_test_control(int op, ...) { return 0; }
SQLITE_API int sqlite3_keyword_count(void) { return 0; }
SQLITE_API int sqlite3_keyword_name(int i,const char **s,int *ii) { return 0; }
SQLITE_API int sqlite3_keyword_check(const char *s,int i) { return 0; }
SQLITE_API sqlite3_str *sqlite3_str_new(sqlite3 *db) { return 0; }
SQLITE_API char *sqlite3_str_finish(sqlite3_str *s_str) { return 0; }
SQLITE_API int sqlite3_str_errcode(sqlite3_str *s_str) { return 0; }
SQLITE_API int sqlite3_str_length(sqlite3_str *s_str) { return 0; }
SQLITE_API char *sqlite3_str_value(sqlite3_str *s_str) { return 0; }
SQLITE_API int sqlite3_status(int op, int *pCurrent, int *pHighwater, int resetFlag) { return 0; }
SQLITE_API int sqlite3_status64(
int op,
sqlite3_int64 *pCurrent,
sqlite3_int64 *pHighwater,
int resetFlag
) { return 0; }
SQLITE_API int sqlite3_db_status(sqlite3 *db, int op, int *pCur, int *pHiwtr, int resetFlg) { return 0; }
SQLITE_API int sqlite3_stmt_status(sqlite3_stmt *stmt, int op,int resetFlg) { return 0; }
SQLITE_API sqlite3_backup *sqlite3_backup_init(
sqlite3 *pDest,
const char *zDestName,
sqlite3 *pSource,
const char *zSourceName
) { return 0; }
SQLITE_API int sqlite3_backup_step(sqlite3_backup *p, int nPage) { return 0; }
SQLITE_API int sqlite3_backup_finish(sqlite3_backup *p) { return 0; }
SQLITE_API int sqlite3_backup_remaining(sqlite3_backup *p) { return 0; }
SQLITE_API int sqlite3_backup_pagecount(sqlite3_backup *p) { return 0; }
SQLITE_API int sqlite3_unlock_notify(
sqlite3 *pBlocked,
void (*xNotify)(void **apArg, int nArg),
void *pNotifyArg
) { return 0; }
SQLITE_API int sqlite3_stricmp(const char *s, const char *ss) { return 0; }
SQLITE_API int sqlite3_strnicmp(const char *s, const char *ss, int i) { return 0; }
SQLITE_API int sqlite3_strglob(const char *zGlob, const char *zStr) { return 0; }
SQLITE_API int sqlite3_strlike(const char *zGlob, const char *zStr, unsigned int cEsc) { return 0; }
SQLITE_API void *sqlite3_wal_hook(
sqlite3 *db,
int(*cb)(void *,sqlite3 *db,const char *s,int i),
void *v
) { return 0; }
SQLITE_API int sqlite3_wal_autocheckpoint(sqlite3 *db, int N) { return 0; }
SQLITE_API int sqlite3_wal_checkpoint(sqlite3 *db, const char *zDb) { return 0; }
SQLITE_API int sqlite3_wal_checkpoint_v2(
sqlite3 *db,
const char *zDb,
int eMode,
int *pnLog,
int *pnCkpt
) { return 0; }
SQLITE_API int sqlite3_vtab_config(sqlite3 *db, int op, ...) { return 0; }
SQLITE_API int sqlite3_vtab_on_conflict(sqlite3 *db) { return 0; }
SQLITE_API int sqlite3_vtab_nochange(sqlite3_context *sctx) { return 0; }
SQLITE_API SQLITE_EXPERIMENTAL const char *sqlite3_vtab_collation(sqlite3_index_info *info,int i) { return 0; }
SQLITE_API int sqlite3_stmt_scanstatus(
sqlite3_stmt *pStmt,
int idx,
int iScanStatusOp,
void *pOut
) { return 0; }
SQLITE_API int sqlite3_db_cacheflush(sqlite3 *db) { return 0; }
SQLITE_API void *sqlite3_preupdate_hook(
sqlite3 *db,
void(*xPreUpdate)(
void *pCtx,
sqlite3 *db,
int op,
char const *zDb,
char const *zName,
sqlite3_int64 iKey1,
sqlite3_int64 iKey2
),
void *v
) { return 0; }
SQLITE_API int sqlite3_preupdate_old(sqlite3 *db, int i, sqlite3_value **s_val) { return 0; }
SQLITE_API int sqlite3_preupdate_count(sqlite3 *db) { return 0; }
SQLITE_API int sqlite3_preupdate_depth(sqlite3 *db) { return 0; }
SQLITE_API int sqlite3_preupdate_new(sqlite3 *db, int i, sqlite3_value **s_val) { return 0; }
SQLITE_API int sqlite3_system_errno(sqlite3 *db) { return 0; }
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_get(
sqlite3 *db,
const char *zSchema,
sqlite3_snapshot **ppSnapshot
) { return 0; }
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_open(
sqlite3 *db,
const char *zSchema,
sqlite3_snapshot *pSnapshot
) { return 0; }
SQLITE_API SQLITE_EXPERIMENTAL void sqlite3_snapshot_free(sqlite3_snapshot *s_sn) { }
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_cmp(
sqlite3_snapshot *p1,
sqlite3_snapshot *p2
) { return 0; }
SQLITE_API SQLITE_EXPERIMENTAL int sqlite3_snapshot_recover(sqlite3 *db, const char *zDb) { return 0; }
SQLITE_API unsigned char *sqlite3_serialize(
sqlite3 *db,
const char *zSchema,
sqlite3_int64 *piSize,
unsigned int mFlags
) { return 0; }
SQLITE_API int sqlite3_deserialize(
sqlite3 *db,
const char *zSchema,
unsigned char *pData,
sqlite3_int64 szDb,
sqlite3_int64 szBuf,
unsigned mFlags
) { return 0; }
SQLITE_API int sqlite3_rtree_geometry_callback(
sqlite3 *db,
const char *zGeom,
int (*xGeom)(sqlite3_rtree_geometry*, int i, sqlite3_rtree_dbl*,int*),
void *pContext
) { return 0; }
SQLITE_API int sqlite3_rtree_query_callback(
sqlite3 *db,
const char *zQueryFunc,
int (*xQueryFunc)(sqlite3_rtree_query_info*),
void *pContext,
void (*xDestructor)(void*)
) { return 0; }
//SQLITE_API int sqlite3session_create(
// sqlite3 *db,
// const char *zDb,
// sqlite3_session **ppSession
//) { return 0; }
//SQLITE_API int sqlite3session_enable(sqlite3_session *pSession, int bEnable) { return 0; }
//SQLITE_API int sqlite3session_indirect(sqlite3_session *pSession, int bIndirect) { return 0; }
//SQLITE_API int sqlite3session_attach(
// sqlite3_session *pSession,
// const char *zTab
//) { return 0; }
//SQLITE_API void sqlite3session_table_filter(
// sqlite3_session *pSession,
// int(*xFilter)(
// void *pCtx,
// const char *zTab
// ),
// void *pCtx
//) { return 0; }
//SQLITE_API int sqlite3session_changeset(
// sqlite3_session *pSession,
// int *pnChangeset,
// void **ppChangeset
//) { return 0; }
//SQLITE_API int sqlite3session_diff(
// sqlite3_session *pSession,
// const char *zFromDb,
// const char *zTbl,
// char **pzErrMsg
//) { return 0; }
//SQLITE_API int sqlite3session_patchset(
// sqlite3_session *pSession,
// int *pnPatchset,
// void **ppPatchset
//) { return 0; }
//SQLITE_API int sqlite3session_isempty(sqlite3_session *pSession) { return 0; }
//SQLITE_API int sqlite3changeset_start(
// sqlite3_changeset_iter **pp,
// int nChangeset,
// void *pChangeset
//) { return 0; }
//SQLITE_API int sqlite3changeset_next(sqlite3_changeset_iter *pIter) { return 0; }
//SQLITE_API int sqlite3changeset_op(
// sqlite3_changeset_iter *pIter,
// const char **pzTab,
// int *pnCol,
// int *pOp,
// int *pbIndirect
//) { return 0; }
//SQLITE_API int sqlite3changeset_pk(
// sqlite3_changeset_iter *pIter,
// unsigned char **pabPK,
// int *pnCol
//) { return 0; }
//SQLITE_API int sqlite3changeset_old(
// sqlite3_changeset_iter *pIter,
// int iVal,
// sqlite3_value **ppValue
//) { return 0; }
//SQLITE_API int sqlite3changeset_new(
// sqlite3_changeset_iter *pIter,
// int iVal,
// sqlite3_value **ppValue
//) { return 0; }
//SQLITE_API int sqlite3changeset_conflict(
// sqlite3_changeset_iter *pIter,
// int iVal,
// sqlite3_value **ppValue
//) { return 0; }
//SQLITE_API int sqlite3changeset_fk_conflicts(
// sqlite3_changeset_iter *pIter,
// int *pnOut
//) { return 0; }
//SQLITE_API int sqlite3changeset_finalize(sqlite3_changeset_iter *pIter) { return 0; }
//SQLITE_API int sqlite3changeset_invert(
// int nIn, const void *pIn,
// int *pnOut, void **ppOut
//) { return 0; }
//SQLITE_API int sqlite3changeset_concat(
// int nA,
// void *pA,
// int nB,
// void *pB,
// int *pnOut,
// void **ppOut
//) { return 0; }
//SQLITE_API int sqlite3changegroup_new(sqlite3_changegroup **pp) { return 0; }
//SQLITE_API int sqlite3changegroup_add(sqlite3_changegroup* scg, int nData, void *pData) { return 0; }
//SQLITE_API int sqlite3changegroup_output(
// sqlite3_changegroup* scg,
// int *pnData,
// void **ppData
//) { return 0; }
//SQLITE_API int sqlite3changeset_apply(
// sqlite3 *db,
// int nChangeset,
// void *pChangeset,
// int(*xFilter)(
// void *pCtx,
// const char *zTab
// ),
// int(*xConflict)(
// void *pCtx,
// int eConflict,
// sqlite3_changeset_iter *p
// ),
// void *pCtx
//) { return 0; }
//SQLITE_API int sqlite3changeset_apply_v2(
// sqlite3 *db,
// int nChangeset,
// void *pChangeset,
// int(*xFilter)(
// void *pCtx,
// const char *zTab
// ),
// int(*xConflict)(
// void *pCtx,
// int eConflict,
// sqlite3_changeset_iter *p
// ),
// void *pCtx,
// void **ppRebase, int *pnRebase,
// int flags
//) { return 0; }
//SQLITE_API int sqlite3rebaser_create(sqlite3_rebaser **ppNew) { return 0; }
//SQLITE_API int sqlite3rebaser_configure(
// sqlite3_rebaser*,
// int nRebase, const void *pRebase
//) { return 0; }
//SQLITE_API int sqlite3rebaser_rebase(
// sqlite3_rebaser*,
// int nIn, const void *pIn,
// int *pnOut, void **ppOut
//) { return 0; }
//SQLITE_API int sqlite3changeset_apply_strm(
// sqlite3 *db,
// int (*xInput)(void *pIn, void *pData, int *pnData),
// void *pIn,
// int(*xFilter)(
// void *pCtx,
// const char *zTab
// ),
// int(*xConflict)(
// void *pCtx,
// int eConflict,
// sqlite3_changeset_iter *p
// ),
// void *pCtx
//) { return 0; }
//SQLITE_API int sqlite3changeset_apply_v2_strm(
// sqlite3 *db,
// int (*xInput)(void *pIn, void *pData, int *pnData),
// void *pIn,
// int(*xFilter)(
// void *pCtx,
// const char *zTab
// ),
// int(*xConflict)(
// void *pCtx,
// int eConflict,
// sqlite3_changeset_iter *p
// ),
// void *pCtx,
// void **ppRebase, int *pnRebase,
// int flags
//) { return 0; }
//SQLITE_API int sqlite3changeset_concat_strm(
// int (*xInputA)(void *pIn, void *pData, int *pnData),
// void *pInA,
// int (*xInputB)(void *pIn, void *pData, int *pnData),
// void *pInB,
// int (*xOutput)(void *pOut, const void *pData, int nData),
// void *pOut
//) { return 0; }
//SQLITE_API int sqlite3changeset_invert_strm(
// int (*xInput)(void *pIn, void *pData, int *pnData),
// void *pIn,
// int (*xOutput)(void *pOut, const void *pData, int nData),
// void *pOut
//) { return 0; }
//SQLITE_API int sqlite3changeset_start_strm(
// sqlite3_changeset_iter **pp,
// int (*xInput)(void *pIn, void *pData, int *pnData),
// void *pIn
//) { return 0; }
//SQLITE_API int sqlite3session_changeset_strm(
// sqlite3_session *pSession,
// int (*xOutput)(void *pOut, const void *pData, int nData),
// void *pOut
//) { return 0; }
//SQLITE_API int sqlite3session_patchset_strm(
// sqlite3_session *pSession,
// int (*xOutput)(void *pOut, const void *pData, int nData),
// void *pOut
//) { return 0; }
//SQLITE_API int sqlite3changegroup_add_strm(sqlite3_changegroup* scg,
// int (*xInput)(void *pIn, void *pData, int *pnData),
// void *pIn
//) { return 0; }
//SQLITE_API int sqlite3changegroup_output_strm(sqlite3_changegroup* scg,
// int (*xOutput)(void *pOut, const void *pData, int nData),
// void *pOut
//) { return 0; }
//SQLITE_API int sqlite3rebaser_rebase_strm(
// sqlite3_rebaser *pRebaser,
// int (*xInput)(void *pIn, void *pData, int *pnData),
// void *pIn,
// int (*xOutput)(void *pOut, const void *pData, int nData),
// void *pOut
//) { return 0; }
SQLITE_API void sqlite3_set_last_insert_rowid(sqlite3 *db,sqlite3_int64 i64) {}
SQLITE_API void sqlite3_interrupt(sqlite3 *db) {}
SQLITE_API void sqlite3_free_table(char **result) {}
SQLITE_API void sqlite3_free(void *v) {}
SQLITE_API void sqlite3_randomness(int N, void *P) {}
SQLITE_API void sqlite3_progress_handler(sqlite3 *db, int i, int(*cb)(void*), void *v) {}
SQLITE_API void sqlite3_value_free(sqlite3_value *s_val) {}
SQLITE_API void sqlite3_set_auxdata(sqlite3_context *sctx, int N, void *v, void(*cb)(void*)) {}
SQLITE_API void sqlite3_result_blob(sqlite3_context *sctx, const void *v, int i, void(*cb)(void*)) {}
SQLITE_API void sqlite3_result_double(sqlite3_context *sctx, double df) {}
SQLITE_API void sqlite3_result_error(sqlite3_context *sctx, const char *s, int i) {}
SQLITE_API void sqlite3_result_error16(sqlite3_context *sctx, const void *v, int i) {}
SQLITE_API void sqlite3_result_error_toobig(sqlite3_context *sctx) {}
SQLITE_API void sqlite3_result_error_nomem(sqlite3_context *sctx) {}
SQLITE_API void sqlite3_result_error_code(sqlite3_context *sctx, int i) {}
SQLITE_API void sqlite3_result_int(sqlite3_context *sctx, int i) {}
SQLITE_API void sqlite3_result_int64(sqlite3_context *sctx, sqlite3_int64 i64) {}
SQLITE_API void sqlite3_result_null(sqlite3_context *sctx) {}
SQLITE_API void sqlite3_result_text(sqlite3_context *sctx, const char *s, int i, void(*cb)(void*)) {}
SQLITE_API void sqlite3_result_text16(sqlite3_context *sctx, const void *v, int i, void(*cb)(void*)) {}
SQLITE_API void sqlite3_result_text16le(sqlite3_context *sctx, const void *v, int i,void(*cb)(void*)) {}
SQLITE_API void sqlite3_result_text16be(sqlite3_context *sctx, const void *v, int i,void(*cb)(void*)) {}
SQLITE_API void sqlite3_result_value(sqlite3_context *sctx, sqlite3_value *s_val) {}
SQLITE_API void sqlite3_result_pointer(sqlite3_context *sctx, void *v,const char *s,void(*cb)(void*)) {}
SQLITE_API void sqlite3_result_zeroblob(sqlite3_context *sctx, int n) {}
SQLITE_API void sqlite3_result_subtype(sqlite3_context *sctx,unsigned int i) {}
SQLITE_API void sqlite3_reset_auto_extension(void) {}
SQLITE_API void sqlite3_mutex_free(sqlite3_mutex *smtx) {}
SQLITE_API void sqlite3_mutex_enter(sqlite3_mutex *smtx) {}
SQLITE_API void sqlite3_mutex_leave(sqlite3_mutex *smtx) {}
SQLITE_API void sqlite3_str_appendf(sqlite3_str *s_str, const char *zFormat, ...) {}
SQLITE_API void sqlite3_str_vappendf(sqlite3_str *s_str, const char *zFormat, va_list va) {}
SQLITE_API void sqlite3_str_append(sqlite3_str *s_str, const char *zIn, int N) {}
SQLITE_API void sqlite3_str_appendall(sqlite3_str *s_str, const char *zIn) {}
SQLITE_API void sqlite3_str_appendchar(sqlite3_str *s_str, int N, char C) {}
SQLITE_API void sqlite3_str_reset(sqlite3_str *s_str) {}
SQLITE_API void sqlite3_log(int iErrCode, const char *zFormat, ...) {}
SQLITE_API void sqlite3_stmt_scanstatus_reset(sqlite3_stmt *stmt) {}
//SQLITE_API void sqlite3session_delete(sqlite3_session *pSession) {}
//SQLITE_API void sqlite3changegroup_delete(sqlite3_changegroup*) {}
//SQLITE_API void sqlite3rebaser_delete(sqlite3_rebaser *p) {}

View File

@ -1,19 +1,11 @@
#pragma once
#include <sqlite3.h>
#include <sys/stat.h>
#include <map>
#include <string>
#include <string_view>
#include <functional>
#define db_err(e) db_err_cmd(e, )
#define db_err_cmd(e, cmd) if (e) { \
LOGE("sqlite3_exec: %s\n", e); \
sqlite3_free(e); \
cmd;\
}
template <class T, size_t num>
class db_data_base {
public:
@ -160,4 +152,6 @@ bool validate_manager(std::string &pkg, int userid, struct stat *st);
void exec_sql(int client);
char *db_exec(const char *sql);
char *db_exec(const char *sql, const db_row_cb &fn);
bool db_err(char *e);
#define db_err_cmd(e, cmd) if (db_err(e)) { cmd; }

View File

@ -182,12 +182,6 @@ bool MagiskInit::patch_sepolicy(const char *file) {
return patch_init;
}
constexpr const char wrapper[] =
"#!/system/bin/sh\n"
"export LD_LIBRARY_PATH=\"$LD_LIBRARY_PATH:/apex/com.android.runtime/" LIBNAME "\"\n"
"exec /sbin/magisk.bin \"$0\" \"$@\"\n"
;
static void sbin_overlay(const raw_data &self, const raw_data &config) {
mount_sbin();
@ -199,17 +193,8 @@ static void sbin_overlay(const raw_data &self, const raw_data &config) {
fd = xopen("/sbin/magiskinit", O_WRONLY | O_CREAT, 0755);
xwrite(fd, self.buf, self.sz);
close(fd);
if (access("/system/apex", F_OK) == 0) {
LOGD("APEX detected, use wrapper\n");
dump_magisk("/sbin/magisk.bin", 0755);
patch_socket_name("/sbin/magisk.bin");
fd = xopen("/sbin/magisk", O_WRONLY | O_CREAT, 0755);
xwrite(fd, wrapper, sizeof(wrapper) - 1);
close(fd);
} else {
dump_magisk("/sbin/magisk", 0755);
patch_socket_name("/sbin/magisk");
}
// Create applet symlinks
char path[64];

View File

@ -96,17 +96,7 @@ else
fi
# Magisk stuffs
if [ -e /apex ]; then
./magiskinit -x magisk /sbin/magisk.bin
[ -e /system/lib64 ] && LIB=lib64 || LIB=lib
cat <<EOF > /sbin/magisk
#!/system/bin/sh
export LD_LIBRARY_PATH="\$LD_LIBRARY_PATH:/apex/com.android.runtime/$LIB"
exec /sbin/magisk.bin "\$0" "\$@"
EOF
else
./magiskinit -x magisk /sbin/magisk
fi
./magiskinit -x magisk /sbin/magisk
chmod 755 /sbin/magisk
ln -s ./magisk /sbin/su
ln -s ./magisk /sbin/resetprop