June 8th, 2012

How can I determine the underlying cause of a EXCEPTION_IN_PAGE_ERROR exception?

A customer was using memory-mapped files and installed an exception handler to log in-page errors in the memory-mapped file region. They wanted to know how they could obtain the real disk error that resulted in the memory manager not being able to page-in the requested data.

Finding the answer isn’t that hard. A quick search for EXCEPTION_IN_PAGE_ERROR reveals that the information is provided in the Exception­Information member of the EXCEPTION_RECORD structure.

EXCEPTION_IN_PAGE_ERROR

The first element of the array contains a read-write flag that indicates the type of operation that caused the access violation. If this value is zero, the thread attempted to read the inaccessible data. If this value is 1, the thread attempted to write to an inaccessible address. If this value is 8, the thread causes a user-mode data execution prevention (DEP) violation.

The second array element specifies the virtual address of the inaccessible data.

The third array element specifies the underlying NTSTATUS code that resulted in the exception.

In other words,

if (GetExceptionCode() == EXCEPTION_IN_PAGE_ERROR)
{
    DiskError = GetExceptionInformation()->
                ExceptionRecord->
                ExceptionInformation[2];
}
Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

0 comments

Discussion are closed.