| 318 | } |
| 319 | |
| 320 | void RtlpDeleteInvertedFunctionTableEntry(PVOID ImageBase) { |
| 321 | |
| 322 | uintptr_t mrData = 0; |
| 323 | DWORD mrDataSize = 0; |
| 324 | auto table = FindLdrpInvertedFunctionTable(mrData, mrDataSize); |
| 325 | DWORD oldProtect = 0; |
| 326 | |
| 327 | if (table == nullptr) { |
| 328 | throw std::runtime_error("[!] Failed to find LdrpInvertedFunctionTable\n"); |
| 329 | } |
| 330 | |
| 331 | VirtualProtect(PVOID(mrData), mrDataSize, PAGE_READWRITE, &oldProtect); |
| 332 | |
| 333 | auto entryIndex = 1; |
| 334 | |
| 335 | while (entryIndex < table->Count) { |
| 336 | if (ImageBase == table->Entries[entryIndex].ImageBase) { |
| 337 | break; |
| 338 | } |
| 339 | entryIndex++; |
| 340 | } |
| 341 | |
| 342 | if (entryIndex <= table->Count) { |
| 343 | if (entryIndex != table->Count) { |
| 344 | |
| 345 | InterlockedDecrement(&table->Epoch); |
| 346 | auto moved_entries = table->Count - entryIndex; |
| 347 | |
| 348 | memmove(&table->Entries[entryIndex], |
| 349 | &table->Entries[entryIndex + 1], |
| 350 | moved_entries * sizeof(INVERTED_FUNCTION_TABLE_ENTRY)); |
| 351 | } |
| 352 | } |
| 353 | |
| 354 | InterlockedDecrement(&table->Epoch); |
| 355 | table->Overflow = 0; |
| 356 | table->Count--; |
| 357 | } |
| 358 | |
| 359 | static void AddExceptionSupport(const Pe::PeNative& mappedPe){ |
| 360 |
no test coverage detected