-
Notifications
You must be signed in to change notification settings - Fork 584
Utility::GetPlatform*(): on Windows query the registry for version info #9699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
fe63342
to
b381210
Compare
@julianbrost I prefer this PR in favor of the OP-closes ones. And you? |
@LordHepipud What do you -as an expert- think of the concept in general? Of querying Registry instead of relying on the OSes the binary is aware of at compile time? |
union { | ||
BYTE AsBytes[512]; | ||
char AsChars[1] = {0}; | ||
} Data; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be nice to have documentation on what this type is used for. I was struggling to wrap my head around this until I found the term type punning
about union types :).
if (err == ERROR_SUCCESS) { | ||
Defer regCloseKey ([hKey]() { (void)RegCloseKey(hKey); }); | ||
RegistryString productName; | ||
auto err (RegQueryValueExA(hKey, "ProductName", nullptr, nullptr, productName.Data.AsBytes, &productName.Size)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe you need another subkey to search for instead of ProductName
e.g OsName
, otherwise, it's still printing false positive information (Tested on fresh installed Windows 11 Pro).
PS C:\Users\yhabteab\Workspace\icinga2\build> .\Bin\Release\Debug\icinga2.exe --version
icinga2.exe - The Icinga 2 network monitoring daemon (version: v2.14.0-94-g88a32cdd0; debug)
Copyright (c) 2012-2023 Icinga GmbH (https://icinga.com/)
License GPLv2+: GNU GPL version 2 or later <https://gnu.org/licenses/gpl2.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
System information:
Platform: Windows
Platform version: Windows 10 Pro 23H2
Kernel: Windows
Kernel version: 6.3.22631
Architecture: x86_64
Build information:
Compiler: MSVC 19.29.30153.0 Build host: YONASHABTEAF0EE OpenSSL version: OpenSSL 3.0.12 24 Oct 2023
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's already way better than the master branch though: Platform version: 8 xD
System information:
Platform: Windows
Platform version: 8
Kernel: Windows
Kernel version: 6.2
Architecture: x86_64
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wait, Windows 11 says "Windows 11" in one key, but "Windows 10" in another? Please could you screen your SOFTWARE\Microsoft\Windows NT\CurrentVersion in RegEdit?
It's already way better than the master branch though: Platform version: 8 xD
That's the point.👍
another subkey to search for instead of
ProductName
e.gOsName
Unfortunately there's no such thing in Server 2012 R2.
Also, "23H2" and the kernel version make the difference.
b381210
to
1bf4159
Compare
not to have to adjust the code (see removed lines) for every new version.
1bf4159
to
1e4aab1
Compare
not to have to adjust the code (see removed lines) for every new version.
closes #7743
closes #9646
Windows 10
Works even as unpriv. user:
TODO
Output of
& "C:\Program Files\ICINGA2\sbin\icinga2.exe" --version
with https://git.icinga.com/packaging/windows-icinga2/-/jobs/272428/artifacts/download (not necessarily as a particular user)