| 387 | |
| 388 | _IRQL_requires_max_(APC_LEVEL) |
| 389 | BOOLEAN ReadPhysicalMemory(IN PVOID64 PhysicalAddress, OUT PVOID Buffer, SIZE_T Length, MEMORY_CACHING_TYPE CachingType) { |
| 390 | BOOLEAN Status; |
| 391 | PVOID VirtualAddress = GetVirtualForPhysical(PhysicalAddress); |
| 392 | if (VirtualAddress) { |
| 393 | __try { |
| 394 | VirtualMemory::CopyMemory(Buffer, VirtualAddress, Length); |
| 395 | Status = TRUE; |
| 396 | } __except (EXCEPTION_EXECUTE_HANDLER) { |
| 397 | Status = FALSE; |
| 398 | } |
| 399 | } else { |
| 400 | Status = FALSE; |
| 401 | } |
| 402 | |
| 403 | if (!Status) { |
| 404 | PVOID MappedMemory = MapPhysicalMemory(PhysicalAddress, Length, CachingType); |
| 405 | if (!MappedMemory) return FALSE; |
| 406 | __try { |
| 407 | VirtualMemory::CopyMemory(Buffer, MappedMemory, Length); |
| 408 | Status = TRUE; |
| 409 | } __except (EXCEPTION_EXECUTE_HANDLER) { |
| 410 | Status = FALSE; |
| 411 | } |
| 412 | UnmapPhysicalMemory(MappedMemory, Length); |
| 413 | } |
| 414 | |
| 415 | return Status; |
| 416 | } |
| 417 | |
| 418 | _IRQL_requires_max_(APC_LEVEL) |
| 419 | BOOLEAN WritePhysicalMemory(OUT PVOID64 PhysicalAddress, IN PVOID Buffer, SIZE_T Length, MEMORY_CACHING_TYPE CachingType) { |
no test coverage detected