mirror of
https://github.com/topjohnwu/Magisk.git
synced 2024-12-22 16:07:39 +00:00
Minor cleanup
This commit is contained in:
parent
9c7cf340a1
commit
732a161b67
@ -152,7 +152,7 @@ static bool dtb_patch(const char *file) {
|
|||||||
int len;
|
int len;
|
||||||
char *value = (char *) fdt_getprop(fdt, node, "fsmgr_flags", &len);
|
char *value = (char *) fdt_getprop(fdt, node, "fsmgr_flags", &len);
|
||||||
byte_data data(value, 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;
|
int len;
|
||||||
const void *value = fdt_getprop(fdt, node, "fsmgr_flags", &len);
|
const void *value = fdt_getprop(fdt, node, "fsmgr_flags", &len);
|
||||||
heap_data copy = byte_view(value, len).clone();
|
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) {
|
if (patched_sz != len) {
|
||||||
modified = true;
|
modified = true;
|
||||||
fdt_setprop(fdt, node, "fsmgr_flags", copy.buf(), patched_sz);
|
fdt_setprop(fdt, node, "fsmgr_flags", copy.buf(), patched_sz);
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#![feature(btree_drain_filter)]
|
#![feature(btree_drain_filter)]
|
||||||
|
|
||||||
pub use base;
|
pub use base;
|
||||||
use cpio::*;
|
use cpio::cpio_commands;
|
||||||
use patch::*;
|
use patch::{hexpatch, patch_encryption, patch_verity};
|
||||||
use payload::*;
|
use payload::extract_boot_from_payload;
|
||||||
|
|
||||||
mod cpio;
|
mod cpio;
|
||||||
mod patch;
|
mod patch;
|
||||||
@ -21,6 +21,12 @@ pub mod ffi {
|
|||||||
fn decompress(buf: &[u8], fd: i32) -> bool;
|
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"]
|
#[namespace = "rust"]
|
||||||
extern "Rust" {
|
extern "Rust" {
|
||||||
unsafe fn extract_boot_from_payload(
|
unsafe fn extract_boot_from_payload(
|
||||||
@ -30,8 +36,5 @@ pub mod ffi {
|
|||||||
) -> bool;
|
) -> bool;
|
||||||
|
|
||||||
unsafe fn cpio_commands(argc: i32, argv: *const *const c_char) -> 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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -200,7 +200,7 @@ int main(int argc, char *argv[]) {
|
|||||||
} else if (argc > 2 && str_starts(action, "compress")) {
|
} else if (argc > 2 && str_starts(action, "compress")) {
|
||||||
compress(action[8] == '=' ? &action[9] : "gzip", argv[2], argv[3]);
|
compress(action[8] == '=' ? &action[9] : "gzip", argv[2], argv[3]);
|
||||||
} else if (argc > 4 && action == "hexpatch") {
|
} 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) {
|
} else if (argc > 2 && action == "cpio"sv) {
|
||||||
if (!rust::cpio_commands(argc - 2, argv + 2))
|
if (!rust::cpio_commands(argc - 2, argv + 2))
|
||||||
usage(argv[0]);
|
usage(argv[0]);
|
||||||
|
@ -2,9 +2,9 @@
|
|||||||
#![allow(clippy::missing_safety_doc)]
|
#![allow(clippy::missing_safety_doc)]
|
||||||
|
|
||||||
use base::Utf8CStr;
|
use base::Utf8CStr;
|
||||||
use cert::*;
|
use cert::read_certificate;
|
||||||
use daemon::*;
|
use daemon::{daemon_entry, find_apk_path, get_magiskd, zygisk_entry, MagiskD};
|
||||||
use logging::*;
|
use logging::{android_logging, magisk_logging, zygisk_logging};
|
||||||
|
|
||||||
mod cert;
|
mod cert;
|
||||||
#[path = "../include/consts.rs"]
|
#[path = "../include/consts.rs"]
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
pub use logging::*;
|
use logging::setup_klog;
|
||||||
// Has to be pub so all symbols in that crate is included
|
// Has to be pub so all symbols in that crate is included
|
||||||
pub use magiskpolicy;
|
pub use magiskpolicy;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user