MCPcopy Create free account
hub / github.com/connorjaydunn/BinaryShield / parseHeaders

Method parseHeaders

src/pe.cpp:131–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

129}
130
131bool PE::parseHeaders()
132{
133 // verify we have a pe via the dos header
134 pDosHeader = (PIMAGE_DOS_HEADER)bytes.data();
135 if (pDosHeader->e_magic != IMAGE_DOS_SIGNATURE)
136 {
137 std::cerr << "invalid dos header" << std::endl;
138 return 0;
139 }
140
141 // verify we havea valid pe via the nt header
142 pNtHeader = (PIMAGE_NT_HEADERS)(bytes.data() + pDosHeader->e_lfanew);
143 if (pNtHeader->Signature != IMAGE_NT_SIGNATURE)
144 {
145 std::cerr << "invalid nt header" << std::endl;
146 return 0;
147 }
148
149 // pSectionHeader is a pointer to the start of an array of type IMAGE_SECTION_HEADER
150 pSectionHeader = (PIMAGE_SECTION_HEADER)(bytes.data() + pDosHeader->e_lfanew + sizeof(IMAGE_NT_HEADERS));
151
152 return 1;
153}
154
155bool PE::open()
156{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected