Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
KiraCoding committed Sep 13, 2024
1 parent 8d6ad1f commit cf5f650
Showing 1 changed file with 26 additions and 28 deletions.
54 changes: 26 additions & 28 deletions src/program.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(&section.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,
}
}
}
Expand Down

0 comments on commit cf5f650

Please sign in to comment.