use libsui::find_section; use libsui::Elf; use libsui::Macho; use libsui::PortableExecutable; use libsui::utils; static TEST_ICO: &[u8] = include_bytes!("./tests/test.ico"); const HELP: &str = r#"Usage: sui "#; fn main() -> Result<(), Box> { if let Some(section) = find_section("__SUI") { println!("Found section"); println!("{}", std::str::from_utf8(section)?); return Ok(()); } let args: Vec = std::env::args().collect(); if args.len() != 4 { eprintln!("{}", HELP); std::process::exit(1); } let exe = std::fs::read(&args[1])?; let data = std::fs::read(&args[2])?; let mut out = std::fs::File::create(&args[3])?; if utils::is_pe(&exe) { PortableExecutable::from(&exe)? .set_icon(TEST_ICO)? .write_resource("__SUI", data)? .build(&mut out)?; } else if utils::is_macho(&exe) { Macho::from(exe)? .write_section("__SUI", data)? .build_and_sign(&mut out)?; } else if utils::is_elf(&exe) { Elf::new(&exe).append("__SUI", &data, &mut out)?; } else { eprintln!("Unsupported file format"); std::process::exit(1); } Ok(()) }