Struct exe::buffer::Buffer [−][src]
pub struct Buffer { /* fields omitted */ }Expand description
A buffer representing the PE file.
Implementations
Creates a new buffer from disk data.
Get the buffer as a mutable slice.
Get the buffer as a mutable pointer.
Extend the buffer with a data slice.
Convert the given offset value to a pointer in the buffer. The function is marked as unsafe because the offset isn’t validated.
Convert the given offset value to a mutable pointer in the buffer. The function is marked as unsafe because the offset isn’t validated.
Get the pointer to the end of the file. This pointer is unsafe because it points at the end of the buffer, which doesn’t contain data.
Convert a pointer to an offset. This returns Error::BadPointer if the pointer
isn’t in the buffer range.
Converts a reference to an offset. Returns a Error::BadPointer error if the reference
isn’t from the buffer.
Gets a reference to an object in the buffer data. This is ultimately how PE objects are created from the buffer.
use exe::buffer::Buffer; use exe::types::{Offset, ImageDOSHeader, ImageNTHeaders32, NT_SIGNATURE}; let buffer = Buffer::from_file("test/compiled.exe").unwrap(); let dos_header = buffer.get_ref::<ImageDOSHeader>(Offset(0)).unwrap(); let nt_header = buffer.get_ref::<ImageNTHeaders32>(dos_header.e_lfanew).unwrap(); assert_eq!(nt_header.signature, NT_SIGNATURE);
Gets a mutable reference to an object in the buffer data.
Gets a slice reference of data in the buffer. This is how to get arrays in the buffer.
use exe::buffer::Buffer; use exe::types::Offset; let buffer = Buffer::from_file("test/compiled.exe").unwrap(); let mz = buffer.get_slice_ref::<u8>(Offset(0), 2).unwrap(); assert_eq!(mz, [0x4D, 0x5A]);
Gets a mutable slice reference of data in the buffer.
Get the size of a zero-terminated C-string in the data.
Gets the size of a zero-terminated UTF16 string in the data.
Get a zero-terminated C-string from the data. The thunk option is there to handle imports by name, whose null terminated value size is dependent on how long the string is (i.e., if it’s an odd length, an extra zero is appended).
use exe::buffer::Buffer; use exe::types::{Offset, CCharString}; let buffer = Buffer::from_file("test/dll.dll").unwrap(); let dll_name = buffer.get_cstring(Offset(0x328), false, None).unwrap(); assert_eq!(dll_name.as_str(), "dll.dll");
Get a mutable zero-terminated C-string from the data.
Get a zero-terminated UTF16 string from the data.
Get a mutable zero-terminated UTF16 string from the data.
Get an ImageImportByName object at the given offset. See the documentation of ImageImportByName
for an explanation of why this is needed.
Read arbitrary data from the buffer.
Read mutable arbitrary data from the buffer.
Write arbitrary data to the buffer.
Trait Implementations
Auto Trait Implementations
impl RefUnwindSafe for Bufferimpl UnwindSafe for BufferBlanket Implementations
Mutably borrows from an owned value. Read more