Skip to content

PeFileOpen

Description

Open and parse a PE file from disk.

Parameters

Name Direction Description
out out Populated on success.
path in Filesystem path.
alloc in Allocator for the read-in buffer and the sections vector. Must outlive the PeFile.

Success

Returns true; out is fully populated and out->owns_data is true.

Failure

Returns false; logs the failing step (open / magic / NT-signature / etc). out is left zeroed.

Usage example (Cross-references)

Usage examples (Cross-references)
    static bool entry_open(PdbCacheEntry *entry, Allocator *alloc) {
        if (!entry->pe_open) {
            if (!PeFileOpen(&entry->pe, entry->module_path, alloc))
                return false;
            entry->pe_open = true;
    }
    
    bool PeFileOpen(PeFile *out, const char *path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_ERROR("PeFileOpen: NULL argument");
    bool PeFileOpen(PeFile *out, const char *path, Allocator *alloc) {
        if (!out || !path || !alloc) {
            LOG_ERROR("PeFileOpen: NULL argument");
            return false;
        }
        u64   capacity = 0;
        if (!ReadCompleteFile(path, &buf, &bytes, &capacity, alloc)) {
            LOG_ERROR("PeFileOpen: failed to read {}", path);
            return false;
        }
Last updated on