61 lines
1.9 KiB
Rust
Raw Normal View History

#![feature(format_args_nl)]
2023-05-30 22:23:11 -07:00
#![allow(clippy::missing_safety_doc)]
2023-06-12 05:59:50 -07:00
use base::Utf8CStr;
2023-06-22 02:23:27 -07:00
use cert::read_certificate;
use daemon::{daemon_entry, find_apk_path, get_magiskd, zygisk_entry, MagiskD};
use logging::{android_logging, magisk_logging, zygisk_logging};
use resetprop::persist::{
persist_delete_prop, persist_get_prop, persist_get_props, persist_set_prop,
};
2022-07-05 21:13:09 -07:00
mod cert;
2023-05-23 21:30:30 -07:00
#[path = "../include/consts.rs"]
mod consts;
2023-05-09 18:54:38 -07:00
mod daemon;
2022-07-05 21:13:09 -07:00
mod logging;
mod resetprop;
2022-07-01 04:53:41 -07:00
#[cxx::bridge]
pub mod ffi {
2023-05-21 23:51:30 -07:00
extern "C++" {
pub type prop_cb;
2023-05-22 21:36:15 -07:00
include!("resetprop/resetprop.hpp");
include!("../base/files.hpp");
pub unsafe fn get_prop_rs(name: *const c_char, persist: bool) -> String;
pub unsafe fn prop_cb_exec(cb: *mut prop_cb, name: *const c_char, value: *const c_char);
pub unsafe fn clone_attr(src: *const c_char, dst: *const c_char);
2023-05-21 23:51:30 -07:00
}
2022-07-01 04:53:41 -07:00
extern "Rust" {
fn rust_test_entry();
2022-07-05 21:13:09 -07:00
fn android_logging();
fn magisk_logging();
fn zygisk_logging();
2023-06-10 01:40:45 -07:00
fn find_apk_path(pkg: &[u8], data: &mut [u8]) -> usize;
2023-06-16 02:33:01 -07:00
fn read_certificate(fd: i32, version: i32) -> Vec<u8>;
unsafe fn persist_get_prop(name: *const c_char, prop_cb: *mut prop_cb);
unsafe fn persist_get_props(prop_cb: *mut prop_cb);
unsafe fn persist_delete_prop(name: *const c_char) -> bool;
unsafe fn persist_set_prop(name: *const c_char, value: *const c_char) -> bool;
2022-07-05 21:13:09 -07:00
}
2023-05-16 02:09:05 -07:00
#[namespace = "rust"]
2023-05-09 18:54:38 -07:00
extern "Rust" {
fn daemon_entry();
fn zygisk_entry();
type MagiskD;
fn get_magiskd() -> &'static MagiskD;
fn get_log_pipe(self: &MagiskD) -> i32;
fn close_log_pipe(self: &MagiskD);
fn setup_logfile(self: &MagiskD);
}
}
2022-07-01 04:53:41 -07:00
fn rust_test_entry() {}
2023-05-21 23:51:30 -07:00
2023-06-12 05:59:50 -07:00
pub fn get_prop(name: &Utf8CStr, persist: bool) -> String {
2023-05-21 23:51:30 -07:00
unsafe { ffi::get_prop_rs(name.as_ptr(), persist) }
}