MCPcopy Create free account
hub / github.com/BeneficialCode/WinArk / CheckValidity

Method CheckValidity

KernelLibrary/PEParser.cpp:33–52  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

31}
32
33void PEParser::CheckValidity() {
34 _dosHeader = reinterpret_cast<IMAGE_DOS_HEADER*>(_address);
35 if (_dosHeader->e_magic != IMAGE_DOS_SIGNATURE) {
36 _valid = false;
37 return;
38 }
39 else {
40 auto ntHeader = (PIMAGE_NT_HEADERS64)(_address + _dosHeader->e_lfanew);
41 if (ntHeader->Signature != IMAGE_NT_SIGNATURE) {
42 _valid = false;
43 return;
44 }
45 _ntHeader = ntHeader;
46 _fileHeader = &ntHeader->FileHeader;
47 _opt64 = &ntHeader->OptionalHeader;
48 _opt32 = (PIMAGE_OPTIONAL_HEADER32)_opt64;
49 _sections = (PIMAGE_SECTION_HEADER)((UCHAR*)_opt64 + _fileHeader->SizeOfOptionalHeader);
50 _valid = true;
51 }
52}
53
54int PEParser::GetSectionCount() const {
55 if (!IsValid())

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected