GitXplorerGitXplorer
f

rust-macho

public
90 stars
18 forks
6 issues

Commits

List of commits on branch master.
Unverified
4bf5fb1f2a0ab02dc09e7f51a95a46e780b1354c

bump version

fflier committed 3 years ago
Unverified
9e8869d22b1dc515a23481e1b580edfe4b988dea

extract parse fat arch code

fflier committed 3 years ago
Unverified
32501c8033fec2e4622caf5d15d9e2281e1d0ba9

parse FAT header with big endian, #23

fflier committed 3 years ago
Unverified
560bef0ef4a7f3442f7d243c2209a0c0ee06e5bd

fix clippy hints

fflier committed 3 years ago
Unverified
5329f294cf26865a02b69d2c97bfd3c3d24a3a38

upgrade uuid

fflier committed 3 years ago
Unverified
6a2b9c76ffc5ec18c748a3ea67f675e6a3e2b981

bump version

fflier committed 3 years ago

README

The README file for this repository.

rust-macho travis crate docs

Mach-O File Format Parser for Rust

Usage

To use, add the following line to Cargo.toml under [dependencies]:

mach_object = "0.1"

or alternatively,

mach_object = { git = "https://github.com/flier/rust-macho.git" }

Examples

Use OFile::parse to read the mach-o file from a &[u8] slice.

use std::io::{Read, Cursor};
use std::fs::File;
use mach_object::{OFile, CPU_TYPE_X86_64, MachCommand, LoadCommand};

let mut f = File::open("test/helloworld").unwrap();
let mut buf = Vec::new();
let size = f.read_to_end(&mut buf).unwrap();
let mut cur = Cursor::new(&buf[..size]);
if let OFile::MachFile { ref header, ref commands } = OFile::parse(&mut cur).unwrap() {
    assert_eq!(header.cputype, CPU_TYPE_X86_64);
    assert_eq!(header.ncmds as usize, commands.len());
    for &MachCommand(ref cmd, cmdsize) in commands {
        if let &LoadCommand::Segment64 { ref segname, ref sections, .. } = cmd {
            println!("segment: {}", segname);

            for ref sect in sections {
                println!("  section: {}", sect.sectname);
            }
        }
    }
}

For more detail, please check the unit tests and the otool example.