pub struct Parser { /* private fields */ }Expand description
The parser of the proka executable.
§Usage
To use this parser, you must put an slice into the initializations.
If the content of the proka executable is in memory, the best way
is to use core::slice::from_raw_parts.
Implementations§
Source§impl Parser
impl Parser
Sourcepub unsafe fn init_unchecked(buf: &'static [u8]) -> Self
pub unsafe fn init_unchecked(buf: &'static [u8]) -> Self
Initialize the parser by passing a slice without checking.
§Safety
You must ensure these if you invoke this function:
- The slice’s content is a valid proka executable (match the magic);
- The slice must contain the header and all section tables.
§Note
Use this function to initialize is NOT recommended, because it might
cause some problems while parsing this header.
Sourcepub fn init(buf: &'static [u8]) -> Result<Self, Error>
pub fn init(buf: &'static [u8]) -> Result<Self, Error>
Initialize the parser by passing a slice.
This is the recommended way to initialize this parser, because it will help you do all checks and return error if something wrong, so you can leave everything about parsing to us :)
§Note
If this crate is used on the kernel-side, you must first map the memory that the slice points to before invoking this function.
Sourcepub fn validate(&self) -> bool
pub fn validate(&self) -> bool
Do more validation after initialization.
§Content
This will validates:
- Is the header min >= max;
- Is each section’s base correct;
- Is the section’s length not zeroed.
- Is section base out of length.
Sourcepub fn sections(&self) -> SectionIter ⓘ
pub fn sections(&self) -> SectionIter ⓘ
Get each section table.