diff --git a/src/win32/pe_image.rs b/src/win32/pe_image.rs index 1cffc5a..6a869a7 100644 --- a/src/win32/pe_image.rs +++ b/src/win32/pe_image.rs @@ -235,6 +235,18 @@ impl ImageBase { self.as_ptr()..self.as_ptr() + self.nt_header().optional_header.size_of_image as usize } + pub unsafe fn as_slice(&self) -> &[u8] { + let ptr = self.as_ptr() as *const u8; + let size = self.nt_header().optional_header.size_of_image as usize; + core::slice::from_raw_parts(ptr, size) + } + + pub unsafe fn as_slice_mut(&self) -> &mut [u8] { + let ptr = self.as_ptr() as *mut u8; + let size = self.nt_header().optional_header.size_of_image as usize; + core::slice::from_raw_parts_mut(ptr, size) + } + } impl ImageNTHeaders64 {