Inactive VT screen buffer writes to active buffer (1803) #250

Open
opened 2026-01-30 21:46:52 +00:00 by claunia · 0 comments
Owner

Originally created by @adoxa on GitHub (May 10, 2018).

Starting with Windows 10 1803, when the active screen buffer has virtual terminal processing enabled and creates another screen buffer, writing to the new, inactive buffer writes to the active buffer. Removing the VT flag writes to the inactive buffer. Quick test program:

#define WIN32_LEAN_AND_MEAN
#include <windows.h>

void test_buffer( DWORD mode )
{
  HANDLE buf;
  char str[] = "Mode 0\n";
  str[5] += (char)mode;
  SetConsoleMode( GetStdHandle( STD_OUTPUT_HANDLE ), mode );
  buf = CreateConsoleScreenBuffer( GENERIC_READ | GENERIC_WRITE, 0, NULL,
				   CONSOLE_TEXTMODE_BUFFER, NULL );
  WriteConsole( buf, str, 7, &mode, NULL );
  CloseHandle( buf );
}

int main( void )
{
  test_buffer( 7 );
  test_buffer( 3 );

  return 0;
}

This should not be outputting anything, but what you actually get is:

J:\>ver

Microsoft Windows [Version 10.0.17134.48]

J:\>test-buffer.exe
Mode 7

(For my purposes I can simply disable VT processing.)

Originally created by @adoxa on GitHub (May 10, 2018). Starting with Windows 10 1803, when the active screen buffer has virtual terminal processing enabled and creates another screen buffer, writing to the new, inactive buffer writes to the active buffer. Removing the VT flag writes to the inactive buffer. Quick test program: ```c #define WIN32_LEAN_AND_MEAN #include <windows.h> void test_buffer( DWORD mode ) { HANDLE buf; char str[] = "Mode 0\n"; str[5] += (char)mode; SetConsoleMode( GetStdHandle( STD_OUTPUT_HANDLE ), mode ); buf = CreateConsoleScreenBuffer( GENERIC_READ | GENERIC_WRITE, 0, NULL, CONSOLE_TEXTMODE_BUFFER, NULL ); WriteConsole( buf, str, 7, &mode, NULL ); CloseHandle( buf ); } int main( void ) { test_buffer( 7 ); test_buffer( 3 ); return 0; } ``` This should not be outputting anything, but what you actually get is: ``` J:\>ver Microsoft Windows [Version 10.0.17134.48] J:\>test-buffer.exe Mode 7 ``` (For my purposes I can simply disable VT processing.)
claunia added the Product-ConhostResolution-Fix-AvailableArea-OutputIssue-Bug labels 2026-01-30 21:46:52 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#250