Bug 1455110: Replace RegOpenKeyEx/RegQueryValueEx with RegGetValue; r=jimm
authorAaron Klotz <aklotz@mozilla.com>
Wed, 18 Apr 2018 14:52:02 -0600
changeset 415170 45c6f888c2acabcc8076ce8220e0993f2aee88df
parent 415169 cac46e410f9911d8748d8366c7ec939c71cebbee
child 415171 b35a1f66c4529227dacf60e43d446918f179df47
child 415186 4ca67a1ab5b2e8a191caeb19ec09b07b7c42849e
push id33889
push useraciure@mozilla.com
push dateTue, 24 Apr 2018 01:14:50 +0000
treeherdermozilla-central@b35a1f66c452 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjimm
bugs1455110
milestone61.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1455110: Replace RegOpenKeyEx/RegQueryValueEx with RegGetValue; r=jimm
toolkit/xre/nsAppRunner.cpp
--- a/toolkit/xre/nsAppRunner.cpp
+++ b/toolkit/xre/nsAppRunner.cpp
@@ -3157,28 +3157,21 @@ public:
 #if defined(MOZ_WIDGET_GTK)
   GdkDisplay* mGdkDisplay;
 #endif
 };
 
 #ifdef XP_WIN
 namespace {
 
-bool PolicyHasRegValue(HKEY aKey, LPCTSTR aName, DWORD* aValue)
+bool PolicyHasRegValue(HKEY aKey, LPCWSTR aName, DWORD* aValue)
 {
-  HKEY hkey = NULL;
-  LONG ret = RegOpenKeyExW(aKey,
-    L"SOFTWARE\\Policies\\Mozilla\\Firefox", 0, KEY_READ, &hkey);
-  if (ret != ERROR_SUCCESS) {
-     return false;
-  }
-  nsAutoRegKey key(hkey);
-  DWORD len = sizeof(aValue);
-  ret = RegQueryValueExW(hkey, aName, 0, NULL, (LPBYTE)aValue, &len);
-  RegCloseKey(key);
+  DWORD len = sizeof(DWORD);
+  LONG ret = ::RegGetValueW(aKey, L"SOFTWARE\\Policies\\Mozilla\\Firefox", aName,
+                            RRF_RT_DWORD, nullptr, aValue, &len);
   return ret == ERROR_SUCCESS;
 }
 
 bool SafeModeBlockedByPolicy()
 {
   LPCTSTR policyName = L"DisableSafeMode";
   DWORD value;
   if (PolicyHasRegValue(HKEY_LOCAL_MACHINE, policyName, &value)) {