File tree Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Expand file tree Collapse file tree 3 files changed +41
-3
lines changed Original file line number Diff line number Diff line change @@ -462,10 +462,11 @@ struct init_data *common_preinit(int argc, char *argv[])
462462 }
463463
464464 // warn in W10 "legacy" terminal emulators
465- if ((win_has_ancestor_process (" powershell.exe" ) ||
465+ if (getenv (" TERM" ) == nullptr &&
466+ get_windows_build () < BUILD_WINDOWS_11_OR_LATER &&
467+ (win_has_ancestor_process (" powershell.exe" ) ||
466468 win_has_ancestor_process (" cmd.exe" )) &&
467- !win_has_ancestor_process (" WindowsTerminal.exe" ) &&
468- getenv (" TERM" ) == nullptr ) {
469+ !win_has_ancestor_process (" WindowsTerminal.exe" )) {
469470 MSG (WARNING, " Running inside PS/cmd terminal is not recommended "
470471 " because scrolling the output freezes the process, "
471472 " consider using Windows Terminal instead!\n " );
Original file line number Diff line number Diff line change 3737
3838#ifdef _WIN32
3939#include <audioclient.h>
40+ #include <ntstatus.h>
4041#include <objbase.h>
4142#include <tlhelp32.h>
4243#include <vfwmsgs.h>
@@ -239,6 +240,37 @@ win_has_ancestor_process(const char *name)
239240 return false;
240241}
241242
243+ unsigned long
244+ get_windows_build ()
245+ {
246+ RTL_OSVERSIONINFOW osVersionInfo = { .dwOSVersionInfoSize =
247+ sizeof (RTL_OSVERSIONINFOW ) };
248+
249+ HMODULE hNtDll = GetModuleHandleW (L"ntdll.dll" );
250+ if (hNtDll == NULL ) {
251+ MSG (VERBOSE , "Cannot load ntdll.dll!\n" );
252+ return 0 ;
253+ }
254+
255+ typedef NTSTATUS (WINAPI * RtlGetVersionFunc )(
256+ PRTL_OSVERSIONINFOW lpVersionInformation );
257+ RtlGetVersionFunc pRtlGetVersion =
258+ (RtlGetVersionFunc ) GetProcAddress (hNtDll , "RtlGetVersion" );
259+ if (pRtlGetVersion == NULL ) {
260+ MSG (VERBOSE , "Cannot get RtlGetVersion from ntdll.dll!\n" );
261+ return 0 ;
262+ }
263+
264+ if (pRtlGetVersion (& osVersionInfo ) != STATUS_SUCCESS ) {
265+ MSG (VERBOSE , "Cannot get Windows version nfo!\n" );
266+ return 0 ;
267+ }
268+ MSG (DEBUG , "Windows version: %lu.%lu (build %lu)\n" ,
269+ osVersionInfo .dwMajorVersion , osVersionInfo .dwMinorVersion ,
270+ osVersionInfo .dwBuildNumber );
271+ return osVersionInfo .dwBuildNumber ;
272+ }
273+
242274#endif // defined _WIN32
243275
244276/* vim: set expandtab sw=8 tw=120: */
Original file line number Diff line number Diff line change 4242#include <stdbool.h>
4343#endif
4444
45+ enum {
46+ BUILD_WINDOWS_11_OR_LATER = 22000 ,
47+ };
48+
4549#ifdef __cplusplus
4650extern "C" {
4751#endif
@@ -86,6 +90,7 @@ const char *hresult_to_str(HRESULT res);
8690const char * get_win32_error (DWORD error );
8791const char * win_wstr_to_str (const wchar_t * wstr );
8892bool win_has_ancestor_process (const char * name );
93+ unsigned long get_windows_build (void );
8994#endif // defined _WIN32
9095
9196#ifdef __cplusplus
You can’t perform that action at this time.
0 commit comments