# HG changeset patch # Parent 5121aa3c8d6a283ba666c1f3f45c1f61ae1eb45c Update to add Win10 pseudo-console support. diff --git a/w32api/include/winbase.h b/w32api/include/winbase.h --- a/w32api/include/winbase.h +++ b/w32api/include/winbase.h @@ -728,10 +728,18 @@ /* Constants associated with features supported only on Vista and later. */ #define THREAD_MODE_BACKGROUND_BEGIN 0x00010000 #define THREAD_MODE_BACKGROUND_END 0x00020000 +#define EXTENDED_STARTUPINFO_PRESENT 0x00080000 + +#define PROC_THREAD_ATTRIBUTE_PARENT_PROCESS 0x00020000 +#define PROC_THREAD_ATTRIBUTE_HANDLE_LIST 0x00020002 +#define PROC_THREAD_ATTRIBUTE_PROTECTION_LEVEL 0x0002000B + +#define PROTECTION_LEVEL_SAME 0xFFFFFFFF + /* http://msdn.microsoft.com/en-us/library/aa363866%28VS.85%29.aspx */ #define SYMBOLIC_LINK_FLAG_DIRECTORY 0x1 /* http://msdn.microsoft.com/en-us/library/aa364962%28VS.85%29.aspx */ #define FILE_NAME_NORMALIZED 0x0 @@ -746,10 +754,115 @@ /* Constants associated with features supported only on Win7 and later. */ #define PROCESS_DEP_ENABLE 1 #define PROCESS_DEP_DISABLE_ATL_THUNK_EMULATION 2 +#define PROC_THREAD_ATTRIBUTE_PREFERRED_NODE 0x00020004 +#define PROC_THREAD_ATTRIBUTE_MITIGATION_POLICY 0x00020007 + +#define PROCESS_CREATION_MITIGATION_POLICY_DEP_ENABLE 1 +#define PROCESS_CREATION_MITIGATION_POLICY_DEP_ATL_THUNK_ENABLE 2 +#define PROCESS_CREATION_MITIGATION_POLICY_SEHOP_ENABLE 4 + +#define PROC_THREAD_ATTRIBUTE_GROUP_AFFINITY 0x00030003 +#define PROC_THREAD_ATTRIBUTE_IDEAL_PROCESSOR 0x00030005 +#define PROC_THREAD_ATTRIBUTE_UMS_THREAD 0x00030006 + +#if _WIN32_WINNT >= _WIN32_WINNT_WIN8 +/* Constants associated with features supported only on Win8 and later. + */ +#define PROCESS_CREATION_MITIGATION_POLICY_FORCE_RELOCATE_IMAGES_ALWAYS_ON 0x00000100 +#define PROCESS_CREATION_MITIGATION_POLICY_FORCE_RELOCATE_IMAGES_ALWAYS_OFF 0x00000200 +#define PROCESS_CREATION_MITIGATION_POLICY_FORCE_RELOCATE_IMAGES_ALWAYS_ON_REQ_RELOCS 0x00000300 + +#define PROCESS_CREATION_MITIGATION_POLICY_HEAP_TERMINATE_ALWAYS_ON 0x00001000 +#define PROCESS_CREATION_MITIGATION_POLICY_HEAP_TERMINATE_ALWAYS_OFF 0x00002000 + +#define PROCESS_CREATION_MITIGATION_POLICY_BOTTOM_UP_ASLR_ALWAYS_ON 0x00010000 +#define PROCESS_CREATION_MITIGATION_POLICY_BOTTOM_UP_ASLR_ALWAYS_OFF 0x00020000 + +#define PROCESS_CREATION_MITIGATION_POLICY_HIGH_ENTROPY_ASLR_ALWAYS_ON 0x00100000 +#define PROCESS_CREATION_MITIGATION_POLICY_HIGH_ENTROPY_ASLR_ALWAYS_OFF 0x00200000 + +#define PROCESS_CREATION_MITIGATION_POLICY_STRICT_HANDLE_CHECKS_ALWAYS_ON 0x01000000 +#define PROCESS_CREATION_MITIGATION_POLICY_STRICT_HANDLE_CHECKS_ALWAYS_OFF 0x02000000 + +#define PROCESS_CREATION_MITIGATION_POLICY_WIN32K_SYSTEM_CALL_DISABLE_ALWAYS_ON 0x10000000 +#define PROCESS_CREATION_MITIGATION_POLICY_WIN32K_SYSTEM_CALL_DISABLE_ALWAYS_OFF 0x20000000 + +#define PROCESS_CREATION_MITIGATION_POLICY_EXTENSION_POINT_DISABLE_ALWAYS_ON (1ULL << 32) +#define PROCESS_CREATION_MITIGATION_POLICY_EXTENSION_POINT_DISABLE_ALWAYS_OFF (2ULL << 32) + +#define PROCESS_CREATION_MITIGATION_POLICY_PROHIBIT_DYNAMIC_CODE_ALWAYS_ON (1ULL << 36) +#define PROCESS_CREATION_MITIGATION_POLICY_PROHIBIT_DYNAMIC_CODE_ALWAYS_OFF (2ULL << 36) + +#define PROCESS_CREATION_MITIGATION_POLICY_PROHIBIT_DYNAMIC_CODE_ALWAYS_ON_ALLOW_OPT_OUT (3ULL << 36) + +#define PROCESS_CREATION_MITIGATION_POLICY_PROHIBIT_DYNAMIC_CODE_DEFER (0ULL << 36) +#define PROCESS_CREATION_MITIGATION_POLICY_PROHIBIT_DYNAMIC_CODE_MASK (3ULL << 36) + +#define PROCESS_CREATION_MITIGATION_POLICY_CONTROL_FLOW_GUARD_DEFER (0ULL << 40) +#define PROCESS_CREATION_MITIGATION_POLICY_CONTROL_FLOW_GUARD_ALWAYS_ON (1ULL << 40) +#define PROCESS_CREATION_MITIGATION_POLICY_CONTROL_FLOW_GUARD_ALWAYS_OFF (2ULL << 40) +#define PROCESS_CREATION_MITIGATION_POLICY_CONTROL_FLOW_GUARD_EXPORT_SUPPRESSION (3ULL << 40) +#define PROCESS_CREATION_MITIGATION_POLICY_CONTROL_FLOW_GUARD_MASK (3ULL << 40) + +#define PROCESS_CREATION_MITIGATION_POLICY2_STRICT_CONTROL_FLOW_GUARD_DEFER (0ULL << 8) +#define PROCESS_CREATION_MITIGATION_POLICY2_STRICT_CONTROL_FLOW_GUARD_ALWAYS_ON (1ULL << 8) +#define PROCESS_CREATION_MITIGATION_POLICY2_STRICT_CONTROL_FLOW_GUARD_ALWAYS_OFF (2ULL << 8) +#define PROCESS_CREATION_MITIGATION_POLICY2_STRICT_CONTROL_FLOW_GUARD_RESERVED (3ULL << 8) +#define PROCESS_CREATION_MITIGATION_POLICY2_STRICT_CONTROL_FLOW_GUARD_MASK (3ULL << 8) + +#define PROCESS_CREATION_MITIGATION_POLICY_BLOCK_NON_MICROSOFT_BINARIES_DEFER (0ULL << 44) +#define PROCESS_CREATION_MITIGATION_POLICY_BLOCK_NON_MICROSOFT_BINARIES_ALWAYS_ON (1ULL << 44) +#define PROCESS_CREATION_MITIGATION_POLICY_BLOCK_NON_MICROSOFT_BINARIES_ALWAYS_OFF (2ULL << 44) +#define PROCESS_CREATION_MITIGATION_POLICY_BLOCK_NON_MICROSOFT_BINARIES_ALLOW_STORE (3ULL << 44) +#define PROCESS_CREATION_MITIGATION_POLICY_BLOCK_NON_MICROSOFT_BINARIES_MASK (3ULL << 44) + +#define PROCESS_CREATION_MITIGATION_POLICY_FONT_DISABLE_DEFER (0ULL << 48) +#define PROCESS_CREATION_MITIGATION_POLICY_FONT_DISABLE_ALWAYS_ON (1ULL << 48) +#define PROCESS_CREATION_MITIGATION_POLICY_FONT_DISABLE_ALWAYS_OFF (2ULL << 48) +#define PROCESS_CREATION_MITIGATION_POLICY_AUDIT_NONSYSTEM_FONTS (3ULL << 48) +#define PROCESS_CREATION_MITIGATION_POLICY_FONT_DISABLE_MASK (3ULL << 48) + +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_REMOTE_DEFER (0ULL << 52) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_REMOTE_ALWAYS_ON (1ULL << 52) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_REMOTE_ALWAYS_OFF (2ULL << 52) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_REMOTE_RESERVED (3ULL << 52) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_REMOTE_MASK (3ULL << 52) + +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_LOW_LABEL_DEFER (0ULL << 56) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_LOW_LABEL_ALWAYS_ON (1ULL << 56) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_LOW_LABEL_ALWAYS_OFF (2ULL << 56) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_LOW_LABEL_RESERVED (3ULL << 56) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_LOW_LABEL_MASK (3ULL << 56) + +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_PREFER_SYSTEM32_DEFER (0ULL << 60) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_PREFER_SYSTEM32_ALWAYS_ON (1ULL << 60) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_PREFER_SYSTEM32_ALWAYS_OFF (2ULL << 60) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_PREFER_SYSTEM32_RESERVED (3ULL << 60) +#define PROCESS_CREATION_MITIGATION_POLICY_IMAGE_LOAD_NO_PREFER_SYSTEM32_MASK (3ULL << 60) + +#if _WIN32_WINNT >= _WIN32_WINNT_WIN10 +#if NTDDI_VERSION >= NTDDI_WIN10_RS3 +/* Additional policy attributes introduced by Win10-1709 (Redstone 3) + */ +#define PROCESS_CREATION_MITIGATION_POLICY2_RESTRICT_INDIRECT_BRANCH_PREDICTION_ALWAYS_ON (1ULL << 16) + +#if NTDDI_VERSION >= NTDDI_WIN10_RS5 +/* Additional policy attributes introduced by Win10-1809 (Redstone 5) + */ +#define PROCESS_CREATION_MITIGATION_POLICY2_SPECULATIVE_STORE_BYPASS_DISABLE_ALWAYS_ON (1ULL << 24) + +/* Redstone 5 also introduced support for pseudo-consoles + */ +#define PROC_THREAD_ATTRIBUTE_PSEUDOCONSOLE 0x00020016 + +#endif /* Win10-1809 (Redstone 5) and later */ +#endif /* Win10-1709 (Redstone 3) and later */ +#endif /* Win10 and later */ +#endif /* Win8 and later */ #endif /* Win7 and later */ #endif /* WinVista and later */ #endif /* WinXP and later */ #endif /* Win2K and later */ #endif /* WinNT from NT4 */ @@ -2875,11 +2988,39 @@ WINBASEAPI BOOL WINAPI SetFirmwareEnviro (LPCWSTR, LPCWSTR, PVOID, DWORD); #if _WIN32_WINNT >= _WIN32_WINNT_VISTA /* Additional features, available only on the WinNT series platforms, from * the release of Windows-Vista onwards. + * + * Note that, to support STARTUPINFOEX, we need a type definintion for + * references to a PROC_THREAD_ATTRIBUTE_LIST data type, but Microsoft's + * online documentation doesn't specify what that represents; define it + * as an opaque struct type, which will always be accessed indirectly. */ +typedef struct _PROC_THREAD_ATTRIBUTE_LIST *LPPROC_THREAD_ATTRIBUTE_LIST; + +typedef struct _STARTUPINFOEXA +{ STARTUPINFOA StartupInfo; + LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList; +} STARTUPINFOEXA, *LPSTARTUPINFOEXA; + +typedef struct _STARTUPINFOEXW +{ STARTUPINFOW StartupInfo; + LPPROC_THREAD_ATTRIBUTE_LIST lpAttributeList; +} STARTUPINFOEXW, *LPSTARTUPINFOEXW; + +typedef __AW_ALIAS__(STARTUPINFOEX), *LPSTARTUPINFOEX; + +BOOL WINAPI InitializeProcThreadAttributeList +(LPPROC_THREAD_ATTRIBUTE_LIST, DWORD, DWORD, PSIZE_T); + +BOOL WINAPI UpdateProcThreadAttribute +(LPPROC_THREAD_ATTRIBUTE_LIST, DWORD, DWORD_PTR, PVOID, SIZE_T, PVOID, PSIZE_T); + +void WINAPI DeleteProcThreadAttributeList +(LPPROC_THREAD_ATTRIBUTE_LIST); + typedef struct _FILE_BASIC_INFO /* http://msdn.microsoft.com/en-us/library/aa364217%28VS.85%29.aspx */ { LARGE_INTEGER CreationTime; LARGE_INTEGER LastAccessTime; LARGE_INTEGER LastWriteTime; diff --git a/w32api/include/wincon.h b/w32api/include/wincon.h --- a/w32api/include/wincon.h +++ b/w32api/include/wincon.h @@ -4,11 +4,11 @@ * Windows console I/O declarations, and API function prototypes. * * $Id$ * * Written by Anders Norlander - * Copyright (C) 1998, 1999, 2002-2006, 2009, 2011, 2016, 2018, + * Copyright (C) 1998, 1999, 2002-2006, 2009, 2011, 2016, 2018, 2021, * MinGW.org Project. * * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -413,10 +413,21 @@ WINAPI BOOL GetConsoleScreenBufferInfoEx WINAPI BOOL GetCurrentConsoleFontEx (HANDLE, BOOL, PCONSOLE_FONT_INFOEX); WINAPI BOOL SetConsoleHistoryInfo (PCONSOLE_HISTORY_INFO); WINAPI BOOL SetConsoleScreenBufferInfoEx (HANDLE, PCONSOLE_SCREEN_BUFFER_INFOEX); WINAPI BOOL SetCurrentConsoleFontEx (HANDLE, BOOL, PCONSOLE_FONT_INFOEX); +#if NTDDI_VERSION >= NTDDI_WIN10_RS5 +/* Windows-10 Version 1809 (Redstone 5) introduced the pseudo-console API. + */ +typedef HANDLE HPCON; +WINAPI HRESULT CreatePseudoConsole (COORD, HANDLE, HANDLE, DWORD, HPCON *); +WINAPI HRESULT ResizePseudoConsole (HPCON, COORD); +WINAPI void ClosePseudoConsole (HPCON); + +#define PSEUDOCONSOLE_INHERIT_CURSOR (DWORD)(1) + +#endif /* Win10 Redstone 5 and later */ #endif /* Vista and later */ #endif /* WinXP and later */ #endif /* Win2K and later */ _END_C_DECLS diff --git a/w32api/lib/kernel32.def b/w32api/lib/kernel32.def --- a/w32api/lib/kernel32.def +++ b/w32api/lib/kernel32.def @@ -89,10 +89,11 @@ ClearCommBreak@4 ClearCommError@12 CloseConsoleHandle@4 CloseHandle@4 ClosePrivateNamespace@8 CloseProfileUserMapping@0 +ClosePseudoConsole@4 CloseThreadpool@4 CloseThreadpoolCleanupGroup@4 CloseThreadpoolCleanupGroupMembers@12 CloseThreadpoolIo@4 CloseThreadpoolTimer@4 @@ -171,10 +172,11 @@ CreatePrivateNamespaceA@12 CreatePrivateNamespaceW@12 CreateProcessA@40 CreateProcessInternalA@48 CreateProcessInternalW@48 CreateProcessW@40 +CreatePseudoConsole@20 CreateRemoteThread@28 CreateRemoteThreadEx@32 CreateSemaphoreA@16 CreateSemaphoreExA@24 CreateSemaphoreExW@24 @@ -991,10 +993,11 @@ ReplaceFileW@24 ReplacePartitionUnit@12 RequestDeviceWakeup@4 RequestWakeupLatency@4 ResetEvent@4 ResetWriteWatch@8 +ResizePseudoConsole@8 ResolveLocaleName@12 RestoreLastError@4 ResumeThread@4 RtlCaptureContext@4 RtlUnwind@16