From 30a2ef8a7e33e759eebd74dd4dddfcd1f4acd35b Mon Sep 17 00:00:00 2001
From: Biswapriyo Nath <[email protected]>
Date: Mon, 2 Dec 2024 17:53:18 +0000
Subject: [PATCH] headers: Split wincon.h into separate consoleapi headers

Fixes https://github.com/mingw-w64/mingw-w64/issues/71

Signed-off-by: Biswapriyo Nath <[email protected]>
---
 mingw-w64-headers/include/consoleapi.h  | 139 ++++++++
 mingw-w64-headers/include/consoleapi2.h | 144 +++++++++
 mingw-w64-headers/include/consoleapi3.h | 146 +++++++++
 mingw-w64-headers/include/wincon.h      | 413 +-----------------------
 mingw-w64-headers/include/wincontypes.h | 130 ++++++++
 5 files changed, 572 insertions(+), 400 deletions(-)
 create mode 100644 mingw-w64-headers/include/consoleapi.h
 create mode 100644 mingw-w64-headers/include/consoleapi2.h
 create mode 100644 mingw-w64-headers/include/consoleapi3.h
 create mode 100644 mingw-w64-headers/include/wincontypes.h

diff --git a/mingw-w64-headers/include/consoleapi.h 
b/mingw-w64-headers/include/consoleapi.h
new file mode 100644
index 0000000..b269ecf
--- /dev/null
+++ b/mingw-w64-headers/include/consoleapi.h
@@ -0,0 +1,139 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifndef _APISETCONSOLE_
+#define _APISETCONSOLE_
+
+#include <_mingw_unicode.h>
+
+#include <apiset.h>
+#include <apisetcconv.h>
+#include <minwinbase.h>
+#include <minwindef.h>
+
+#include <wincontypes.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+
+WINBASEAPI WINBOOL WINAPI AllocConsole(void);
+
+#if (NTDDI_VERSION >= NTDDI_WIN11_GE)
+
+typedef enum ALLOC_CONSOLE_MODE {
+  ALLOC_CONSOLE_MODE_DEFAULT = 0,
+  ALLOC_CONSOLE_MODE_NEW_WINDOW = 1,
+  ALLOC_CONSOLE_MODE_NO_WINDOW = 2
+} ALLOC_CONSOLE_MODE;
+
+typedef struct ALLOC_CONSOLE_OPTIONS {
+  ALLOC_CONSOLE_MODE mode;
+  WINBOOL useShowWindow;
+  WORD showWindow;
+} ALLOC_CONSOLE_OPTIONS, *PALLOC_CONSOLE_OPTIONS;
+
+typedef enum ALLOC_CONSOLE_RESULT {
+  ALLOC_CONSOLE_RESULT_NO_CONSOLE = 0,
+  ALLOC_CONSOLE_RESULT_NEW_CONSOLE = 1,
+  ALLOC_CONSOLE_RESULT_EXISTING_CONSOLE = 2
+} ALLOC_CONSOLE_RESULT, *PALLOC_CONSOLE_RESULT;
+
+WINBASEAPI HRESULT WINAPI AllocConsoleWithOptions(PALLOC_CONSOLE_OPTIONS 
options, PALLOC_CONSOLE_RESULT result);
+
+#endif /* NTDDI_VERSION >= NTDDI_WIN11_GE */
+
+WINBASEAPI WINBOOL WINAPI FreeConsole(void);
+
+#if (_WIN32_WINNT >= 0x0500)
+
+WINBASEAPI WINBOOL WINAPI AttachConsole(DWORD process_id);
+
+#define ATTACH_PARENT_PROCESS ((DWORD)-1)
+
+#endif /* _WIN32_WINNT >= 0x0500 */
+
+WINBASEAPI UINT WINAPI GetConsoleCP(void);
+WINBASEAPI UINT WINAPI GetConsoleOutputCP(void);
+
+#define ENABLE_PROCESSED_INPUT 0x0001
+#define ENABLE_LINE_INPUT 0x0002
+#define ENABLE_ECHO_INPUT 0x0004
+#define ENABLE_WINDOW_INPUT 0x0008
+#define ENABLE_MOUSE_INPUT 0x0010
+#define ENABLE_INSERT_MODE 0x0020
+#define ENABLE_QUICK_EDIT_MODE 0x0040
+#define ENABLE_EXTENDED_FLAGS 0x0080
+#define ENABLE_AUTO_POSITION 0x0100
+#define ENABLE_VIRTUAL_TERMINAL_INPUT 0x0200
+
+#define ENABLE_PROCESSED_OUTPUT 0x0001
+#define ENABLE_WRAP_AT_EOL_OUTPUT 0x0002
+#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x0004
+#define DISABLE_NEWLINE_AUTO_RETURN 0x0008
+#define ENABLE_LVB_GRID_WORLDWIDE 0x0010
+
+WINBASEAPI WINBOOL WINAPI GetConsoleMode(HANDLE console_handle, LPDWORD mode);
+WINBASEAPI WINBOOL WINAPI SetConsoleMode(HANDLE console_handle, DWORD mode);
+WINBASEAPI WINBOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE console_input, 
LPDWORD number_of_events);
+
+WINBASEAPI WINBOOL WINAPI ReadConsoleInputA(HANDLE console_input, 
PINPUT_RECORD buffer, DWORD length, LPDWORD number_of_events_read);
+WINBASEAPI WINBOOL WINAPI ReadConsoleInputW(HANDLE console_input, 
PINPUT_RECORD buffer, DWORD length, LPDWORD number_of_events_read);
+#define ReadConsoleInput __MINGW_NAME_AW(ReadConsoleInput)
+
+WINBASEAPI WINBOOL WINAPI PeekConsoleInputA(HANDLE console_input, 
PINPUT_RECORD buffer, DWORD length, LPDWORD number_of_events_read);
+WINBASEAPI WINBOOL WINAPI PeekConsoleInputW(HANDLE console_input, 
PINPUT_RECORD buffer, DWORD length, LPDWORD number_of_events_read);
+#define PeekConsoleInput __MINGW_NAME_AW(PeekConsoleInput)
+
+typedef struct _CONSOLE_READCONSOLE_CONTROL {
+  ULONG nLength;
+  ULONG nInitialChars;
+  ULONG dwCtrlWakeupMask;
+  ULONG dwControlKeyState;
+} CONSOLE_READCONSOLE_CONTROL, *PCONSOLE_READCONSOLE_CONTROL;
+
+WINBASEAPI WINBOOL WINAPI ReadConsoleA(HANDLE console_input, LPVOID buffer, 
DWORD number_of_chars_to_read, LPDWORD number_of_chars_read, 
PCONSOLE_READCONSOLE_CONTROL input_control);
+WINBASEAPI WINBOOL WINAPI ReadConsoleW(HANDLE console_input, LPVOID buffer, 
DWORD number_of_chars_to_read, LPDWORD number_of_chars_read, 
PCONSOLE_READCONSOLE_CONTROL input_control);
+#define ReadConsole __MINGW_NAME_AW(ReadConsole)
+
+WINBASEAPI WINBOOL WINAPI WriteConsoleA(HANDLE console_output, const void 
*buffer, DWORD number_of_chars_to_write, LPDWORD number_of_chars_written, 
LPVOID reserved);
+WINBASEAPI WINBOOL WINAPI WriteConsoleW(HANDLE console_output, const void 
*buffer, DWORD number_of_chars_to_write, LPDWORD number_of_chars_written, 
LPVOID reserved);
+#define WriteConsole __MINGW_NAME_AW(WriteConsole)
+
+#define CTRL_C_EVENT 0
+#define CTRL_BREAK_EVENT 1
+#define CTRL_CLOSE_EVENT 2
+#define CTRL_LOGOFF_EVENT 5
+#define CTRL_SHUTDOWN_EVENT 6
+
+typedef WINBOOL(WINAPI *PHANDLER_ROUTINE)(DWORD ctrl_type);
+WINBASEAPI WINBOOL WINAPI SetConsoleCtrlHandler(PHANDLER_ROUTINE 
handler_routine, WINBOOL add);
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
+
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+
+#if (NTDDI_VERSION >= NTDDI_WIN10_RS5)
+#define PSEUDOCONSOLE_INHERIT_CURSOR (0x1)
+
+WINBASEAPI HRESULT WINAPI CreatePseudoConsole(COORD size, HANDLE input, HANDLE 
output, DWORD flags, HPCON *pc);
+WINBASEAPI HRESULT WINAPI ResizePseudoConsole(HPCON pc, COORD size);
+WINBASEAPI void WINAPI ClosePseudoConsole(HPCON pc);
+#endif
+
+#if (NTDDI_VERSION >= NTDDI_WIN11_GE)
+WINBASEAPI HRESULT WINAPI ReleasePseudoConsole(HPCON pc);
+#endif
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _APISETCONSOLE_ */
diff --git a/mingw-w64-headers/include/consoleapi2.h 
b/mingw-w64-headers/include/consoleapi2.h
new file mode 100644
index 0000000..184e47f
--- /dev/null
+++ b/mingw-w64-headers/include/consoleapi2.h
@@ -0,0 +1,144 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifndef _APISETCONSOLEL2_
+#define _APISETCONSOLEL2_
+
+#include <_mingw_unicode.h>
+
+#include <apiset.h>
+#include <apisetcconv.h>
+#include <minwinbase.h>
+#include <minwindef.h>
+
+#include <wincontypes.h>
+#include <windef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+
+#define FOREGROUND_BLUE 0x0001
+#define FOREGROUND_GREEN 0x0002
+#define FOREGROUND_RED 0x0004
+#define FOREGROUND_INTENSITY 0x0008
+#define BACKGROUND_BLUE 0x0010
+#define BACKGROUND_GREEN 0x0020
+#define BACKGROUND_RED 0x0040
+#define BACKGROUND_INTENSITY 0x0080
+#define COMMON_LVB_LEADING_BYTE 0x0100
+#define COMMON_LVB_TRAILING_BYTE 0x0200
+#define COMMON_LVB_GRID_HORIZONTAL 0x0400
+#define COMMON_LVB_GRID_LVERTICAL 0x0800
+#define COMMON_LVB_GRID_RVERTICAL 0x1000
+#define COMMON_LVB_REVERSE_VIDEO 0x4000
+#define COMMON_LVB_UNDERSCORE 0x8000
+
+#define COMMON_LVB_SBCSDBCS 0x0300
+
+WINBASEAPI WINBOOL WINAPI FillConsoleOutputCharacterA(HANDLE console_output, 
CHAR character, DWORD length, COORD write_coord, LPDWORD 
number_of_chars_written);
+WINBASEAPI WINBOOL WINAPI FillConsoleOutputCharacterW(HANDLE console_output, 
WCHAR character, DWORD length, COORD write_coord, LPDWORD 
number_of_chars_written);
+#define FillConsoleOutputCharacter __MINGW_NAME_AW(FillConsoleOutputCharacter)
+
+WINBASEAPI WINBOOL WINAPI FillConsoleOutputAttribute(HANDLE console_output, 
WORD attribute, DWORD length, COORD write_coord, LPDWORD 
number_of_attrs_written);
+WINBASEAPI WINBOOL WINAPI GenerateConsoleCtrlEvent(DWORD ctrl_event, DWORD 
process_group_id);
+WINBASEAPI HANDLE WINAPI CreateConsoleScreenBuffer(DWORD desired_access, DWORD 
share_mode, const SECURITY_ATTRIBUTES *security_attributes, DWORD flags, LPVOID 
screen_buffer_data);
+WINBASEAPI WINBOOL WINAPI SetConsoleActiveScreenBuffer(HANDLE console_output);
+WINBASEAPI WINBOOL WINAPI FlushConsoleInputBuffer(HANDLE console_input);
+WINBASEAPI WINBOOL WINAPI SetConsoleCP(UINT code_page_id);
+WINBASEAPI WINBOOL WINAPI SetConsoleOutputCP(UINT code_page_id);
+
+typedef struct _CONSOLE_CURSOR_INFO {
+  DWORD dwSize;
+  WINBOOL bVisible;
+} CONSOLE_CURSOR_INFO, *PCONSOLE_CURSOR_INFO;
+
+WINBASEAPI WINBOOL WINAPI GetConsoleCursorInfo(HANDLE console_output, 
PCONSOLE_CURSOR_INFO console_cursor_info);
+WINBASEAPI WINBOOL WINAPI SetConsoleCursorInfo(HANDLE console_output, const 
CONSOLE_CURSOR_INFO *console_cursor_info);
+
+typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
+  COORD dwSize;
+  COORD dwCursorPosition;
+  WORD wAttributes;
+  SMALL_RECT srWindow;
+  COORD dwMaximumWindowSize;
+} CONSOLE_SCREEN_BUFFER_INFO, *PCONSOLE_SCREEN_BUFFER_INFO;
+
+WINBASEAPI WINBOOL WINAPI GetConsoleScreenBufferInfo(HANDLE console_output, 
PCONSOLE_SCREEN_BUFFER_INFO console_screen_buffer_info);
+
+typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX {
+  ULONG cbSize;
+  COORD dwSize;
+  COORD dwCursorPosition;
+  WORD wAttributes;
+  SMALL_RECT srWindow;
+  COORD dwMaximumWindowSize;
+  WORD wPopupAttributes;
+  WINBOOL bFullscreenSupported;
+  COLORREF ColorTable[16];
+} CONSOLE_SCREEN_BUFFER_INFOEX, *PCONSOLE_SCREEN_BUFFER_INFOEX;
+
+WINBASEAPI WINBOOL WINAPI GetConsoleScreenBufferInfoEx(HANDLE console_output, 
PCONSOLE_SCREEN_BUFFER_INFOEX console_screen_buffer_info_ex);
+WINBASEAPI WINBOOL WINAPI SetConsoleScreenBufferInfoEx(HANDLE console_output, 
PCONSOLE_SCREEN_BUFFER_INFOEX console_screen_buffer_info_ex);
+WINBASEAPI WINBOOL WINAPI SetConsoleScreenBufferSize(HANDLE console_output, 
COORD size);
+WINBASEAPI WINBOOL WINAPI SetConsoleCursorPosition(HANDLE console_output, 
COORD cursor_position);
+WINBASEAPI COORD WINAPI GetLargestConsoleWindowSize(HANDLE console_output);
+WINBASEAPI WINBOOL WINAPI SetConsoleTextAttribute(HANDLE console_output, WORD 
attributes);
+WINBASEAPI WINBOOL WINAPI SetConsoleWindowInfo(HANDLE console_output, WINBOOL 
absolute, const SMALL_RECT *console_window);
+
+WINBASEAPI WINBOOL WINAPI WriteConsoleOutputCharacterA(HANDLE console_output, 
LPCSTR character, DWORD length, COORD write_coord, LPDWORD 
number_of_chars_written);
+WINBASEAPI WINBOOL WINAPI WriteConsoleOutputCharacterW(HANDLE console_output, 
LPCWSTR character, DWORD length, COORD write_coord, LPDWORD 
number_of_chars_written);
+#define WriteConsoleOutputCharacter 
__MINGW_NAME_AW(WriteConsoleOutputCharacter)
+
+WINBASEAPI WINBOOL WINAPI WriteConsoleOutputAttribute(HANDLE console_output, 
const WORD *attribute, DWORD length, COORD write_coord, LPDWORD 
number_of_attrs_written);
+
+WINBASEAPI WINBOOL WINAPI ReadConsoleOutputCharacterA(HANDLE console_output, 
LPSTR character, DWORD length, COORD read_coord, LPDWORD number_of_chars_read);
+WINBASEAPI WINBOOL WINAPI ReadConsoleOutputCharacterW(HANDLE console_output, 
LPWSTR character, DWORD length, COORD read_coord, LPDWORD number_of_chars_read);
+#define ReadConsoleOutputCharacter __MINGW_NAME_AW(ReadConsoleOutputCharacter)
+
+WINBASEAPI WINBOOL WINAPI ReadConsoleOutputAttribute(HANDLE console_output, 
LPWORD attribute, DWORD length, COORD read_coord, LPDWORD number_of_attrs_read);
+
+WINBASEAPI WINBOOL WINAPI WriteConsoleInputA(HANDLE console_input, const 
INPUT_RECORD *buffer, DWORD length, LPDWORD number_of_events_written);
+WINBASEAPI WINBOOL WINAPI WriteConsoleInputW(HANDLE console_input, const 
INPUT_RECORD *buffer, DWORD length, LPDWORD number_of_events_written);
+#define WriteConsoleInput __MINGW_NAME_AW(WriteConsoleInput)
+
+WINBASEAPI WINBOOL WINAPI ScrollConsoleScreenBufferA(HANDLE console_output, 
const SMALL_RECT *scroll_rectangle, const SMALL_RECT *clip_rectangle, COORD 
destination_origin, const CHAR_INFO *fill);
+WINBASEAPI WINBOOL WINAPI ScrollConsoleScreenBufferW(HANDLE console_output, 
const SMALL_RECT *scroll_rectangle, const SMALL_RECT *clip_rectangle, COORD 
destination_origin, const CHAR_INFO *fill);
+#define ScrollConsoleScreenBuffer __MINGW_NAME_AW(ScrollConsoleScreenBuffer)
+
+WINBASEAPI WINBOOL WINAPI WriteConsoleOutputA(HANDLE console_output, const 
CHAR_INFO *buffer, COORD buffer_size, COORD buffer_coord, PSMALL_RECT 
write_region);
+WINBASEAPI WINBOOL WINAPI WriteConsoleOutputW(HANDLE console_output, const 
CHAR_INFO *buffer, COORD buffer_size, COORD buffer_coord, PSMALL_RECT 
write_region);
+#define WriteConsoleOutput __MINGW_NAME_AW(WriteConsoleOutput)
+
+WINBASEAPI WINBOOL WINAPI ReadConsoleOutputA(HANDLE console_output, PCHAR_INFO 
buffer, COORD buffer_size, COORD buffer_coord, PSMALL_RECT read_region);
+WINBASEAPI WINBOOL WINAPI ReadConsoleOutputW(HANDLE console_output, PCHAR_INFO 
buffer, COORD buffer_size, COORD buffer_coord, PSMALL_RECT read_region);
+#define ReadConsoleOutput __MINGW_NAME_AW(ReadConsoleOutput)
+
+WINBASEAPI DWORD WINAPI GetConsoleTitleA(LPSTR console_title, DWORD size);
+WINBASEAPI DWORD WINAPI GetConsoleTitleW(LPWSTR console_title, DWORD size);
+#define GetConsoleTitle __MINGW_NAME_AW(GetConsoleTitle)
+
+#if (_WIN32_WINNT >= 0x0600)
+
+WINBASEAPI DWORD WINAPI GetConsoleOriginalTitleA(LPSTR console_title, DWORD 
size);
+WINBASEAPI DWORD WINAPI GetConsoleOriginalTitleW(LPWSTR console_title, DWORD 
size);
+#define GetConsoleOriginalTitle __MINGW_NAME_AW(GetConsoleOriginalTitle)
+
+#endif /* _WIN32_WINNT >= 0x0600 */
+
+WINBASEAPI WINBOOL WINAPI SetConsoleTitleA(LPCSTR console_title);
+WINBASEAPI WINBOOL WINAPI SetConsoleTitleW(LPCWSTR console_title);
+#define SetConsoleTitle __MINGW_NAME_AW(SetConsoleTitle)
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _APISETCONSOLEL2_ */
diff --git a/mingw-w64-headers/include/consoleapi3.h 
b/mingw-w64-headers/include/consoleapi3.h
new file mode 100644
index 0000000..7336308
--- /dev/null
+++ b/mingw-w64-headers/include/consoleapi3.h
@@ -0,0 +1,146 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifndef _APISETCONSOLEL3_
+#define _APISETCONSOLEL3_
+
+#include <_mingw_unicode.h>
+
+#include <apiset.h>
+#include <apisetcconv.h>
+#include <minwinbase.h>
+#include <minwindef.h>
+
+#include <wincontypes.h>
+#include <windef.h>
+
+#ifndef NOGDI
+#include <wingdi.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+
+WINBASEAPI WINBOOL WINAPI GetNumberOfConsoleMouseButtons(LPDWORD 
number_of_mouse_buttons);
+
+#if (_WIN32_WINNT >= 0x0500)
+
+WINBASEAPI COORD WINAPI GetConsoleFontSize(HANDLE console_output, DWORD font);
+WINBASEAPI WINBOOL WINAPI GetCurrentConsoleFont(HANDLE console_output, WINBOOL 
maximum_window, PCONSOLE_FONT_INFO console_current_font);
+
+#ifndef NOGDI
+
+typedef struct _CONSOLE_FONT_INFOEX {
+  ULONG cbSize;
+  DWORD nFont;
+  COORD dwFontSize;
+  UINT FontFamily;
+  UINT FontWeight;
+  WCHAR FaceName[LF_FACESIZE];
+} CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
+
+WINBASEAPI WINBOOL WINAPI GetCurrentConsoleFontEx(HANDLE console_output, 
WINBOOL maximum_window, PCONSOLE_FONT_INFOEX console_current_font_ex);
+WINBASEAPI WINBOOL WINAPI SetCurrentConsoleFontEx(HANDLE console_output, 
WINBOOL maximum_window, PCONSOLE_FONT_INFOEX console_current_font_ex);
+
+#endif /* !NOGDI */
+
+#define CONSOLE_NO_SELECTION 0x0000
+#define CONSOLE_SELECTION_IN_PROGRESS 0x0001
+#define CONSOLE_SELECTION_NOT_EMPTY 0x0002
+#define CONSOLE_MOUSE_SELECTION 0x0004
+#define CONSOLE_MOUSE_DOWN 0x0008
+
+typedef struct _CONSOLE_SELECTION_INFO {
+  DWORD dwFlags;
+  COORD dwSelectionAnchor;
+  SMALL_RECT srSelection;
+} CONSOLE_SELECTION_INFO, *PCONSOLE_SELECTION_INFO;
+
+WINBASEAPI WINBOOL WINAPI GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO 
console_selection_info);
+
+#define HISTORY_NO_DUP_FLAG 0x1
+
+typedef struct _CONSOLE_HISTORY_INFO {
+  UINT cbSize;
+  UINT HistoryBufferSize;
+  UINT NumberOfHistoryBuffers;
+  DWORD dwFlags;
+} CONSOLE_HISTORY_INFO, *PCONSOLE_HISTORY_INFO;
+
+WINBASEAPI WINBOOL WINAPI GetConsoleHistoryInfo(PCONSOLE_HISTORY_INFO 
console_history_info);
+WINBASEAPI WINBOOL WINAPI SetConsoleHistoryInfo(PCONSOLE_HISTORY_INFO 
console_history_info);
+
+#define CONSOLE_FULLSCREEN 1
+#define CONSOLE_FULLSCREEN_HARDWARE 2
+
+WINBASEAPI WINBOOL APIENTRY GetConsoleDisplayMode(LPDWORD mode_flags);
+
+#define CONSOLE_FULLSCREEN_MODE 1
+#define CONSOLE_WINDOWED_MODE 2
+
+WINBASEAPI WINBOOL APIENTRY SetConsoleDisplayMode(HANDLE console_output, DWORD 
flags, PCOORD new_screen_buffer_dimensions);
+WINBASEAPI HWND APIENTRY GetConsoleWindow(void);
+
+#endif /* _WIN32_WINNT >= 0x0500 */
+
+#if (_WIN32_WINNT >= 0x0501)
+
+WINBASEAPI WINBOOL APIENTRY AddConsoleAliasA(LPSTR source, LPSTR target, LPSTR 
exe_name);
+WINBASEAPI WINBOOL APIENTRY AddConsoleAliasW(LPWSTR source, LPWSTR target, 
LPWSTR exe_name);
+#define AddConsoleAlias __MINGW_NAME_AW(AddConsoleAlias)
+
+WINBASEAPI DWORD APIENTRY GetConsoleAliasA(LPSTR source, LPSTR target_buffer, 
DWORD target_buffer_length, LPSTR exe_name);
+WINBASEAPI DWORD APIENTRY GetConsoleAliasW(LPWSTR source, LPWSTR 
target_buffer, DWORD target_buffer_length, LPWSTR exe_name);
+#define GetConsoleAlias __MINGW_NAME_AW(GetConsoleAlias)
+
+WINBASEAPI DWORD APIENTRY GetConsoleAliasesLengthA(LPSTR exe_name);
+WINBASEAPI DWORD APIENTRY GetConsoleAliasesLengthW(LPWSTR exe_name);
+#define GetConsoleAliasesLength __MINGW_NAME_AW(GetConsoleAliasesLength)
+
+WINBASEAPI DWORD APIENTRY GetConsoleAliasExesLengthA(void);
+WINBASEAPI DWORD APIENTRY GetConsoleAliasExesLengthW(void);
+#define GetConsoleAliasExesLength __MINGW_NAME_AW(GetConsoleAliasExesLength)
+
+WINBASEAPI DWORD APIENTRY GetConsoleAliasesA(LPSTR alias_buffer, DWORD 
alias_buffer_length, LPSTR exe_name);
+WINBASEAPI DWORD APIENTRY GetConsoleAliasesW(LPWSTR alias_buffer, DWORD 
alias_buffer_length, LPWSTR exe_name);
+#define GetConsoleAliases __MINGW_NAME_AW(GetConsoleAliases)
+
+WINBASEAPI DWORD APIENTRY GetConsoleAliasExesA(LPSTR exe_name_buffer, DWORD 
exe_name_buffer_length);
+WINBASEAPI DWORD APIENTRY GetConsoleAliasExesW(LPWSTR exe_name_buffer, DWORD 
exe_name_buffer_length);
+#define GetConsoleAliasExes __MINGW_NAME_AW(GetConsoleAliasExes)
+
+#endif /* _WIN32_WINNT >= 0x0501 */
+
+WINBASEAPI void APIENTRY ExpungeConsoleCommandHistoryA(LPSTR exe_name);
+WINBASEAPI void APIENTRY ExpungeConsoleCommandHistoryW(LPWSTR exe_name);
+#define ExpungeConsoleCommandHistory 
__MINGW_NAME_AW(ExpungeConsoleCommandHistory)
+
+WINBASEAPI WINBOOL APIENTRY SetConsoleNumberOfCommandsA(DWORD number, LPSTR 
exe_name);
+WINBASEAPI WINBOOL APIENTRY SetConsoleNumberOfCommandsW(DWORD number, LPWSTR 
exe_name);
+#define SetConsoleNumberOfCommands __MINGW_NAME_AW(SetConsoleNumberOfCommands)
+
+WINBASEAPI DWORD APIENTRY GetConsoleCommandHistoryLengthA(LPSTR exe_name);
+WINBASEAPI DWORD APIENTRY GetConsoleCommandHistoryLengthW(LPWSTR exe_name);
+#define GetConsoleCommandHistoryLength 
__MINGW_NAME_AW(GetConsoleCommandHistoryLength)
+
+WINBASEAPI DWORD APIENTRY GetConsoleCommandHistoryA(LPSTR commands, DWORD 
command_buffer_length, LPSTR exe_name);
+WINBASEAPI DWORD APIENTRY GetConsoleCommandHistoryW(LPWSTR commands, DWORD 
command_buffer_length, LPWSTR exe_name);
+#define GetConsoleCommandHistory __MINGW_NAME_AW(GetConsoleCommandHistory)
+
+#if (_WIN32_WINNT >= 0x0501)
+WINBASEAPI DWORD APIENTRY GetConsoleProcessList(LPDWORD process_list, DWORD 
process_count);
+#endif /* _WIN32_WINNT >= 0x0501 */
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _APISETCONSOLEL3_ */
diff --git a/mingw-w64-headers/include/wincon.h 
b/mingw-w64-headers/include/wincon.h
index d4dea61..47fb873 100644
--- a/mingw-w64-headers/include/wincon.h
+++ b/mingw-w64-headers/include/wincon.h
@@ -3,422 +3,35 @@
  * This file is part of the mingw-w64 runtime package.
  * No warranty is given; refer to the file DISCLAIMER.PD within this package.
  */
