| 21 | } |
| 22 | |
| 23 | std::pair<void*, void*> GetSectionRange(void* dllBase, std::string const& sectionName) |
| 24 | { |
| 25 | auto ntHeaders = GetNtHeaders((UINT_PTR)dllBase); |
| 26 | auto sectionHeader = IMAGE_FIRST_SECTION(ntHeaders); |
| 27 | for (int i = 0; i < ntHeaders->FileHeader.NumberOfSections; i++, sectionHeader++) |
| 28 | { |
| 29 | char currentSection[9]; |
| 30 | memcpy(currentSection, sectionHeader->Name, 8); |
| 31 | currentSection[8] = 0; // ensure null-termination |
| 32 | if (_stricmp(sectionName.c_str(), currentSection) == 0) |
| 33 | { |
| 34 | auto sectionVa = Rva2Va<char*>(dllBase, sectionHeader->VirtualAddress); |
| 35 | return { sectionVa, sectionVa + sectionHeader->Misc.VirtualSize }; |
| 36 | } |
| 37 | } |
| 38 | return {}; |
| 39 | } |
| 40 | } |
no test coverage detected