[KERNEL32] lpNumberOfCharsWritten is optional for WriteConsole (#1079)
authorAndrew Boyarshin <andrew.boyarshin@gmail.com>
Thu, 11 Aug 2022 23:58:18 +0000 (06:58 +0700)
committerGitHub <noreply@github.com>
Thu, 11 Aug 2022 23:58:18 +0000 (01:58 +0200)
Some applications (and libraries, like replxx) rely on this undocumented behavior.

dll/win32/kernel32/client/console/readwrite.c

index b06f7ab..00fbf77 100644 (file)
@@ -681,8 +681,8 @@ IntWriteConsole(IN HANDLE hConsoleOutput,
     /* Release the capture buffer if needed */
     if (CaptureBuffer) CsrFreeCaptureBuffer(CaptureBuffer);
 
-    /* Retrieve the results */
-    if (Success)
+    /* Retrieve the results. NOTE: lpNumberOfCharsWritten optional since Vista+ */
+    if (Success && lpNumberOfCharsWritten)
     {
         _SEH2_TRY
         {
@@ -695,7 +695,7 @@ IntWriteConsole(IN HANDLE hConsoleOutput,
         }
         _SEH2_END;
     }
-    else
+    else if (!Success)
     {
         BaseSetLastNTError(ApiMessage.Status);
     }