[comp.windows.ms] Page fault and General Protection fault handling in Windows

ed@odi.com (Ed Schwalenberg) (09/04/90)

My Windows application needs to manage memory much like a virtual memory
system at the page level:  I need to set pages to be not-present, read-only,
or read-write, catch page faults (for not-present) and General Protection
faults (for write to read-only page), and have the handler fetch a page or
update the page permissions, then continue the faulting instruction.  Segment-
level protection isn't good enough; there aren't enough segment selectors to
go around.

Nowhere in the Windows 3.0 SDK can I find any hint about how to do these things
using supported interfaces.  I'm waiting semi-patiently for the Windows
Developer's Notes and the DDK to arrive, and I'm looking into Microsoft Online.
While I'm waiting, hoping that one of these sources will have the answers I
need, I've performed a variety of experiments to see if I can discover a way
to do it.

I've discovered ways to accomplish nearly everything necessary to implement
the page-fault trapping, except one thing: telling Windows to use Ring 3 for
my program.  The 80386 paging hardware only supports read-only pages in ring
3; the other rings are considered "supervisor level" and may modify any page
that's present.  Windows runs its interrupt-level code in ring 0, and most of
its code and all user code in ring 1.  The Windows Guide To Programming warns,
"Do not assume the privilege level in which your application is running.
Future versions of Windows applications will change the privilege-level ring
in which applications will run."  Of course, I want to be in the future now.

Thank you for your support.

Ed Schwalenberg
Object Design, Inc.,  1 New England Executive Park, Burlington, MA 01803
617-270-9797x104