From 8d42c0ce7739c38f69adb49bf660169b71dba859 Mon Sep 17 00:00:00 2001 From: bicarus <202771338+bicarus-dev@users.noreply.github.com> Date: Fri, 10 Jul 2026 00:26:03 -0700 Subject: [PATCH] asio: fix XP build; remove call to RegGetValueA (#788) ## Link to GitHub Issue or related Pull Request, if one exists Fixes #787 ## Description of change Remove the call to `RegGetValueA` as it is Vista and up. Replace with `RegOpenKeyExA` + `RegQueryValueExA` ## Testing --- src/spice2x/hooks/audio/asio_driver_scan.cpp | 28 +++++++++++++------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/src/spice2x/hooks/audio/asio_driver_scan.cpp b/src/spice2x/hooks/audio/asio_driver_scan.cpp index ef8d425..57e1a85 100644 --- a/src/spice2x/hooks/audio/asio_driver_scan.cpp +++ b/src/spice2x/hooks/audio/asio_driver_scan.cpp @@ -32,18 +32,28 @@ namespace hooks::audio { RegEnumKeyA(hkEnum, index, key_name, sizeof(key_name)) == ERROR_SUCCESS; index++) { - // read description (display name), fall back to the key name + // read description (display name), fall back to the key name. + // RegOpenKeyExA + RegQueryValueExA is used instead of RegGetValueA + // because the latter is unavailable on Windows XP. char desc[256] = { 0 }; DWORD size = sizeof(desc); std::string name = key_name; - if (RegGetValueA(hkEnum, - key_name, - ASIO_REG_DESC, - RRF_RT_REG_SZ | wow64_flag, - nullptr, - desc, - &size) == ERROR_SUCCESS && desc[0]) { - name = desc; + HKEY hkDriver = nullptr; + if (RegOpenKeyExA(hkEnum, key_name, 0, + KEY_QUERY_VALUE | wow64_flag, &hkDriver) == ERROR_SUCCESS) { + DWORD type = 0; + if (RegQueryValueExA(hkDriver, + ASIO_REG_DESC, + nullptr, + &type, + reinterpret_cast(desc), + &size) == ERROR_SUCCESS + && type == REG_SZ && desc[0]) { + // ensure null termination + desc[sizeof(desc) - 1] = '\0'; + name = desc; + } + RegCloseKey(hkDriver); } // merge with an existing entry from the other view (match by name)