[RTL/x64] Properly handle UNW_FLAG_CHAININFO

This commit is contained in:
Timo Kreuzer 2021-06-15 11:28:02 +02:00
parent 6a9a739185
commit d24700f82e

View file

@ -523,16 +523,6 @@ RtlVirtualUnwind(
/* Get a pointer to the unwind info */
UnwindInfo = RVA(ImageBase, FunctionEntry->UnwindData);
/* Check for chained info */
if (UnwindInfo->Flags & UNW_FLAG_CHAININFO)
{
UNIMPLEMENTED_DBGBREAK();
/* See https://docs.microsoft.com/en-us/cpp/build/chained-unwind-info-structures */
FunctionEntry = (PRUNTIME_FUNCTION)&(UnwindInfo->UnwindCode[(UnwindInfo->CountOfCodes + 1) & ~1]);
UnwindInfo = RVA(ImageBase, FunctionEntry->UnwindData);
}
/* The language specific handler data follows the unwind info */
LanguageHandler = ALIGN_UP_POINTER_BY(&UnwindInfo->UnwindCode[UnwindInfo->CountOfCodes], sizeof(ULONG));
*HandlerData = (LanguageHandler + 1);
@ -560,6 +550,8 @@ RtlVirtualUnwind(
i += UnwindOpSlots(UnwindInfo->UnwindCode[i]);
}
RepeatChainedInfo:
/* Process the remaining unwind ops */
while (i < UnwindInfo->CountOfCodes)
{
@ -650,6 +642,16 @@ RtlVirtualUnwind(
}
}
/* Check for chained info */
if (UnwindInfo->Flags & UNW_FLAG_CHAININFO)
{
/* See https://docs.microsoft.com/en-us/cpp/build/exception-handling-x64?view=msvc-160#chained-unwind-info-structures */
FunctionEntry = (PRUNTIME_FUNCTION)&(UnwindInfo->UnwindCode[(UnwindInfo->CountOfCodes + 1) & ~1]);
UnwindInfo = RVA(ImageBase, FunctionEntry->UnwindData);
i = 0;
goto RepeatChainedInfo;
}
/* Unwind is finished, pop new Rip from Stack */
if (Context->Rsp != 0)
{