Windows System Programming : Exception Handling - Vectored Exception Handling

1/30/2015 1:09:55 AM

Exception handling functions can be directly associated with exceptions, just as console control handlers can be associated with console control events. When an exception occurs, the vectored exception handlers are called first, before the system unwinds the stack to look for structured exception handlers. No keywords, such as __try and __catch, are required.

Vectored exception handling (VEH) management is similar to console control handler management, although the details are different. Add, or “register,” a handler using AddVectoredExceptionHandler.

PVOID WINAPI AddVectoredExceptionHandler (   ULONG FirstHandler,   PVECTORED_EXCEPTION_HANDLER VectoredHandler)

Handlers can be chained, so the FirstHandler parameter specifies that the handler should either be the first one called when the exception occurs (nonzero value) or the last one called (zero value). Subsequent AddVectoredExceptionHandler calls can update the order. For example, if two handlers are added, both with a zero FirstHandler value, the handlers will be called in the order in which they were added.

The return value is a handler to the exception handler (NULL indicates failure). This handle is the sole parameter to RemoveVectoredExceptionHandler, which returns a non-NULL value if it succeeds.

The successful return value is a pointer to the exception handler, that is, -VectoredHandler. A NULL return value indicates failure.

VectoredHandler is a pointer to the handler function of the form:

LONG WINAPI VectoredHandler (PEXCEPTION_POINTERS   ExceptionInfo)

PEXCEPTION_POINTERS is the address of an EXCEPTION_POINTERS structure with processor-specific and general information. 

A VEH handler function should be fast so that the exception handler will be reached quickly. In particular, the handler should never access a synchronization object that might block the thread, such as a mutex . In most cases, the VEH simply accesses the exception structure, performs some minimal processing (such as setting a flag), and returns. There are two possible return values, both of which are familiar from the SEH discussion.

  1. EXCEPTION_CONTINUE_EXECUTION— No more handlers are executed, SEH is not performed, and control is returned to the point where the exception occurred. As with SEH, this may not always be possible or advisable.

  2. EXCEPTION_CONTINUE_SEARCH— The next VEH handler, if any, is executed. If there are no additional handlers, the stack is unwound to search for SEH handlers.

  •  Windows System Programming : Exception Handling - Example: A Console Control Handler
  •  Windows System Programming : Exception Handling - Console Control Handlers
  •  Microsoft Enterprise Library : Relieving Cryptography Complexity - Diving in with an Example (part 2) - Obtaining and Comparing Hash Values
  •  Microsoft Enterprise Library : Relieving Cryptography Complexity - Diving in with an Example (part 1) - Encrypting and Decrypting Data Using A Symmetric Provider
  •  Microsoft Enterprise Library : Relieving Cryptography Complexity - How Do I Use the Cryptography Block?
  •  Microsoft Enterprise Library : Relieving Cryptography Complexity - What Does the Cryptography Block Do?
  •  Review : Aztech FG7008GR(AC) 2400Mbps Gigabit Router
  •  Using Exchange Server 2010 Antispam Tools (part 6) - Sender Reputation
  •  Using Exchange Server 2010 Antispam Tools (part 5) - Sender Filtering, Sender ID
  •  Using Exchange Server 2010 Antispam Tools (part 4) - IP Block and Allow Lists, Recipient Filtering , Tarpitting
    Video tutorials
    - How To Install Windows 8

    - How To Install Windows Server 2012

    - How To Install Windows Server 2012 On VirtualBox

    - How To Disable Windows 8 Metro UI

    - How To Install Windows Store Apps From Windows 8 Classic Desktop

    - How To Disable Windows Update in Windows 8

    - How To Disable Windows 8 Metro UI

    - How To Add Widgets To Windows 8 Lock Screen

    - How to create your first Swimlane Diagram or Cross-Functional Flowchart Diagram by using Microsoft Visio 2010
    programming4us programming4us
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    Popular Tags
    Video Tutorail Microsoft Access Microsoft Excel Microsoft OneNote Microsoft PowerPoint Microsoft Project Microsoft Visio Microsoft Word Active Directory Exchange Server Sharepoint Sql Server Windows Server 2008 Windows Server 2012 Windows 7 Windows 8 Adobe Flash Professional Dreamweaver Adobe Illustrator Adobe Photoshop CorelDRAW X5 CorelDraw 10 windows Phone 7 windows Phone 8 Iphone