From 603c0173c00f5e9890e3928e14eee9e44e34e515 Mon Sep 17 00:00:00 2001 From: Keith Marshall Date: Sun, 13 Jun 2021 21:31:31 +0100 Subject: [PATCH] Implement pseudo-console legacy platform support. --- w32api/ChangeLog | 9 +++++++++ w32api/include/wincon.h | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 48 insertions(+) diff --git a/w32api/ChangeLog b/w32api/ChangeLog index 3813005..26431c6 100644 --- a/w32api/ChangeLog +++ b/w32api/ChangeLog @@ -1,5 +1,14 @@ 2021-06-13 Keith Marshall + Implement pseudo-console legacy platform support. + + * include/wincon.h [NTDDI_VERSION >= NTDDI_WIN10_RS5] + [_MINGW_LEGACY_SUPPORT] (CreatePseudoConsole, ResizePseudoConsole) + [_MINGW_LEGACY_SUPPORT] (ClosePseudoConsole): Add inline stub function + implementations, to enforce run-time linking. + +2021-06-13 Keith Marshall + Update to add Win10 pseudo-console support. * include/winbase.h [_WIN32_WINNT >= _WIN32_WINNT_VISTA] diff --git a/w32api/include/wincon.h b/w32api/include/wincon.h index 1073c08..71f3254 100644 --- a/w32api/include/wincon.h +++ b/w32api/include/wincon.h @@ -425,6 +425,45 @@ WINAPI void ClosePseudoConsole (HPCON); #define PSEUDOCONSOLE_INHERIT_CURSOR (DWORD)(1) +#ifdef _MINGW_LEGACY_SUPPORT +/* For MinGW legacy platform support, provide inline redirector stubs, + * to facilate graceful fallback action, in the event that any program, + * which has been linked with the pseudo-console API, is run on an older + * version of Windows. + */ +#include "legacy.h" + +__CRT_ALIAS WINAPI HRESULT CreatePseudoConsole +( COORD size, HANDLE input, HANDLE output, DWORD flags, HPCON *con ) +{ + typedef WINAPI HRESULT (*api)( COORD, HANDLE, HANDLE, DWORD, HPCON * ); + + static void *call = API_UNCHECKED; + return ((call = __kernel32_entry_point( call, __FUNCTION__ )) != NULL) + ? ((api)(call))( size, input, output, flags, con ) + : __legacy_support( ERROR_OLD_WIN_VERSION ); +} + +__CRT_ALIAS WINAPI HRESULT ResizePseudoConsole (HPCON con, COORD size) +{ + typedef WINAPI HRESULT (*api)( HPCON, COORD ); + + static void *call = API_UNCHECKED; + return ((call = __kernel32_entry_point( call, __FUNCTION__ )) != NULL) + ? ((api)(call))( con, size ) : __legacy_support( ERROR_OLD_WIN_VERSION ); +} + +__CRT_ALIAS WINAPI void ClosePseudoConsole (HPCON con) +{ + typedef WINAPI void (*api)( HPCON ); + + static void *call = API_UNCHECKED; + if( (call = __kernel32_entry_point( call, __FUNCTION__ )) == NULL ) + (void)__legacy_support( ERROR_OLD_WIN_VERSION ); + else ((api)(call))( con ); +} +#endif /* _MINGW_LEGACY_SUPPORT */ + #endif /* Win10 Redstone 5 and later */ #endif /* Vista and later */ #endif /* WinXP and later */ -- 2.11.0