| 129 | } |
| 130 | |
| 131 | bool 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 | |
| 155 | bool PE::open() |
| 156 | { |
nothing calls this directly
no outgoing calls
no test coverage detected