INNER CODE UNIT · Rust
replace_module_vermagic
KernelSU-Next/KernelSU-Next · userspace/ksuinit/src/lib.rs:203
fn replace_module_vermagic(buffer: &mut Vec<u8>, required_vermagic: &str) -> Result<()> {
struct ModinfoLocation {
offset: usize,
size: usize,
section_header_offset: usize,
alignment: usize,
little_endian: bool,
}
let location = {
let elf = Elf::parse(buffer)?;
if !elf.is_64 {
bail!("Only ELF64 modules are supported");
}
let section_table_offset =
usize::try_from(elf.header.e_shoff).context("Section table offset overflow")?;