To install click the Add extension button. That's it.

The source code for the WIKI 2 extension is being checked by specialists of the Mozilla Foundation, Google, and Apple. You could also do it yourself at any point in time.

4,5
Kelly Slayton
Congratulations on this excellent venture… what a great idea!
Alexander Grigorievskiy
I use WIKI 2 every day and almost forgot how the original Wikipedia looks like.
Live Statistics
English Articles
Improved in 24 Hours
Added in 24 Hours
Languages
Recent
Show all languages
What we do. Every page goes through several hundred of perfecting techniques; in live mode. Quite the same Wikipedia. Just better.
.
Leo
Newton
Brights
Milds

Microsoft-specific exception handling mechanisms

From Wikipedia, the free encyclopedia

The Microsoft Windows family of operating systems employ some specific exception handling mechanisms.

YouTube Encyclopedic

  • 1/3
    Views:
    122 709
    3 912 666
    100 501
  • Handling Exceptions in C# - When to catch them, where to catch them, and how to catch them
  • What Your Boss Can TRACK About YOU with Microsoft Teams
  • Remote Procedure Calls (RPC)

Transcription

Structured Exception Handling

Microsoft Structured Exception Handling is the native exception handling mechanism for Windows and a forerunner technology to Vectored Exception Handling (VEH).[1] It features the finally 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: __try, __except and __finally — for this purpose. Other exception handling aspects are backed by a number of Win32 API functions,[2] for example, RaiseException 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 __try statement essentially calls a compiler-defined EH_prolog function. That function allocates an _EXCEPTION_REGISTRATION_RECORD on the stack pointing to the __except_handler3[a] function in msvcrt.dll,[b] then adds the record to the list's head. At the end of the __try block a compiler-defined EH_epilog function is called that does the reverse operation. Either of these compiler-defined routines can be inline. All the programmer-defined __except and __finally blocks are called from within __except_handler3. If the programmer-defined blocks are present, the _EXCEPTION_REGISTRATION_RECORD created by EH_prolog is extended with a few additional fields used by __except_handler3.[3]

In the case of an exception in user mode code, the operating system[c] 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 kernel32!UnhandledExceptionFilter which displays the General protection fault error message.[d] Then the list is traversed once more giving handlers a chance to clean up any resources used. Finally, the execution returns to kernel mode[e] 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 (UNWIND_INFO) interpreted by the system when an exception occurs.[4][5] 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 __try on both x86 and x64.[6]

Vectored Exception Handling

Vectored Exception Handling was introduced in Windows XP.[7] 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.[1][7] Compared with SEH, VEH works more like kernel-delivered Unix signals.[8]

Notes

  1. ^ The name varies in different versions of VC runtime
  2. ^ ntdll.dll and kernel32.dll, as well as other programs linked statically with VC runtime, have this function compiled-in instead
  3. ^ More specifically, ntdll!RtlDispatchException system routine called from ntdll!KiUserExceptionDispatcher which is in turn called from the nt!KiDispatchException kernel function. (See Ken Johnson (November 16, 2007). "A catalog of NTDLL kernel mode to user mode callbacks, part 2: KiUserExceptionDispatcher". for details)
  4. ^ The message can be silenced by altering the process's error mode; the default last handler can be replaced with SetUnhandledExceptionFilter API
  5. ^ ntdll!KiUserExceptionDispatcher calls either nt!ZwContinue or nt!ZwRaiseException

References

  1. ^ a b "Vectored Exception Handling in Windows Server 2003 (Through Internet Archive)". Archived from the original on 2008-01-18.
  2. ^ Microsoft Corp. (2009-11-12). "Structured Exception Handling Functions". MSDN Library. Retrieved 2022-07-23.
  3. ^ Peter Kleissner (February 14, 2009). "Windows Exception Handling - Peter Kleissner". Archived from the original on October 14, 2013. Retrieved 2009-11-21., Compiler based Structured Exception Handling section
  4. ^ "Exceptional Behavior - x64 Structured Exception Handling". The NT Insider.
  5. ^ "x64 exception handling". VC++ 2019 documentation.
  6. ^ "MSVC compatibility". Clang 11 documentation.
  7. ^ a b "Under the Hood: New Vectored Exception Handling in Windows XP". Archived from the original on 2008-09-15.
  8. ^ "Windows Server 2003 Discover Improved System Info, New Kernel, Debugging, Security, and UI APIs". Archived from the original on 2008-05-05.

External links

This page was last edited on 24 August 2023, at 05:07
Basis of this page is in Wikipedia. Text is available under the CC BY-SA 3.0 Unported License. Non-text media are available under their specified licenses. Wikipedia® is a registered trademark of the Wikimedia Foundation, Inc. WIKI 2 is an independent company and has no affiliation with Wikimedia Foundation.