OSDN Git Service

Implement pseudo-console legacy platform support.
authorKeith Marshall <keith@users.osdn.me>
Sun, 13 Jun 2021 20:31:31 +0000 (21:31 +0100)
committerKeith Marshall <keith@users.osdn.me>
Sun, 13 Jun 2021 20:31:31 +0000 (21:31 +0100)
w32api/ChangeLog
w32api/include/wincon.h

index 3813005..26431c6 100644 (file)
@@ -1,5 +1,14 @@
 2021-06-13  Keith Marshall  <keith@users.osdn.me>
 
+       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  <keith@users.osdn.me>
+
        Update to add Win10 pseudo-console support.
 
        * include/winbase.h [_WIN32_WINNT >= _WIN32_WINNT_VISTA]
index 1073c08..71f3254 100644 (file)
@@ -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 */