To parse an Xbox 360 executable (XEX) header, use the XexHeader::read method. This method requires a reader that implements both std::io::Read and std::io::Seek. It validates the magic bytes (expecting XEX2) and extracts module flags, code offsets, certificate offsets, and various header fields.
If the header is invalid or missing the XEX2 magic bytes, it will return an error: missing 'XEX2' magic bytes in XEX header.
use crate::executable::xex::XexHeader;
use std::fs::File;
let mut file = File::open("path/to/executable.xex")?;
let header = XexHeader::read(&mut file)?;
println!("Module Flags: {:?}", header.module_flags);
println!("Code Offset: {}", header.code_offset);