Struct cwe_checker_lib::utils::binary::MemorySegment
source · pub struct MemorySegment {
pub bytes: Vec<u8>,
pub base_address: u64,
pub read_flag: bool,
pub write_flag: bool,
pub execute_flag: bool,
}
Expand description
A continuous segment in the memory image.
Fields§
§bytes: Vec<u8>
The contents of the segment
base_address: u64
The base address, i.e. the address of the first byte of the segment
read_flag: bool
Is the segment readable
write_flag: bool
Is the segment writeable
execute_flag: bool
Is the segment executable
Implementations§
source§impl MemorySegment
impl MemorySegment
sourcepub fn from_elf_section(
binary: &[u8],
base_address: u64,
section_header: &SectionHeader
) -> Self
pub fn from_elf_section( binary: &[u8], base_address: u64, section_header: &SectionHeader ) -> Self
Generate a segment from a section header of a relocatable ELF object file.
sourcepub fn from_elf_segment(
binary: &[u8],
program_header: &ProgramHeader
) -> MemorySegment
pub fn from_elf_segment( binary: &[u8], program_header: &ProgramHeader ) -> MemorySegment
Generate a segment from a program header of an ELF file.
sourcepub fn from_pe_section(
binary: &[u8],
section_header: &SectionTable
) -> MemorySegment
pub fn from_pe_section( binary: &[u8], section_header: &SectionTable ) -> MemorySegment
Generate a segment from a section table from a PE file.
sourcepub fn from_bare_metal_file(binary: &[u8], base_address: u64) -> MemorySegment
pub fn from_bare_metal_file(binary: &[u8], base_address: u64) -> MemorySegment
Generate a segment with the given base_address
and content given by binary
.
The segment is readable, writeable and executable, its size equals the size of binary
.
sourcepub fn new_bare_metal_ram_segment(base_address: u64, size: u64) -> MemorySegment
pub fn new_bare_metal_ram_segment(base_address: u64, size: u64) -> MemorySegment
Generate a segment with the given base address and size. The segment is readable and writeable, but not executable. The content is set to a vector of zeroes.
Trait Implementations§
source§impl Clone for MemorySegment
impl Clone for MemorySegment
source§fn clone(&self) -> MemorySegment
fn clone(&self) -> MemorySegment
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for MemorySegment
impl Debug for MemorySegment
source§impl<'de> Deserialize<'de> for MemorySegment
impl<'de> Deserialize<'de> for MemorySegment
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Hash for MemorySegment
impl Hash for MemorySegment
source§impl PartialEq for MemorySegment
impl PartialEq for MemorySegment
source§fn eq(&self, other: &MemorySegment) -> bool
fn eq(&self, other: &MemorySegment) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.source§impl Serialize for MemorySegment
impl Serialize for MemorySegment
impl Eq for MemorySegment
impl StructuralEq for MemorySegment
impl StructuralPartialEq for MemorySegment
Auto Trait Implementations§
impl RefUnwindSafe for MemorySegment
impl Send for MemorySegment
impl Sync for MemorySegment
impl Unpin for MemorySegment
impl UnwindSafe for MemorySegment
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.