Skip to content

Windows: read the software PTE layout from the kernel when resolving paged out pages - #2080

Open
vmaca123 wants to merge 5 commits into
volatilityfoundation:developfrom
vmaca123:windows-pagefile-pte-layout
Open

vmaca123 wants to merge 5 commits into
volatilityfoundation:developfrom
vmaca123:windows-pagefile-pte-layout

Conversation

@vmaca123

@vmaca123 vmaca123 commented Nov 7, 2026 •

Copy link
Copy Markdown

This picks up the page file part of #581 and #778 on current develop. It only touches the Windows Intel layers and adds one Windows automagic. There are five commits:

  1. a small guard that does not depend on symbols;
  2. the layout change;
  3. a fix for reads that start inside a paged out page;
  4. a safe fallback for kernels whose mask can't be read;
  5. a check of PageFileAllocated, added after review (comment).

What goes wrong

WindowsMixin._translate_swap decodes a software (paged out) PTE with fixed rules:

  1. Page file number from bits 1-4. Kernels whose _MMPTE_SOFTWARE has SwizzleBit keep PageFileLow at bits 12-15. On those kernels, bits 1-4 hold PageFileReserved, PageFileAllocated, ColdPage and SwizzleBit.
  2. PageFileHigh used as is. On the same kernels, software PTEs whose SwizzleBit is clear carry InvalidPteMask. With a mask of 0x200000000000, a demand-zero PTE reads as PageFileHigh 0x2000, i.e. page file offset 0x2000000. The mask depends on the CPU: on the Windows 11 laptop below it is 0, and only points 1, 3, 4 and 5 apply.
  3. Bit 7 required. Bit 7 is bit 2 of the Protection field, so pages with protection 1-3 (read-only, execute, execute-read) are never looked up.
  4. Any level. An entry at any level of the walk is sent to the page file at PageFileHigh << invalid_bits. A paged out page directory entry therefore becomes a 2 MB (or 4 MB) read at a scaled offset.
  5. PageFileAllocated ignored. Some PTEs carry a page file offset but have PageFileAllocated clear, and their slot does not hold their page (see commit 5). develop reads those with bit 7 set, guard pages among them.

When the layout changed. In the ISFs of Volatility's own symbol pack (volatility3-test-data, windows.zip), SwizzleBit and the bit 12 layout first appear in kernels 6.1.7601.24214, 6.3.9600.19101, 10.0.14393.2430 and 10.0.17134.228. Unpatched builds of the same releases (e.g. 9600.19067, 17134.191) still use bit 1. 6.1.7601.24214 is the kernel in KB4343900 and 17134.228 is KB4343909. Both are the August 14, 2018 updates that added the L1 Terminal Fault mitigations. So patched Windows 7 / 8.1 and early Windows 10 images are affected too, not only 1803 and later.

Change

Commit 1 (no symbols needed): _translate_swap only resolves faults at the page table entry level, and leaves PageFileHigh of all ones alone (that PTE has to be rebuilt from the VAD).

Commit 2:

  • New automagic. WinSoftwarePteLayout (priority 35, after KernelPDBScanner) reads the bit positions of _MMPTE_SOFTWARE.PageFileLow and .SwizzleBit from the kernel's symbols.
    • It reads InvalidPteMask from MiState.Hardware. Where that field doesn't exist, it reads the older global MiInvalidPteMask instead: 26 kernel ISFs with SwizzleBit in the symbol pack have only the global, 13 x64 and 13 PAE.
    • It stores them as three optional settings on the kernel layer: page_file_low_bit, swizzle_bit and invalid_pte_mask. Commit 5 adds a fourth.
    • Process layers copy the settings with the rest of the layer configuration.
  • With these settings, _translate_swap:
    • reads the number at page_file_low_bit;
    • removes the mask only when SwizzleBit is clear;
    • accepts any non-zero protection instead of requiring bit 7. Protection 0 is left alone: in the kernel half these are free system PTE lists and timestamps, and in user space only garbage from smeared page tables.
  • Without them (layers built without a kernel module, e.g. yarascan, or by hand), the old bit 1 number and bit 7 test are kept.

Commit 3: _translate_swap returned the start of the page file slot without the offset inside the page, so a read that does not start on a page boundary got the bytes from the start of the slot. develop has the same code. It now returns the slot plus the offset, as _translate does for a present page. Reads of whole pages were right, which is why the page level checks below did not show it (see "Reads inside a page" under Results).

Commit 4: if the kernel has SwizzleBit but the mask can't be read (or has bits outside PageFileHigh), commit 2 still set the layout and removed nothing, which brings back the demand-zero reads at 0x2000000. A mask of 0, which CPUs that need no mask report, is now kept, and when the mask is unknown, PTEs whose SwizzleBit is clear are left unresolved instead of being read from a guessed slot.

Commit 5: some PTEs carry a page file offset in PageFileHigh but have _MMPTE_SOFTWARE.PageFileAllocated clear.

  • Which PTEs. On the seven images checked (six VMs and the CI image), every decommitted (protection 0x10) and guard page PTE with an offset is among them.
  • Where their slots point. In the AllocationBitmap, their slot is often free, or it is also named by another PTE with the bit set. On those seven and my laptop's live dump, PTEs with the bit set never share a slot with each other and never point to a free one.
  • What the slots hold. In the test VMs, 466 such slots held another page, recognised by markers written in the guests. That page's own PTE names the same slot with the bit set; it is in another process for 394 of the 466.
  • How this came about. Commit 2 opened these PTEs to the page file by dropping the bit 7 test. develop already read the ones with bit 7 set, guard pages included.
  • What the kernel does. The page fault handler reads the page file slot only when PageFileAllocated is set. I checked this in the code of 14393, 19041, 19044 x86 and 26100 (comment). ricardojrdez found the same gate on 17763, 20348, 9600 x64 and 9200 x86 (comment), and my 17763 and 20348 VM kernels have it too (comment). So do 9200.22490 x64 and 9600.19067 x86 from the July 2018 updates (comment).
  • The change. The automagic now also reads where PageFileAllocated is: bit 2, 13, 14 or 24 in the x86/x64 kernels of the symbol pack (24 only in kernels from pre-release Windows 8 branches). It stores it as a fourth setting, page_file_allocated_bit.
    • _translate_swap leaves PTEs with it clear unresolved.
    • Without a swap layer, they are no longer reported as swapped.
    • Kernels without the field, such as Windows 7, and layers without the kernel's layout are unchanged.

With the number now read from the right bits, the order of --single-swap-locations matters: the n-th file is used for page file number n (pagefile.sys is normally 0 and swapfile.sys 1).

Which decoding is right

The existing proposals disagree on PTEs whose SwizzleBit is 1 and whose PageFileHigh has the mask bit set:

WinDbg. On the CI image win-10_19041-2025_03.dmp, I sampled 287 user-space software PTEs across 45 processes, up to 25 per kind (SwizzleBit × mask bit × page file number × bit 7, demand zero, all ones). I ran !pte on each in kd (WinDbg 1.2611.4001.0).

  • The PTE values kd read are the ones my own page table walk read.
  • kd's PageFile/Offset matches this PR's decoding for 287 of 287. Always-clear and always-XOR match 150, develop matches 0.
  • In every SwizzleBit 1 kind, only this decoding matches.
  • Example: kd shows 0000200000000080 as DemandZero, and develop reads it from the page file at 0x2000000.
  • kd decodes the fields without looking at PageFileAllocated. 66 of the 287 are page file PTEs with it clear, and since commit 5 the branch leaves them unresolved.

The kernel's own allocation bitmap. I checked each decoded slot against _MMPAGING_FILE.Bitmaps->AllocationBitmap. This covers all software PTEs inside a VAD, walking page tables directly under present upper-level entries.

