Files
dwmblurglass/Common/VersionHelper.cpp
T
2025-12-19 16:42:23 +08:00

50 lines
1.7 KiB
C++

/**
* FileName: VersionHelper.cpp
*
* Copyright (C) 2024 Maplespe
*
* This file is part of MToolBox and DWMBlurGlass.
* DWMBlurGlass is free software: you can redistribute it and/or modify it under the terms of the
* GNU Lesser General Public License as published by the Free Software Foundation, either version 3
* of the License, or any later version.
*
* DWMBlurGlass is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with Foobar.
* If not, see <https://www.gnu.org/licenses/lgpl-3.0.html>.
*/
#include "VersionHelper.h"
namespace MDWMBlurGlass
{
namespace Utils
{
PKUSER_SHARED_DATA get_kernel_shared_info()
{
return reinterpret_cast<PKUSER_SHARED_DATA>(0x7FFE0000);
}
}
namespace os
{
const ULONG buildNumber = Utils::get_kernel_shared_info()->NtBuildNumber;
const ULONG minorVersion = Utils::get_kernel_shared_info()->NtMinorVersion;
const ULONG majorVersion = Utils::get_kernel_shared_info()->NtMajorVersion;
const ULONG ubrNumber = []() -> ULONG {
ULONG value = 0;
HKEY hKey = nullptr;
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE,
L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion",
0, KEY_READ, &hKey) == ERROR_SUCCESS)
{
DWORD size = sizeof(DWORD);
RegQueryValueExW(hKey, L"UBR", nullptr, nullptr,
reinterpret_cast<LPBYTE>(&value), &size);
RegCloseKey(hKey);
}
return value;
}();
const NT_PRODUCT_TYPE productType = Utils::get_kernel_shared_info()->NtProductType;
}
}