a crash course on thedepths of win32 structured exception handling, msj january 1997

19
Click Here to Install Silverlight Uni ted State s Change |  All Microsoft Sites MSDN Home | Developer Cent ers | Library | Downloads | Code C ent er | Subscriptions | MSDN Worldwide Search for MSDN Magazi ne Go Advanced Search MSJ H ome January 199 7 Search Source Code Back Issues Subscribe Reader Services Write to U s MSDN Magazine MIND Archive Magazine Newsgroup MSDN Home > MSJ > January 1997 January 1997 A Crash Course on the Depths of Win32™ Structured Exception Handling At its hea rt, Win 32 structur ed e xce ption handli ng is an ope ratin g sy stem- provided service. All the docs you're likely to find about SEH describe one particular com-piler's runtime library wr apping around the operating sys tem implementation. I'l l strip SEH to its most fundamental concepts. Matt Pietrek Th is article assumes you're f amiliar with C++, Win3 2 Code for this article: Exception.exe (33KB) Matt Pi etrek is the author of Win dows 95 Syst em Programming Secrets (IDG Books, 1995). He works at Nu Mega Tec hnol ogi es Inc., and can be r eac hed at [email protected]. Of all the facilities provided by Win32® operating systems, perhaps the most widely used but underdocumented is structured exception handling (SEH). When you think of Win32 structured exception handling, you probably think of terms like _try, _finally, and _except. You can find good descriptions of SEH in  just about any competent Win32 book (even the remedial ones). Even the Win32 SDK has a fairly complete overview of using structured exception handling with _try, _finally, and _except. With all this documentation, where do I get off saying that SEH is underdocumented? At its heart, Win32 structured exception handling is an operating system- provided service. All the documentation you're likely to find about S EH desc ri bes one particular c om pil er's runtim e librar y wrappin g around t he operat ing syst em implem entat ion. T here's nothing magical about the keywords _try, _finally, or _except. Microsoft's OS and compiler groups defined these keywords and what they do. Other C++ compiler vendors have simply gone along with their semantics. While the compiler SEH layer tames the nastiness of raw operating system SEH, it's had the effect of keeping the raw operating system SEH details from public view. I've received numerous email messages from people who have needed to implement compiler-level SEH and couldn't find much in the way of documentation for the operating system facilities. In a rational world, I'd be able to point to the runtime library sources for Visual C++ or Borland C++ and be done with it. Alas, for some unk nown reason, compiler-level SEH seems to be a big Search Microsoft.com 6/10/2010 A Crash Course on theDepths of Win3… microsoft.com/msj/…/Exception.aspx 1/19

Upload: tzving

Post on 07-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 1/19

Page 2: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 2/19

Page 3: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 3/19

Page 4: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 4/19

Page 5: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 5/19

Page 6: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 6/19

Page 7: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 7/19

Page 8: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 8/19

Page 9: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 9/19

Page 10: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 10/19

Page 11: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 11/19

Page 12: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 12/19

Page 13: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 13/19

Page 14: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 14/19

Page 15: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 15/19

Page 16: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 16/19

Page 17: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 17/19

Page 18: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 18/19

Page 19: A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

8/6/2019 A Crash Course on TheDepths of Win32 Structured Exception Handling, MSJ January 1997

http://slidepdf.com/reader/full/a-crash-course-on-thedepths-of-win32-structured-exception-handling-msj-january 19/19