+
 #ifndef _WINCON_
 #define _WINCON_
 
-#include <_mingw_unicode.h>
-
 #include <winapifamily.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-#define CONSOLE_REAL_OUTPUT_HANDLE (LongToHandle(-2))
-#define CONSOLE_REAL_INPUT_HANDLE (LongToHandle(-3))
-
-  typedef struct _COORD {
-    SHORT X;
-    SHORT Y;
-  } COORD,*PCOORD;
-
-  typedef struct _SMALL_RECT {
-    SHORT Left;
-    SHORT Top;
-    SHORT Right;
-    SHORT Bottom;
-  } SMALL_RECT,*PSMALL_RECT;
-
-  typedef struct _KEY_EVENT_RECORD {
-    WINBOOL bKeyDown;
-    WORD wRepeatCount;
-    WORD wVirtualKeyCode;
-    WORD wVirtualScanCode;
-    union {
-      WCHAR UnicodeChar;
-      CHAR AsciiChar;
-    } uChar;
-    DWORD dwControlKeyState;
-  } KEY_EVENT_RECORD,*PKEY_EVENT_RECORD;
-
-#define RIGHT_ALT_PRESSED 0x1
-#define LEFT_ALT_PRESSED 0x2
-#define RIGHT_CTRL_PRESSED 0x4
-#define LEFT_CTRL_PRESSED 0x8
-#define SHIFT_PRESSED 0x10
-#define NUMLOCK_ON 0x20
-#define SCROLLLOCK_ON 0x40
-#define CAPSLOCK_ON 0x80
-#define ENHANCED_KEY 0x100
-#define NLS_DBCSCHAR 0x10000
-#define NLS_ALPHANUMERIC 0x0
-#define NLS_KATAKANA 0x20000
-#define NLS_HIRAGANA 0x40000
-#define NLS_ROMAN 0x400000
-#define NLS_IME_CONVERSION 0x800000
-#define ALTNUMPAD_BIT 0x4000000
-#define NLS_IME_DISABLE 0x20000000
-
-  typedef struct _MOUSE_EVENT_RECORD {
-    COORD dwMousePosition;
-    DWORD dwButtonState;
-    DWORD dwControlKeyState;
-    DWORD dwEventFlags;
-  } MOUSE_EVENT_RECORD,*PMOUSE_EVENT_RECORD;
+#include <wincontypes.h>
 
