5.2.4 Unwind Initiation

Initiating a General Unwind

A thread may initiate a general unwind operation by calling one of two system library routines. The routines differ only in how their first argument specifies the target frame: as a virtual frame pointer or a real frame pointer. These routines are defined as follows:

RtlUnwind( VirtualTargetFrame, TargetPC, ExceptionRecord, ReturnValue )

RtlUnwindRfp( RealTargetFrame, TargetPC, ExceptionRecord, ReturnValue )

Arguments

VirtualTargetFrame  

If nonzero, the virtual frame pointer of the target procedure invocation to which the unwind should be done. If zero, an exit unwind is initiated. In addition, the EXCEPTION_EXIT_UNWIND flag is set to 1 in the exception record.

RealTargetFrame  

If nonzero, the real frame pointer of the target procedure invocation to which the unwind should be done. If zero, an exit unwind is initiated. In addition, the EXCEPTION_EXIT_UNWIND flag is set to 1 in the exception record.

TargetPC  

The address within the target invocation at which to continue execution. If TargetFrame is zero, then TargetPC is ignored.

ExceptionRecord  

If nonzero, the address of a primary exception record. If zero, specifies that a default exception record should be supplied (see below).

ReturnValue  

The value to use as the return value (contents of R0) at the completion of the unwind.

Function Value

None.

Remarks

If the ExceptionRecord argument is zero, then RtlUnwind() or RtlUnwindRfp() supplies a default exception record that specifies exactly one exception record in which ExceptionCode is STATUS_UNWIND if a nonzero TargetFrame is specified, and STATUS_EXIT_UNWIND otherwise. For either an explicit or a default exception record, the EXCEPTION_UNWINDING flag is set to 1, and the EXCEPTION_EXIT_UNWIND flag is set to 1 if a null TargetFrame is specified. ExceptionAddress is set to the address of the call to RtlUnwind() or RtlUnwindRfp().

If the ExceptionRecord argument is specified when the unwind is initiated, then all other properties of the exception record are determined by ExceptionRecord. If RtlUnwind() or RtlUnwindRfp() detects that a specified exception record is not a valid unwind record, it will raise the exception of STATUS_INVALID_EXCEPTION. If the TargetFrame cannot be found, then the last-chance handler will be called since all procedures have been terminated.

Once an unwind is initiated, control never returns from the call.