11#include "../utils/artefacts_util.h"
22 namesRVA(0), namesBuf(
nullptr), namesBufSize(0),
23 dllsRVA(0), dllsBufSize(0), dllsBuf(
nullptr)
51 if (!this->namesBuf) {
52 this->namesBufSize = 0;
66 this->dllsBufSize = 0;
77 return descriptosCount;
89 if (!this->namesBuf)
return 0;
90 return this->namesBufSize;
100 return descriptorsRVA;
110 if ((descriptorsRVA +
descriptors_size_b) > vBufSize || (namesRVA + namesBufSize) > vBufSize) {
124 memcpy(vBuf + namesRVA, namesBuf, namesBufSize);
125 memcpy(vBuf + dllsRVA, dllsBuf, dllsBufSize);
128 imp_dir->VirtualAddress = descriptorsRVA;
144 DWORD descriptorsRVA;
145 size_t descriptosCount;
163 if (!peBuffer.
vBuf)
return;
165 this->is64bit = peconv::is64bit(peBuffer.
vBuf);
171 collectMainIatData();
209 void collectMainIatData();
212 bool hasDynamicIAT()
const;
214 size_t getMainIATSize()
const;
218 bool findImportTable(
IN const peconv::ExportsMapper* exportsMap);
219 size_t collectIATs(
IN const peconv::ExportsMapper* exportsMap);
221 bool isDefaultImportValid(
IN const peconv::ExportsMapper* exportsMap);
229 if (foundIATs.find(
iat_offset) != foundIATs.end()) {
236 void deleteFoundIATs()
238 std::map<DWORD, IATBlock*>::iterator
itr;
239 for (
itr = foundIATs.begin();
itr != foundIATs.end(); ++
itr) {
247 std::map<DWORD, IATBlock*> foundIATs;
249 std::set<DWORD> mainIatThunks;
#define PATTERN_NOT_FOUND
t_imprec_res rebuildImportTable(const IN peconv::ExportsMapper *exportsMap, IN const pesieve::t_imprec_mode &imprec_mode)
ImpReconstructor(PeBuffer &_peBuffer)
enum pesieve::ImpReconstructor::imprec_res t_imprec_res
bool printFoundIATs(std::string reportPath)
enum pesieve::ImpReconstructor::imprec_filter t_imprec_filter
@ IMP_RECOVERY_NOT_APPLICABLE
bool allocDllsSpace(DWORD dlls_rva, size_t dlls_area_size)
bool allocNamesSpace(DWORD names_rva, size_t names_size)
BYTE * getDllSpaceAt(const DWORD rva, size_t required_size)
ImportTableBuffer(DWORD _descriptorsRVA)
BYTE * getNamesSpaceAt(const DWORD rva, size_t required_size)
bool setTableInPe(BYTE *vBuf, size_t vBufSize)
size_t getDescriptorsSize()
bool allocDesciptors(size_t descriptors_count)
size_t getDescriptosCount()
IMAGE_IMPORT_DESCRIPTOR * descriptors
#define MASK_TO_DWORD(val)
size_t is_64bit_code(BYTE *loadedData, size_t loadedSize)
size_t fill_iat(BYTE *vBuf, size_t vBufSize, IN const peconv::ExportsMapper *exportsMap, IN OUT IATBlock &iat, IN ThunkFoundCallback *callback)
The types used by PE-sieve API.