MCPcopy Create free account
hub / github.com/d35ha/CallObfuscator / section_of_rva

Method section_of_rva

src/load.cpp:183–212  ·  view source on GitHub ↗

Get the section of some rva.

Source from the content-addressed store, hash-verified

181
182// Get the section of some rva.
183BOOL cobf::section_of_rva(DWORD rva, PIMAGE_SECTION_HEADER& sec)
184{
185 // Get the sections.
186 PIMAGE_DOS_HEADER dos_hdr = (PIMAGE_DOS_HEADER)this->pe_rawf.data();
187 PIMAGE_NT_HEADERS nt_hdrs = (PIMAGE_NT_HEADERS)&this->pe_rawf[dos_hdr->e_lfanew];
188 PIMAGE_SECTION_HEADER c_sec = (PIMAGE_SECTION_HEADER)&this->pe_rawf[dos_hdr->e_lfanew +
189 sizeof(nt_hdrs->Signature) + sizeof(nt_hdrs->FileHeader) +
190 nt_hdrs->FileHeader.SizeOfOptionalHeader];
191
192 // Loop on the sections.
193 WORD n_secs = nt_hdrs->FileHeader.NumberOfSections;
194 while (n_secs--)
195 {
196 // Check if not contained.
197 if (rva < (size_t)c_sec->VirtualAddress || rva >= (size_t)c_sec->VirtualAddress +
198 c_sec->Misc.VirtualSize)
199 {
200 // Move to the next one.
201 c_sec++;
202 continue;
203 };
204
205 // Found.
206 sec = c_sec;
207 return TRUE;
208 };
209
210 // Not found.
211 return FALSE;
212};
213
214// Verify and get the dos header.
215BOOL cobf::get_dos_header(PIMAGE_DOS_HEADER& dos_hdr)

Callers 2

make_the_iat_writableMethod · 0.95
rva_to_offsetMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected