diff --git a/ChangeLog.txt b/ChangeLog.txt index 0477ea06b6..cc4fb35fb2 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -7,6 +7,11 @@ Entries may not always be in chronological/commit order. See license at the end of file. */ +2024-10-18 07:56 UTC+0200 Aleksander Czajczynski (hb fki.pl) + * src/common/hbver.c + * guard Win10 build number getter from the unknown, + using old Win32 API that is not going to be deprecated. + 2024-10-17 15:04 UTC+0200 Aleksander Czajczynski (hb fki.pl) * .github/workflows/windows-ci.yml * update windows MSYS2 integration runner set of diff --git a/src/common/hbver.c b/src/common/hbver.c index 82c5ac3d16..1bd9bb0cd3 100644 --- a/src/common/hbver.c +++ b/src/common/hbver.c @@ -414,7 +414,15 @@ static void s_hb_winVerInit( void ) memory, though build number is there only on Win10 and up. https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/ntexapi_x/kuser_shared_data/index.htm */ - s_iWinNT = ( int ) * ( PULONG ) ( 0x7FFE0000 + 0x0260 ); + MEMORY_BASIC_INFORMATION minfo; + minfo.Protect = 0; + if( VirtualQuery( ( void * ) 0x7FFE0000, &minfo, sizeof( minfo ) ) && + ( minfo.Protect & ( PAGE_READONLY | PAGE_READWRITE | PAGE_WRITECOPY | + PAGE_EXECUTE_READ | PAGE_EXECUTE_READWRITE | PAGE_EXECUTE_WRITECOPY ) ) && + ! ( minfo.Protect & ( PAGE_GUARD | PAGE_NOACCESS ) ) ) + s_iWinNT = ( int ) * ( PULONG ) ( 0x7FFE0000 + 0x0260 ); + else + s_iWinNT = 1; /* unknown NT emulator */ /* COMPAT: this seems much simpler than dyn-calling GetVersionEx or WDK RtlGetVersion (having in mind deprecation warnings,