use crate::{HEADER_SIZE, SECTION_SIZE};
#[repr(C)]
#[derive(Debug, Clone, Copy)]
pub struct Section {
pub name: [u8; 16],
pub is_loadable: bool,
pub is_execable: bool,
pub base: u32,
pub length: u32
}
#[derive(Debug, Clone, Copy)]
pub(crate) struct SectionIter {
pub buf: &'static [u8],
pub total: u16,
pub current: u16,
}
impl Iterator for SectionIter {
type Item = Section;
fn next(&mut self) -> Option<Self::Item> {
let base = HEADER_SIZE + self.current as usize * SECTION_SIZE;
let buf = &self.buf[base..base + SECTION_SIZE];
if self.current >= self.total {
return None;
}
let section = unsafe { *(buf.as_ptr() as *const Section) };
Some(section)
}
}