Search code examples
numberssizevirtualwindbg

Windbg - PEB Paged Out (Virtual Page Size Confusion)


Can someone please explain to me what this means. (I've bolded the specific part in question).

The "Start VPN" field – in this case, 0x37D9BD30 – indicates the starting virtual page number. This must be converted to an actual address, by multiplying it by the page size. You can use the ? (Evaluate Expression) command to multiply this value by 0x2000, which is the page size for the Itanium-based machine the example comes from.

kd> ? 37d9bd3e*2000        
Evaluate expression: 7676040298496 = 000006fb`37a7c000

Then the size of the range can be converted to bytes:

kd> ? 37d9bd3e-37d9bd30+1          <--   computes the number of pages
Evaluate expression: 15 = 00000000`0000000f
kd> ? f*2000
Evaluate expression: 122880 = 00000000`0001e000

So ExplorerFrame.dll starts at address 0x000006Fb37A7C000 and is 0x1E000 bytes large. You can load its symbols with:

kd> .reload /f ExplorerFrame.dll=6fb`37a7c000,1e000

Solution

  • The page size depends on the processor. Calling GetSystemInfo() [MSDN] gives you the page size in the field SYSTEM_INFO.dwPageSize. Wikipedia provides code that does it:

    #include <stdio.h>
    #include <windows.h>
    
    int main(void) {
        SYSTEM_INFO si;
        GetSystemInfo(&si);
    
        printf("The page size for this system is %u bytes.\n", si.dwPageSize);
    
        return 0;
    }
    

    For the possible page sizes, refer to an Intel CPU manual.

    • x86 CPUs may have 4k (most common), 2M (PAE supported) or 4M (no PAE support)
    • x64 CPUs may have 4k (most common), 2M or even have 1G pages. It does not have 4M, since all x64 CPUs support PAE
    • Itanium may have 4k, 8k, 64k, 256k, 1M, 4M, 16M or 256M pages