Fix NTSTATUS/Win32 error code mismatch in registry::GetKeyName() (#40410)
ZwQueryKey returns NTSTATUS, but the second call was checked with THROW_IF_WIN32_ERROR() which expects LSTATUS/Win32 error codes. This caused NTSTATUS failure codes to be misinterpreted, potentially masking real errors or throwing incorrect exceptions. The first call on line 48 already uses THROW_NTSTATUS correctly, and ZwQueryKey at line 237 uses THROW_IF_NTSTATUS_FAILED correctly. Co-authored-by: Ben Hillis <benhill@ntdev.microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Ben Hillis committed
May 4, 2026 at 18:02 UTC
15a28dfea876f2d4ae56e75c13e9b439bd03cdde
1 file changed
+1
-1
src/windows/common/registry.cpp
+1
-1
@@ -51,7 +51,7 @@ std::wstring GetKeyPath(_In_ HKEY Key)
51
std::vector<char> buffer(requiredSize, 0);
52
53
status = ZwQueryKey(Key, KeyNameInformation, buffer.data(), static_cast<ULONG>(buffer.size()), &requiredSize);
54
- THROW_IF_WIN32_ERROR(status);
54
+ THROW_IF_NTSTATUS_FAILED(status);
55
56
const auto* info = reinterpret_cast<KEY_NAME_INFORMATION*>(buffer.data());
57