The x86-64 Windows ABI has the concept of a legitimate epilog, which is a special type of function epilog that can be simulated during exception handling in order to restore the callers context1 as described here:
If the RIP is within an epilog [when an exception occurs], then control is leaving the function, ... and the effects of the epilog must be continued to compute the context of the caller function. To determine if the RIP is within an epilog, the code stream from RIP on is examined. If that code stream can be matched to the trailing portion of a legitimate epilog, then it is in an epilog, and the remaining portion of the epilog is simulated, with the context record updated as each instruction is processed...
You can find a prose description of a legitimate epilog here, which includes the following example:
If no frame pointer is used in the function, then the epilog must first deallocate the fixed part of the stack, the nonvolatile registers are popped, and control is returned to the calling function. For example,
add RSP, fixed-allocation-size pop R13 pop R14 pop R15 ret
It contains a similar example with lea
to restore the stack when a frame pointer is used.
What if, however, there is no fixed size allocation at all within the function? It is not uncommon for functions not to use the stack. Does a dummy add rsp, 0
need to be inserted in this case to conform to the rules for a legitimate epilog, or may it be omitted?
1 For example, to restore the non-volatile registers that may have been clobbered by the callee.
RUNTIME_FUNCTION
table entry that describes the current function. in c/c++ we use for this__try/__except
for example. in masm -PROC FRAME:ehandler
- msdn.microsoft.com/en-us/library/ms235231.aspx – HelenaheleneUNWIND_INFO
that documents exactly on an instruction-by-instruction basis what your prolog does. The mechanism for the epilog is very different (see my links). Note that your link talks about prolog, not epilog. – BarranquillaCase c)
– HelenaheleneKiUserExceptionDispatcher
). I think you need correctRUNTIME_FUNCTION
for you function. epilog anyway will be not problem – Helenaheleneadd rsp, xxx
? – Hebron