77 this->artefacts = origArtefacts;
79 ULONGLONG moduleBase = artefacts.regionStart + artefacts.peBaseOffset;
80 if (!peBuffer.readRemote(moduleBase, artefacts.calculatedImgSize)) {
85 std::cout <<
"[!] The PE header was shifted by: " << std::hex <<
shift_size << std::endl;
88 if (this->artefacts.hasNtHdrs() && reconstructFileHdr()) {
95 if (!peconv::is_pe_raw(peBuffer.vBuf, peBuffer.vBufSize)) {
96 if (!fixSectionsVirtualSize(peBuffer.processHndl) || !fixSectionsCharacteristics(peBuffer.processHndl)) {
100 return peBuffer.isValidPe();
105 BYTE *vBuf = this->peBuffer.vBuf;
106 const size_t vBufSize = this->peBuffer.vBufSize;
107 if (!vBuf)
return false;
109 if (!this->artefacts.hasSectionHdrs()) {
122 const size_t hdr_sec_count = peconv::get_sections_count(vBuf, vBufSize);
140 std::cout <<
i <<
"# Invalid section found: " << std::hex
149 std::cout <<
i <<
"# Fixed section " << std::hex <<
sec_rva <<
" size: " << std::hex
163 std::cout <<
"Trimmed section: " << std::dec <<
i << std::endl;
168 if (
curr_sec->Misc.VirtualSize > 0) {
224 BYTE *vBuf = this->peBuffer.vBuf;
225 const size_t vBufSize = this->peBuffer.vBufSize;
226 if (!vBuf)
return false;
228 if (!this->artefacts.hasNtHdrs()) {
231 size_t nt_offset = this->artefacts.dropPeBase(this->artefacts.ntFileHdrsOffset);
243 if (artefacts.is64bit) {
251 if (this->artefacts.secHdrsOffset) {
252 const size_t sec_offset = this->artefacts.dropPeBase(this->artefacts.secHdrsOffset);
256 std::cout <<
"[WARNING] Calculated sections header offset is different than the saved one!\n";
268 BYTE *vBuf = this->peBuffer.vBuf;
269 const size_t vBufSize = this->peBuffer.vBufSize;
270 if (!vBuf)
return false;
272 if (!this->artefacts.hasNtHdrs()) {
279 if (!peconv::validate_ptr(vBuf, vBufSize,
pe_ptr,
sizeof(DWORD))) {
289 if (
nt32->FileHeader.SizeOfOptionalHeader == 0) {
307 if (!peconv::get_nt_hdrs(vBuf, vBufSize)) {
size_t fill_iat(BYTE *vBuf, size_t vBufSize, IN const peconv::ExportsMapper *exportsMap, IN OUT IATBlock &iat, IN ThunkFoundCallback *callback)