Structured Exception Handling

I have a question in the structured Exception handling. From what i have read about i dont understand the reasoning behind the following action taken by the OS in case of the exception :

When a thread faults, We traverse through a list of EXCEPTION_REGISTRATIONs until we find the handler that handles the current exception. After calling the Handler(user defined call back) what is the need for Calling the Exception handlers again with the EH_UNWINDING Exception. I read as ,this was for the clean up purpose. Why not whatever cleanup that must happen , can happen at the first invocation to the handler.
Also I dont understand the purpose of unwinding a stack. Can anyone explain it ?

The first invocation of the handler is to allow each handler to filter the
exception and handle or pass on the exception - that is the purpose of the
first call by definition. Once a handler “handles” the exception, all
handlers in the chain above that particular one must be called back for
unwind since execution will not proceed normally in these frames. The
unwind call is used to allow cleanup as you said (like invoking __finally
blocks etc). This is the way SEH was designed.

Ross

On Tue, Oct 7, 2008 at 7:47 AM, wrote:

> I have a question in the structured Exception handling. From what i have
> read about i dont understand the reasoning behind the following action taken
> by the OS in case of the exception :
>
> When a thread faults, We traverse through a list of
> EXCEPTION_REGISTRATIONs until we find the handler that handles the current
> exception. After calling the Handler(user defined call back) what is the
> need for Calling the Exception handlers again with the EH_UNWINDING
> Exception. I read as ,this was for the clean up purpose. Why not whatever
> cleanup that must happen , can happen at the first invocation to the
> handler.
> Also I dont understand the purpose of unwinding a stack. Can anyone explain
> it ?
>
> —
> NTDEV is sponsored by OSR
>
> For our schedule of WDF, WDM, debugging and other seminars visit:
> http://www.osr.com/seminars
>
> To unsubscribe, visit the List Server section of OSR Online at
> http://www.osronline.com/page.cfm?name=ListServer
>