Skip to content
PeOpenFromMemory

PeOpenFromMemory

Description

Parse a PE image from an in-memory byte range – L-value / ownership-transfer form (mirrors VecInsertL).

data is u8 **: ownership is moving from caller to parser. On entry *data is the caller’s buffer (allocated through alloc); on exit (success OR failure) *data == NULL. Calling code:

u8 *buf = my_buffer; PeOpenFromMemory(&pe, &buf, n, &alloc); // buf == NULL afterwards.

Success

Returns true; out owns the bytes; *data == NULL.

Failure

Returns false; the bytes have been freed through alloc; *data == NULL; out is left zeroed.

Usage example (Cross-references)

Usage examples (Cross-references)
    // MemSets the caller's view. Anything that fails past the snapshot
    // cleans up via PeDeinit -- the buffer never leaks.
    bool PeOpenFromMemory(Pe *out, Buf *in) {
        if (!out || !in || !in->data || !in->allocator) {
            LOG_FATAL("PeOpenFromMemory: NULL argument (contract violation)");
    bool PeOpenFromMemory(Pe *out, Buf *in) {
        if (!out || !in || !in->data || !in->allocator) {
            LOG_FATAL("PeOpenFromMemory: NULL argument (contract violation)");
        }
        Buf taken = *in;
        MemCopy(BufData(&copy), data, data_size);
        copy.length = (size)data_size;
        return PeOpenFromMemory(out, &copy);
    }
            return false;
        }
        return PeOpenFromMemory(out, &data);
    }
Last updated on