-#define FROM_LEFT_1ST_BUTTON_PRESSED 0x1
-#define RIGHTMOST_BUTTON_PRESSED 0x2
-#define FROM_LEFT_2ND_BUTTON_PRESSED 0x4
-#define FROM_LEFT_3RD_BUTTON_PRESSED 0x8
-#define FROM_LEFT_4TH_BUTTON_PRESSED 0x10
-
-#define MOUSE_MOVED 0x1
-#define DOUBLE_CLICK 0x2
-#define MOUSE_WHEELED 0x4
-#if (_WIN32_WINNT >= 0x0600)
-#define MOUSE_HWHEELED 0x8
+#ifndef NOGDI
+#include <wingdi.h>
 #endif
 
-  typedef struct _WINDOW_BUFFER_SIZE_RECORD {
-    COORD dwSize;
-  } WINDOW_BUFFER_SIZE_RECORD,*PWINDOW_BUFFER_SIZE_RECORD;
-
-  typedef struct _MENU_EVENT_RECORD {
-    UINT dwCommandId;
-  } MENU_EVENT_RECORD,*PMENU_EVENT_RECORD;
-
-  typedef struct _FOCUS_EVENT_RECORD {
-    WINBOOL bSetFocus;
-  } FOCUS_EVENT_RECORD,*PFOCUS_EVENT_RECORD;
-
-  typedef struct _INPUT_RECORD {
-    WORD EventType;
-    union {
-      KEY_EVENT_RECORD KeyEvent;
-      MOUSE_EVENT_RECORD MouseEvent;
-      WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
-      MENU_EVENT_RECORD MenuEvent;
-      FOCUS_EVENT_RECORD FocusEvent;
-    } Event;
-  } INPUT_RECORD,*PINPUT_RECORD;
-
-#define KEY_EVENT 0x1
-#define MOUSE_EVENT 0x2
-#define WINDOW_BUFFER_SIZE_EVENT 0x4
-#define MENU_EVENT 0x8
-#define FOCUS_EVENT 0x10
-
-  typedef struct _CHAR_INFO {
-    union {
-      WCHAR UnicodeChar;
-      CHAR AsciiChar;
-    } Char;
-    WORD Attributes;
-  } CHAR_INFO,*PCHAR_INFO;
-
-#define FOREGROUND_BLUE 0x1
-#define FOREGROUND_GREEN 0x2
-#define FOREGROUND_RED 0x4
-#define FOREGROUND_INTENSITY 0x8
-#define BACKGROUND_BLUE 0x10
-#define BACKGROUND_GREEN 0x20
-#define BACKGROUND_RED 0x40
-#define BACKGROUND_INTENSITY 0x80
-#define COMMON_LVB_LEADING_BYTE 0x100
-#define COMMON_LVB_TRAILING_BYTE 0x200
-#define COMMON_LVB_GRID_HORIZONTAL 0x400
-#define COMMON_LVB_GRID_LVERTICAL 0x800
-#define COMMON_LVB_GRID_RVERTICAL 0x1000
-#define COMMON_LVB_REVERSE_VIDEO 0x4000
-#define COMMON_LVB_UNDERSCORE 0x8000
-
-#define COMMON_LVB_SBCSDBCS 0x300
-
-  typedef struct _CONSOLE_SCREEN_BUFFER_INFO {
-    COORD dwSize;
-    COORD dwCursorPosition;
-    WORD wAttributes;
-    SMALL_RECT srWindow;
-    COORD dwMaximumWindowSize;
-  } CONSOLE_SCREEN_BUFFER_INFO,*PCONSOLE_SCREEN_BUFFER_INFO;
-
-  typedef struct _CONSOLE_CURSOR_INFO {
-    DWORD dwSize;
-    WINBOOL bVisible;
-  } CONSOLE_CURSOR_INFO,*PCONSOLE_CURSOR_INFO;
-
-  typedef struct _CONSOLE_FONT_INFO {
-    DWORD nFont;
-    COORD dwFontSize;
-  } CONSOLE_FONT_INFO,*PCONSOLE_FONT_INFO;
-
-  typedef struct _CONSOLE_SELECTION_INFO {
-    DWORD dwFlags;
-    COORD dwSelectionAnchor;
-    SMALL_RECT srSelection;
-  } CONSOLE_SELECTION_INFO,*PCONSOLE_SELECTION_INFO;
-
-#define CONSOLE_NO_SELECTION 0x0
-#define CONSOLE_SELECTION_IN_PROGRESS 0x1
-#define CONSOLE_SELECTION_NOT_EMPTY 0x2
-#define CONSOLE_MOUSE_SELECTION 0x4
-#define CONSOLE_MOUSE_DOWN 0x8
-
-  typedef WINBOOL (WINAPI *PHANDLER_ROUTINE)(DWORD CtrlType);
-
-#define CTRL_C_EVENT 0
-#define CTRL_BREAK_EVENT 1
-#define CTRL_CLOSE_EVENT 2
-
-#define CTRL_LOGOFF_EVENT 5
-#define CTRL_SHUTDOWN_EVENT 6
-
-#define ENABLE_PROCESSED_INPUT 0x1
-#define ENABLE_LINE_INPUT 0x2
-#define ENABLE_ECHO_INPUT 0x4
-#define ENABLE_WINDOW_INPUT 0x8
-#define ENABLE_MOUSE_INPUT 0x10
-#define ENABLE_INSERT_MODE 0x20
-#define ENABLE_QUICK_EDIT_MODE 0x40
-#define ENABLE_EXTENDED_FLAGS 0x80
-#define ENABLE_AUTO_POSITION 0x100
-#define ENABLE_VIRTUAL_TERMINAL_INPUT 0x200
-
-#define ENABLE_PROCESSED_OUTPUT 0x1
-#define ENABLE_WRAP_AT_EOL_OUTPUT 0x2
-#define ENABLE_VIRTUAL_TERMINAL_PROCESSING 0x4
-#define DISABLE_NEWLINE_AUTO_RETURN 0x8
-#define ENABLE_LVB_GRID_WORLDWIDE 0x10
-
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
-
-#define PeekConsoleInput __MINGW_NAME_AW(PeekConsoleInput)
-#define ReadConsoleInput __MINGW_NAME_AW(ReadConsoleInput)
-#define WriteConsoleInput __MINGW_NAME_AW(WriteConsoleInput)
-#define ReadConsoleOutput __MINGW_NAME_AW(ReadConsoleOutput)
-#define WriteConsoleOutput __MINGW_NAME_AW(WriteConsoleOutput)
-#define ReadConsoleOutputCharacter __MINGW_NAME_AW(ReadConsoleOutputCharacter)
-#define WriteConsoleOutputCharacter 
__MINGW_NAME_AW(WriteConsoleOutputCharacter)
-#define FillConsoleOutputCharacter __MINGW_NAME_AW(FillConsoleOutputCharacter)
-#define ScrollConsoleScreenBuffer __MINGW_NAME_AW(ScrollConsoleScreenBuffer)
-#define GetConsoleTitle __MINGW_NAME_AW(GetConsoleTitle)
-#define SetConsoleTitle __MINGW_NAME_AW(SetConsoleTitle)
-#define ReadConsole __MINGW_NAME_AW(ReadConsole)
-#define WriteConsole __MINGW_NAME_AW(WriteConsole)
-#define AddConsoleAlias __MINGW_NAME_AW(AddConsoleAlias)
-#define GetConsoleAlias __MINGW_NAME_AW(GetConsoleAlias)
-#define GetConsoleAliasesLength __MINGW_NAME_AW(GetConsoleAliasesLength)
-#define GetConsoleAliasExesLength __MINGW_NAME_AW(GetConsoleAliasExesLength)
-#define GetConsoleAliases __MINGW_NAME_AW(GetConsoleAliases)
-#define GetConsoleAliasExes __MINGW_NAME_AW(GetConsoleAliasExes)
-
-  WINBASEAPI WINBOOL WINAPI PeekConsoleInputA(HANDLE 
hConsoleInput,PINPUT_RECORD lpBuffer,DWORD nLength,LPDWORD 
lpNumberOfEventsRead);
-  WINBASEAPI WINBOOL WINAPI PeekConsoleInputW(HANDLE 
hConsoleInput,PINPUT_RECORD lpBuffer,DWORD nLength,LPDWORD 
lpNumberOfEventsRead);
-  WINBASEAPI WINBOOL WINAPI ReadConsoleInputA(HANDLE 
hConsoleInput,PINPUT_RECORD lpBuffer,DWORD nLength,LPDWORD 
lpNumberOfEventsRead);
-  WINBASEAPI WINBOOL WINAPI ReadConsoleInputW(HANDLE 
hConsoleInput,PINPUT_RECORD lpBuffer,DWORD nLength,LPDWORD 
lpNumberOfEventsRead);
-  WINBASEAPI WINBOOL WINAPI WriteConsoleInputA(HANDLE hConsoleInput,CONST 
INPUT_RECORD *lpBuffer,DWORD nLength,LPDWORD lpNumberOfEventsWritten);
-  WINBASEAPI WINBOOL WINAPI WriteConsoleInputW(HANDLE hConsoleInput,CONST 
INPUT_RECORD *lpBuffer,DWORD nLength,LPDWORD lpNumberOfEventsWritten);
-  WINBASEAPI WINBOOL WINAPI ReadConsoleOutputA(HANDLE 
hConsoleOutput,PCHAR_INFO lpBuffer,COORD dwBufferSize,COORD 
dwBufferCoord,PSMALL_RECT lpReadRegion);
-  WINBASEAPI WINBOOL WINAPI ReadConsoleOutputW(HANDLE 
hConsoleOutput,PCHAR_INFO lpBuffer,COORD dwBufferSize,COORD 
dwBufferCoord,PSMALL_RECT lpReadRegion);
-  WINBASEAPI WINBOOL WINAPI WriteConsoleOutputA(HANDLE hConsoleOutput,CONST 
CHAR_INFO *lpBuffer,COORD dwBufferSize,COORD dwBufferCoord,PSMALL_RECT 
lpWriteRegion);
-  WINBASEAPI WINBOOL WINAPI WriteConsoleOutputW(HANDLE hConsoleOutput,CONST 
CHAR_INFO *lpBuffer,COORD dwBufferSize,COORD dwBufferCoord,PSMALL_RECT 
lpWriteRegion);
-  WINBASEAPI WINBOOL WINAPI ReadConsoleOutputCharacterA(HANDLE 
hConsoleOutput,LPSTR lpCharacter,DWORD nLength,COORD dwReadCoord,LPDWORD 
lpNumberOfCharsRead);
-  WINBASEAPI WINBOOL WINAPI ReadConsoleOutputCharacterW(HANDLE 
hConsoleOutput,LPWSTR lpCharacter,DWORD nLength,COORD dwReadCoord,LPDWORD 
lpNumberOfCharsRead);
-  WINBASEAPI WINBOOL WINAPI ReadConsoleOutputAttribute(HANDLE 
hConsoleOutput,LPWORD lpAttribute,DWORD nLength,COORD dwReadCoord,LPDWORD 
lpNumberOfAttrsRead);
-  WINBASEAPI WINBOOL WINAPI WriteConsoleOutputCharacterA(HANDLE 
hConsoleOutput,LPCSTR lpCharacter,DWORD nLength,COORD dwWriteCoord,LPDWORD 
lpNumberOfCharsWritten);
-  WINBASEAPI WINBOOL WINAPI WriteConsoleOutputCharacterW(HANDLE 
hConsoleOutput,LPCWSTR lpCharacter,DWORD nLength,COORD dwWriteCoord,LPDWORD 
lpNumberOfCharsWritten);
-  WINBASEAPI WINBOOL WINAPI WriteConsoleOutputAttribute(HANDLE 
hConsoleOutput,CONST WORD *lpAttribute,DWORD nLength,COORD dwWriteCoord,LPDWORD 
lpNumberOfAttrsWritten);
-  WINBASEAPI WINBOOL WINAPI FillConsoleOutputCharacterA(HANDLE 
hConsoleOutput,CHAR cCharacter,DWORD nLength,COORD dwWriteCoord,LPDWORD 
lpNumberOfCharsWritten);
-  WINBASEAPI WINBOOL WINAPI FillConsoleOutputCharacterW(HANDLE 
hConsoleOutput,WCHAR cCharacter,DWORD nLength,COORD dwWriteCoord,LPDWORD 
lpNumberOfCharsWritten);
-  WINBASEAPI WINBOOL WINAPI FillConsoleOutputAttribute(HANDLE 
hConsoleOutput,WORD wAttribute,DWORD nLength,COORD dwWriteCoord,LPDWORD 
lpNumberOfAttrsWritten);
-  WINBASEAPI WINBOOL WINAPI GetConsoleMode(HANDLE hConsoleHandle,LPDWORD 
lpMode);
-  WINBASEAPI WINBOOL WINAPI GetNumberOfConsoleInputEvents(HANDLE 
hConsoleInput,LPDWORD lpNumberOfEvents);
-  WINBASEAPI WINBOOL WINAPI GetConsoleScreenBufferInfo(HANDLE 
hConsoleOutput,PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo);
-  WINBASEAPI COORD WINAPI GetLargestConsoleWindowSize(HANDLE hConsoleOutput);
-  WINBASEAPI WINBOOL WINAPI GetConsoleCursorInfo(HANDLE 
hConsoleOutput,PCONSOLE_CURSOR_INFO lpConsoleCursorInfo);
-  WINBASEAPI WINBOOL WINAPI GetCurrentConsoleFont(HANDLE 
hConsoleOutput,WINBOOL bMaximumWindow,PCONSOLE_FONT_INFO lpConsoleCurrentFont);
-  WINBASEAPI COORD WINAPI GetConsoleFontSize(HANDLE hConsoleOutput,DWORD 
nFont);
-  WINBASEAPI WINBOOL WINAPI GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO 
lpConsoleSelectionInfo);
-  WINBASEAPI WINBOOL WINAPI GetNumberOfConsoleMouseButtons(LPDWORD 
lpNumberOfMouseButtons);
-  WINBASEAPI WINBOOL WINAPI SetConsoleMode(HANDLE hConsoleHandle,DWORD dwMode);
-  WINBASEAPI WINBOOL WINAPI SetConsoleActiveScreenBuffer(HANDLE 
hConsoleOutput);
-  WINBASEAPI WINBOOL WINAPI FlushConsoleInputBuffer(HANDLE hConsoleInput);
-  WINBASEAPI WINBOOL WINAPI SetConsoleScreenBufferSize(HANDLE 
hConsoleOutput,COORD dwSize);
-  WINBASEAPI WINBOOL WINAPI SetConsoleCursorPosition(HANDLE 
hConsoleOutput,COORD dwCursorPosition);
-  WINBASEAPI WINBOOL WINAPI SetConsoleCursorInfo(HANDLE hConsoleOutput,CONST 
CONSOLE_CURSOR_INFO *lpConsoleCursorInfo);
-  WINBASEAPI WINBOOL WINAPI ScrollConsoleScreenBufferA(HANDLE 
hConsoleOutput,CONST SMALL_RECT *lpScrollRectangle,CONST SMALL_RECT 
*lpClipRectangle,COORD dwDestinationOrigin,CONST CHAR_INFO *lpFill);
-  WINBASEAPI WINBOOL WINAPI ScrollConsoleScreenBufferW(HANDLE 
hConsoleOutput,CONST SMALL_RECT *lpScrollRectangle,CONST SMALL_RECT 
*lpClipRectangle,COORD dwDestinationOrigin,CONST CHAR_INFO *lpFill);
-  WINBASEAPI WINBOOL WINAPI SetConsoleWindowInfo(HANDLE hConsoleOutput,WINBOOL 
bAbsolute,CONST SMALL_RECT *lpConsoleWindow);
-  WINBASEAPI WINBOOL WINAPI SetConsoleTextAttribute(HANDLE hConsoleOutput,WORD 
wAttributes);
-  WINBASEAPI WINBOOL WINAPI SetConsoleCtrlHandler(PHANDLER_ROUTINE 
HandlerRoutine,WINBOOL Add);
-  WINBASEAPI WINBOOL WINAPI GenerateConsoleCtrlEvent(DWORD dwCtrlEvent,DWORD 
dwProcessGroupId);
-  WINBASEAPI WINBOOL WINAPI AllocConsole(VOID);
-  WINBASEAPI WINBOOL WINAPI FreeConsole(VOID);
-  WINBASEAPI WINBOOL WINAPI AttachConsole(DWORD dwProcessId);
-
-#define ATTACH_PARENT_PROCESS ((DWORD)-1)
+#ifndef NOAPISET
+#include <consoleapi.h>
+#include <consoleapi2.h>
+#include <consoleapi3.h>
+#endif
 
