Page Entry replacement.

Hello,
I’m developing a driver which will hook the Page Fault Handler, wait for a specific page to be requested to be loaded, and point his Page Entry’s page frame to my own allocated page.
**It might seem like malware :), but it is not.

The code is pretty much logical, the page frame is indeed replaced.
BUT, as soon as i try to IRET back to user-mode, I get a ‘memory corruption’ BSOD telling me that the PTE is corrupt.

MEMORY_MANAGEMENT (1a)  
 # Any other values for parameter 1 must be individually examined.  
Arguments:  
Arg1: 00041284, A PTE or the working set list is corrupt.  
Arg2: 00401001  
Arg3: 00000000  
Arg4: c0883000  

My code can be viewed here:
http://codepad.org/ZJgaamFa

My question is, what could be wrong with the Page Entry?
Could it be the type of memory which is assigned to the entry is incorrect?
are some fields of the entry incorrect?

Thanks in advance.

**Sorry for the double post

The header file included in the file above can be viewed here:
http://codepad.org/8Un7E3Kg

This is not going to work, Windows has additional structures about
paging that are not documented or easily locatable and which if not
updated will cause a crash. So even though you claim to not be doing
malware all you are doing is corrupting the system. This will never
work.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

xxxxx@gmail.com” wrote in message
news:xxxxx@ntdev:

> Hello,
> I’m developing a driver which will hook the Page Fault Handler, wait for a specific page to be requested to be loaded, and point his Page Entry’s page frame to my own allocated page.
> **It might seem like malware :), but it is not.
>
> The code is pretty much logical, the page frame is indeed replaced.
> BUT, as soon as i try to IRET back to user-mode, I get a ‘memory corruption’ BSOD telling me that the PTE is corrupt.
> <br>&gt; MEMORY_MANAGEMENT (1a)<br>&gt; # Any other values for parameter 1 must be individually examined.<br>&gt; Arguments:<br>&gt; Arg1: 00041284, A PTE or the working set list is corrupt.<br>&gt; Arg2: 00401001<br>&gt; Arg3: 00000000<br>&gt; Arg4: c0883000<br>&gt;
>
> My code can be viewed here:
> http://codepad.org/ZJgaamFa
>
> My question is, what could be wrong with the Page Entry?
> Could it be the type of memory which is assigned to the entry is incorrect?
> are some fields of the entry incorrect?
>
> Thanks in advance.

I will be glad to hear about those nondocumented structures.

P.s, i’ve managed to get the page replaced and the program to work properly.
Although, as soon as the i exit the program - i get a “PFN list Corrupt” BSOD.

What part of undocumented don’t you understand? There are things like
the page frame database that you need to update, but which are
undocumented and not particularly locatable. Microsoft has been
aggressive improving the memory manager for better performance, and this
work is not documented anywhere, so even if you get something working on
one version of Windows, you are likely to break the others.

Don Burn (MVP, Windows DKD)
Windows Filesystem and Driver Consulting
Website: http://www.windrvr.com
Blog: http://msmvps.com/blogs/WinDrvr

xxxxx@gmail.com” wrote in message
news:xxxxx@ntdev:

> I will be glad to hear about those nondocumented structures.
>
> P.s, i’ve managed to get the page replaced and the program to work properly.
> Although, as soon as the i exit the program - i get a “PFN list Corrupt” BSOD.

What you’re doing is not multiprocessor friendly.

mm

-----Original Message-----
From: xxxxx@lists.osr.com
[mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@gmail.com
Sent: Saturday, February 19, 2011 10:52 AM
To: Windows System Software Devs Interest List
Subject: RE:[ntdev] Page Entry replacement.

I will be glad to hear about those nondocumented structures.

P.s, i’ve managed to get the page replaced and the program to work properly.
Although, as soon as the i exit the program - i get a “PFN list Corrupt”
BSOD.


NTDEV is sponsored by OSR

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at
http://www.osronline.com/page.cfm?name=ListServer

> I will be glad to hear about those nondocumented structures.

MS just posted some job ads - you have a chance to get in.

**It might seem like malware :), but it is not.

then perhaps… madware? :wink:

–pa