Commit 81a34aa6 authored by Aaron Klotz's avatar Aaron Klotz
Browse files

Bug 1383501: Change remaining references to HKEY_CLASSES_ROOT to...

Bug 1383501: Change remaining references to HKEY_CLASSES_ROOT to HKEY_LOCAL_MACHINE in mscom-related code; r=jimm

MozReview-Commit-ID: GAV3iqapXss

--HG--
extra : rebase_source : c0ed0578ca2e560203fc6c1a8fd172272209e84c
parent 26140736
Loading
Loading
Loading
Loading
+7 −6
Original line number Diff line number Diff line
@@ -197,14 +197,15 @@ a11y::IsHandlerRegistered()
    return false;
  }

  nsAutoString clsid;
  GUIDToString(CLSID_AccessibleHandler, clsid);

  nsAutoString subKey;
  subKey.AppendLiteral("CLSID\\");
  nsAutoString iid;
  GUIDToString(CLSID_AccessibleHandler, iid);
  subKey.Append(iid);
  subKey.AppendLiteral("\\InprocHandler32");
  subKey.AppendLiteral(u"SOFTWARE\\Classes\\CLSID\\");
  subKey.Append(clsid);
  subKey.AppendLiteral(u"\\InprocHandler32");

  rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_CLASSES_ROOT, subKey,
  rv = regKey->Open(nsIWindowsRegKey::ROOT_KEY_LOCAL_MACHINE, subKey,
                    nsIWindowsRegKey::ACCESS_READ);
  if (NS_FAILED(rv)) {
    return false;
+19 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ static const char16_t kFlags[] = u"FLAGS";
static const char16_t kProxyStubClsid32[] = u"\\ProxyStubClsid32";
static const char16_t kClsid[] = u"\\CLSID\\";
static const char16_t kInprocServer32[] = u"\\InprocServer32";
static const char16_t kInprocHandler32[] = u"\\InprocHandler32";
static const char16_t kTypeLib[] = u"\\TypeLib";
static const char16_t kVersion[] = u"Version";
static const char16_t kWin32[] = u"Win32";
@@ -170,6 +171,24 @@ AnnotateClsidRegistrationForHive(JSONWriter& aJson, HKEY aHive,
  if (GetStringValue(aHive, inprocServerSubkey, kThreadingModel, apartment)) {
    aJson.StringProperty("ThreadingModel", NS_ConvertUTF16toUTF8(apartment).get());
  }

  nsAutoString inprocHandlerSubkey(clsidSubkey);
  inprocHandlerSubkey.AppendLiteral(kInprocHandler32);
  nsAutoString pathToHandlerDll;
  if (GetStringValue(aHive, inprocHandlerSubkey, kDefaultValue, pathToHandlerDll)) {
    aJson.StringProperty("HandlerPath", NS_ConvertUTF16toUTF8(pathToHandlerDll).get());
    if (GetLoadedPath(pathToHandlerDll)) {
      aJson.StringProperty("LoadedHandlerPath",
                           NS_ConvertUTF16toUTF8(pathToHandlerDll).get());
    }
  }

  nsAutoString handlerApartment;
  if (GetStringValue(aHive, inprocHandlerSubkey, kThreadingModel,
                     handlerApartment)) {
    aJson.StringProperty("HandlerThreadingModel",
                         NS_ConvertUTF16toUTF8(handlerApartment).get());
  }
}

static void
+12 −9
Original line number Diff line number Diff line
@@ -263,17 +263,20 @@ template <size_t N>
static HRESULT
BuildClsidPath(wchar_t (&aPath)[N], REFCLSID aClsid)
{
  const wchar_t kClsid[] = {L'C', L'L', L'S', L'I', L'D', L'\\'};
  const wchar_t kSubkey[] = L"SOFTWARE\\Classes\\CLSID\\";

  // We exclude kSubkey's null terminator in the length because we include
  // the stringified GUID's null terminator.
  constexpr uint32_t kSubkeyLen = mozilla::ArrayLength(kSubkey) - 1;

  const size_t kReqdGuidLen = 39;
  static_assert(N >= kReqdGuidLen + mozilla::ArrayLength(kClsid),
                "aPath array is too short");
  if (wcsncpy_s(aPath, kClsid, mozilla::ArrayLength(kClsid))) {
  static_assert(N >= kReqdGuidLen + kSubkeyLen, "aPath array is too short");
  if (wcsncpy_s(aPath, kSubkey, kSubkeyLen)) {
    return E_INVALIDARG;
  }

  int guidConversionResult =
    StringFromGUID2(aClsid, &aPath[mozilla::ArrayLength(kClsid)],
                    N - mozilla::ArrayLength(kClsid));
    StringFromGUID2(aClsid, &aPath[kSubkeyLen], N - kSubkeyLen);
  if (!guidConversionResult) {
    return E_INVALIDARG;
  }
@@ -290,7 +293,7 @@ Handler::Unregister(REFCLSID aClsid)
    return hr;
  }

  hr = HRESULT_FROM_WIN32(SHDeleteKey(HKEY_CLASSES_ROOT, path));
  hr = HRESULT_FROM_WIN32(SHDeleteKey(HKEY_LOCAL_MACHINE, path));
  if (FAILED(hr)) {
    return hr;
  }
@@ -309,7 +312,7 @@ Handler::Register(REFCLSID aClsid)

  HKEY rawClsidKey;
  DWORD disposition;
  LONG result = RegCreateKeyEx(HKEY_CLASSES_ROOT, path, 0, nullptr,
  LONG result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, path, 0, nullptr,
                               REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
                               nullptr, &rawClsidKey, &disposition);
  if (result != ERROR_SUCCESS) {
@@ -322,7 +325,7 @@ Handler::Register(REFCLSID aClsid)
  }

  HKEY rawInprocHandlerKey;
  result = RegCreateKeyEx(HKEY_CLASSES_ROOT, path, 0, nullptr,
  result = RegCreateKeyEx(HKEY_LOCAL_MACHINE, path, 0, nullptr,
                          REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS,
                          nullptr, &rawInprocHandlerKey, &disposition);
  if (result != ERROR_SUCCESS) {