-  WINBASEAPI DWORD WINAPI GetConsoleTitleA(LPSTR lpConsoleTitle,DWORD nSize);
-  WINBASEAPI DWORD WINAPI GetConsoleTitleW(LPWSTR lpConsoleTitle,DWORD nSize);
-  WINBASEAPI WINBOOL WINAPI SetConsoleTitleA(LPCSTR lpConsoleTitle);
-  WINBASEAPI WINBOOL WINAPI SetConsoleTitleW(LPCWSTR lpConsoleTitle);
-  WINBASEAPI WINBOOL WINAPI ReadConsoleA(HANDLE hConsoleInput,LPVOID 
lpBuffer,DWORD nNumberOfCharsToRead,LPDWORD lpNumberOfCharsRead,LPVOID 
lpReserved);
-  WINBASEAPI WINBOOL WINAPI ReadConsoleW(HANDLE hConsoleInput,LPVOID 
lpBuffer,DWORD nNumberOfCharsToRead,LPDWORD lpNumberOfCharsRead,LPVOID 
lpReserved);
-  WINBASEAPI WINBOOL WINAPI WriteConsoleA(HANDLE hConsoleOutput,CONST VOID 
*lpBuffer,DWORD nNumberOfCharsToWrite,LPDWORD lpNumberOfCharsWritten,LPVOID 
lpReserved);
-  WINBASEAPI WINBOOL WINAPI WriteConsoleW(HANDLE hConsoleOutput,CONST VOID 
*lpBuffer,DWORD nNumberOfCharsToWrite,LPDWORD lpNumberOfCharsWritten,LPVOID 
lpReserved);
+#define CONSOLE_REAL_OUTPUT_HANDLE (LongToHandle(-2))
+#define CONSOLE_REAL_INPUT_HANDLE (LongToHandle(-3))
 
 #define CONSOLE_TEXTMODE_BUFFER 1
 
