Insert a parsed import.
| 308 | |
| 309 | // Insert a parsed import. |
| 310 | BOOL cobf::insert_import(cmod& dll_mod, DWORD dll_off, size_t th_sym, DWORD fth_rva, DWORD oth_off) |
| 311 | { |
| 312 | // Check if imported by ordinal. |
| 313 | if (IMAGE_SNAP_BY_ORDINAL(th_sym)) |
| 314 | { |
| 315 | // Inserting the import. |
| 316 | dll_mod.mod_syms.push_back(csym(IMAGE_ORDINAL(th_sym), dll_off, fth_rva, oth_off)); |
| 317 | return TRUE; |
| 318 | }; |
| 319 | |
| 320 | // Imported by name. |
| 321 | PCHAR p_name; |
| 322 | if (!this->rva_to_ptr((DWORD)th_sym, (PVOID*)&p_name)) |
| 323 | { |
| 324 | // Invalid rva. |
| 325 | return FALSE; |
| 326 | }; |
| 327 | |
| 328 | // Inserting the import. |
| 329 | p_name += sizeof(IMAGE_IMPORT_BY_NAME::Hint); |
| 330 | |
| 331 | // Inserting the import. |
| 332 | dll_mod.mod_syms.push_back(csym(p_name, dll_off, fth_rva, oth_off, |
| 333 | (DWORD)((PBYTE)p_name - this->pe_rawf.data()))); |
| 334 | return TRUE; |
| 335 | }; |
| 336 | |
| 337 | // Convert RVA to pointer after checking it. |
| 338 | BOOL cobf::rva_to_ptr(DWORD ptr_rva, PVOID* p_ptr) |
no test coverage detected