From 9476a76dc093adab164bdc2951fda0fbb85abe47 Mon Sep 17 00:00:00 2001 From: Ben Hamilton Date: Thu, 10 Mar 2022 14:35:02 -0700 Subject: [PATCH] win: Use RegOpenKeyExW() instead of RegOpenKeyEx() Similar to crrev.com/c/3516536, this CL fixes the Windows build when the UNICODE preprocessor macro is not defined where code passes Unicode string literals with L"..." to non-Unicode APIs like RegOpenKeyEx(). This fixes the build by explicitly using RegOpenKeyExW() instead. Change-Id: I14a827357b9cbd42452e0e5eb13a3430569559a5 Reviewed-on: https://chromium-review.googlesource.com/c/crashpad/crashpad/+/3516538 Reviewed-by: Mark Mentovai Commit-Queue: Mark Mentovai --- snapshot/win/system_snapshot_win.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/snapshot/win/system_snapshot_win.cc b/snapshot/win/system_snapshot_win.cc index 6fc69458..a19253f2 100644 --- a/snapshot/win/system_snapshot_win.cc +++ b/snapshot/win/system_snapshot_win.cc @@ -158,11 +158,11 @@ void SystemSnapshotWin::Initialize(ProcessReaderWin* process_reader) { bool version_data_found = false; int os_version_build = 0; HKEY key; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", - 0, - KEY_QUERY_VALUE, - &key) == ERROR_SUCCESS) { + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion", + 0, + KEY_QUERY_VALUE, + &key) == ERROR_SUCCESS) { ScopedRegistryKey scoped_key(key); // Read the four components of the version from the registry. @@ -282,11 +282,11 @@ std::string SystemSnapshotWin::CPUVendor() const { #elif defined(ARCH_CPU_ARM64) HKEY key; - if (RegOpenKeyEx(HKEY_LOCAL_MACHINE, - L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", - 0, - KEY_QUERY_VALUE, - &key) != ERROR_SUCCESS) { + if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, + L"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0", + 0, + KEY_QUERY_VALUE, + &key) != ERROR_SUCCESS) { return std::string(); }