2023-06-14 22:24:42 +08:00
|
|
|
#![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};
|
2022-07-05 21:13:09 -07:00
|
|
|
|
2023-06-14 22:24:42 +08: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;
|
2022-07-01 04:53:41 -07:00
|
|
|
|
|
|
|
#[cxx::bridge]
|
|
|
|
pub mod ffi {
|
2023-05-21 23:51:30 -07:00
|
|
|
extern "C++" {
|
2023-05-22 21:36:15 -07:00
|
|
|
include!("resetprop/resetprop.hpp");
|
2023-05-21 23:51:30 -07:00
|
|
|
unsafe fn get_prop_rs(name: *const c_char, persist: bool) -> String;
|
|
|
|
}
|
|
|
|
|
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>;
|
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) }
|
|
|
|
}
|