The Microsoft Windows family of operating systems employ some specific exception handling mechanisms.
Structured Exception Handling.
Microsoft Structured Exception Handling is the native exception handling mechanism for Windows and a forerunner technology to Vectored Exception Handling (VEH). It features the codice_1 mechanism not present in standard C++ exceptions (but present in most imperative languages introduced later). SEH is set up and handled separately for each thread of execution.
Usage.
Microsoft supports SEH as a programming technique at the compiler level only. MS Visual C++ compiler features three non-standard keywords: codice_2, codice_3 and codice_4 — for this purpose. Other exception handling aspects are backed by a number of Win32 API functions, for example, codice_5 to raise SEH exceptions manually.
Implementation.
IA-32.
Each thread of execution in Windows IA-32 edition or the WoW64 emulation layer for the x86-64 version has a link to an undocumented _EXCEPTION_REGISTRATION_RECORD list at the start of its Thread Information Block. The codice_2 statement essentially calls a compiler-defined codice_7 function. That function allocates an _EXCEPTION_REGISTRATION_RECORD on the stack pointing to the codice_8 function in codice_9, then adds the record to the list's head. At the end of the codice_2 block a compiler-defined codice_11 function is called that does the reverse operation. Either of these compiler-defined routines can be inline. All the programmer-defined codice_3 and codice_4 blocks are called from within codice_8. If the programmer-defined blocks are present, the _EXCEPTION_REGISTRATION_RECORD created by codice_7 is extended with a few additional fields used by codice_8.
In the case of an exception in user mode code, the operating system parses the thread's _EXCEPTION_REGISTRATION_RECORD list and calls each exception handler in sequence until a handler signals it has handled the exception (by return value) or the list is exhausted. The last one in the list is always the codice_17 which displays the General protection fault error message. Then the list is traversed once more giving handlers a chance to clean up any resources used. Finally, the execution returns to kernel mode where the process is either resumed or terminated.
The patent on this mode of SEH, US5628016, expired in 2014.
x86-64.
SEH on 64-bit Windows does not involve a runtime exception handler list; instead, it uses a stack unwinding table (codice_18) interpreted by the system when an exception occurs.
This means that the compiler does not have to generate extra code to manually perform stack unwinding and to call exception handlers appropriately. It merely has to emit information in the form of unwinding tables about the stack frame layout and specified exception handlers.
Support.
GCC 4.8+ from Mingw-w64 supports using 64-bit SEH for C++ exceptions. LLVM clang supports codice_2 on both x86 and x64.
Vectored Exception Handling.
Vectored Exception Handling was introduced in Windows XP. Vectored Exception Handling is made available to Windows programmers using languages such as C++ and Visual Basic. VEH does not replace Structured Exception Handling (SEH); rather, VEH and SEH coexist, with VEH handlers having priority over SEH handlers.
Compared with SEH, VEH works more like kernel-delivered Unix signals.
References.
 ;templatestyles src="Reflist/styles.css" / ;