Win32 Programming Lesson 25: Unhandled Exceptions Bet you’ve never encountered one of those, eh?

Slides:



Advertisements
Similar presentations
Chapter 2.2 – More about Ruby Maciej Mensfeld Presented by: Maciej Mensfeld More about Ruby dev.mensfeld.pl github.com/mensfeld senior.
Advertisements

Exceptions Chapter Throwing and Catching Exceptions When a program runs into a problem that it cannot handle, it throws an exception. Exceptions.
CSE 332: C++ exceptions Overview of C++ Exceptions Normal program control flow is halted –At the point where an exception is thrown The program call stack.
Chapter 11 Debugging and Handling Exceptions
Slides prepared by Rose Williams, Binghamton University ICS201 Exception Handling University of Hail College of Computer Science and Engineering Department.
Understand Error Handling Software Development Fundamentals LESSON 1.4.
1 Lecture 11 Interfaces and Exception Handling from Chapters 9 and 10.
Debugging Techniques1. 2 Introduction Bugs How to debug Using of debugger provided by the IDE Exception Handling Techniques.
15-213/ Intro to Computer Systems by btan with reference to Spring 10’s slides.
C HAPTER 11 Risky Behavior. O VERVIEW Handling Risky Code Exceptions Agreeing to Risk try/catch blocks finally block Declaring an Exception Handle or.
Unix Processes.
16-Jun-15 Exceptions. Errors and Exceptions An error is a bug in your program dividing by zero going outside the bounds of an array trying to use a null.
Advanced OS Chapter 3p2 Sections 3.4 / 3.5. Interrupts These enable software to respond to signals from hardware. The set of instructions to be executed.
1 JMH Associates © 2004, All rights reserved Chapter 4 Structured Exception Handling.
Advanced Java Course Exception Handling. Throwables Class Throwable has two subclasses: –Error So bad that you never even think about trying to catch.
Exception Error handling. Exception 4 n An unusual occurrence during program execution that requires immediate handling n Errors are the most common type.
Win32 Programming Lesson 9: Jobs & Thread Basics.
1 Exception Handling Introduction to Exception Handling Exception Handling in PLs –Ada –C++ –Java Sebesta Chapter 14.
Bordoloi and Bock EXCEPTIONS. Bordoloi and Bock Errors Two types of errors can be found in a program: compilation errors and runtime errors. There is.
PZ11A Programming Language design and Implementation -4th Edition Copyright©Prentice Hall, PZ11A - Exception handling Programming Language Design.
June 14, 2001Exception Handling in Java1 Richard S. Huntrods June 14, 2001 University of Calgary.
CPSC 252 Exception Handling Page 1 Exceptions and exception handling Client programmers can make errors using a class attempting to dequeue an item from.
Exception Handling 1. Introduction Users may use our programs in an unexpected ways. Due to design errors or coding errors, our programs may fail in unexpected.
Object Oriented Programming
Win32 Programming Lesson 24: More SEH That’s right… you’ll never generate an exception, will you?
CIS 270—Application Development II Chapter 13—Exception Handling.
Understanding Events and Exceptions Lesson 3. Objective Domain Matrix Skills/ConceptsMTA Exam Objectives Understand events and event handling Understand.
Slides Credit Umair Javed LUMS Web Application Development.
1 JavaScript. 2 What’s wrong with JavaScript? A very powerful language, yet –Often hated –Browser inconsistencies –Misunderstood –Developers find it painful.
Win32 Programming Lesson 13: Thread Pooling (Wow, Java is good for something…)
Instructor: Chris Trenkov Hands-on Course Python for Absolute Beginners (Spring 2015) Class #001 (January 9, 2015)
CMSC 202 Exceptions. Aug 7, Error Handling In the ideal world, all errors would occur when your code is compiled. That won’t happen. Errors which.
Win32 Programming Lesson 16: Virtual Memory. Where are we?  We’ve covered the theory of Windows memory, and poked around some  Now let’s use how to.
Win32 Programming Lesson 1: Why We’re All Here. Why We’re Here…  Okay, maybe that’s too grandiose  Windows – in particular Win32 Thirty-what?  What.
CIS 3301 C# Lesson 13 Interfaces. CIS 3302 Objectives Understand the Purpose of Interfaces. Define an Interface. Use an Interface. Implement Interface.
VB.Net - Exceptions Copyright © Martin Schray
COMP Exception Handling Yi Hong June 10, 2015.
Java Threads. What is a Thread? A thread can be loosely defined as a separate stream of execution that takes place simultaneously with and independently.
Win32 Programming Lesson 18: More Memory Mapped Files and the HEAP (Finally, cool stuff!)
1 Chapter Eleven Handling Events. 2 Objectives Learn about delegates How to create composed delegates How to handle events How to use the built-in EventHandler.
Introduction to Exception Handling and Defensive Programming.
Presented by IBM developer Works ibm.com/developerworks/ 2006 January – April © 2006 IBM Corporation. Making the most of The Eclipse debugger.
Module 6: Debugging a Windows CE Image.  Overview Debug Zones IDE Debug Setup IDE Debug Commands Platform Builder Integrated Kernel Debugger Other Debugging.
Synchronized and Monitors. synchronized is a Java keyword to denote a block of code which must be executed atomically (uninterrupted). It can be applied.
BIO Java 1 Exception Handling Aborting program not always a good idea – can’t lose messages – E-commerce: must ensure correct handling of private.
©Ian Sommerville 2004Software Engineering, 7th edition. Chapter 4 Slide 1 Slide 1 What we'll cover here l Using the debugger: Starting the debugger Setting.
Exceptions in C++. Exceptions  Exceptions provide a way to handle the errors generated by our programs by transferring control to functions called handlers.
CSE 332: C++ Statements C++ Statements In C++ statements are basic units of execution –Each ends with ; (can use expressions to compute values) –Statements.
Exception Handling in Java Topics: Introduction Errors and Error handling Exceptions Types of Exceptions Coding Exceptions Summary.
Fall 2015CISC/CMPE320 - Prof. McLeod1 CISC/CMPE320 Today: –Review declaration, implementation, simple class structure. –Add an exception class and show.
1 SWIFT 2.0: New features Dzianis Astravukh AUGUST 5, 2015.
Programming Fundamentals. Topics to be covered Today Recursion Inline Functions Scope and Storage Class A simple class Constructor Destructor.
And other languages…. must remember to check return value OR, must pass label/exception handler to every function Caller Function return status Caller.
CHAPTER 18 C – C++ Section 1: Exceptions. Error Handling with Exceptions Forces you to defend yourself Separates error handling code from the source.
EXCEPTIONS. Catching exceptions Whenever a runtime error occurs, it create an exception object. The program stops running at this point and Python prints.
1 Exception handling Programming Language Design and Implementation (4th Edition) by T. Pratt and M. Zelkowitz Prentice Hall, 2001 Section 11.1.
CSE 332: C++ Exceptions Motivation for C++ Exceptions Void Number:: operator/= (const double denom) { if (denom == 0.0) { // what to do here? } m_value.
Exceptions in the Java programming language J. W. Rider.
Eighth Lecture Exception Handling in Java
Java Exceptions a quick review….
CSCE Student presentation LARRY PARKER
Chapter Eleven Handling Events.
Crash Handlers Riddhiman Ghosh Debugging Applications for
Exceptions with Functions
CodePainter Revolution Trainer Course
Debugging and Handling Exceptions
Following Malware Execution in IDA
CMSC 202 Exceptions.
Exceptions.
Crash Handlers Riddhiman Ghosh Debugging Applications for
Presentation transcript:

Win32 Programming Lesson 25: Unhandled Exceptions Bet you’ve never encountered one of those, eh?

Where are we?  Covered exception handling in depth…  But there’s more! Yay! And an assignment, how lucky you are!

Applications don’t have to handle  What happens if the outermost exception handler returns EXCEPTION_CONTINUE_SEARCH?  Well, then you have an unhandled exception  Handled by the OS… But you have one last chance to catch it before this… it’s a million to one shot, but it just might work!

SetUnhandledExceptionFilter  PTOP_LEVEL_EXCEPTION_FILTER SetUnhandledExceptionFilter(PTOP_LEVEL_E XCEPTION_FILTER pTopLevelExceptionFilter);  Usually called during initialization  Function called declared like this: LONG WINAPI TopLevelUnhandledExceptionFilter(PEXCEPTION_ POINTERS pExceptionInfo) Note returns address of previously installed filter

Return Values  EXCEPTION_EXECUTE_HANDLER: Terminate, executing finally blocks  EXCEPTION_CONTINUE_EXECUTION: Continue at the instruction that raised the exception  EXCEPTION_CONTINUE_SEARCH: Really don’t handle the exception…

UnhandledExceptionFilter  Called automatically when we return EXCEPTION_CONTINUE_SEARCH  Turns things over to Windows Error Reporting (WER) eventually…  But first, it does the following in order

Steps 1. Allow write access to a resource (EXE and DLL) and continue 2. Notify the debugger of an unhandled exception 3. Notify your global filter function 4. Notify the debugger of an unhandled exception (again!) 5. Terminate the process

WER Linkage  When the exception is passed to Windows WER gets a call from an Advanced Local Procedure Call (ALPC)  Blocks all local thread execution  Passed to a dedicated service WerSvc… spawns WerFault.exe  This executable handled the functionality of reporting etc.  Configurable behavior via Registry

Just In Time Debugging  Nice, because we can debug without restarting our application and reproducing the fault in a debugger  Configured through the registry  Called CreateProcess (How? Anything we should think about?)  Aside: don’t have to wait for a blowup… can always call vsjitdebugger.exe –p PID

Vectored Exception Handling  SEH has one fundamental structural property…  PVOID AddVectoredExceptionHandler( ULONG bFirstInTheList, PVECTORED_EXCEPTION_HANDLER pfnHandler);  Called before SEH handling  Remove by ULONG RemoveVectoredExceptionHandler(PVOID Handler)

Vectored Continue Handler  Called when we’re continuing up *after* everything else  Can return EXCEPTION_CONTINUE_EXECUTION

C++ try and catch  Suddenly, we should think back about C++ SEH  That is, try/catch blocks  Internally implemented by __try and __except blocks…  Should use the C++ mechanism whenever possible, as it knows about the underlying language issues

Exceptions and the Debugger  Let’s look at the options…

Assignment  Construct an “error handling experimenters lab” that lets you combine these things together in a GUI and tells you what order things get processed in.  Output should show me how things get executed… there’s room for some *very* imaginative programming here