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)
- In
Pe.c:498:
// 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)");- In
Pe.c:500:
bool PeOpenFromMemory(Pe *out, Buf *in) {
if (!out || !in || !in->data || !in->allocator) {
LOG_FATAL("PeOpenFromMemory: NULL argument (contract violation)");
}
Buf taken = *in;- In
Pe.c:545:
MemCopy(BufData(©), data, data_size);
copy.length = (size)data_size;
return PeOpenFromMemory(out, ©);
}- In
Pe.c:558:
return false;
}
return PeOpenFromMemory(out, &data);
}
Last updated on