Hi all,
I’m currently trying to understand the relationship between a shared memory page, a prototype PTE, and the processes that share the page.
Here’s my current example.
At physical address 0x1df1f000 is a 4KB page containing some text, “This is the contents of the file”. This file is currently open in Notepad.exe.
If I view the PFN database entry for the file, I see this:
lkd> !pfn 1df1f
PFN 0001DF1F at address FFFFFA800059D5D0
flink 00016C41 blink / share count 00025CBF pteaddress FFFFF8A001BD6E00
reference count 0000 used entry count 0000 Cached color 0 Priority 5
restore pte FA80027E6F9004C0 containing page 02BDA9 Standby P
Shared
If I’m understanding this correctly, the ‘P’ flag, and ‘Shared’ indicate this is a shared page, and therefore the ‘pteaddress’ value will point to a prototype PTE at 0xFFFFF8A001BD6E00. I can confirm this by running the !pool command:
lkd> !pool FFFFF8A001BD6E00 2
Pool page fffff8a001bd6e00 region is Paged pool
*fffff8a001bd6df0 size: 210 previous size: 210 (Allocated) *MmSt
Pooltag MmSt : Mm section object prototype ptes, Binary : nt!mm
I believe I’m correct in saying that the ‘MmSt’ pool tag is used for prototype PTEs in the paged pool.
I am however a little confused as how this prototype PTE can be used to track the data.
Here’s the output from WinDBG showing the PTE and the data at that page is describes:
lkd> !pte FFFFF8A001BD6E00
VA fffff8a001bd6e00
PXE at FFFFF6FB7DBEDF88 PPE at FFFFF6FB7DBF1400 PDE at FFFFF6FB7E280068 PTE at FFFFF6FC5000DEB0
contains 000000003D0C4863 contains 000000000309F863 contains 000000002CD6C863 contains ACD000002BDA9943
pfn 3d0c4 —DA–KWEV pfn 309f —DA–KWEV pfn 2cd6c —DA–KWEV pfn 2bda9 -G-D—KW-V
lkd> !dd 2bda9e00
#2bda9e00 1df1f8c0 00000000 18e218c0 00000000
#2bda9e10 18ee28c0 00000000 1b0e38c0 00000000
#2bda9e20 6f9004c0 fa80027e 6f9004c0 fa80027e
#2bda9e30 6f9004c0 fa80027e 6f9004c0 fa80027e
#2bda9e40 6f9004c0 fa80027e 6f9004c0 fa80027e
#2bda9e50 6f9004c0 fa80027e 6f9004c0 fa80027e
#2bda9e60 6f9004c0 fa80027e 6f9004c0 fa80027e
#2bda9e70 6f9004c0 fa80027e 6f9004c0 fa80027e
I’m not entirely sure what’ I’m looking at here, I thought it might be a _SECTION_OBJECT, but I’m not entirely sure, any ideas?
Essentially, what I’m trying to do is determine all of the virtual addresses that correspond to a single physical page, which is mentioned here: https://channel9.msdn.com/Forums/TechOff/Windows-Memory-Management-question
So what I’d like to do is to find any virtual addresses that have accessed the shared page at 0x1df1f000.
I’m guessing that the address of this prototype PTE should be somewhere within Notepad’s page tables, is that correct?
As the page is now on the standby list, it is possible to restore this, of soft-fault it back into the processes working set, however, I’m not sure how the memory manager determines which working set it originally came from. The is an OriginalPte element within the _MMPFN structure, but it doesn’t seem to contain a valid virtual address.
Any advice or input would be appreciated.
Thanks