PeOpen
Description
Open and parse a PE file from disk.
Parameters
| Name | Direction | Description |
|---|---|---|
out |
out | Populated on success. |
path |
in | Filesystem path. Str * preferred; Zstr accepted. |
alloc |
in | Allocator for the read-in buffer and the sections vector. Must outlive the Pe. |
Success
Returns true; out owns the read-in buffer.
Failure
Returns false; logs the failing step. out is left zeroed.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
PdbCache.c:62:
static bool entry_open(PdbCacheEntry *entry, Allocator *alloc) {
if (!entry->pe_open) {
if (!PeOpen(&entry->pe, &entry->module_path, alloc))
return false;
entry->pe_open = true;- In
Pe.c:558:
bool pe_open(Pe *out, Zstr path, Allocator *alloc) {
if (!out || !path || !alloc) {
LOG_FATAL("PeOpen: NULL argument (contract violation)");
}
Buf data = BufInit(alloc);- In
Pe.c:563:
if (FileReadAndClose(path, &data) < 0) {
BufDeinit(&data);
LOG_ERROR("PeOpen: failed to read {}", path);
return false;
}- In
Pe.c:1666:
Pe pe;
bool ok = PeOpen(&pe, (Zstr)StrBegin(&path), base);
if (ok) {
ok = pe.machine == PE_MACHINE_X86_64 && VecLen(&pe.sections) == 1 &&- In
Pe.c:1708:
Pe pe;
bool opened = PeOpen(&pe, (Zstr)StrBegin(&path), base);
if (opened)
PeDeinit(&pe);
Last updated on