MCPcopy Create free account
hub / github.com/ReversecLabs/C3 / GetSectionRange

Function GetSectionRange

Src/CebuLoader/PeUtils.cpp:23–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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}

Callers 1

FindInSectionFunction · 0.85

Calls 1

GetNtHeadersFunction · 0.85

Tested by

no test coverage detected