MachoOpenFromMemoryCopy
Description
Parse a Mach-O image from an in-memory byte range – R-value / copy form (mirrors VecInsertR).
Parser allocates its own buffer through alloc and MemCopys the caller’s bytes in. Caller’s pointer is never retained; their buffer remains theirs.
Success
Returns true; out owns an independent copy of data.
Failure
Returns false; out zeroed; caller’s data untouched.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
MachO.c:449:
bool macho_open_from_memory_copy(Macho *out, const u8 *data, size data_size, Allocator *alloc) {
if (!out || !data || !alloc) {
LOG_FATAL("MachoOpenFromMemoryCopy: NULL argument (contract violation)");
}
Buf copy = BufInit(alloc);- In
MachO.c:453:
Buf copy = BufInit(alloc);
if (!VecReserve(©, (u64)data_size)) {
LOG_ERROR("MachoOpenFromMemoryCopy: allocation failed ({} bytes)", (u64)data_size);
return false;
}- In
MachO.c:227:
// MachoDeinit on success.
static bool open_blob(Macho *out, const u8 *bytes, u32 len, DefaultAllocator *alloc) {
return MachoOpenFromMemoryCopy(out, bytes, len, ALLOCATOR_OF(alloc));
}- In
MachO.c:352:
Macho m;
bool ok = MachoOpenFromMemoryCopy(&m, blob, sizeof(blob), base);
if (!ok) {
DefaultAllocatorDeinit(&alloc);- In
MachO.c:381:
Macho m;
if (!MachoOpenFromMemoryCopy(&m, blob, sizeof(blob), base)) {
DefaultAllocatorDeinit(&alloc);
return false;- In
MachO.c:412:
Macho m;
bool ok = !MachoOpenFromMemoryCopy(&m, fat, sizeof(fat), base);
DefaultAllocatorDeinit(&alloc);- In
MachO.c:429:
Macho m;
if (!MachoOpenFromMemoryCopy(&m, blob, sizeof(blob), base)) {
DefaultAllocatorDeinit(&alloc);
return false;- In
MachO.c:450:
DefaultAllocator alloc = DefaultAllocatorInit();
Macho m;
bool opened = MachoOpenFromMemoryCopy(&m, bytes, len, ALLOCATOR_OF(&alloc));
if (opened)
MachoDeinit(&m);- In
MachO.c:528:
Macho m;
if (!MachoOpenFromMemoryCopy(&m, two_blob, sizeof(two_blob), base)) {
DefaultAllocatorDeinit(&alloc);
return false;- In
MachO.c:1127:
Macho m;
bool ok = MachoOpenFromMemoryCopy(&m, buf, sizeof(buf), base);
ok = ok && VecLen(&m.segments) == 0 && VecLen(&m.sections) == 0;
ok = ok && m.cputype == 0x01000007u && m.filetype == MACHO_FILE_TYPE_EXECUTE;- In
MachO.c:1163:
Macho m;
bool ok = MachoOpenFromMemoryCopy(&m, buf, sizeof(buf), base);
ok = ok && VecLen(&m.segments) == 1 && VecLen(&m.sections) == 0;
ok = ok && ZstrCompare(VecPtrAt(&m.segments, 0)->name, "__TEXT") == 0;- In
MachO.c:1195:
Macho m;
bool ok = MachoOpenFromMemoryCopy(&m, buf, sizeof(buf), base);
ok = ok && VecLen(&m.segments) == 1;
ok = ok && ZstrCompare(VecPtrAt(&m.segments, 0)->name, "ABCDEFGHIJKLMNOP") == 0;- In
MachO.c:1216:
Macho m;
bool ok = MachoOpenFromMemoryCopy(&m, buf, len, base);
ok = ok && VecLen(&m.segments) == 1 && VecLen(&m.sections) == 2;
ok = ok && VecPtrAt(&m.sections, 0)->addr == 0x100000000ull;- In
MachO.c:1257:
Macho m;
bool ok = MachoOpenFromMemoryCopy(&m, buf, sizeof(buf), base);
ok = ok && VecLen(&m.sections) == 1;
ok = ok && ZstrCompare(VecPtrAt(&m.sections, 0)->section, "abcdefghijklmnop") == 0;- In
MachO.c:1288:
Macho m;
bool ok = MachoOpenFromMemoryCopy(&m, buf, sizeof(buf), base);
ok = ok && VecLen(&m.segments) == 1;
if (ok)- In
MachO.c:1319:
Macho m;
bool ok = MachoOpenFromMemoryCopy(&m, buf, sizeof(buf), base);
ok = ok && VecLen(&m.segments) == 0 && VecLen(&m.sections) == 0;
if (ok)- In
MachO.c:1343:
Macho m;
if (!MachoOpenFromMemoryCopy(&m, g_symblob, len, base)) {
DefaultAllocatorDeinit(&alloc);
return false;- In
MachO.c:1383:
Macho m;
if (!MachoOpenFromMemoryCopy(&m, g_symblob, len, base)) {
DefaultAllocatorDeinit(&alloc);
return false;- In
MachO.c:1500:
Macho m;
bool opened = MachoOpenFromMemoryCopy(&m, buf, sizeof(buf), base);
if (opened)
MachoDeinit(&m);- In
MachO.c:1548:
Macho m;
bool ok = MachoOpenFromMemoryCopy(&m, b, BUF, base);
// Canonical-true check: real code stores exactly `true` (== 1); the
// mutant stores 42, so `== true` is false under the mutation.
Last updated on