Struct BinaryPatcher

Source
pub struct BinaryPatcher<R: Read + Seek, W: Write + Seek, A: Fn(u64) -> Result<u64>, O: Fn(u64) -> Result<u64>> {
    pub input: R,
    pub output: W,
    input_len: u64,
    address_to_offset: A,
    offset_to_address: O,
    range_maps: Vec<RangeMap>,
}
Expand description

A binary patcher that can be used to apply patches to binary data.

Fields§

§input: R§output: W§input_len: u64§address_to_offset: A§offset_to_address: O§range_maps: Vec<RangeMap>

Implementations§

Source§

impl<R: Read + Seek, W: Write + Seek, A: Fn(u64) -> Result<u64>, O: Fn(u64) -> Result<u64>> BinaryPatcher<R, W, A, O>

Source

pub fn new( input: R, output: W, address_to_offset: A, offset_to_address: O, ) -> Result<Self>

Creates a new BinaryPatcher with the specified input and output streams.

Source

pub fn copy_up_to(&mut self, original_offset: u64) -> Result<()>

Copies data from the input stream to the output stream up to the specified address of original stream.

Source

pub fn map_offset(&mut self, original_offset: u64) -> Result<u64>

Maps an original offset to a new offset in the output stream.

Source

pub fn replace_bytes( &mut self, original_length: u64, new_data: &[u8], ) -> Result<()>

Replaces bytes in the output stream with new data, starting from the current position in the input stream.

  • original_length - The length of the original data to be replaced.
  • new_data - The new data to write to the output stream.
Source

pub fn replace_bytes_with_write<F: Fn(&mut W) -> Result<()>>( &mut self, original_length: u64, write: F, ) -> Result<()>

Replaces bytes in the output stream with new data, starting from the current position in the input stream.

  • original_length - The length of the original data to be replaced.
  • write - A function that writes the new data to the output stream.
Source

pub fn patch_u32_address(&mut self, original_offset: u64) -> Result<()>

Patches a u32 address in the output stream at the specified original offset.

Auto Trait Implementations§

§

impl<R, W, A, O> Freeze for BinaryPatcher<R, W, A, O>
where R: Freeze, W: Freeze, A: Freeze, O: Freeze,

§

impl<R, W, A, O> RefUnwindSafe for BinaryPatcher<R, W, A, O>

§

impl<R, W, A, O> Send for BinaryPatcher<R, W, A, O>
where R: Send, W: Send, A: Send, O: Send,

§

impl<R, W, A, O> Sync for BinaryPatcher<R, W, A, O>
where R: Sync, W: Sync, A: Sync, O: Sync,

§

impl<R, W, A, O> Unpin for BinaryPatcher<R, W, A, O>
where R: Unpin, W: Unpin, A: Unpin, O: Unpin,

§

impl<R, W, A, O> UnwindSafe for BinaryPatcher<R, W, A, O>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> ErasedDestructor for T
where T: 'static,