Skip to content
PeFileOpenFromMemory

PeFileOpenFromMemory

Description

Parse a PE image from an in-memory byte range. The data buffer is borrowed – the caller must keep it alive for the lifetime of the returned PeFile.

Success

Returns true; out->owns_data is false.

Failure

Returns false; logs the failing step. out is left zeroed.

Usage example (Cross-references)

Usage examples (Cross-references)
    
        PeFile pe;
        bool   ok = PeFileOpenFromMemory(&pe, blob, sizeof(blob), base);
        if (!ok) {
            DefaultAllocatorDeinit(&alloc);
        build_pe_blob();
        PeFile pe;
        if (!PeFileOpenFromMemory(&pe, blob, sizeof(blob), base)) {
            DefaultAllocatorDeinit(&alloc);
            return false;
    
        PeFile pe;
        bool   ok = !PeFileOpenFromMemory(&pe, garbage, sizeof(garbage), base);
    
        DefaultAllocatorDeinit(&alloc);
    // ---------------------------------------------------------------------------
    
    bool PeFileOpenFromMemory(PeFile *out, u8 *data, size data_size, Allocator *alloc) {
        if (!out || !data || !alloc) {
            LOG_ERROR("PeFileOpenFromMemory: NULL argument");
    bool PeFileOpenFromMemory(PeFile *out, u8 *data, size data_size, Allocator *alloc) {
        if (!out || !data || !alloc) {
            LOG_ERROR("PeFileOpenFromMemory: NULL argument");
            return false;
        }
            return false;
        }
        if (!PeFileOpenFromMemory(out, (u8 *)buf, (size)bytes, alloc)) {
            AllocatorFree(alloc, buf, capacity);
            return false;
Last updated on