decoding DESKTOP (Szechuan): allocated / free / slots claimed twice CI image: allocated / free / slots claimed twice
this PR 105,853 / 3,626 / 306 164,311 / 0 / 0
this PR before commit 5 106,528 / 4,701 / 866 165,547 / 23,664 / 47
always clear 74,091 / 37,138 / 11,523 126,482 / 62,728 / 41,373
always XOR (#778) 73,811 / 38,884 / 11,465 126,482 / 62,728 / 41,373
develop 23,284 / 114,074 / 1,204 73,138 / 30,097 / 1,112

The first row leaves out the PTEs with PageFileAllocated clear (8,705 on DESKTOP, 24,900 on the CI image), which the other rows count. I chose that rule after seeing these counts, so the row shows the rule agrees with the bitmap, not independent evidence for it; the marker results under "Tested later on six VMs" are that.

Results

Image. DESKTOP memory of the public DFIR Madness case "The Case of the Stolen Szechuan Sauce" (Windows 10 x64, 19041), with its pagefile.sys (as in my comment on #778). The counts are software PTEs inside a VAD, translated with each version's _translate.

develop this PR
PTEs into pagefile.sys whose slot is allocated (14,108) translated to that slot 11 13,963
... of which develop dropped because bit 7 is clear 11,127 0
... of which develop sent to the wrong page file number 2,970 0
... with PageFileAllocated clear, left unresolved by commit 5 (the bitmap marks the slot used, but the PTE has PageFileAllocated clear) – 145
demand-zero PTEs (84,158) sent to pagefile.sys 18,480 0
compressed store PTEs (page file 2) sent to pagefile.sys 127 0
protection 0 PTEs (3,967) page fault page fault

Bytes and plugins:

  • Bytes. Every page this branch reads from pagefile.sys is the 4 KB at the slot above. I compared them with MemProcFS 5.19 on the same page file, reading page by page. MemProcFS's scatter read can return bytes that change with the order of the request for pages it cannot read, so it is not a reference for those pages.

    • Reading page by page, MemProcFS returns the same bytes for 14,003 of the 14,092 pages, other bytes for 18, and can't read 71.
    • Agreeing with MemProcFS shows consistency, not correctness, because MemProcFS doesn't check PageFileAllocated either. Commit 5 stopped reading 453 pages, and MemProcFS had matched the branch on 71 of those.

    Before commit 5 the branch read 14,545 pages: 14,074 the same as MemProcFS, 68 other, 403 unreadable. The rest of this point describes that run. Outside the 70 2 MB regions described next, MemProcFS can't read 9 and every other page matches.

    All 68 differing pages and 394 of the unreadable ones lie in 70 regions whose page table, as reached by the walk, does not look like one:

    • in 22, at least 32 entries look like UTF-16 text;
    • in 37, at least 32 entries have the valid bit set but point past the 2 GB of RAM;
    • in 11, an upper-level entry is unreadable or invalid (one PDPTE is 0x15ff000000de840f, which reads as instruction bytes).

    Of 150 random tables with no difference, 146 show none of this. These look like page tables smeared during acquisition. There MemProcFS returns other resident pages (66) or zeros (2), and none of its bytes match a page file slot under any of the decodings above, so the difference does not come from the page file decoding. develop matches MemProcFS for 2 of 18,752 pages.

  • Reads inside a page. I tried reading the compressed store on DESKTOP through these layers (not part of this PR). 70 compressed blocks lay inside MemCompression pages that are in pagefile.sys. Read before commit 3, none of them decompressed, and ntdll's RtlDecompressBuffer rejected them too. The bytes at the right offset of the same slots decompress to what MemProcFS returns for 70 of 70, and after commit 3 the reads through the layer do the same. Decoding all 95,900 store PTEs again with commit 5 gives the same 66,572 pages with the same bytes.

  • Plugin output.

    • Without a page file, the output of pslist, cmdline, dlllist, envars, vadinfo, malfind, svcscan and netscan is identical to develop on the CI image, on DESKTOP and on DC01 (24 of 24, compared on commit 4). Commit 5 changes none of the 24.
    • With DESKTOP's page file, pslist, svcscan and netscan are unchanged. The others read more:
      • cmdline recovers one command line, which matches MemProcFS.
      • dlllist fills 12 empty names and finds 20 more modules. Of the 32 new rows, 27 match MemProcFS by base and name, and 4 are found but still have no name. One is a bogus entry (base 0x2, empty name) that the list walk now reaches.
      • envars gives 62 more variables, and vadinfo 13 more file names.
    • Commit 5 changes none of the eight outputs with DESKTOP's page file.
  • windows.malfind with the page file gives 8 rows on develop and 7 on this branch. The dropped VAD (PID 3316, 0x10c6baf0000) was reported only because one of its 16 pages was demand-zero and came back as the 4 KB at pagefile.sys 0x2000000. MemProcFS shows content for that region from the compressed store, which Volatility does not read either way.

Other kernels:

  • Kernel half of the CI image. 769,853 PTE-level software entries with protection 0 (mostly with the low 32 bits all zero) are page faults on develop and on this branch. The 2,355 with protection 1 or 3 are now resolved; commit 5 doesn't change this.
  • Kernel half of DESKTOP, with its page file. Of the PTE-level entries with protection 1-3 that now resolve to pagefile.sys, 327 point to slots the allocation bitmap marks as used, none to free slots, and 47 past the end of the file (those reads fail). Before commit 5 the counts were 330, 3 and 86. Commit 5 makes 46 with PageFileAllocated clear page faults (45 had gone to pagefile.sys, 1 was reported as swapped), and 32 at protection 4 and above. Protection 0 entries all stay page faults.
  • Windows Server 2012 R2 (DC01 from the same case, no SwizzleBit). The automagic sets page_file_low_bit = 1 and page_file_allocated_bit = 14.
    • Before commit 5, the one difference from develop was 369 PTEs with protection 1-3 reported as swapped.
    • Of those, 42 have PageFileAllocated set and are still reported as swapped. The other 327 are page faults again.
    • Commit 5 also makes page faults of 1,432 PTEs with bit 7 set and PageFileAllocated clear, which develop reports as swapped.
    • DC01 has no page file, so on kernels with the bit at 14 (Windows 8 / 8.1 without the August 2018 updates) commit 5 is checked only by these counts.
  • Windows 11 (25H2, kernel 10.0.26100, PDB B661C6FE72991D160FE37C48B8BC5470-1, Intel CPU family 6 model 189).
    • Image. A Task Manager live kernel dump of my own laptop. Volatility doesn't open this dump type (0x6, see Can't process a Windows 10 64bit Crash Dump #1112), so for this check only I read it the way type 0x5 is read, with a local shim. Nothing in this PR depends on that. The page tables of all 1,191 processes are in the dump.
    • Layout and mask. The symbols have the same layout (PageFileLow 12, SwizzleBit 4). MiState.Hardware.InvalidPteMask is 0 on this CPU, and kd shows the same. None of the 5,082,057 software PTEs inside a VAD has SwizzleBit set, so the mask part changes nothing here.
    • WinDbg. kd !pte matches this PR's decoding for 125 of 125 sampled PTEs (5 kinds × 25, 57 processes). 26 of them are page file PTEs with PageFileAllocated clear. kd decodes those the same way, and since commit 5 the branch leaves them unresolved.
    • What develop does.
      • Bits 1-4 here hold PageFileReserved, PageFileAllocated and ColdPage.
      • 2,945,908 compressed store PTEs have only PageFileAllocated set, so they happen to read as page file 2. That is why develop's number is right for 100 of the 125 samples.
      • 35,281 compressed store PTEs with bit 7 set read as page file 0, so develop would read them from pagefile.sys.
      • 627 pagefile.sys PTEs read as page file 2.
      • The 674,078 pagefile.sys PTEs with bit 7 clear are not looked up at all.
    • Allocation bitmap. With this PR's decoding, the 3,732,243 decoded slots of PTEs with PageFileAllocated set are all allocated, and none is claimed twice. The 231,893 decoded PTEs with it clear are left unresolved. Before commit 5, 2,855 decoded slots were free and 3,872 claimed twice. With bits 1-4, 501,225 are free, 49,242 lie past the end of the file, 8,887 point to a page file 3 that doesn't exist, and 133,612 are claimed twice.

Tests

test/test_windows_swap_ptes.py builds page tables by hand for WindowsIntel32e, WindowsIntelPAE and WindowsIntel. It also runs the automagic against small ISFs: mask in MiState, global mask, no mask, a bad mask, values already set, a layer without a kernel offset, a non-Windows layer, PageFileAllocated at bit 2 and at bit 13, and inheritance through build_configuration. It also covers:

  • reads from inside a paged out page;
  • reads across into the next page, whether it is present or paged out to a slot that isn't the next one;
  • an unknown or zero mask;
  • a read-only paged out page table;
  • a page file number without a swap layer;
  • PTEs with PageFileAllocated clear, with and without a swap layer.

That is 74 tests, needing no image and running in about two seconds. On develop 48 fail; the 26 that pass check behaviour that must not change. They run in a new CI step.

Locally, on the last commit, these CI steps pass: Windows plugins on win-10_19041-2025_03.dmp 63, Windows volshell 2, and ruff. Linux plugins (41) and Linux volshell (1) passed on commit 4. Commit 5 changes no Linux code, and I didn't re-run them.

Same place as #2043. This touches the same place in WindowsMixin as #2043: both add methods after _page_is_valid. With both applied the conflict is only textual, and both test files pass.

Version. I have not bumped the framework version or added an API_CHANGES.md entry, since the new settings are optional. Happy to add a minor bump if you want one.

Tested later on six VMs (comment): Server 2016 (14393), 2019 (17763), 2022 (20348) and 2025 (26100), Windows 10 21H2 x86 PAE (19044), and Windows 11 24H2 (26100), each a complete dump plus pagefile.sys. That comment is from before commit 5:

  • Inside the marked arrays, pages read from pagefile.sys matched markers written inside the guests, with no wrong page.
  • Every page file PTE inside a VAD went to the slot given by the kernel's layout.
  • Plugin output without a page file was the same as develop (48 of 48).
  • With swapfile.sys as the second swap location, all 299 page file 1 PTEs (x86 and Windows 11) went to the right slot in it.

Later checks (comment):

  • Outside the arrays, 601 pages read from pagefile.sys whose PTE has PageFileAllocated clear held a full marker pair (118, 180, 113, 106 and 84 on five VMs, none on x86). For 466 of them, the marker is another page's own. This led to commit 5.
  • Re-run with commit 5 on all six VMs (comment).
    • In the marker check, every page that commit 5 no longer reads from pagefile.sys has PageFileAllocated clear, and no page is newly read from it.
    • The pages in the marked arrays that show their own marker are unchanged.
    • Plugin output with pagefile.sys is the same as on commit 4 (48 of 48).
  • swapfile.sys. 43 of the 299 page file 1 PTEs have PageFileAllocated clear, and their slots in swapfile.sys are free. Commit 5 leaves them unresolved. The 256 with the bit set still go to the right slot.
  • PTEs with PageFileHigh = 1 and both page file bits clear are reset PTEs (MEM_RESET). The kernel tests for this shape in MI_IS_RESET_PTE (14393, 17763, 20348, 26100 and 19044 x86), and while such a page is clean, MiCheckReservePageFileSpace reserves no page file space for it (14393, 20348, 26100). They are 212,638 of the 231,821 PTEs with both bits clear on my laptop's live dump, and 1,025 of 3,291 on the CI image. develop reads those with bit 7 set from a page file slot (all but one on the laptop, at slot 1 of pagefile.sys; all 1,025 on the CI image, at slot 0x2001). Commit 5 leaves them unresolved (comment).

Not tested:

  • Kernels older than 14393 with a page file. Commit 5 changes kernels with PageFileAllocated at bit 14 (Windows 8 / 8.1 without the August 2018 updates). The fault handler tests that bit the same way on 9200 and 9600, x64 and x86 (comment, comment), but I've run commit 5 on such a kernel only on DC01, which has no page file. The kernels with the bit at 24 come from pre-release Windows 8 branches, and I haven't looked at their code. Windows 7 has no PageFileAllocated, so commit 5 doesn't change it.
  • An InvalidPteMask other than 0 on builds other than 19041. All six VMs had mask 0, and the two 19041 images had 0x2000.
  • swapfile.sys page contents. The 25 pages I compared with MemProcFS (all zero, Windows 11) have PageFileAllocated clear, so commit 5 no longer reads them, and no page read from swapfile.sys has been compared.

If you have such images with their page files, running this branch over them would help a lot. windows.dlllist, envars and malfind with --single-swap-locations are where differences show. The comparison scripts I used are on the pr2080-check-scripts branch of my fork.

Not changed here:

This came out of a student team project on local LLMs for digital forensics at Joongbu University, advised by @Slothmor3 and @ring7a. Team: @vmaca123, @pmj2744, @ydam113.

_translate_swap sent a paged out entry at any level of the walk to the
page file, at PageFileHigh << invalid_bits. A paged out page directory
entry holds the location of a page table, so this read 2 MB (4 MB
without PAE) of the page file at a scaled offset as if it were data.
PageFileHigh of all ones, which means the PTE has to be rebuilt from the
VAD, was also sent to the page file.

Resolve only faults at the page table entry level, and leave all ones
alone. Adds hand-built page table tests for the three Windows layers,
run in CI as a unit test step that needs no image.
Kernels whose _MMPTE_SOFTWARE has SwizzleBit (from the August 2018 L1TF
updates onwards) keep the page file number at bit 12 instead of bit 1,
and add InvalidPteMask to software PTEs whose SwizzleBit is clear. The
Windows layers read the number at bit 1 and used PageFileHigh as is, so
demand-zero PTEs were read from the page file at 0x2000000 and most paged
out pages went to the wrong page file or offset.

- WinSoftwarePteLayout copies the bit positions of PageFileLow and
  SwizzleBit, and InvalidPteMask from MiState.Hardware or the older global
  MiInvalidPteMask, onto the kernel's layer as three optional settings.
  Process layers inherit them with the rest of the layer configuration.
- With these settings, _translate_swap reads the page file number at
  PageFileLow, removes the mask only when SwizzleBit is clear, and accepts
  any non-zero protection instead of requiring bit 7, which is part of the
  protection and is clear for read-only and execute pages.
- Without them, the old layout and the bit 7 test are kept.
_translate_swap returned the start of the page file slot, so a read that
did not start on a page boundary got the bytes from the start of the
slot. Reads of whole pages were right, which is why page level checks
did not show it. Return the slot plus the offset inside the page, as
_translate does for a present page.
When the kernel has SwizzleBit but its InvalidPteMask could not be read,
or was rejected, the layout was still set and no mask was removed, so a
demand-zero PTE was again read from the page file at 0x2000000. Keep a
mask of 0, which is what CPUs that need no mask report, and leave PTEs
whose swizzle bit is clear unresolved when the mask is unknown.

Adds tests for this, for a read-only paged out page table, and for a
page file number without a swap layer.
@vmaca123
vmaca123 force-pushed the windows-pagefile-pte-layout branch from 23703a5 to 28934db Compare November 10, 2026 15:10
@vmaca123

Copy link
Copy Markdown
Author

I've updated the branch:

  • A fourth commit fixes a case found while reviewing: when the kernel has SwizzleBit but its InvalidPteMask can't be read, the previous version still set the layout and brought back the reads at 0x2000000. PTEs whose SwizzleBit is clear are now left unresolved in that case, and a mask of 0 is kept.
  • The third commit is re-authored (it had the wrong e-mail address), hence the force push. The code is unchanged.
  • The description now has plugin output comparisons with develop. Without a page file, pslist, cmdline, dlllist, envars, vadinfo, malfind, svcscan and netscan are identical on the three images I have.

I could only test 64-bit images of two builds (10.0.19041 and 10.0.26100) against real bytes. If you have 32-bit images or other builds with their page files, could you run the branch over them? The description lists what I couldn't test.

@vmaca123

vmaca123 commented Nov 12, 2026 •

Copy link
Copy Markdown
Author

Update (2026-11-18): Some of the PTEs in the second table have PageFileAllocated clear: 6,340 on Server 2016, 13,533 on 2019, 10,184 on 2022, 6,555 on 2025, 26,684 on x86 and 29,615 on Windows 11. The same is true of 43 of the 299 swapfile.sys PTEs, among them the 25 Windows 11 pages compared with MemProcFS. Their slots are free or belong to another page, so commit 5 leaves them unresolved, and matching MemProcFS on them says nothing about the bytes. The marker results in the first table are unchanged. Details: #2080 (comment)


I tested the "Not tested" items myself on six Hyper-V VMs: Windows Server 2016, 2019, 2022 and 2025, Windows 10 21H2 x86 (PAE), and Windows 11 24H2.

Inside each VM, a script allocated 64 MB buffers well past the RAM size and wrote a marker into every page: process number, buffer and page index. It held the buffers until most of them were paged out. The dump was a complete dump taken by NMI into a dedicated dump file, and pagefile.sys was copied from the VM's disk after power-off. Each page of these buffers that Volatility read from pagefile.sys was then checked against its own marker:

VM Build Read from pagefile.sys: right page / wrong page develop
Server 2016 14393 511,356 / 0 same as the branch
Server 2019 17763 600,009 / 0 none read
Server 2022 20348 640,911 / 0 none read
Server 2025 26100 608,710 / 0 none read
Windows 10 x86 19044 219,907 / 0 none read
Windows 11 26100 480,450 / 0 none read

Beyond the marked buffers, I looked at every software PTE inside a process VAD that points into pagefile.sys. The table shows how many each version translated to the slot given by the kernel's own layout and mask:

VM PTEs Branch: right slot / other slot develop: right slot
Server 2016 550,744 550,744 / 0 543,122
Server 2019 655,018 655,018 / 0 4
Server 2022 765,610 765,610 / 0 7
Server 2025 741,917 741,917 / 0 29
Windows 10 x86 484,412 484,412 / 0 683
Windows 11 1,008,852 1,008,852 / 0 5

On 14393 the kernel has no SwizzleBit and PageFileLow starts at bit 1, and the automagic picked that up. develop gets these PTEs right too, except the 7,622 whose protection doesn't have bit 7 set (read-only and similar). The marked buffers were all read-write, which is why both versions agree on them. On the x86 PAE kernel the automagic found PageFileLow at bit 12 and SwizzleBit at bit 4, as on x64. InvalidPteMask was 0 in all six (host CPU i9-12900K). develop also sent 123 PTEs with PageFileHigh 0xFFFFFFFF on x86, and 37 compressed-store PTEs on Windows 11, to other places in pagefile.sys; the branch doesn't.

MemProcFS 5.19.0 read the same bytes for all of these pages on Server 2016, 2022, 2025 and Windows 11. It couldn't open the x86 dump. On Server 2019 it differed on half the pages until its kernel symbols were in place; that was on the MemProcFS side (ufrisk/MemProcFS#432). With the symbols, 655,017 of 655,018 matched, and the remaining page was unreadable in MemProcFS.

Without a page file, windows.pslist, cmdline, dlllist, envars, vadinfo, malfind, svcscan and netscan gave the same output on develop and the branch for all six dumps (48 of 48). With pagefile.sys attached, the branch returns more: for example 42 to 744 more envars rows per dump, and command lines and DLL paths that develop shows as empty.

Later I also checked swapfile.sys, given as the second swap location. All page file 1 PTEs (274 on x86, 25 on Windows 11) went to the right slot in swapfile.sys; develop read none of them. Only the 25 Windows 11 pages could be compared with MemProcFS: they matched, but all 25 were zero pages.

Still not covered: pages in the compressed store (#2081).

@ricardojrdez

Copy link
Copy Markdown
Contributor

I tested this branch on seven VirtualBox guests with known page content. The builds are 19045, 22631 and 26100, and InvalidPteMask is non-zero on all three. That covers the "non-zero mask on builds other than 19041" case from your list.

Setup

  • Branch head 28934dbf; baseline is its merge base on develop, 77ff0b19. _translate_swap there is the same as in v2.28.2.
  • Guests: Windows 10 22H2 (19045.6456), Windows 11 23H2 (22631.7654) and Windows 11 24H2 (26100.9725). Each has 4 GiB RAM and a system-managed pagefile.sys. Memory compression was off ("nomc") or on ("mc"). With compression on I used compressible pressure, and on 19045 also incompressible pressure ("mcr").
  • In each run, one process committed 512 MiB (131,072 pages). Every page held a self-describing marker: run id, PID, sequence number, VA and a checksum. The process then emptied its working set, and 3 GiB of memory pressure pushed the pages out.
  • The VM was paused, dumped with VBoxManage debugvm dumpvmcore and powered off without resuming. pagefile.sys was then read from the VM disk, so RAM and page file are from the same instant.
  • Ground truth comes from my own 4-level walk from DirectoryTableBase. It decodes the leaf PTEs with the PDB bitfields and MiState.Hardware.InvalidPteMask, and reads paged-out page tables from pagefile.sys. For every page-file PTE, it gives the expected marker.
  • Reader: EPROCESS.add_process_layer(), then layer.read(va, 4096, pad=False) on every marker page. Each result is classed as correct, another marker page (wrong address), other wrong bytes, or zero/unreadable. I also recorded the translated layer and offset.
  • The automagic set page_file_low_bit=12, swizzle_bit=4 and invalid_pte_mask=0x200000000000 on the kernel layer of all three builds, and the process layers inherited them.

Pages in pagefile.sys whose page table is resident (--single-swap-locations pagefile.sys, slot 0)

Build Run Pages with SwizzleBit=0 (mask set) branch: correct branch: wrong / other marker develop: correct
19045 nomc 92,672 49,152 92,672 0 / 0 0
22631 nomc 131,046 65,536 131,046 0 / 0 0
26100 nomc 352 0 352 0 / 0 0
26100 mc 2,048 2,048 2,048 0 / 0 0
  • All 226,118 reads went to swap_layers0 at exactly the slot given by the ground truth. That includes 67,584 SwizzleBit=0 PTEs on 22631/26100 whose mask bit is set.
  • develop reports every one of these pages as unreadable. It derives page file 11 (SwizzleBit=1) or 3 (SwizzleBit=0) and finds no such layer.
  • As a diagnostic I gave develop pagefile.sys in all 16 slots, so the number no longer matters. It then returned another marker page exactly 8,192 pages away (the unremoved mask) for 41,613 pages on 19045 and 59,099 on 22631. It returned other wrong bytes for 7,234 / 6,296 pages, and on 26100 mc for all 2,048 pages. The branch fixes exactly this.

Pages expected to stay unreadable. These came back as exceptions, never as bytes. No configuration of the branch (with or without the page file) returned a wrong or other-marker page in any run (0 of 917,504 pages).

Build Run Class Pages branch + pagefile.sys
19045 nomc page table itself paged out 38,400 unreadable (PagedInvalidAddressException)
26100 nomc page table itself paged out 130,720 unreadable (PagedInvalidAddressException)
19045 mc / mcr compressed store (page file 2) 131,072 / 131,072 unreadable (SwappedInvalidAddressException)
22631 mc compressed store 131,072 unreadable
26100 mc compressed store 129,024 unreadable
  • On develop, the paged-out page-table entries raised SwappedInvalidAddressException (the upper-level path). On the branch they raise PagedInvalidAddressException, as expected from commit 1.
  • The 26 transition pages on 22631 nomc were correct on both branches.
  • Without a page file, the branch read none of the paged-out pages and returned no wrong bytes.

Plugin parity without a page file. The JSON output of windows.pslist, windows.cmdline and windows.dlllist is byte-identical between the branch and develop on one image per build: 19045 (113 / 113 / 4,830 rows), 22631 (118 / 118 / 4,965) and 26100 (126 / 126 / 5,478).

Not covered by this test

  • All marker pages were read-write (protection 4, bit 7 set), so dropping the bit-7 requirement is not exercised.
  • All reads were whole, page-aligned pages, so the in-page offset fix (commit 3) is not exercised.
  • swapfile.sys was not tested.
  • Pages behind paged-out page tables and compressed-store pages remain unreadable, as described in the PR.

@vmaca123

vmaca123 commented Nov 16, 2026 •

Copy link
Copy Markdown
Author

Update (2026-11-18): 6,340 of the 550,744 PTEs below, including 1,148 of the 7,622, have PageFileAllocated clear. Their slots are free or belong to another page, so commit 5 leaves them unresolved, and matching MemProcFS on them says nothing about the bytes. The 25 swapfile.sys pages are among these as well. Details: #2080 (comment)


Thank you for running this. A non-zero InvalidPteMask on 22631 and 26100 was the case I couldn't produce. Apart from the two 19041 images, everything I could dump reports a mask of 0: my laptop (26100) and six Hyper-V guests, all on one i9-12900K host.

For the three items your test didn't reach, this is what I have. It doesn't replace a test like yours.

Bit 7

Server 2016 (14393) from my earlier comment has 7,622 page-file PTEs whose protection doesn't have bit 7 set (6,432 read-only, 1,190 with protection 0x10 or 0x18). develop leaves those unreadable. The branch sends all 550,744 page-file PTEs inside process VADs in that dump to the slot given by the kernel's layout, and MemProcFS 5.19.0 read the same bytes as the branch for all 550,744 pages.

This is the only image with its page file where I can separate the bit-7 change. On DC01 (Server 2012 R2, in the description) it is also the only difference from develop, 369 PTEs, but I have no page file to check their bytes. On the newer builds develop already reads the page file number from the wrong bits, so the bit-7 change can't be measured on its own there. test_a_read_only_page_is_paged_out covers it with built page tables.

Offset inside a page (commit 3)

I read paged-out pages at a random offset and length, 600 reads per image, with every fourth read crossing into the next page. Reads inside a page were compared with pagefile.sys at slot + offset, where the slot comes from my own page-table walk rather than from Volatility. It uses the same rule as the branch, so that column checks the offset. The MemProcFS columns are the independent check: every read that returned bytes was compared with MemProcFS reading the same address and length.

Image Branch Inside a page: same as pagefile.sys Inside a page: same as MemProcFS Crossing: same as MemProcFS
Szechuan Sauce DESKTOP (19041, mask 0x2000) commits 1-3 450 / 450 435 / 435 (15 unreadable in MemProcFS) 131 / 131
Server 2022 28934db 450 / 450 450 / 450 150 / 150
Server 2025 28934db 450 / 450 450 / 450 150 / 150
Windows 11 24H2 28934db 450 / 450 450 / 450 146 / 146
Windows 10 x86 28934db 450 / 450 – (MemProcFS can't open it) –

The remaining reads (0 to 19 per image, all of them crossing reads) raised an exception and returned no bytes. With only the first two commits, 440 of the 450 inside reads on DESKTOP came back with the bytes at the start of the slot instead of the bytes at the offset. The other 10 matched pagefile.sys at slot + offset.

Server 2016 and 2019 aren't in the table. My sampler assumed the newer PTE layout and found only 53 candidates on 14393 (the 52 readable ones all matched). On Server 2019 MemProcFS didn't have its kernel symbols when this ran.

test_a_read_inside_a_paged_out_page_starts_at_that_offset and test_a_read_across_a_paged_out_page_continues_in_the_next_page cover it with built page tables.

swapfile.sys

Still thin, as the description says. In my earlier comment, all page file 1 PTEs (274 on x86, 25 on Windows 11) went to the right slot in swapfile.sys. The only pages I could compare with MemProcFS were those 25, and all were zero.

I can share the sampling scripts if they would help.

@ricardojrdez

Copy link
Copy Markdown
Contributor

Thanks, that covers the three gaps well enough for me to follow, and the numbers line up with your earlier comment.

I also ran test/test_windows_swap_ptes.py on 28934dbf: 59 passed. With volatility3/ from the merge base (77ff0b19), the three tests you cite fail on all three architectures. For the crossing read, develop returns PF0:NEXT instead of \0\0\0\0NEXT, which is exactly the commit 3 bug.

A few follow-ups, mostly so the evidence doesn't depend only on MemProcFS agreeing with the branch:

Bit 7

  • MemProcFS decodes these PTEs the same way the branch does (no bit 7 requirement), so matching bytes show the two are consistent, not that the slot is the right one. Could you run the 7,622 PTEs on 14393 through the AllocationBitmap check from the description? Allocated vs free slots for that subset would be independent evidence.
  • On the 1,190 with protection 0x10 / 0x18: if I read the WRK definitions correctly, 0x18 is MM_NOACCESS and 0x10 is
    MM_DECOMMIT. Reading a paged-out no-access page is fine for us, but a decommitted PTE that still carries a page file number is surprising. Do you know what those are? A split by protection value, plus the allocation bitmap result for each, would answer it.

Offset inside a page

  • With only commits 1-2, 10 of the 450 inside reads on DESKTOP matched slot + offset. Were those pages uniform (e.g. all zero), so that the start of the slot and the offset hold the same bytes?
  • For the crossing reads that raised (up to 19 per image): which exception was it, and what kind of PTE did the second page have (demand zero, compressed store, paged-out page table, protection 0, past the end of the file)? And what did MemProcFS return for those addresses? If they all fall into the "expected to stay unreadable" classes, that closes it.
  • Minor: the crossing test goes from a paged-out page into a present page. A case where both pages are in the page file, in non-adjacent slots, would cover the split in _mapping on the swap side as well.

swapfile.sys

  • Agreed it stays thin. I don't think it needs to block this PR, since the change there is only the page file number, and that is already covered by the slot checks.

Yes, please share the sampling scripts (!pte sampling, allocation bitmap, random-offset reads). I'd like to rerun them on my VirtualBox images, where the mask is non-zero on 22631 and 26100, and add a read-only marker run to cover bit 7 directly.

…ated

Kernels whose _MMPTE_SOFTWARE has PageFileAllocated leave a page file
offset in PageFileHigh of some PTEs that have it clear. In the images
checked, every decommitted (protection 0x10) and guard page PTE with an
offset was among them. Their slot was free in the page file's
AllocationBitmap or also named by a PTE with the bit set, and in test VMs
such a slot held that other page, as markers written in the guest showed.

The automagic now also reads the position of PageFileAllocated (it moves
between kernels), and _translate_swap leaves PTEs with it clear
unresolved, so without a swap layer they are no longer reported as
swapped. Kernels without the field, and layers without the kernel's
layout, are unchanged.

The tests also read across two paged out pages in slots that are not
next to each other, and each test slot now ends with its own tag.

Co-authored-by: pmj2744 <267242619+pmj2744@users.noreply.github.com>
Co-authored-by: ydam113 <81817139+ydam113@users.noreply.github.com>
@vmaca123

Copy link
Copy Markdown
Author

Thank you for running the tests on the merge base. Your question about protection 0x10 turned up a problem that this branch made worse and that develop already has, so that comes first.

PTEs with PageFileAllocated clear

On 14393, all 1,030 PTEs with protection 0x10 have _MMPTE_SOFTWARE.PageFileAllocated (bit 13 on that kernel) clear. So do:

  • all 323 guard pages (0x14);
  • 69 of the 160 at 0x18;
  • 49 of the 6,432 read-only ones;
  • 4,869 at 0x04 and 0x06.

That is 6,340 of the 550,744 page file PTEs. On the eight images below, the two groups behave differently. DESKTOP is left out because of its smeared page tables, and DC01 because I couldn't read its bitmap. Counts are page file 0 PTEs inside a VAD with the slot inside the file. Each cell gives PTEs / slots free in AllocationBitmap / slots also named by another PTE with the bit set.

Image PageFileAllocated set PageFileAllocated clear
Server 2016 (14393) 544,404 / 0 / 0 6,340 / 223 / 5,231
Server 2019 (17763) 641,485 / 0 / 0 13,533 / 40 / 9,584
Server 2022 (20348) 755,426 / 0 / 0 10,184 / 220 / 8,503
Server 2025 (26100) 735,362 / 0 / 0 6,555 / 1 / 5,741
Windows 11 24H2 (26100) 979,237 / 0 / 0 29,615 / 8,453 / 12,110
Windows 10 x86 PAE (19044) 457,728 / 0 / 0 26,684 / 25,423 / 33
CI image (19041) 36,467 / 0 / 0 24,535 / 23,406 / 40
My laptop, Windows 11 25H2 (26100), live dump 674,623 / 0 / 0 207,131 / 81 / 0

On the seven images other than the laptop, protection 0x10 and the guard values 0x11 and 0x14 occur only with the bit clear.

Where I could find out what a bit-clear slot holds, it held something else:

  • Markers. Every page inside the marked arrays that was read from pagefile.sys had the bit set and showed its own marker (511,356, 600,009, 640,911, 608,710, 480,450 and 219,907 on the six VMs). So the markers never show what a bit-clear page's own content is, only what its slot holds.
    • Outside the arrays, 601 pages with the bit clear held a full marker pair (118, 180, 113, 106, 84 and 0).
    • For 466 of them, another PTE with the bit set names the same slot, and that page shows this marker as its own. The other PTE is in another process for 394 of them and in the same process for 72.
    • For 93, no other PTE I walked names the slot.
    • For 42 (Windows 11), the owning page is outside the marked arrays, so I couldn't compare.
  • Owners on 14393. Of the 6,340, 223 slots are free and 5,231 are also named by a process PTE with the bit set.
    • Of the remaining 886, 299 slots are named by _MMPFN.OriginalPte of a resident page (active or standby) with the bit set.
    • I found no owner for 587. I didn't walk prototype PTEs, kernel space or page tables below transition entries.
  • PFN entries. The bit means the same thing in OriginalPte. Entries with it set never name a slot that a process PTE with it set also names. All 22,220 pairs of such a slot and a PFN entry come from OriginalPte values with the bit clear.
  • swapfile.sys. 43 of the 299 page file 1 PTEs from my earlier comment have the bit clear: all 25 on Windows 11 and 18 on x86. All 43 slots are free in swapfile.sys's bitmap. So the 25 swapfile.sys pages I compared with MemProcFS (all zero) were among them, and commit 5 no longer reads any of them.

Reading these slots returns a free slot's old contents or another page. MemProcFS reads these PTEs the same way, which is why matching it didn't catch this. develop reads the ones with bit 7 set: on 14393 that is 5,192 of the 6,340, including every guard page. WinDbg's !pte doesn't look at the bit either. On my laptop's Windows 11 dump it prints PageFile: 0, Offset: 3f6ece for 003F6ECE00000022.

I can't say what these PTEs are.

  • On the six VMs and the CI image, most of them have PageFileReserved set (6,287 of the 6,340 on 14393). That looks like page file space reserved for the page but never written for it.
  • On my laptop's live dump, only 72 of the 207,131 have PageFileReserved set.
  • I haven't looked at the kernel's code.

Commit 5 (9eeb1fa9, pushed)

What changes:

  • The automagic also reads where PageFileAllocated is. In the x86/x64 kernels of the symbol pack it is at bit 2, 13, 14 or 24.
  • _translate_swap leaves PTEs with it clear unresolved.
  • Without a swap layer, such a PTE now raises PagedInvalidAddressException instead of SwappedInvalidAddressException, because it isn't in any page file. This also changes the swapped count of windows.statistics.
  • Kernels without the field, such as Windows 7, and layers without the kernel's layout are unchanged.

Re-run with commit 5:

  • Markers on three VMs. The pages that show their own marker are the same: 511,356 on 14393, 219,907 on x86 and 480,450 on Windows 11. No page with the bit clear is read.
  • DC01 (Server 2012 R2, bit 14): 327 of the 369 differences from develop had the bit clear and are left alone again. 1,432 PTEs with bit 7 set that develop reports as swapped are also left alone, because their bit is clear. Kernels with the bit at 14 (Windows 8/8.1 without the August 2018 updates) are checked only this way, since DC01 has no page file.
  • Plugins. The eight plugins in the description give the same output with and without commit 5, 32 of 32. That covers the CI image, DESKTOP and DC01 without a page file, and DESKTOP with its page file.

Bit 7

Of the 7,622 PTEs, 6,474 have PageFileAllocated set: 6,383 read-only and 91 at 0x18. All their slots are allocated, and no other PTE with the bit set names them. The other 1,148 have it clear (49 read-only, 1,030 at 0x10, 69 at 0x18), so commit 5 leaves them alone.

The allocation bitmap by protection, allocated / free:

  • 0x01: 6,432 / 0
  • 0x10: 963 / 67
  • 0x18: 159 / 1

For the bit-clear ones, "allocated" mostly means another PTE with the bit set names the slot.

Offset inside a page

The 10 reads with commits 1-2. In all 10, the bytes at the start of the slot equal the bytes at the offset. 3 pages are all zero, 1 is a single repeated non-zero byte, and in the other 6 both ranges are zero.

The 19 failed crossing reads on DESKTOP. All but one failed on the second page:

Second page Exception Count MemProcFS for the second part
compressed store SwappedInvalidAddressException 8 bytes 3, unreadable 5
PTE 0 PagedInvalidAddressException 5 bytes 1, unreadable 4
prototype PTE PagedInvalidAddressException 4 bytes 3, unreadable 1
demand zero PagedInvalidAddressException 1 zeros
  • The last one raised InvalidAddressException in the physical layer. Its own PTE is 0x5300530050, which reads as UTF-16 text, in a smeared table. The next page maps past the end of RAM, and MemProcFS can't read it either.
  • For the other 18, MemProcFS read the first part to the same bytes as the slot.
  • None of the 19 is past the end of the file or a paged-out page table.
  • On the VMs, the x86 one goes into the compressed store. Of the 4 on Windows 11, 3 go into demand-zero pages, where MemProcFS returns zeros, and 1 into a PTE of 0, which MemProcFS can't read.

Two page file pages. I added test_a_read_across_two_paged_out_pages_uses_the_slot_of_each, with slots 9 then 5. Each test slot now ends with its own tag, so the test checks both slots. In the samples:

  • DESKTOP: 127 of the 131 crossing reads went from one page file page into another, 8 of them into a slot that isn't the next one.
  • Windows 11: 146 such reads, 3 into a slot that isn't the next one.
  • x86: 148, all into the next slot.

All of them equal pagefile.sys read directly at both slots.

With commit 5, some reads that worked before now fail:

Image Inside reads that now fail Crossing reads that now fail Other reads
DESKTOP 12 0 same bytes as before
Windows 11 21 5 same bytes as before
x86 27 14 same bytes as before

In every one of them, the first or second page has PageFileAllocated clear. On DESKTOP, 9 of the 12 slots are free, and the slots are named by up to 141 PTEs.

Tests. There are now 74, and develop fails 48 of them. On commit 5, these CI steps pass:

  • the Windows plugin tests on the CI image (63);
  • Windows volshell (2);
  • ruff.

Scripts. They are on the pr2080-check-scripts branch of my fork: https://github.com/vmaca123/volatility3/tree/pr2080-check-scripts.

  • The README says what each one reads and writes, and the order to run them.
  • pte_swizzle_probe.py writes the raw PTE list and bitmaps that the others use.
  • allocated_bit_check.py and pfn_original_pte_slots.py are the PageFileAllocated checks above.
  • subpage_followup.py re-draws the random-offset sample with the same seed.

I've updated the description for commit 5. Numbers measured before it are marked as such.

@vmaca123

Copy link
Copy Markdown
Author

Follow-up on PageFileAllocated, with what I couldn't say in my last comment.

What the kernel does

The page fault handler reads the page file slot only when PageFileAllocated is set. Otherwise it resolves the fault as demand zero.

  • 19041 (the CI image, read with kd): nt!MiDispatchFault handles transition PTEs first (fffff804'362598ed bt rbx,0Bh), then tests bit 2 (fffff804'362598f8 movzx eax,bl; shr al,2; test al,1; jne).
    • The taken branch leads to MiResolvePageFileFault (fffff804'36259e66).
    • The fall-through leads to MiResolveDemandZeroFault (fffff804'36259968).
  • The same gate on other builds:
    • 14393 tests bit 13 (shr rax,0Dh; test al,1; jne).
    • 19044 x86 tests bit 2 (shrd ecx,eax,2; test cl,1; jne).
    • On 26100, MiDispatchFault goes to MiResolvePageFileFault only if MiGetPagingFileOffset returns non-zero, and that function returns 0 when bit 2 is clear.
  • The bits match the two bitmaps. On 26100, MiReleasePageFileInfo clears the slot in AllocationBitmap for PageFileAllocated and in ReservationBitmap for PageFileReserved.
  • Where Reserved-only offsets come from. MiReservePageFileSpaceForPage and decommit (MiDecommitHandlePageFileFormatPte) write PTEs with Reserved only. Decommit releases the allocation and keeps the reservation.

So commit 5 matches the kernel. For these PTEs the right content is a zero page, or no access for decommitted pages, and Volatility leaves them unresolved as it does demand-zero PTEs. I checked 14393, 19041, 19044 x86 and 26100, not 17763, 20348 or Windows 8/8.1.

There is a second kind of bit-clear PTE: PageFileHigh = 1 with both bits clear, e.g. 0x0000000100000080. My laptop's live dump has 207,050 of them (almost all of its 207,131 bit-clear PTEs), and Server 2016, Server 2019, the Windows 11 VM and the CI image have 53, 6, 5 and 918. I don't know what they are. The kernel treats them as demand zero too, and before commit 5 the branch read slot 1 for them.

Owners of the remaining slots on 14393

In my last comment, 886 bit-clear PTEs (on 834 slots) pointed to a used slot that no PTE with the bit set in my walk names.

  • 299 slots: _MMPFN.OriginalPte of a resident page (186 active, 113 standby) names the slot with the bit set.
  • The other 535 slots: I scanned the dump and pagefile.sys for 8-byte values shaped like a software PTE with the bit set and that slot number. All 535 have one in RAM outside the PFN database that isn't one of the PTEs I walked, and 315 also have one in pagefile.sys. I haven't located the structures; I didn't walk prototype PTEs, kernel space or paged-out page tables.
  • Controls: with the same number of slots, slots owned by a walked PTE are found 834 of 834 times, and free slots match 29 of 834 times (3.5%) in RAM.

Re-run with commit 5 on all six VMs

  • Markers. I compared each VM's marker check page by page with the run from before commit 5 (marker_commit5_diff.py).
    • Every page that commit 5 no longer reads from pagefile.sys has PageFileAllocated clear. Every page it still reads there has the bit set, and no page is newly read from it.
    • That is 144, 218, 175, 124, 327 and 337 pages on Server 2016, 2019, 2022, 2025, x86 and Windows 11. They include all 601 pages with another position's marker.
    • Pages in the marked arrays that show their own marker from pagefile.sys are unchanged: 511,356, 600,009, 640,911, 608,710, 219,907 and 480,450.
    • Outside the arrays, full marker pairs still come from pagefile.sys only on x86 (173 pages) and Windows 11 (108). Each sits where its own array would put it, but that array has only 173 (x86) or 98 and 10 (Windows 11) such pages, below my 256-page threshold, so my check counts them as outside.
  • Plugins with pagefile.sys. The eight plugins in the description give the same output with commit 4 (28934dbf) and commit 5 on all six VMs, 48 of 48. netscan is empty with both on Server 2025 and Windows 11. On Server 2016 they're also the same without the page file, 8 of 8.
  • swapfile.sys. On x86, the 256 page file 1 PTEs with the bit set still go to the right slot. The 18 on x86 and 25 on Windows 11 with it clear are now unresolved. With swapfile.sys added as the second swap location, no marked page is read from it, so the marker counts don't change on either VM.

MemProcFS

MemProcFS reads PTEs with PageFileAllocated clear the same way. On the five VMs where Volatility read a marker pair from such a PTE's slot before commit 5 (118, 180, 113, 106 and 84 pages on Server 2016, 2019, 2022, 2025 and Windows 11), MemProcFS returns the same marker for all 601. I've opened ufrisk/MemProcFS#441 there.

The new scripts are on the same pr2080-check-scripts branch: slot_owner_scan.py, mpfs_allocated0_markers.py, mpfs_marker_slot_state.py and marker_commit5_diff.py, plus an updated pfn_original_pte_slots.py that lists the 834 slots no walked PTE names, split by whether an OriginalPte names them.

@ricardojrdez

Copy link
Copy Markdown
Contributor

I checked the PageFileAllocated gate on the builds you hadn't looked at: 17763, 20348 and 9600 x64, plus 9200 x86. I did it statically: ntoskrnl.exe from the symbol server (17763) or from the evaluation ISOs (Server 2022, Server 2012 R2) and the Windows 8 x86 ISO, the matching ntkrnlmp/ntkrpamp PDB converted with pdbconv, and MiDispatchFault disassembled from the PDB public symbols.

In all of them MiDispatchFault checks Prototype and then Transition, and after that tests PageFileAllocated. If the bit is set it calls MiResolvePageFileFault; otherwise it falls through to MiResolveDemandZeroFault.

  • 17763.1 and 17763.9479 (x64), bit 2: the same code as 19041. bt rbx,0Bh (fffff800'1403f77b on .9479), then movzx eax,bl; shr al,2; test al,1; jne (...3f7ac). The taken branch reaches MiResolvePageFileFault (...3f8a6), the fall-through MiResolveDemandZeroFault (...3f86b). rbx holds the PTE, loaded with mov rbx,[r15].
  • 20348.587 (Server 2022 x64), bit 2: bt rbx,0Bh (...330dbc), then movzx eax,bl; shr al,2; test al,1; jne (...330dc7). Taken: MiResolvePageFileFault (...331248). Fall-through: MiResolveDemandZeroFault (...330e2c).
  • 9600.17031 (Server 2012 R2 x64), bit 14: mov rax,[r14]; ... bt rax,0Bh (...ab536), then shr rax,0Eh; test al,1; jne (...ab541). Taken: MiResolvePageFileFault (...abed4). Fall-through: MiResolveDemandZeroFault (...ab5b3).
  • 9200.16384 (Windows 8 x86 PAE), bit 14: mov esi,[ebx]; mov edi,[ebx+4], then and eax,800h; jne for Transition, then shrd eax,edi,0Eh; test al,1; jne (0043c0a5). Taken: MiResolvePageFileFault (0043cc2a). Fall-through: MiResolveDemandZeroFault (0043c109).

The PDB layouts match: PageFileAllocated is bit 2 on 17763/20348 and bit 14 on 9200/9600, where PageFileReserved is bit 13 and InStore bit 12. So the gate depends on the kernel's own _MMPTE_SOFTWARE, which is what reading the layout from the symbols gives you. I couldn't get a Windows 8 x64 (9200) kernel, so that one is still unchecked.

@vmaca123

Copy link
Copy Markdown
Author

Thanks for checking these four builds.

I looked at the kernels of two of my VMs the same way (ntoskrnl.exe from the guest, its PDB converted with pdbconv, MiDispatchFault disassembled from the PDB symbols). Both have the same gate:

  • 20348.587 (Server 2022): the same build as yours, with the same addresses. bt rbx,0Bh is at ...330dbc, and movzx eax,bl; shr al,2; test al,1; jne at ...330dc7. The taken branch reaches MiResolvePageFileFault (...331248), the fall-through MiResolveDemandZeroFault (...330e2c). rbx is loaded with mov rbx,[rdi].
  • 17763.3650 (Server 2019): the same sequence at other addresses. Prototype (bt rbx,0Ah) goes to MiResolveProtoPteFault and Transition (bt rbx,0Bh, ...5754b) to MiResolveTransitionFault. Then comes the bit 2 test (...5757c). The taken branch reaches MiResolvePageFileFault (...57676), the fall-through MiResolveDemandZeroFault (...5763b). rbx comes from mov rbx,[r15], as on your 17763 builds.

I've added your results to the description, under commit 5 and in "Not tested". 9600 x64 and 9200 x86 are now checked in the kernel code (Windows 8 x64 and 8.1 x86 are not), but I still haven't run commit 5 on a bit 14 kernel with a page file.

@vmaca123

Copy link
Copy Markdown
Author

I went back to two items in "Not tested" and to the kernels with PageFileAllocated at bit 24. None of them needed new images. Nothing in the branch changes; the description gets four edits (listed at the end).

1. PTEs with PageFileHigh = 1 and both page file bits clear are reset PTEs.

The kernel tests for this exact shape in MI_IS_RESET_PTE. On 26100.1742 (RVA 0x38ca90) it returns false if Valid, Prototype, Transition, PageFileAllocated or PageFileReserved is set. Then it removes InvalidPteMask (unless SwizzleBit is set), and shr rcx,20h; cmp rcx,1; sete al (0x38cacf) gives the result. 17763.3650, 20348.587 and 19044 x86 have the same function with the same checks. 14393.693 has it too, testing bits 13 and 12 and with no mask step.

Where it is used:

  • Reservation. MiCheckReservePageFileSpace makes the same test on the PFN's OriginalPte. If the page is reset, the PFN isn't Modified (test byte ptr [..+22h],10h, _MMPFN.u3.e1.Modified), and the PTE has neither Dirty1 nor Dirty (test ..,42h, bits 1 and 6 of _MMPTE_HARDWARE), it reserves no page file space.
    • 26100 does this inline (shr r9,20h; cmp r9,1 at 0x38bace).
    • 14393 (0xb593d) and 20348 (0x34425f) call MI_IS_RESET_PTE.
  • Other callers on 26100. MiActOnPte, MiRestoreTransitionPte, MiReservePageFileSpaceForPage and MiCombineCandidate.
  • Writer, on 26100.
    • For MEM_RESET, MiResetVirtualMemory passes action 0 (cmp dword ptr [rsp+70h],80000h at 0x26ddce, setne r15b at 0x26dddf) through MiWalkVaRange (0x26c839) to MiActOnPte.
    • There, a PTE that is still 0 (never touched) gets MiMakePageFilePte(r15) | Protection << 5 when the VAD check passes (0x26dc25-0x26dc41), and r15 is 1 on that path (0x26d535, 0x26d580).
    • MiMakePageFilePte(n) is n << 32, with InvalidPteMask ORed in when the mask isn't 0 (SwizzleBit instead if n overlaps the mask).
    • So a never-touched read-write page in a MEM_RESET range becomes 0x0000000100000080 when the mask is 0 (0x0000200100000080 on the CI image). I didn't trace what a reset page that is resident gets when it is trimmed later.

This is consistent with the MEM_RESET documentation: "data in the memory range ... is no longer of interest. The pages should not be read from or written to the paging file" (VirtualAlloc). So PageFileHigh = 1 here marks a reset page; it doesn't name a slot.

How many there are, counted with the kernel's rule on the same probe data as before (software PTEs inside VADs):

Image PTEs with both bits clear (PageFileHigh neither 0 nor all ones) reset PTEs of those with bit 7 set
Laptop live dump, 26100 231,821 212,638 212,637
CI image, 19041 3,291 1,025 1,025
s2016 / s2019 / s2022 / s2025 53 / 10 / 8 / 31 53 / 6 / 0 / 0 0 / 0 / 0 / 0
w10x86 / w11 VM 741 / 44 0 / 5 0 / 5
  • Laptop. 198,579 of the reset PTEs are exactly 0x0000000100000080 (page file 0, protection 4).
    • Of the other 19,183 PTEs with both bits clear, 19,174 are on the virtual store page file (PageFileLow = 2) and 9 on page file 0.
    • The kernel uses PageFileHigh 2, 3 and 4 as markers on the store page file too (MiDetermineModifiedPageListHead, MiSetStoreVirtualPagefileValue). That covers 10,499 with 2 and 1,494 with 3; the other 7,181 have larger values. I didn't look further at those.
  • s2016 and s2019. The 53 and 6 reset PTEs are all exactly 0x100000200, i.e. protection 0x10 (decommitted).
  • Slot 1. No PTE with PageFileAllocated set names slot 1 on any of these images.
  • DESKTOP is left out because some of its page tables are smeared. It has 103 reset-shaped PTEs inside VADs, 94 of them with protection 0.
  • develop reads PTEs with bit 7 set from the page file. For the reset PTEs that is slot 1 of pagefile.sys on the laptop, and slot 0x2001 on the CI image, where develop doesn't remove the mask.
  • Commit 5 leaves them unresolved. On 26100, MiGetPagingFileOffset returns 0 when PageFileAllocated is clear, and MiDispatchFault then goes to MiResolveDemandZeroFault (comment).

2. Windows 8 x64 and 8.1 x86 fault handlers.

I took both kernels from the July 10, 2018 security-only updates in the Microsoft Update Catalog. That is the month before the August 2018 updates that moved the bits on 9600.

  • KB4338820 x64 (windows8-rt-kb4338820-x64_d60bd40b1cfafbf1276176d0e1306d80299a43cb.msu, the package for Windows Embedded 8 Standard and Server 2012): ntoskrnl 6.2.9200.22490, PDB A88C045A3F9649DDB9D8A464CDACF519-1.
  • KB4338824 x86 (windows8.1-kb4338824-x86_cf4f9e25151dc17a9e56bec3ca5a753d4c48dd7e.msu): ntoskrnl 6.3.9600.19067, PDB ntkrpamp.pdb CCBF66CCC65D48F086B04C77E8D15953-1.

The SHA-1 in each file name matches the download. Both PDBs put PageFileReserved at bit 13 and PageFileAllocated at bit 14. MiDispatchFault has the same gate you found on 9600 x64 and 9200 x86:

  • 9200.22490 x64. bt rax,0Bh (0x150bcd) goes to MiResolveTransitionFault. Then comes shr rax,0Eh; test al,1; jne (0x150bfe). The taken branch reaches MiResolvePageFileFault (0x150cbb), the fall-through MiResolveDemandZeroFault (0x150c94).
  • 9600.19067 x86. and eax,800h (0xb9035) goes to MiResolveTransitionFault. Then comes shrd edx,esi,0Eh; shr esi,0Eh; test dl,1; jne (0xb905a). The taken branch reaches MiResolvePageFileFault (0xb911d), the fall-through MiResolveDemandZeroFault (0xb9105).

3. Kernels with PageFileAllocated at bit 24.

These are 15 x64 ISFs in the symbol pack, and no x86 ones. I fetched their PDBs from the Microsoft symbol server by GUID. The source paths in each PDB name the build branch:

Branch ISFs _EPROCESS size
wmm1 2 1,224
wmm2 2 1,224
wmm3 2 1,328
winmain_win8m3 2 1,328
fbl_pdc_4 1 1,320
w8beta_se 4 1,616
wm8b 2 1,616

None of them is the branch of a shipped kernel I could check: 9200.22490 reports win8_ldr_escrow in its FileVersion, and Windows 8 RTM (9200) has the bit at 14 and an _EPROCESS of 1,632 (Vergilius: _MMPTE_SOFTWARE, _EPROCESS). So in the symbol pack, bit 24 occurs only in kernels from these pre-release branches. I haven't looked at their code.

Scripts. reset_pte_count.py, kernel_disasm.py (which produced the disassembly above), kernel_call_context.py, kernel_pdb_fetch.py and isf_bit24_branches.py are now on the pr2080-check-scripts branch (2f3075f).

Description changes:

  • The kernel evidence for commit 5 adds the two Windows 8 kernels.
  • "The change" says bit 24 is only in kernels from pre-release Windows 8 branches.
  • "Not tested" lists 9200 and 9600 as checked in the code for both x64 and x86, and says the same about bit 24.
  • The PageFileHigh = 1 item moves from "Not tested" to "Later checks".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants