mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 21:41:26 +12:00
sysinfo/arm64: Improve code around registry access and document the fields
This commit is contained in:
parent
939479f55e
commit
92c1a8c45d
1 changed files with 17 additions and 5 deletions
|
@ -88,16 +88,23 @@ namespace utils
|
||||||
|
|
||||||
const auto read_reg_sz = [](HKEY hKey, std::string_view value_name) -> std::pair<bool, std::string>
|
const auto read_reg_sz = [](HKEY hKey, std::string_view value_name) -> std::pair<bool, std::string>
|
||||||
{
|
{
|
||||||
char sz[256];
|
constexpr usz MAX_SZ_LEN = 255;
|
||||||
DWORD sz_len = sizeof(sz);
|
char sz[MAX_SZ_LEN + 1];
|
||||||
|
DWORD sz_len = MAX_SZ_LEN;
|
||||||
|
|
||||||
|
// Safety; null terminate
|
||||||
|
sz[0] = 0;
|
||||||
|
sz[MAX_SZ_LEN] = 0;
|
||||||
|
|
||||||
|
// Read string
|
||||||
if (ERROR_SUCCESS != RegQueryValueExA(hKey, value_name.data(), nullptr, nullptr, reinterpret_cast<LPBYTE>(sz), &sz_len))
|
if (ERROR_SUCCESS != RegQueryValueExA(hKey, value_name.data(), nullptr, nullptr, reinterpret_cast<LPBYTE>(sz), &sz_len))
|
||||||
{
|
{
|
||||||
return { false, "" };
|
return { false, "" };
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sz_len < sizeof(sz))
|
// Safety, force null terminator
|
||||||
|
if (sz_len < MAX_SZ_LEN)
|
||||||
{
|
{
|
||||||
// Safety, force null terminator
|
|
||||||
sz[sz_len] = 0;
|
sz[sz_len] = 0;
|
||||||
}
|
}
|
||||||
return { true, sz };
|
return { true, sz };
|
||||||
|
@ -109,10 +116,15 @@ namespace utils
|
||||||
return "Unknown Windows";
|
return "Unknown Windows";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Read ProductName (string), CurrentMajorVersionNumber (dword), CurrentMinorVersionNumber (dword) and CurrentBuildNumber (string) as well as CurrentVersion (string)
|
// ProductName (SZ) - Actual windows install name e.g Windows 10 Pro)
|
||||||
|
// CurrentMajorVersionNumber (DWORD) - e.g 10 for windows 10, 11 for windows 11
|
||||||
|
// CurrentMinorVersionNumber (DWORD) - usually 0 for newer windows, pairs with major version
|
||||||
|
// CurrentBuildNumber (SZ) - Windows build number, e.g 19045, used to identify different releases like 23H2, 24H2, etc
|
||||||
|
// CurrentVersion (SZ) - NT kernel version, e.g 6.3 for Windows 10
|
||||||
const auto [product_valid, product_name] = read_reg_sz(hKey, "ProductName");
|
const auto [product_valid, product_name] = read_reg_sz(hKey, "ProductName");
|
||||||
if (!product_valid)
|
if (!product_valid)
|
||||||
{
|
{
|
||||||
|
RegCloseKey(hKey);
|
||||||
return "Unknown Windows";
|
return "Unknown Windows";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue