51 lines
1.2 KiB
Rust
Raw Normal View History

#![feature(format_args_nl)]
2023-06-09 21:43:26 +08:00
#![feature(btree_drain_filter)]
2022-07-01 04:53:41 -07:00
pub use base;
2023-06-22 02:23:27 -07:00
use cpio::cpio_commands;
use patch::{hexpatch, patch_encryption, patch_verity};
use payload::extract_boot_from_payload;
2023-06-25 03:50:21 +08:00
use sha::{get_sha, sha_digest, SHA};
2023-05-04 18:49:33 -07:00
2023-06-09 21:43:26 +08:00
mod cpio;
2023-06-20 18:17:26 -07:00
mod patch;
2023-05-04 18:49:33 -07:00
mod payload;
2023-06-20 14:29:09 -07:00
// Suppress warnings in generated code
#[allow(warnings)]
2023-06-21 00:22:48 +08:00
mod proto;
2023-06-09 21:43:26 +08:00
mod ramdisk;
2023-06-25 03:50:21 +08:00
mod sha;
#[cxx::bridge]
2023-05-04 18:49:33 -07:00
pub mod ffi {
unsafe extern "C++" {
2023-05-19 15:16:54 -07:00
include!("compress.hpp");
fn decompress(buf: &[u8], fd: i32) -> bool;
}
2023-06-22 02:23:27 -07:00
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(
partition: *const c_char,
in_path: *const c_char,
out_path: *const c_char,
) -> bool;
2023-06-09 21:43:26 +08:00
unsafe fn cpio_commands(argc: i32, argv: *const *const c_char) -> bool;
}
2023-06-25 03:50:21 +08:00
extern "Rust" {
type SHA;
fn get_sha(use_sha1: bool) -> Box<SHA>;
fn finalize(&mut self) -> Vec<u8>;
fn update(&mut self, data: &[u8]);
fn sha_digest(data: &[u8], use_sha1: bool) -> Vec<u8>;
}
}