From c15a9c1d097cfd5c10c361a24981ff215fcd4153 Mon Sep 17 00:00:00 2001 From: Andrew Boyarshin Date: Fri, 12 Aug 2022 06:58:18 +0700 Subject: [PATCH] [KERNEL32] lpNumberOfCharsWritten is optional for WriteConsole (#1079) Some applications (and libraries, like replxx) rely on this undocumented behavior. --- dll/win32/kernel32/client/console/readwrite.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dll/win32/kernel32/client/console/readwrite.c b/dll/win32/kernel32/client/console/readwrite.c index b06f7ab8299..00fbf7761cb 100644 --- a/dll/win32/kernel32/client/console/readwrite.c +++ b/dll/win32/kernel32/client/console/readwrite.c @@ -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); }