use crate::errors::ModuleError;
use crate::mods::prelude::*;
use crate::modules::protos::olecf::*;
pub mod parser;
fn main(_ctx: &mut ModuleContext, data: &[u8]) -> Result<Olecf, ModuleError> {
let mut olecf = Olecf::new();
match parser::OLECFParser::new(data) {
Ok(parser) => {
olecf.set_is_olecf(parser.is_valid_header());
olecf.streams = parser
.get_streams()
.map(|(name, entry)| {
let mut s = Stream::new();
s.set_name(name.to_string());
s.set_size(entry.size);
s.set_type(match entry.stream_type {
1 => StreamType::STORAGE,
2 => StreamType::STREAM,
5 => StreamType::ROOT,
_ => StreamType::UNKNOWN,
});
s
})
.collect();
}
Err(_) => {
olecf.set_is_olecf(false);
}
}
Ok(olecf)
}
register_module!("olecf", Olecf, main);