| 270 | } |
| 271 | |
| 272 | void LoadImageVolatileMetadata(fextl::set<uint64_t>& VolatileInstructions, FEXCore::IntervalList<uint64_t>& VolatileValidRanges, |
| 273 | HMODULE Module, IMAGE_NT_HEADERS* Nt, uint64_t Address, uint64_t EndAddress) { |
| 274 | ULONG Size; |
| 275 | |
| 276 | const auto* LoadConfig = |
| 277 | reinterpret_cast<_IMAGE_LOAD_CONFIG_DIRECTORY64*>(RtlImageDirectoryEntryToData(Module, true, IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG, &Size)); |
| 278 | if (!LoadConfig || LoadConfig->Size <= offsetof(_IMAGE_LOAD_CONFIG_DIRECTORY64, VolatileMetadataPointer)) { |
| 279 | return; |
| 280 | } |
| 281 | |
| 282 | if (LoadConfig->VolatileMetadataPointer < Address || LoadConfig->VolatileMetadataPointer + sizeof(IMAGE_VOLATILE_METADATA) >= EndAddress) { |
| 283 | return; |
| 284 | } |
| 285 | |
| 286 | const auto* VolatileMetadata = reinterpret_cast<IMAGE_VOLATILE_METADATA*>(LoadConfig->VolatileMetadataPointer); |
| 287 | if (!VolatileMetadata || Address + VolatileMetadata->VolatileAccessTable + VolatileMetadata->VolatileAccessTableSize >= EndAddress || |
| 288 | Address + VolatileMetadata->VolatileInfoRangeTable + VolatileMetadata->VolatileInfoRangeTableSize >= EndAddress) { |
| 289 | return; |
| 290 | } |
| 291 | |
| 292 | const auto* VolatileAccessTableBegin = reinterpret_cast<IMAGE_VOLATILE_RVA_METADATA*>(Address + VolatileMetadata->VolatileAccessTable); |
| 293 | const auto* VolatileAccessTableEnd = |
| 294 | VolatileAccessTableBegin + (VolatileMetadata->VolatileAccessTableSize / sizeof(IMAGE_VOLATILE_RVA_METADATA)); |
| 295 | for (auto It = VolatileAccessTableBegin; It != VolatileAccessTableEnd; It++) { |
| 296 | VolatileInstructions.emplace(Address + It->Rva); |
| 297 | } |
| 298 | |
| 299 | const auto* VolatileInfoRangeTableBegin = reinterpret_cast<IMAGE_VOLATILE_RANGE_METADATA*>(Address + VolatileMetadata->VolatileInfoRangeTable); |
| 300 | const auto* VolatileInfoRangeTableEnd = |
| 301 | VolatileInfoRangeTableBegin + (VolatileMetadata->VolatileInfoRangeTableSize / sizeof(IMAGE_VOLATILE_RANGE_METADATA)); |
| 302 | for (auto It = VolatileInfoRangeTableBegin; It != VolatileInfoRangeTableEnd; It++) { |
| 303 | VolatileValidRanges.Insert({Address + It->Rva, Address + It->Rva + It->Size}); |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | void LoadImageVolatileMetadata(const fextl::string& ModuleName, uint64_t Address) { |
| 308 | const auto Module = reinterpret_cast<HMODULE>(Address); |
no test coverage detected