PeDeinit
Description
Release storage owned by a Pe. Frees the data Buf through its carried allocator (unconditional – parser always owns its bytes) and tears down the sections vector. Safe on a zeroed struct.
Success
Returns to the caller. *self is zeroed.
Failure
Function cannot fail. NULL self is a no-op.
Usage example (Cross-references)
Usage examples (Cross-references)
- In
PdbCache.c:126:
PdbDeinit(&e->pdb);
if (e->pe_open)
PeDeinit(&e->pe);
StrDeinit(&e->module_path);
}- In
Pe.c:537:
fail:
PeDeinit(out);
return false;
}- In
Pe.c:569:
}
void PeDeinit(Pe *self) {
if (!self)
return;- In
Pe.c:502:
ok = ok && pe.codeview.pdb_path && ZstrCompare(pe.codeview.pdb_path, kPdbPath) == 0;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:526:
ok = ok && !PeRvaToOffset(&pe, 0xdead0000, &garbage);
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:564:
ok = ok && PeFindSection(&pe, ".nope") == NULL;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:594:
ok = ok && !PeRvaToOffset(&pe, 0x100, &low);
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:605:
bool opened = PeOpenFromMemoryCopy(&pe, bytes, len, ALLOCATOR_OF(&alloc));
if (opened)
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return !opened;- In
Pe.c:666:
ok = ok && pe.image_base == PE_IMAGE_BASE; // L230 assign, image_base assembly
ok = ok && pe.size_of_image == PE_SIZE_OF_IMAGE;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:685:
}
bool ok = pe.image_base == 0x7766554433221100ull;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:704:
ok = ok && pe.size_of_image == PE_SIZE_OF_IMAGE;
ok = ok && pe.machine == PE_MACHINE_I386;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:721:
}
bool ok = pe.image_base == 0x00410000ull;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:744:
bool ok = PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc));
if (ok)
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:766:
bool opened = PeOpenFromMemoryCopy(&pe, bad, sizeof(bad), ALLOCATOR_OF(&alloc));
if (opened)
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return !opened;- In
Pe.c:795:
if (ok) {
ok = ok && pe.size_of_image == PE_SIZE_OF_IMAGE;
PeDeinit(&pe);
}
DefaultAllocatorDeinit(&alloc);- In
Pe.c:818:
}
bool ok = pe.codeview.present && pe.codeview.age == CV_AGE;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:844:
}
bool ok = pe.codeview.present == false; // no debug dir -> absent
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:868:
ok = ok && pe.codeview.age == CV_AGE;
ok = ok && pe.codeview.pdb_path && ZstrCompare(pe.codeview.pdb_path, kPdbPath) == 0;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:886:
}
bool ok = pe.codeview.present == false; // L424 default must survive
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:903:
}
bool ok = pe.codeview.present == false;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:933:
}
bool ok = pe.codeview.present == false; // unterminated -> rejected
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:961:
}
bool ok = pe.codeview.present == true && ZstrCompare(pe.codeview.pdb_path, "ABCD") == 0;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:986:
}
bool ok = pe.codeview.present == true && pe.codeview.age == CV_AGE && ZstrCompare(pe.codeview.pdb_path, "") == 0;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1002:
}
bool ok = pe.codeview.present == false;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1026:
}
bool ok = pe.codeview.present == false;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1050:
}
bool ok = pe.codeview.present == true && pe.codeview.age == CV_AGE && MemCompare(pe.codeview.guid, kGuid, 16) == 0;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1070:
}
bool ok = pe.codeview.present == true && pe.codeview.age == CV_AGE && MemCompare(pe.codeview.guid, kGuid, 16) == 0;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1094:
}
bool ok = pe.codeview.present == false;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1124:
}
bool ok = pe.codeview.present == false; // real rejects the overrun
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1147:
}
bool ok = pe.codeview.present == true && pe.codeview.age == CV_AGE && MemCompare(pe.codeview.guid, kGuid, 16) == 0;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1175:
}
bool ok = pe.codeview.present == false; // NUL past region_end ignored
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1202:
}
bool ok = pe.codeview.present == false; // only index 0 may be read
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1243:
}
bool ok = pe.codeview.present == true && pe.codeview.age == CV_AGE && MemCompare(pe.codeview.guid, kGuid, 16) == 0;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1285:
ok = ok && VecPtrAt(&pe.sections, 1)->virtual_address == 0x2000;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1315:
}
bool ok = VecLen(&pe.sections) == 2;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1344:
ok = ok && ZstrLen(s->name) == 8;
ok = ok && ZstrCompare(s->name, "ABCDEFGH") == 0;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1370:
bool opened = PeOpenFromMemoryCopy(&pe, blob, total, ALLOCATOR_OF(&alloc));
if (opened)
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return !opened;- In
Pe.c:1409:
u64 off = 0;
bool ok = PeRvaToOffset(&pe, 0x2040, &off) && off == 0x340;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1448:
ok = ok && !PeRvaToOffset(&pe, 0x0FFF, &tmp); // just below start
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1487:
ok = ok && !PeRvaToOffset(&pe, 0x1010, &past);
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1513:
u64 off = 0xdead;
bool ok = !PeRvaToOffset(&pe, 0x9000, &off);
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1549:
ok = ok && PeFindSection(&pe, ".text") != NULL;
ok = ok && PeFindSection(&pe, ".absent") == NULL;
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1592:
ok = ok && PeFindSection(&pe, "") == NULL; // L580 upper bound
PeDeinit(&pe);
DebugAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1623:
bool ok = !opened && BufData(&pe.data) == NULL && BufLength(&pe.data) == 0 && VecLen(&pe.sections) == 0;
if (opened)
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1670:
ok = pe.machine == PE_MACHINE_X86_64 && VecLen(&pe.sections) == 1 &&
ZstrCompare(VecPtrAt(&pe.sections, 0)->name, ".text") == 0;
PeDeinit(&pe);
}- In
Pe.c:1710:
bool opened = PeOpen(&pe, (Zstr)StrBegin(&path), base);
if (opened)
PeDeinit(&pe);
FileRemove(&path);- In
Pe.c:1737:
bool ok = PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc));
if (ok)
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return ok;- In
Pe.c:1758:
bool opened = PeOpenFromMemoryCopy(&pe, blob, sizeof(blob), ALLOCATOR_OF(&alloc));
if (opened)
PeDeinit(&pe);
DefaultAllocatorDeinit(&alloc);
return !opened;
Last updated on