-  WINBASEAPI HANDLE WINAPI CreateConsoleScreenBuffer(DWORD 
dwDesiredAccess,DWORD dwShareMode,CONST SECURITY_ATTRIBUTES 
*lpSecurityAttributes,DWORD dwFlags,LPVOID lpScreenBufferData);
-  WINBASEAPI UINT WINAPI GetConsoleCP(VOID);
-  WINBASEAPI WINBOOL WINAPI SetConsoleCP(UINT wCodePageID);
-  WINBASEAPI UINT WINAPI GetConsoleOutputCP(VOID);
-  WINBASEAPI WINBOOL WINAPI SetConsoleOutputCP(UINT wCodePageID);
-
-#define CONSOLE_FULLSCREEN 1
-#define CONSOLE_FULLSCREEN_HARDWARE 2
-  WINBASEAPI WINBOOL WINAPI GetConsoleDisplayMode(LPDWORD lpModeFlags);
-
-#define CONSOLE_FULLSCREEN_MODE 1
-#define CONSOLE_WINDOWED_MODE 2
-  WINBASEAPI WINBOOL WINAPI SetConsoleDisplayMode(HANDLE hConsoleOutput, DWORD 
dwFlags, PCOORD lpNewScreenBufferDimensions);
-
-  WINBASEAPI HWND WINAPI GetConsoleWindow(VOID);
-  WINBASEAPI DWORD WINAPI GetConsoleProcessList(LPDWORD lpdwProcessList,DWORD 
dwProcessCount);
-  WINBASEAPI WINBOOL WINAPI AddConsoleAliasA(LPSTR Source,LPSTR Target,LPSTR 
ExeName);
-  WINBASEAPI WINBOOL WINAPI AddConsoleAliasW(LPWSTR Source,LPWSTR 
Target,LPWSTR ExeName);
-  WINBASEAPI DWORD WINAPI GetConsoleAliasA(LPSTR Source,LPSTR 
TargetBuffer,DWORD TargetBufferLength,LPSTR ExeName);
-  WINBASEAPI DWORD WINAPI GetConsoleAliasW(LPWSTR Source,LPWSTR 
TargetBuffer,DWORD TargetBufferLength,LPWSTR ExeName);
-  WINBASEAPI DWORD WINAPI GetConsoleAliasesLengthA(LPSTR ExeName);
-  WINBASEAPI DWORD WINAPI GetConsoleAliasesLengthW(LPWSTR ExeName);
-  WINBASEAPI DWORD WINAPI GetConsoleAliasExesLengthA(VOID);
-  WINBASEAPI DWORD WINAPI GetConsoleAliasExesLengthW(VOID);
-  WINBASEAPI DWORD WINAPI GetConsoleAliasesA(LPSTR AliasBuffer,DWORD 
AliasBufferLength,LPSTR ExeName);
-  WINBASEAPI DWORD WINAPI GetConsoleAliasesW(LPWSTR AliasBuffer,DWORD 
AliasBufferLength,LPWSTR ExeName);
-  WINBASEAPI DWORD WINAPI GetConsoleAliasExesA(LPSTR ExeNameBuffer,DWORD 
ExeNameBufferLength);
-  WINBASEAPI DWORD WINAPI GetConsoleAliasExesW(LPWSTR ExeNameBuffer,DWORD 
ExeNameBufferLength);
-
-WINBASEAPI VOID WINAPI ExpungeConsoleCommandHistoryA(LPSTR ExeName);
-WINBASEAPI VOID WINAPI ExpungeConsoleCommandHistoryW(LPWSTR ExeName);
-#define ExpungeConsoleCommandHistory 
__MINGW_NAME_AW(ExpungeConsoleCommandHistory)
-
-WINBASEAPI WINBOOL WINAPI SetConsoleNumberOfCommandsA(DWORD Number, LPSTR 
ExeName);
-WINBASEAPI WINBOOL WINAPI SetConsoleNumberOfCommandsW(DWORD Number, LPWSTR 
ExeName);
-#define SetConsoleNumberOfCommands __MINGW_NAME_AW(SetConsoleNumberOfCommands)
-
-WINBASEAPI DWORD WINAPI GetConsoleCommandHistoryLengthA(LPSTR ExeName);
-WINBASEAPI DWORD WINAPI GetConsoleCommandHistoryLengthW(LPWSTR ExeName);
-#define GetConsoleCommandHistoryLength 
__MINGW_NAME_AW(GetConsoleCommandHistoryLength)
-
-WINBASEAPI DWORD WINAPI GetConsoleCommandHistoryA(LPSTR Commands, DWORD 
CommandBufferLength, LPSTR ExeName);
-WINBASEAPI DWORD WINAPI GetConsoleCommandHistoryW(LPWSTR Commands, DWORD 
CommandBufferLength, LPWSTR ExeName);
-#define GetConsoleCommandHistory __MINGW_NAME_AW(GetConsoleCommandHistory)
-
-#ifndef NOGDI
-
-typedef struct _CONSOLE_FONT_INFOEX {
-  ULONG cbSize;
-  DWORD nFont;
-  COORD dwFontSize;
-  UINT  FontFamily;
-  UINT  FontWeight;
-  WCHAR FaceName[LF_FACESIZE];
-} CONSOLE_FONT_INFOEX, *PCONSOLE_FONT_INFOEX;
-
-WINBASEAPI WINBOOL WINAPI GetCurrentConsoleFontEx(
-  HANDLE hConsoleOutput,
-  WINBOOL bMaximumWindow,
-  PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx
-);
-
-WINBASEAPI WINBOOL WINAPI SetCurrentConsoleFontEx(
-  HANDLE hConsoleOutput,
-  WINBOOL bMaximumWindow,
-  PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx
-);
-
-#endif  /* NOGDI */
-
-#define HISTORY_NO_DUP_FLAG 0x1
-
-typedef struct _CONSOLE_HISTORY_INFO {
-  UINT  cbSize;
-  UINT  HistoryBufferSize;
-  UINT  NumberOfHistoryBuffers;
-  DWORD dwFlags;
-} CONSOLE_HISTORY_INFO, *PCONSOLE_HISTORY_INFO;
-
-typedef struct _CONSOLE_READCONSOLE_CONTROL {
-  ULONG nLength;
-  ULONG nInitialChars;
-  ULONG dwCtrlWakeupMask;
-  ULONG dwControlKeyState;
-} CONSOLE_READCONSOLE_CONTROL, *PCONSOLE_READCONSOLE_CONTROL;
-
-typedef struct _CONSOLE_SCREEN_BUFFER_INFOEX {
-  ULONG      cbSize;
-  COORD      dwSize;
-  COORD      dwCursorPosition;
-  WORD       wAttributes;
-  SMALL_RECT srWindow;
-  COORD      dwMaximumWindowSize;
-  WORD       wPopupAttributes;
-  WINBOOL    bFullscreenSupported;
-  COLORREF   ColorTable[16];
-} CONSOLE_SCREEN_BUFFER_INFOEX, *PCONSOLE_SCREEN_BUFFER_INFOEX;
-
-WINBOOL WINAPI GetConsoleHistoryInfo(
-  PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo
-);
-
-#if (_WIN32_WINNT >= 0x0600)
-#define GetConsoleOriginalTitle __MINGW_NAME_AW(GetConsoleOriginalTitle)
-
-WINBASEAPI DWORD WINAPI GetConsoleOriginalTitleA(
-  LPSTR lpConsoleTitle,
-  DWORD nSize
-);
-
-WINBASEAPI DWORD WINAPI GetConsoleOriginalTitleW(
-  LPWSTR lpConsoleTitle,
-  DWORD nSize
-);
-#endif /* (_WIN32_WINNT >= 0x0600) */
-
-WINBASEAPI WINBOOL WINAPI GetConsoleScreenBufferInfoEx(
-  HANDLE hConsoleOutput,
-  PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx
-);
-
-WINBASEAPI WINBOOL WINAPI SetConsoleHistoryInfo(
-  PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo
-);
-
-WINBASEAPI WINBOOL WINAPI SetConsoleScreenBufferInfoEx(
-  HANDLE hConsoleOutput,
-  PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx
-);
-
-#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
-
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-
-#if (NTDDI_VERSION >= 0x0A000006)
-
-/* CreatePseudoConsole Flags */
-#define PSEUDOCONSOLE_INHERIT_CURSOR 1
-
-typedef VOID* HPCON;
-
-WINBASEAPI HRESULT WINAPI CreatePseudoConsole(COORD size, HANDLE hInput, 
HANDLE hOutput, DWORD dwFlags, HPCON* phPC);
-WINBASEAPI HRESULT WINAPI ResizePseudoConsole(HPCON hPC, COORD size);
-WINBASEAPI VOID WINAPI ClosePseudoConsole(HPCON hPC);
-
-#endif /* NTDDI_WIN10_RS5 */
-
-#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) */
-
 #ifdef __cplusplus
 }
 #endif
