PATH:
opt
/
bitninja-threat-hunting
/
node_modules
/
node-pty
/
deps
/
winpty
/
misc
// Determines whether this is a new console by testing whether MARK moves the // cursor. // // WARNING: This test program may behave erratically if run under winpty. // #include <windows.h> #include <stdio.h> #include <string.h> #include "TestUtil.cc" const int SC_CONSOLE_MARK = 0xFFF2; const int SC_CONSOLE_SELECT_ALL = 0xFFF5; static COORD getWindowPos(HANDLE conout) { CONSOLE_SCREEN_BUFFER_INFO info = {}; BOOL ret = GetConsoleScreenBufferInfo(conout, &info); ASSERT(ret && "GetConsoleScreenBufferInfo failed"); return { info.srWindow.Left, info.srWindow.Top }; } static COORD getWindowSize(HANDLE conout) { CONSOLE_SCREEN_BUFFER_INFO info = {}; BOOL ret = GetConsoleScreenBufferInfo(conout, &info); ASSERT(ret && "GetConsoleScreenBufferInfo failed"); return { static_cast<short>(info.srWindow.Right - info.srWindow.Left + 1), static_cast<short>(info.srWindow.Bottom - info.srWindow.Top + 1) }; } static COORD getCursorPos(HANDLE conout) { CONSOLE_SCREEN_BUFFER_INFO info = {}; BOOL ret = GetConsoleScreenBufferInfo(conout, &info); ASSERT(ret && "GetConsoleScreenBufferInfo failed"); return info.dwCursorPosition; } static void setCursorPos(HANDLE conout, COORD pos) { BOOL ret = SetConsoleCursorPosition(conout, pos); ASSERT(ret && "SetConsoleCursorPosition failed"); } int main() { const HANDLE conout = openConout(); const HWND hwnd = GetConsoleWindow(); ASSERT(hwnd != NULL && "GetConsoleWindow() returned NULL"); // With the legacy console, the Mark command moves the the cursor to the // top-left cell of the visible console window. Determine whether this // is the new console by seeing if the cursor moves. const auto windowSize = getWindowSize(conout); if (windowSize.X <= 1) { printf("Error: console window must be at least 2 columns wide\n"); trace("Error: console window must be at least 2 columns wide"); return 1; } bool cursorMoved = false; const auto initialPos = getCursorPos(conout); const auto windowPos = getWindowPos(conout); setCursorPos(conout, { static_cast<short>(windowPos.X + 1), windowPos.Y }); { const auto posA = getCursorPos(conout); SendMessage(hwnd, WM_SYSCOMMAND, SC_CONSOLE_MARK, 0); const auto posB = getCursorPos(conout); cursorMoved = memcmp(&posA, &posB, sizeof(posA)) != 0; SendMessage(hwnd, WM_CHAR, 27, 0x00010001); // Send ESCAPE } setCursorPos(conout, initialPos); if (cursorMoved) { printf("Legacy console (i.e. MARK moved cursor)\n"); trace("Legacy console (i.e. MARK moved cursor)"); } else { printf("Windows 10 new console (i.e MARK did not move cursor)\n"); trace("Windows 10 new console (i.e MARK did not move cursor)"); } return 0; }
[-] DebugServer.py
[edit]
[+]
Font-Report-June2016
[-] Win32Echo1.cc
[edit]
[-] font-notes.txt
[edit]
[-] ShowArgv.cc
[edit]
[-] SetCursorPos.cc
[edit]
[-] UnicodeDoubleWidthTest.cc
[edit]
[-] SetBufferSize.cc
[edit]
[-] GetFont.cc
[edit]
[-] FreezePerfTest.cc
[edit]
[-] color-test.sh
[edit]
[+]
..
[-] ShowConsoleInput.cc
[edit]
[-] MouseInputNotes.txt
[edit]
[-] DebugClient.py
[edit]
[-] ScreenBufferTest2.cc
[edit]
[-] Win10WrapTest1.cc
[edit]
[-] VeryLargeRead.cc
[edit]
[-] FormatChar.h
[edit]
[-] ChangeScreenBuffer.cc
[edit]
[-] IdentifyConsoleWindow.ps1
[edit]
[-] DumpLines.py
[edit]
[-] EnableExtendedFlags.txt
[edit]
[-] TestUtil.cc
[edit]
[-] MoveConsoleWindow.cc
[edit]
[-] ClearConsole.cc
[edit]
[-] IsNewConsole.cc
[edit]
[-] ConoutMode.cc
[edit]
[-] SetWindowRect.cc
[edit]
[-] ConinMode.cc
[edit]
[-] WindowsBugCrashReader.cc
[edit]
[-] WriteConsole.cc
[edit]
[-] UnicodeWideTest1.cc
[edit]
[-] Notes.txt
[edit]
[-] Win32Test2.cc
[edit]
[-] ScreenBufferFreezeInactive.cc
[edit]
[-] GetConsolePos.cc
[edit]
[-] VkEscapeTest.cc
[edit]
[-] Win32Test1.cc
[edit]
[-] winbug-15048.cc
[edit]
[-] Win32Write1.cc
[edit]
[-] ScreenBufferTest.cc
[edit]
[-] OSVersion.cc
[edit]
[-] BufferResizeTests.cc
[edit]
[-] Spew.py
[edit]
[-] build32.sh
[edit]
[-] build64.sh
[edit]
[-] SetFont.cc
[edit]
[-] SelectAllTest.cc
[edit]
[-] UnixEcho.cc
[edit]
[-] ConinMode.ps1
[edit]
[-] Utf16Echo.cc
[edit]
[-] UnicodeWideTest2.cc
[edit]
[-] FontSurvey.cc
[edit]
[-] GetCh.cc
[edit]
[-] Win10WrapTest2.cc
[edit]
[-] Win32Echo2.cc
[edit]
[-] Win32Test3.cc
[edit]
[-] Win10ResizeWhileFrozen.cc
[edit]