Minor cleanup

This commit is contained in:
topjohnwu 2023-06-22 02:23:27 -07:00
parent 9c7cf340a1
commit 732a161b67
5 changed files with 16 additions and 13 deletions

View File

@ -152,7 +152,7 @@ static bool dtb_patch(const char *file) {
int len;
char *value = (char *) fdt_getprop(fdt, node, "fsmgr_flags", &len);
byte_data data(value, len);
patched |= (rust::patch_verity(data) != len);
patched |= (patch_verity(data) != len);
}
}
}
@ -225,7 +225,7 @@ static bool fdt_patch(void *fdt) {
int len;
const void *value = fdt_getprop(fdt, node, "fsmgr_flags", &len);
heap_data copy = byte_view(value, len).clone();
auto patched_sz = rust::patch_verity(copy);
auto patched_sz = patch_verity(copy);
if (patched_sz != len) {
modified = true;
fdt_setprop(fdt, node, "fsmgr_flags", copy.buf(), patched_sz);

View File

@ -2,9 +2,9 @@
#![feature(btree_drain_filter)]
pub use base;
use cpio::*;
use patch::*;
use payload::*;
use cpio::cpio_commands;
use patch::{hexpatch, patch_encryption, patch_verity};
use payload::extract_boot_from_payload;
mod cpio;
mod patch;
@ -21,6 +21,12 @@ pub mod ffi {
fn decompress(buf: &[u8], fd: i32) -> bool;
}
extern "Rust" {
fn hexpatch(file: &[u8], from: &[u8], to: &[u8]) -> bool;
fn patch_encryption(buf: &mut [u8]) -> usize;
fn patch_verity(buf: &mut [u8]) -> usize;
}
#[namespace = "rust"]
extern "Rust" {
unsafe fn extract_boot_from_payload(
@ -30,8 +36,5 @@ pub mod ffi {
) -> bool;
unsafe fn cpio_commands(argc: i32, argv: *const *const c_char) -> bool;
fn hexpatch(file: &[u8], from: &[u8], to: &[u8]) -> bool;
fn patch_encryption(buf: &mut [u8]) -> usize;
fn patch_verity(buf: &mut [u8]) -> usize;
}
}

View File

@ -200,7 +200,7 @@ int main(int argc, char *argv[]) {
} else if (argc > 2 && str_starts(action, "compress")) {
compress(action[8] == '=' ? &action[9] : "gzip", argv[2], argv[3]);
} else if (argc > 4 && action == "hexpatch") {
return rust::hexpatch(byte_view(argv[2]), byte_view(argv[3]), byte_view(argv[4])) ? 0 : 1;
return hexpatch(byte_view(argv[2]), byte_view(argv[3]), byte_view(argv[4])) ? 0 : 1;
} else if (argc > 2 && action == "cpio"sv) {
if (!rust::cpio_commands(argc - 2, argv + 2))
usage(argv[0]);

View File

@ -2,9 +2,9 @@
#![allow(clippy::missing_safety_doc)]
use base::Utf8CStr;
use cert::*;
use daemon::*;
use logging::*;
use cert::read_certificate;
use daemon::{daemon_entry, find_apk_path, get_magiskd, zygisk_entry, MagiskD};
use logging::{android_logging, magisk_logging, zygisk_logging};
mod cert;
#[path = "../include/consts.rs"]

View File

@ -1,4 +1,4 @@
pub use logging::*;
use logging::setup_klog;
// Has to be pub so all symbols in that crate is included
pub use magiskpolicy;