pub struct MachOBinary<'a> {
    pub index: Option<usize>,
    pub macho: MachO<'a>,
    pub data: &'a [u8],
}
Expand description

A Mach-O binary.

Fields

index: Option<usize>

Index within a fat binary this Mach-O resides at.

If None, this is not inside a fat binary.

macho: MachO<'a>

The parsed Mach-O binary.

data: &'a [u8]

The raw data backing the Mach-O binary.

Implementations

Parse a non-universal Mach-O binary from raw data.

Attempt to extract a reference to raw signature data in a Mach-O binary.

An LC_CODE_SIGNATURE load command in the Mach-O file header points to signature data in the __LINKEDIT segment.

This function is used as part of parsing signature data. You probably want to use a function that parses referenced data.

Obtain the code signature in the entity.

Returns Ok(None) if no signature exists, Ok(Some) if it does, or Err if there is a parse error.

Determine the start and end offset of the executable segment of a binary.

Whether this is an executable Mach-O file.

The start offset of the code signature data within the __LINKEDIT segment.

The end offset of the code signature data within the __LINKEDIT segment.

The byte offset within the binary at which point “code” stops.

If a signature is present, this is the offset of the start of the signature. Else it represents the end of the binary.

Obtain __LINKEDIT segment data before the signature data.

If there is no signature, returns all the data for the __LINKEDIT segment.

Obtain slices of segment data suitable for digesting.

The slices are likely digested as part of computing digests embedded in the code directory.

Resolve the load command for the code signature.

Attempt to locate embedded Info.plist data.

Determines whether this crate is capable of signing a given Mach-O binary.

Code in this crate is limited in the amount of Mach-O binary manipulation it can perform (supporting rewriting all valid Mach-O binaries effectively requires low-level awareness of all Mach-O constructs in order to perform offset manipulation). This function can be used to test signing compatibility.

We currently only support signing Mach-O files already containing an embedded signature. Often linked binaries automatically contain an embedded signature containing just the code directory (without a cryptographically signed signature), so this limitation hopefully isn’t impactful.

Estimate the size in bytes of an embedded code signature.

Attempt to resolve the mach-o targeting settings.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Converts self into T using Into<T>. Read more

Causes self to use its Binary implementation when Debug-formatted. Read more

Causes self to use its Display implementation when Debug-formatted. Read more

Causes self to use its LowerExp implementation when Debug-formatted. Read more

Causes self to use its LowerHex implementation when Debug-formatted. Read more

Causes self to use its Octal implementation when Debug-formatted. Read more

Causes self to use its Pointer implementation when Debug-formatted. Read more

Causes self to use its UpperExp implementation when Debug-formatted. Read more

Causes self to use its UpperHex implementation when Debug-formatted. Read more

Formats each item in a sequence. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Pipes by value. This is generally the method you want to use. Read more

Borrows self and passes that borrow into the pipe function. Read more

Mutably borrows self and passes that borrow into the pipe function. Read more

Borrows self, then passes self.borrow() into the pipe function. Read more

Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more

Borrows self, then passes self.as_ref() into the pipe function.

Mutably borrows self, then passes self.as_mut() into the pipe function. Read more

Borrows self, then passes self.deref() into the pipe function.

Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more

Should always be Self

Immutable access to a value. Read more

Mutable access to a value. Read more

Immutable access to the Borrow<B> of a value. Read more

Mutable access to the BorrowMut<B> of a value. Read more

Immutable access to the AsRef<R> view of a value. Read more

Mutable access to the AsMut<R> view of a value. Read more

Immutable access to the Deref::Target of a value. Read more

Mutable access to the Deref::Target of a value. Read more

Calls .tap() only in debug builds, and is erased in release builds.

Calls .tap_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more

Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref() only in debug builds, and is erased in release builds. Read more

Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref() only in debug builds, and is erased in release builds. Read more

Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more

Attempts to convert self into T using TryInto<T>. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more