1use crate::{HEADER_SIZE, SECTION_SIZE};
3
4#[repr(C)]
6#[derive(Debug, Clone, Copy)]
7pub struct Section {
8 pub name: [u8; 16],
10
11 pub is_loadable: bool,
13
14 pub is_execable: bool,
16
17 pub base: u32,
19
20 pub length: u32
22}
23
24#[derive(Debug, Clone, Copy)]
26pub(crate) struct SectionIter {
27 pub buf: &'static [u8],
28 pub total: u16,
29 pub current: u16,
30}
31
32impl Iterator for SectionIter {
34 type Item = Section;
35
36 fn next(&mut self) -> Option<Self::Item> {
37 let base = HEADER_SIZE + self.current as usize * SECTION_SIZE;
38 let buf = &self.buf[base..base + SECTION_SIZE];
39
40 if self.current >= self.total {
42 return None;
43 }
44
45 let section = unsafe { *(buf.as_ptr() as *const Section) };
47 Some(section)
48 }
49}