Exception Handling in the kernel

Discussion in 'Windows Vista Drivers' started by fat_boy, Jun 24, 2005.

  1. fat_boy

    fat_boy Guest

    Hi all.

    I have never used exception handling in driver code, but I recall that
    in NT4 you could use it in code called by an application, so
    read/write/deviceiocontrol dispatch code could contain it.

    I was wondering if the situation had changed at all and was looking for
    a definitive statement on what exception handling can be used, where it
    can be used, and at what level/priority it can be used.

    Not having found an answer on line, or in the DDK, I was wondering if
    anyone can enlighten me?
     
    fat_boy, Jun 24, 2005
    #1
    1. Advertisements

  2. fat_boy

    Mark Roddy Guest

    SEH is supported as it was in nt4. As you stated, its use ought to be
    limited to your passive level dispatch side code and ought not to be
    used over on the interrupt side of your driver. I don't believe there is
    an explicit restriction on application vs system process threads, and I
    don't see why there should be. If you can search far enough back in the
    various newsgroups or perhaps on ntdev, the reasons why bad things might
    happen on interrupt side processing has been discussed.

    Of course you also cannot use C++ style exception handling as there is
    no runtime support in the kernel, and you should be aware that SEH
    exception frames are a bit large and the kernel stack is a bit small.

    --

    =====================
    Mark Roddy DDK MVP
    Windows 2003/XP/2000 Consulting
    Hollis Technology Solutions 603-321-1032
    www.hollistech.com
     
    Mark Roddy, Jun 24, 2005
    #2
    1. Advertisements

  3. fat_boy

    fat_boy Guest

    So no change then really. I saw in the 2003 DDK mention of SEH in
    reference to a few Probexxx() functions.

    I guess I'll continue to not use it.

    Thx
     
    fat_boy, Jun 24, 2005
    #3
  4. Just to be clear - there are some cases where you HAVE to use exception
    handling. For instance if you are directly accessing memory via a usermode
    virtual address. You would have to first capture and probe the address and
    then wrap any accesses to it in a try/except block.
     
    Jonathan Morrison [MSFT], Jun 24, 2005
    #4
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.