38 ULONGLONG field_end = field_start + field_size;
40 bool isInside = (field_start >= this->
rva && (field_start < (this->
rva + this->
loadedSize)))
59 if (hdr_sec_num == 0 && section_number == 0) {
60 return loadRemoteImageAsSection(remoteModData);
63 PIMAGE_SECTION_HEADER section_hdr = peconv::get_section_hdr(remoteModData.
headerBuffer, peconv::MAX_HEADER_SIZE, section_number);
64 if ((!section_hdr) || section_hdr->Misc.VirtualSize == 0) {
67 this->rawSize = section_hdr->SizeOfRawData;
68 this->rva = section_hdr->VirtualAddress;
84 if (hdr_sec_num == 0 && section_number == 0) {
85 return loadOriginalImageAsSection(modData);
88 if (section_hdr ==
nullptr) {
91 this->rawSize = section_hdr->SizeOfRawData;
92 const size_t raw_code_size = section_hdr->SizeOfRawData;
93 const size_t orig_code_size = section_hdr->Misc.VirtualSize > raw_code_size ? section_hdr->Misc.VirtualSize : raw_code_size;
99 this->rva = section_hdr->VirtualAddress;
101 BYTE *orig_code = modData.
original_module + section_hdr->VirtualAddress;
118 bool loadOriginalImageAsSection(
ModuleData& modData)
121 std::cout <<
"PE with no sections! Loading original image as section\n";
126 peconv::UNALIGNED_BUF buf = peconv::alloc_unaligned(modData.
original_size);
129 std::cout <<
"Could not alloc: " << std::hex << modData.
original_size <<
"\n";
139 std::cout <<
"Copied local: " << std::hex << modData.
original_size <<
"\n";
144 bool _loadRemoteImageAsSection(RemoteModuleData& remoteModData,
size_t image_size)
146 peconv::UNALIGNED_BUF buf = peconv::alloc_unaligned(image_size);
150 size_t read_size = peconv::read_remote_pe(remoteModData.processHandle, (PBYTE)remoteModData.modBaseAddr, image_size, buf, image_size);
151 if (read_size != image_size) {
153 peconv::free_unaligned(buf);
156 this->loadedSection = buf;
157 this->loadedSize = read_size;
163 bool loadRemoteImageAsSection(RemoteModuleData& remoteModData)
166 std::cout <<
"PE with no sections! Loading remote image as section\n";
168 if (_loadRemoteImageAsSection(remoteModData, remoteModData.getModuleSize())) {
172 return _loadRemoteImageAsSection(remoteModData, remoteModData.calcImgSize());