| 417 | |
| 418 | _IRQL_requires_max_(APC_LEVEL) |
| 419 | BOOLEAN WritePhysicalMemory(OUT PVOID64 PhysicalAddress, IN PVOID Buffer, SIZE_T Length, MEMORY_CACHING_TYPE CachingType) { |
| 420 | BOOLEAN Status; |
| 421 | PVOID VirtualAddress = GetVirtualForPhysical(PhysicalAddress); |
| 422 | if (VirtualAddress) { |
| 423 | __try { |
| 424 | VirtualMemory::CopyMemory(VirtualAddress, Buffer, Length); |
| 425 | Status = TRUE; |
| 426 | } __except (EXCEPTION_EXECUTE_HANDLER) { |
| 427 | Status = FALSE; |
| 428 | } |
| 429 | } else { |
| 430 | Status = FALSE; |
| 431 | } |
| 432 | |
| 433 | if (!Status) { |
| 434 | PVOID MappedMemory = MapPhysicalMemory(PhysicalAddress, Length, CachingType); |
| 435 | if (!MappedMemory) return FALSE; |
| 436 | __try { |
| 437 | VirtualMemory::CopyMemory(MappedMemory, Buffer, Length); |
| 438 | Status = TRUE; |
| 439 | } __except (EXCEPTION_EXECUTE_HANDLER) { |
| 440 | Status = FALSE; |
| 441 | } |
| 442 | UnmapPhysicalMemory(MappedMemory, Length); |
| 443 | } |
| 444 | |
| 445 | return Status; |
| 446 | } |
| 447 | } |
| 448 | |
| 449 | namespace Mdl { |
no test coverage detected