pub struct Binary { /* private fields */ }
Expand description
This is the main interface to read and write Mach-O binary attributes.
Note that this structure implements the generic::Binary
trait from which other generic
functions are exposed
Implementations§
§impl Binary
impl Binary
pub fn commands(&self) -> CommandsIter<'_> ⓘ
pub fn commands(&self) -> CommandsIter<'_> ⓘ
Return an iterator over the different crate::macho::Commands
used by the
Mach-O binary
pub fn sections(&self) -> Sections<'_> ⓘ
pub fn sections(&self) -> Sections<'_> ⓘ
Return an iterator over the different crate::macho::Section
of the binary
pub fn segments(&self) -> Segments<'_> ⓘ
pub fn segments(&self) -> Segments<'_> ⓘ
Return an iterator over the different crate::macho::commands::Segment
(LC_SEGMENT/LC_SIGNATURE
)
of the binary.
pub fn libraries(&self) -> Libraries<'_> ⓘ
pub fn libraries(&self) -> Libraries<'_> ⓘ
Return an iterator over the crate::macho::commands::Dylib
used by this binary
pub fn relocations(&self) -> Relocations<'_> ⓘ
pub fn relocations(&self) -> Relocations<'_> ⓘ
Return an iterator over the different crate::macho::Relocation
of this binary
pub fn symbols(&self) -> Symbols<'_> ⓘ
pub fn symbols(&self) -> Symbols<'_> ⓘ
Return an iterator over the different crate::macho::Symbol
of this binary
pub fn dyld_info(&self) -> Option<DyldInfo<'_>>
pub fn dyld_info(&self) -> Option<DyldInfo<'_>>
Return the LC_DYLD_INFO/LC_DYLD_INFO_ONLY
command if present
pub fn main_command(&self) -> Option<Main<'_>>
pub fn main_command(&self) -> Option<Main<'_>>
Return the LC_MAIN
command if present
pub fn dylinker(&self) -> Option<Dylinker<'_>>
pub fn dylinker(&self) -> Option<Dylinker<'_>>
Return the LC_LOAD_DYLINKER/LC_ID_DYLINKER
command if present
pub fn function_starts(&self) -> Option<FunctionStarts<'_>>
pub fn function_starts(&self) -> Option<FunctionStarts<'_>>
Return the LC_FUNCTION_STARTS
command if present
pub fn source_version(&self) -> Option<SourceVersion<'_>>
pub fn source_version(&self) -> Option<SourceVersion<'_>>
Return the LC_SOURCE_VERSION
command if present
pub fn thread_command(&self) -> Option<ThreadCommand<'_>>
pub fn thread_command(&self) -> Option<ThreadCommand<'_>>
Return the LC_THREAD/LC_UNIXTHREAD
command if present
pub fn symbol_command(&self) -> Option<SymbolCommand<'_>>
pub fn symbol_command(&self) -> Option<SymbolCommand<'_>>
Return the LC_SYMTAB
command if present
pub fn dynamic_symbol(&self) -> Option<DynamicSymbolCommand<'_>>
pub fn dynamic_symbol(&self) -> Option<DynamicSymbolCommand<'_>>
Return the LC_DYSYMTAB
command if present
pub fn code_signature(&self) -> Option<CodeSignature<'_>>
pub fn code_signature(&self) -> Option<CodeSignature<'_>>
Return the LC_CODE_SIGNATURE
command if present
pub fn code_signature_dir(&self) -> Option<CodeSignatureDir<'_>>
pub fn code_signature_dir(&self) -> Option<CodeSignatureDir<'_>>
Return the LC_DYLIB_CODE_SIGN_DRS
command if present
pub fn data_in_code(&self) -> Option<DataInCode<'_>>
pub fn data_in_code(&self) -> Option<DataInCode<'_>>
Return the LC_DATA_IN_CODE
command if present
pub fn segment_split_info(&self) -> Option<SegmentSplitInfo<'_>>
pub fn segment_split_info(&self) -> Option<SegmentSplitInfo<'_>>
Return the LC_SEGMENT_SPLIT_INFO
command if present
pub fn encryption_info(&self) -> Option<EncryptionInfo<'_>>
pub fn encryption_info(&self) -> Option<EncryptionInfo<'_>>
Return the LC_ENCRYPTION_INFO/LC_ENCRYPTION_INFO_64
command if present
pub fn sub_framework(&self) -> Option<SubFramework<'_>>
pub fn sub_framework(&self) -> Option<SubFramework<'_>>
Return the LC_SUB_FRAMEWORK
command if present
pub fn subclients(&self) -> SubClients<'_> ⓘ
pub fn subclients(&self) -> SubClients<'_> ⓘ
Return the LC_SUBCLIENT
command if present
pub fn dyld_environment(&self) -> Option<DyldEnvironment<'_>>
pub fn dyld_environment(&self) -> Option<DyldEnvironment<'_>>
Return the LC_DYLD_ENVIRONMENT
command if present
pub fn build_version(&self) -> Option<BuildVersion<'_>>
pub fn build_version(&self) -> Option<BuildVersion<'_>>
Return the LC_BUILD_VERSION
command if present
pub fn dyld_chained_fixups(&self) -> Option<DyldChainedFixups<'_>>
pub fn dyld_chained_fixups(&self) -> Option<DyldChainedFixups<'_>>
Return the LC_DYLD_CHAINED_FIXUPS
command if present
pub fn dyld_exports_trie(&self) -> Option<DyldExportsTrie<'_>>
pub fn dyld_exports_trie(&self) -> Option<DyldExportsTrie<'_>>
Return the LC_DYLD_EXPORTS_TRIE
command if present
pub fn two_level_hints(&self) -> Option<TwoLevelHints<'_>>
pub fn two_level_hints(&self) -> Option<TwoLevelHints<'_>>
Return the LC_TWOLEVEL_HINTS
command if present
pub fn linker_opt_hint(&self) -> Option<LinkerOptHint<'_>>
pub fn linker_opt_hint(&self) -> Option<LinkerOptHint<'_>>
Return the LC_LINKER_OPTIMIZATION_HINT
command if present
pub fn version_min(&self) -> Option<VersionMin<'_>>
pub fn version_min(&self) -> Option<VersionMin<'_>>
Return the LC_VERSION_MIN_MACOSX/VERSION_MIN_IPHONEOS
command if present
pub fn support_arm64_ptr_auth(&self) -> bool
pub fn support_arm64_ptr_auth(&self) -> bool
Check if the binary is supporting ARM64 pointer authentication (arm64e)
pub fn bindings(&self) -> BindingsInfo<'_> ⓘ
pub fn bindings(&self) -> BindingsInfo<'_> ⓘ
Return an iterator over the bindings located in DyldInfo
or DyldChainedFixups
pub fn symbol_stubs(&self) -> Stubs<'_> ⓘ
pub fn symbol_stubs(&self) -> Stubs<'_> ⓘ
Return an iterator over the symbol stubs.
These stubs are involved when calling an imported function and are similar to the ELF’s plt/got mechanism.
There are located in sections like: __stubs,__auth_stubs,__symbol_stub,__picsymbolstub4
pub fn objc_metadata(&self) -> Option<Metadata<'_>>
pub fn objc_metadata(&self) -> Option<Metadata<'_>>
Return Objective-C metadata if present
pub fn get_int_from_virtual_address<T>(&self, addr: u64) -> Result<T, Error>where
T: Num + FromPrimitive + ToPrimitive,
pub fn get_int_from_virtual_address<T>(&self, addr: u64) -> Result<T, Error>where T: Num + FromPrimitive + ToPrimitive,
Get the integer value at the given virtual address
pub fn write(&mut self, output: &Path)
pub fn write(&mut self, output: &Path)
Write back the current MachO binary into the file specified in parameter
pub fn write_with_config(&mut self, output: &Path, config: Config)
pub fn write_with_config(&mut self, output: &Path, config: Config)
Write back the current MachO binary into the file specified in parameter with the configuration provided in the second parameter.
pub fn add_library<'a>(&'a mut self, libname: &str) -> Dylib<'a>
pub fn add_library<'a>(&'a mut self, libname: &str) -> Dylib<'a>
Insert a new shared library through a LC_LOAD_DYLIB
command
Trait Implementations§
§impl Binary for Binary
impl Binary for Binary
§fn entrypoint(&self) -> u64
fn entrypoint(&self) -> u64
§fn original_size(&self) -> u64
fn original_size(&self) -> u64
§fn debug_info(&self) -> Option<DebugInfo<'_>>
fn debug_info(&self) -> Option<DebugInfo<'_>>
crate::pdb::DebugInfo
or crate::dwarf::DebugInfo
. Read more§fn disassemble(&self, address: u64, size: u64) -> InstructionsIt<'_> ⓘ
fn disassemble(&self, address: u64, size: u64) -> InstructionsIt<'_> ⓘ
§fn disassemble_symbol(&self, name: &str) -> InstructionsIt<'_> ⓘ
fn disassemble_symbol(&self, name: &str) -> InstructionsIt<'_> ⓘ
§fn disassemble_address(&self, address: u64) -> InstructionsIt<'_> ⓘ
fn disassemble_address(&self, address: u64) -> InstructionsIt<'_> ⓘ
§fn disassemble_slice(&self, slice: &[u8], address: u64) -> InstructionsIt<'_> ⓘ
fn disassemble_slice(&self, slice: &[u8], address: u64) -> InstructionsIt<'_> ⓘ
address
parameter. Read more