Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Driver Kit
Design Guide
64-Bit Issues
 UNWIND_INFO Structure

  Switch on low bandwidth view
Windows Driver Kit: Kernel-Mode Driver Architecture
UNWIND_INFO Structure

The unwind data information structure is used to record the effects that a function has on the stack pointer and where the nonvolatile registers are saved on the stack. The UNWIND_INFO structure has the following format:

typedef struct _UNWIND_INFO {
    UBYTE Version       : 3;
    UBYTE Flags         : 5;
    UBYTE SizeOfProlog;
    UBYTE CountOfCodes;
    UBYTE FrameRegister : 4;
    UBYTE FrameOffset   : 4;
    UNWIND_CODE UnwindCode[1];
    union {
        OPTIONAL ULONG ExceptionHandler;
        OPTIONAL ULONG FunctionEntry;
    };
    OPTIONAL ULONG ExceptionData[]; 
} UNWIND_INFO, *PUNWIND_INFO;

The UNWIND_INFO structure must be DWORD aligned in memory. The members of UNWIND_INFO contain the following information:

Version
Specifies the version number of the unwind data. Currently set to 1.
Flags
Specifies flags for the unwind data. The following flags are currently defined:
FlagMeaning
UNW_FLAG_EHANDLERThe function has an exception handler that should be called when looking for functions that need to examine exceptions.
UNW_FLAG_UHANDLERThe function has a termination handler that should be called when unwinding an exception.
UNW_FLAG_CHAININFOThis UNWIND_INFO structure is not the primary one for the procedure. Instead, the chained-unwind-info entry (FunctionEntry member) is the contents of a previous RUNTIME_FUNCTION entry. If this flag is set, then the UNW_FLAG_EHANDLER and UNW_FLAG_UHANDLER flags must be cleared. Also, the frame register and fixed-stack allocation fields must have the same values as in the primary unwind information.

SizeOfProlog
Specifies the length of the function prolog in bytes.
CountOfCodes
Specifies the number of slots in the unwind codes array. (For more information, see UNWIND_CODE Structure.) Note that some unwind codes (for example, UWOP_SAVE_NONVOL) require more than one slot in the array.
FrameRegister
Specifies the number of the nonvolatile register used as the frame pointer, if nonzero. If zero, specifies that the function does not use a frame pointer. This frame pointer uses the same encoding described in the OpInfo member of the UNWIND_CODE Structure.
FrameOffset
Specifies the scaled offset from RSP that is applied to the FP register when it is established, if the FrameRegister member is nonzero. The actual FP register is set to RSP plus 16 times this number, allowing offsets from 0 to 240. This permits pointing the FP register into the middle of the local stack allocation for dynamic stack frames, allowing better code density through shorter instructions (more instructions can use the 8-bit signed offset form).
UnwindCode
Specifies an array of items that explains the effect of the prolog on the nonvolatile registers and RSP. See the UNWIND_CODE Structure for the meanings of individual items. For alignment purposes, this array always has an even number of entries, with the final entry potentially unused (in which case, the array is one longer than indicated by the CountOfCodes member).
ExceptionHandler
Specifies an image-relative pointer to the function's language-specific exception/termination handler (if flag UNW_FLAG_CHAININFO is clear and one of the flags UNW_FLAG_EHANDLER or UNW_FLAG_UHANDLER is set).
ExceptionData
Specifies the function's language-specific exception handler data. The format of this data is unspecified and completely determined by the specific exception handler at ExceptionHandler in use.
FunctionEntry
Specifies the contents of the chained unwind information (if flag UNW_FLAG_CHAININFO is set). In this case, the UNWIND_INFO structure ends with three ULONGs, which represent the RUNTIME_FUNCTION information for the function of the chained unwind.


Send feedback on this topic
Built on May 20, 2009
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker