2#include "Logger/Logger.h"
10 const auto dos_header =
reinterpret_cast<PIMAGE_DOS_HEADER>(
module_base_);
11 const auto nt_headers =
reinterpret_cast<PIMAGE_NT_HEADERS>(
module_base_ + dos_header->e_lfanew);
16 const auto section_count = nt_headers->FileHeader.NumberOfSections;
17 const auto first_section = IMAGE_FIRST_SECTION(nt_headers);
18 const auto end_section = first_section + section_count;
20 const auto data_section_header =
std::find_if(first_section, end_section, [](_IMAGE_SECTION_HEADER hdr)
22 auto name = std::string(
reinterpret_cast<
char*>(hdr.Name), 8);
23 name.erase(std::remove(name.begin(), name.end(),
'\0'), name.end());
25 return name ==
".data";
28 if (data_section_header == end_section)
30 Log::GetLog()->error(
"Failed to get the base of the .data section.");
34 data_base_ += data_section_header->VirtualAddress;