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

commit 41c99aa60ad9e8d9141caa988b68d54911d64c00
Author:     Timo Kreuzer <timo.kreu...@reactos.org>
AuthorDate: Tue Sep 19 02:56:07 2023 +0300
Commit:     Timo Kreuzer <timo.kreu...@reactos.org>
CommitDate: Thu Sep 21 21:33:47 2023 +0300

    [KERNEL32] Fix RaiseException to correctly copy the passed in parameters as 
ULONG_PTR
    
    Fixes C++ exception handling on x64.
---
 dll/win32/kernel32/client/except.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/dll/win32/kernel32/client/except.c 
b/dll/win32/kernel32/client/except.c
index b248878366e..04931ecd606 100644
--- a/dll/win32/kernel32/client/except.c
+++ b/dll/win32/kernel32/client/except.c
@@ -697,14 +697,16 @@ Quit:
  */
 VOID
 WINAPI
-RaiseException(IN DWORD dwExceptionCode,
-               IN DWORD dwExceptionFlags,
-               IN DWORD nNumberOfArguments,
-               IN CONST ULONG_PTR *lpArguments OPTIONAL)
+RaiseException(
+    _In_ DWORD dwExceptionCode,
+    _In_ DWORD dwExceptionFlags,
+    _In_ DWORD nNumberOfArguments,
+    _In_opt_ const ULONG_PTR *lpArguments)
 {
     EXCEPTION_RECORD ExceptionRecord;
 
     /* Setup the exception record */
+    RtlZeroMemory(&ExceptionRecord, sizeof(ExceptionRecord));
     ExceptionRecord.ExceptionCode = dwExceptionCode;
     ExceptionRecord.ExceptionRecord = NULL;
     ExceptionRecord.ExceptionAddress = (PVOID)RaiseException;
@@ -726,7 +728,7 @@ RaiseException(IN DWORD dwExceptionCode,
         ExceptionRecord.NumberParameters = nNumberOfArguments;
         RtlCopyMemory(ExceptionRecord.ExceptionInformation,
                       lpArguments,
-                      nNumberOfArguments * sizeof(ULONG));
+                      nNumberOfArguments * sizeof(ULONG_PTR));
     }
 
     /* Better handling of Delphi Exceptions... a ReactOS Hack */

Reply via email to