Struct SectionTable
pub struct SectionTable {
pub name: String,
pub virtual_size: u32,
pub virtual_address: u32,
pub size_of_raw_data: u32,
pub pointer_to_raw_data: u32,
pub pointer_to_relocations: u32,
pub pointer_to_line_numbers: u32,
pub number_of_relocations: u16,
pub number_of_line_numbers: u16,
pub characteristics: u32,
}Expand description
Provides access to low-level file and memory parsing utilities.
The crate::Parser type is used for decoding CIL bytecode and metadata streams.
§Usage Examples
use dotscope::{Parser, assembly::decode_instruction};
let code = [0x2A]; // ret
let mut parser = Parser::new(&code);
let instr = decode_instruction(&mut parser, 0x1000)?;
assert_eq!(instr.mnemonic, "ret");Owned section table entry.
Fields§
§name: StringSection name (up to 8 bytes)
virtual_size: u32Virtual size
virtual_address: u32Virtual address (RVA)
size_of_raw_data: u32Size of raw data
pointer_to_raw_data: u32Pointer to raw data
pointer_to_relocations: u32Pointer to relocations
pointer_to_line_numbers: u32Pointer to line numbers
number_of_relocations: u16Number of relocations
number_of_line_numbers: u16Number of line numbers
characteristics: u32Section characteristics
Implementations§
§impl SectionTable
impl SectionTable
pub fn calculate_table_size(section_count: usize) -> u64
pub fn calculate_table_size(section_count: usize) -> u64
pub fn from_layout_info(
name: String,
virtual_address: u32,
virtual_size: u32,
file_offset: u64,
file_size: u64,
characteristics: u32,
) -> Result<Self>
pub fn from_layout_info( name: String, virtual_address: u32, virtual_size: u32, file_offset: u64, file_size: u64, characteristics: u32, ) -> Result<Self>
Creates a SectionTable from layout information.
This converts from the layout planning structures used during write operations back to the PE section table format.
§Arguments
name- Section namevirtual_address- RVA where section is mappedvirtual_size- Virtual size of section in memoryfile_offset- File offset where section data is storedfile_size- Size of section data in filecharacteristics- Section characteristics flags
§Returns
A new SectionTable instance
§Errors
Returns an error if the file offset or size exceed u32 range
pub fn update_virtual_location(
&mut self,
virtual_address: u32,
virtual_size: u32,
)
pub fn update_virtual_location( &mut self, virtual_address: u32, virtual_size: u32, )
Updates the virtual address and size of this section.
§Arguments
virtual_address- New RVA where section is mappedvirtual_size- New virtual size of section in memory
pub fn update_file_location(
&mut self,
file_offset: u64,
file_size: u64,
) -> Result<()>
pub fn update_file_location( &mut self, file_offset: u64, file_size: u64, ) -> Result<()>
pub fn update_characteristics(&mut self, characteristics: u32)
pub fn update_characteristics(&mut self, characteristics: u32)
Updates the section characteristics flags.
§Arguments
characteristics- New section characteristics flags
pub fn write_to<W: Write>(&self, writer: &mut W) -> Result<()>
pub fn write_to<W: Write>(&self, writer: &mut W) -> Result<()>
Writes this section header to the writer.
Each section header is 40 bytes and describes a section’s location in both the file and virtual memory, along with its characteristics (readable, writable, executable, etc.).
§Arguments
writer- The writer to output the section header to
§Errors
Returns an error if writing fails.
Trait Implementations§
§impl Clone for SectionTable
impl Clone for SectionTable
§fn clone(&self) -> SectionTable
fn clone(&self) -> SectionTable
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for SectionTable
impl RefUnwindSafe for SectionTable
impl Send for SectionTable
impl Sync for SectionTable
impl Unpin for SectionTable
impl UnwindSafe for SectionTable
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more