Exception Handling in Device Drivers

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

You should use structured exception handling (SEH) to recover from exceptions, such as alignment, access permissions, and so on when accessing caller buffers.

Although you can use SEH, also known as __try/__except blocks, to handle exceptions caused by attempts to access caller buffers, nothing can protect the application from itself. If the application passes in a pointer in its own address space, and the driver updates the pointer, the application must use the correct pointer value. Device Manager encloses calls to driver entry points with __try/__except blocks so that unhandled driver crashes do not cause Device Manager to crash. Invalid pointer values might break the driver.**

You should use CeOpenCallerBuffer and CeCloseCallerBuffer to verify that the caller has access to the memory that is pointed to by nested pointers; structures containing pointers must have the pointers validated.**

See Also

Concepts

Accessing Memory from a Driver

Other Resources

GetCurrentProcessId
GetOwnerProcess
Memory Architecture