33 if (!vBuf || !exportsMap || !iat.iatOffset)
return 0;
35 size_t max_check = vBufSize -
sizeof(FIELD_T);
36 if (max_check <
sizeof(FIELD_T)) {
40 iat.isTerminated =
true;
41 const peconv::ExportedFunc *exp =
nullptr;
44 bool is_terminated =
true;
45 FIELD_T *imp = (FIELD_T*)(iat.iatOffset + (ULONG_PTR)vBuf);
46 for (; imp < (FIELD_T*)(vBuf + max_check); imp++) {
50 iat.appendSeries(series);
56 const FIELD_T imp_va = (*imp);
59 if (!callback->shouldProcessVA(imp_va))
break;
63 const peconv::ExportedFunc *exp = exportsMap->find_export_by_va(imp_va);
67 if (!callback->shouldAcceptExport(imp_va, *exp))
break;
70 is_terminated =
false;
72 iat.append(offset, imp_va, exp);
76 series->
insert(offset, imp_va);
80 iat.appendSeries(series);
83 iat.isTerminated = is_terminated;
84 if (!exp && iat.iatOffset && iat.countThunks() > 0) {
85 BYTE *iat_ptr = (BYTE*)(iat.iatOffset + (ULONG_PTR)vBuf);
86 size_t diff = (BYTE*)imp - iat_ptr;
96 if (!vBuf || !vBufSize || !exportsMap)
return nullptr;
98 const bool is64bit = (
sizeof(FIELD_T) ==
sizeof(DWORD)) ?
false :
true;
100 size_t max_check = vBufSize -
sizeof(FIELD_T);
101 if (search_offset > vBufSize || max_check <
sizeof(FIELD_T)) {
105 for (BYTE* ptr = vBuf + search_offset; ptr < vBuf + max_check; ptr++) {
106 FIELD_T *to_check = (FIELD_T*)ptr;
107 if (!peconv::validate_ptr(vBuf, vBufSize, to_check,
sizeof(FIELD_T)))
break;
108 FIELD_T possible_va = (*to_check);
109 if (possible_va == 0)
continue;
112 if (!callback->shouldProcessVA(possible_va))
continue;
116 const peconv::ExportedFunc *exp = exportsMap->find_export_by_va(possible_va);
120 if (!callback->shouldAcceptExport(possible_va, *exp))
continue;
123 DWORD iat_offset = DWORD(ptr - vBuf);
126 size_t _iat_size =
fill_iat<FIELD_T>(vBuf, vBufSize, exportsMap, *iat_block, callback);
128 iat_block->
iatSize = _iat_size;
131 delete iat_block; iat_block =
nullptr;
size_t fill_iat(BYTE *vBuf, size_t vBufSize, IN const peconv::ExportsMapper *exportsMap, IN OUT IATBlock &iat, IN ThunkFoundCallback *callback)
IATBlock * find_iat(BYTE *vBuf, size_t vBufSize, IN const peconv::ExportsMapper *exportsMap, IN size_t search_offset, IN ThunkFoundCallback *callback)