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>
impl<R: Read + Seek, W: Write + Seek, A: Fn(u64) -> Result<u64>, O: Fn(u64) -> Result<u64>> BinaryPatcher<R, W, A, O>
Sourcepub fn new(
input: R,
output: W,
address_to_offset: A,
offset_to_address: O,
) -> Result<Self>
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.
Sourcepub fn copy_up_to(&mut self, original_offset: u64) -> Result<()>
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.
Sourcepub fn map_offset(&mut self, original_offset: u64) -> Result<u64>
pub fn map_offset(&mut self, original_offset: u64) -> Result<u64>
Maps an original offset to a new offset in the output stream.
Sourcepub fn replace_bytes(
&mut self,
original_length: u64,
new_data: &[u8],
) -> Result<()>
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.
Sourcepub fn replace_bytes_with_write<F: Fn(&mut W) -> Result<()>>(
&mut self,
original_length: u64,
write: F,
) -> Result<()>
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.
Sourcepub fn patch_u32_address(&mut self, original_offset: u64) -> Result<()>
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>
impl<R, W, A, O> RefUnwindSafe for BinaryPatcher<R, W, A, O>
impl<R, W, A, O> Send for BinaryPatcher<R, W, A, O>
impl<R, W, A, O> Sync for BinaryPatcher<R, W, A, O>
impl<R, W, A, O> Unpin for BinaryPatcher<R, W, A, O>
impl<R, W, A, O> UnwindSafe for BinaryPatcher<R, W, A, O>
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
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>
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 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>
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