[NTOS:KD] Avoid _alloca inside SEH, as it's apparently incompatible with PSEH. CORE...
authorThomas Faber <thomas.faber@reactos.org>
Tue, 12 Dec 2017 11:44:44 +0000 (12:44 +0100)
committerThomas Faber <thomas.faber@reactos.org>
Thu, 14 Dec 2017 10:46:16 +0000 (11:46 +0100)
ntoskrnl/kd/kdio.c
ntoskrnl/kd64/kdprint.c
ntoskrnl/kdbg/kdb_cli.c

index 2058420..50e4d81 100644 (file)
@@ -574,17 +574,18 @@ KdpPrintString(
     PLIST_ENTRY CurrentEntry;
     PKD_DISPATCH_TABLE CurrentTable;
     PCHAR String;
+    CHAR StringBuffer[512];
 
     if (!KdpDebugMode.Value) return 0;
 
-    Length = min(Length, 512);
+    Length = min(Length, sizeof(StringBuffer));
 
     if (ExGetPreviousMode() != KernelMode)
     {
         _SEH2_TRY
         {
             ProbeForRead(UnsafeString, Length, 1);
-            String = _alloca(Length);
+            String = StringBuffer;
             RtlCopyMemory(String, UnsafeString, Length);
         }
         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
index 71a681d..7604a25 100644 (file)
@@ -220,14 +220,15 @@ KdpPrompt(IN LPSTR PromptString,
 {
     STRING PromptBuffer, ResponseBuffer;
     BOOLEAN Enable, Resend;
-    PVOID CapturedPrompt;
+    CHAR CapturedPrompt[512];
+    CHAR SafeResponseBuffer[512];
     PCHAR SafeResponseString;
 
     /* Normalize the lengths */
     PromptLength = min(PromptLength,
-                       512);
+                       sizeof(CapturedPrompt));
     MaximumResponseLength = min(MaximumResponseLength,
-                                512);
+                                sizeof(SafeResponseBuffer));
 
     /* Check if we need to verify the string */
     if (PreviousMode != KernelMode)
@@ -241,7 +242,6 @@ KdpPrompt(IN LPSTR PromptString,
                          1);
 
             /* Capture prompt */
-            CapturedPrompt = _alloca(PromptLength);
             KdpMoveMemory(CapturedPrompt,
                           PromptString,
                           PromptLength);
@@ -251,7 +251,7 @@ KdpPrompt(IN LPSTR PromptString,
             ProbeForWrite(ResponseString,
                           MaximumResponseLength,
                           1);
-            SafeResponseString = _alloca(MaximumResponseLength);
+            SafeResponseString = SafeResponseBuffer;
         }
         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {
index a2829e4..f5e71bd 100644 (file)
@@ -3675,12 +3675,14 @@ KdpPrompt(
     KIRQL OldIrql;
     PCHAR InString;
     PCHAR OutString;
+    CHAR InStringBuffer[512];
+    CHAR OutStringBuffer[512];
 
     /* Normalize the lengths */
     InStringLength = min(InStringLength,
-                         512);
+                         sizeof(InStringBuffer));
     OutStringLength = min(OutStringLength,
-                          512);
+                          sizeof(OutStringBuffer));
 
     /* Check if we need to verify the string */
     if (PreviousMode != KernelMode)
@@ -3694,7 +3696,7 @@ KdpPrompt(
                          1);
 
             /* Capture prompt */
-            InString = _alloca(InStringLength);
+            InString = InStringBuffer;
             RtlCopyMemory(InString,
                           UnsafeInString,
                           InStringLength);
@@ -3703,7 +3705,7 @@ KdpPrompt(
             ProbeForWrite(UnsafeOutString,
                           OutStringLength,
                           1);
-            OutString = _alloca(OutStringLength);
+            OutString = OutStringBuffer;
         }
         _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
         {