diff --git a/src/program.rs b/src/program.rs index 86971f7..fea72ca 100644 --- a/src/program.rs +++ b/src/program.rs @@ -145,34 +145,32 @@ impl Program { fn init() -> Self { let base = Base::program(); - { - let pe = unsafe { PeView::module(base.as_nonnull().as_ptr()) }; - - let len = pe.nt_headers().OptionalHeader.SizeOfImage as usize; - - let sections = pe - .section_headers() - .iter() - .map(|section| { - let name = section.name().unwrap(); - - let base = unsafe { - Base::new_unchecked( - base.add(section.VirtualAddress as usize).as_ptr().cast(), - ) - }; - - let len = section.VirtualSize as usize; - - Section::new(name, base, len) - }) - .collect(); - - Self { - base, - len, - sections, - } + let pe = unsafe { PeView::module(base.as_nonnull().as_ptr()) }; + + let len = pe.nt_headers().OptionalHeader.SizeOfImage as usize; + + let sections = pe + .section_headers() + .iter() + .map(|section| { + let name = section + .name() + .unwrap_or(unsafe { from_utf8_unchecked(§ion.Name) }); + + let base = unsafe { + Base::new_unchecked(base.add(section.VirtualAddress as usize).as_ptr().cast()) + }; + + let len = section.VirtualSize as usize; + + Section::new(name, base, len) + }) + .collect(); + + Self { + base, + len, + sections, } } }