-#endif
+
+#endif /* _WINCON_ */
diff --git a/mingw-w64-headers/include/wincontypes.h 
b/mingw-w64-headers/include/wincontypes.h
new file mode 100644
index 0000000..702cef2
--- /dev/null
+++ b/mingw-w64-headers/include/wincontypes.h
@@ -0,0 +1,130 @@
+/**
+ * This file has no copyright assigned and is placed in the Public Domain.
+ * This file is part of the mingw-w64 runtime package.
+ * No warranty is given; refer to the file DISCLAIMER.PD within this package.
+ */
+
+#ifndef _WINCONTYPES_
+#define _WINCONTYPES_
+
+#include <minwindef.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
+
+typedef struct _COORD {
+  SHORT X;
+  SHORT Y;
+} COORD, *PCOORD;
+
+typedef struct _SMALL_RECT {
+  SHORT Left;
+  SHORT Top;
+  SHORT Right;
+  SHORT Bottom;
+} SMALL_RECT, *PSMALL_RECT;
+
+typedef struct _KEY_EVENT_RECORD {
+  WINBOOL bKeyDown;
+  WORD wRepeatCount;
+  WORD wVirtualKeyCode;
+  WORD wVirtualScanCode;
+  union {
+    WCHAR UnicodeChar;
+    CHAR AsciiChar;
+  } uChar;
+  DWORD dwControlKeyState;
+} KEY_EVENT_RECORD, *PKEY_EVENT_RECORD;
+
+#define RIGHT_ALT_PRESSED 0x0001
+#define LEFT_ALT_PRESSED 0x0002
+#define RIGHT_CTRL_PRESSED 0x0004
+#define LEFT_CTRL_PRESSED 0x0008
+#define SHIFT_PRESSED 0x0010
+#define NUMLOCK_ON 0x0020
+#define SCROLLLOCK_ON 0x0040
+#define CAPSLOCK_ON 0x0080
+#define ENHANCED_KEY 0x0100
+#define NLS_DBCSCHAR 0x00010000
+#define NLS_ALPHANUMERIC 0x00000000
+#define NLS_KATAKANA 0x00020000
+#define NLS_HIRAGANA 0x00040000
+#define NLS_ROMAN 0x00400000
+#define NLS_IME_CONVERSION 0x00800000
+#define ALTNUMPAD_BIT 0x04000000
+#define NLS_IME_DISABLE 0x20000000
+
+typedef struct _MOUSE_EVENT_RECORD {
+  COORD dwMousePosition;
+  DWORD dwButtonState;
+  DWORD dwControlKeyState;
+  DWORD dwEventFlags;
+} MOUSE_EVENT_RECORD, *PMOUSE_EVENT_RECORD;
+
+#define FROM_LEFT_1ST_BUTTON_PRESSED 0x0001
+#define RIGHTMOST_BUTTON_PRESSED 0x0002
+#define FROM_LEFT_2ND_BUTTON_PRESSED 0x0004
+#define FROM_LEFT_3RD_BUTTON_PRESSED 0x0008
+#define FROM_LEFT_4TH_BUTTON_PRESSED 0x0010
+
+#define MOUSE_MOVED 0x0001
+#define DOUBLE_CLICK 0x0002
+#define MOUSE_WHEELED 0x0004
+#if (_WIN32_WINNT >= 0x0600)
+#define MOUSE_HWHEELED 0x0008
+#endif /* _WIN32_WINNT >= 0x0600 */
+
+typedef struct _WINDOW_BUFFER_SIZE_RECORD {
+  COORD dwSize;
+} WINDOW_BUFFER_SIZE_RECORD, *PWINDOW_BUFFER_SIZE_RECORD;
+
+typedef struct _MENU_EVENT_RECORD {
+  UINT dwCommandId;
+} MENU_EVENT_RECORD, *PMENU_EVENT_RECORD;
+
+typedef struct _FOCUS_EVENT_RECORD {
+  WINBOOL bSetFocus;
+} FOCUS_EVENT_RECORD, *PFOCUS_EVENT_RECORD;
+
+typedef struct _INPUT_RECORD {
+  WORD EventType;
+  union {
+    KEY_EVENT_RECORD KeyEvent;
+    MOUSE_EVENT_RECORD MouseEvent;
+    WINDOW_BUFFER_SIZE_RECORD WindowBufferSizeEvent;
+    MENU_EVENT_RECORD MenuEvent;
+    FOCUS_EVENT_RECORD FocusEvent;
+  } Event;
+} INPUT_RECORD, *PINPUT_RECORD;
+
+#define KEY_EVENT 0x0001
+#define MOUSE_EVENT 0x0002
+#define WINDOW_BUFFER_SIZE_EVENT 0x0004
+#define MENU_EVENT 0x0008
+#define FOCUS_EVENT 0x0010
+
+typedef struct _CHAR_INFO {
+  union {
+    WCHAR UnicodeChar;
+    CHAR AsciiChar;
+  } Char;
+  WORD Attributes;
+} CHAR_INFO, *PCHAR_INFO;
+
+typedef struct _CONSOLE_FONT_INFO {
+  DWORD nFont;
+  COORD dwFontSize;
+} CONSOLE_FONT_INFO, *PCONSOLE_FONT_INFO;
+
+typedef VOID *HPCON;
+
+#endif /* WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _WINCONTYPES_ */
-- 
2.47.1

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to