Skip to content

MachoFileOpen

Description

Open and parse a Mach-O file from disk.

Success

Returns true; out->owns_data is true.

Failure

Returns false on read / magic / load-command parse error. Fat/universal headers (CAFEBABE) are rejected as unsupported in v1; the caller must pick a slice.

Usage example (Cross-references)

Usage examples (Cross-references)
    
        MachoFile m;
        if (!MachoFileOpen(&m, path, base)) {
            DefaultAllocatorDeinit(&alloc);
            return false;
    
        MachoFile m;
        if (!MachoFileOpen(&m, path, base)) {
            DefaultAllocatorDeinit(&alloc);
            return false;
        if (e->main_open)
            return true;
        if (!MachoFileOpen(&e->main, e->module_path, alloc))
            return false;
        e->main_open = true;
            return false;
        }
        if (!path_exists(path.data) || !MachoFileOpen(&e->dsym, path.data, alloc)) {
            StrDeinit(&path);
            return false;
    }
    
    bool MachoFileOpen(MachoFile *out, const char *path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_ERROR("MachoFileOpen: NULL argument");
    bool MachoFileOpen(MachoFile *out, const char *path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_ERROR("MachoFileOpen: NULL argument");
            return false;
        }
        u64   capacity = 0;
        if (!ReadCompleteFile(path, &buf, &bytes, &capacity, alloc)) {
            LOG_ERROR("MachoFileOpen: failed to read {}", path);
            return false;
        }
Last updated on