Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting...
Please check out the Community Guidelines in the Announcements and Administration Category.

Which types of exceptions cannot be handled?

0xrepnz0xrepnz Member Posts: 16

I know some exceptions like PAGE_FAULT_IN_NONPAGED_AREA cannot be caught using __try and __except. Is there any resource detailing which types of exceptions cannot be caught? How can I know which exceptions cannot be caught?

I don't need it for a specific reason, just because I'm curious (And don't want to cause bugchecks)


  • Tim_RobertsTim_Roberts Member - All Emails Posts: 13,226

    There's probably a really raucous religious discussion waiting to be had here. ;)

    I almost never use __try/__except in a kernel driver, unless I'm handling user-mode addresses in a METHOD_NEITHER ioctl. I tend to think it's a crutch to spackle over lazy programming. If I have processing that might throw an exception, I'd rather get the BSOD so I can diagnose it and add protection. An ounce of prevention is better than a pound of cure.

    That does mean my testing had better be pretty thorough.

    Tim Roberts, [email protected]
    Providenza & Boekelheide, Inc.

  • 0xrepnz0xrepnz Member Posts: 16
    I'm asking because one of the third party software drivers installed on my PC (again, I did not develop the driver) caused a blue screen today. Analyzing the blue screen I saw it happened because the driver accessed a pointer from user mode with __try (the developer of the driver passed the address of a kernel object he obtained from user mode using SystemHandleInformation.. Heh) this object was already removed and that caused the fault in a nonpaged area,
    I removed this aweful driver.

    I don't intend to do shady stuff in a kernel driver, I'm just curious.
  • Scott_Noone_(OSR)Scott_Noone_(OSR) Administrator Posts: 3,221

    You can only catch invalid user pointer accesses. If you touch an invalid kernel address it will crash the machine.

    Analyzing the blue screen I saw it happened because the driver accessed a pointer from user mode with __try

    Before you touch a pointer from user mode you need to call either ProbeForRead or ProbeForWrite on it. These will raise an exception if the address supplied by user mode is a kernel address.


Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Upcoming OSR Seminars
Kernel Debugging 30 Mar 2020 OSR Seminar Space
Writing WDF Drivers 13 April 2020 OSR Seminar Space & ONLINE
Developing Minifilters 20 Apr 2020 OSR Seminar Space & ONLINE
Internals & Software Drivers TBD Dulles, VA