I found the reason why generated badmemorylist contains invalid PFNs.
The script takes the MemTest86 error address and does:
$pageAddr = "0x" + $fullAddr.Substring(0, 6)
This does not convert a physical address to a PFN. It only truncates the hexadecimal string.
Example:
MemTest86 log:
Address: 4A0BC000
Current script generates:
But Windows badmemorylist expects PFN (Page Frame Number), not a physical address.
The correct conversion is:
PFN = PhysicalAddress >> 12
because Windows pages are 4096 bytes.
Correct result:
0x4A0BC000 >> 12 = 0x4A0BC
not:
0x4A0BC0
The current conversion makes Windows interpret the address as:
0x4A0BC0 * 0x1000 = 0x4A0BC0000
which is about 18.5 GB physical address.
This explains why on a system with only 8 GB RAM the generated badmemorylist contains PFNs outside the installed memory range:
badmemorylist
0x4a0bc0
0x4a0bc1
0x4a0bc2
...
Those pages cannot exist on this system, so Windows ignores them.
Suggested fix:
Replace:
$fullAddr = $matches[1]
if ($fullAddr.Length -ge 6) {
$pageAddr = "0x" + $fullAddr.Substring(0, 6)
$null = $uniquePages.Add($pageAddr)
}
with:
$fullAddr = [Convert]::ToUInt64($matches[1],16)
$pfn = $fullAddr -shr 12
$pageAddr = "0x{0:X}" -f $pfn
$null = $uniquePages.Add($pageAddr)
Also it would be useful to validate that generated PFNs are within the detected physical RAM range before writing them to BCD.
Thanks.

I found the reason why generated badmemorylist contains invalid PFNs.
The script takes the MemTest86 error address and does:
$pageAddr = "0x" + $fullAddr.Substring(0, 6)This does not convert a physical address to a PFN. It only truncates the hexadecimal string.
Example:
MemTest86 log:
Address: 4A0BC000Current script generates:
But Windows badmemorylist expects PFN (Page Frame Number), not a physical address.
The correct conversion is:
PFN = PhysicalAddress >> 12because Windows pages are 4096 bytes.
Correct result:
0x4A0BC000 >> 12 = 0x4A0BCnot:
0x4A0BC0The current conversion makes Windows interpret the address as:
0x4A0BC0 * 0x1000 = 0x4A0BC0000which is about 18.5 GB physical address.
This explains why on a system with only 8 GB RAM the generated badmemorylist contains PFNs outside the installed memory range:
Those pages cannot exist on this system, so Windows ignores them.
Suggested fix:
Replace:
with:
Also it would be useful to validate that generated PFNs are within the detected physical RAM range before writing them to BCD.
Thanks.