https://git.reactos.org/?p=reactos.git;a=commitdiff;h=d24700f82e9c6e670f9dfb759df85a6a2f006b63

commit d24700f82e9c6e670f9dfb759df85a6a2f006b63
Author:     Timo Kreuzer <timo.kreu...@reactos.org>
AuthorDate: Tue Jun 15 11:28:02 2021 +0200
Commit:     Timo Kreuzer <timo.kreu...@reactos.org>
CommitDate: Sat Jul 3 12:56:48 2021 +0200

    [RTL/x64] Properly handle UNW_FLAG_CHAININFO
---
 sdk/lib/rtl/amd64/unwind.c | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/sdk/lib/rtl/amd64/unwind.c b/sdk/lib/rtl/amd64/unwind.c
index a0bd12b28fb..af00aeec3bd 100644
--- a/sdk/lib/rtl/amd64/unwind.c
+++ b/sdk/lib/rtl/amd64/unwind.c
@@ -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)
     {

Reply via email to