Bug 1358276: Add FixCorruptOleAccRegistration to PostUpdate; r?mhowell draft
authorAaron Klotz <aklotz@mozilla.com>
Wed, 26 Apr 2017 14:19:19 -0600
changeset 569766 a362fb5ec554a54f0df719860cde620ce40fa5f5
parent 568252 3f0c8da53c5cb015933b10b52ded3f30432b378a
child 626296 5102e94b7cdc236314d9a7df278cad906a898f82
push id56272
push useraklotz@mozilla.com
push dateThu, 27 Apr 2017 22:22:25 +0000
reviewersmhowell
bugs1358276
milestone55.0a1
Bug 1358276: Add FixCorruptOleAccRegistration to PostUpdate; r?mhowell MozReview-Commit-ID: 64hU21BgELu Some third-party software tampers with the registry settings for the IAccessible COM interface which is provided by Windows. If these settings become corrupted, our a11y implementation breaks. We attempt to detect this by loading the path to the IAccessible typelib and checking to see if that file still exists. If it is missing, we reset the typelib GUID and version to the system default. The GUIDs and version number included in this patch hold from Windows 7 through to Windows 10 Anniversary Update. The Windows 10 Creators update does not use a typelib anymore, so we do nothing in that case. This fix is intended to run on 32-bit builds only.
browser/installer/windows/nsis/shared.nsh
--- a/browser/installer/windows/nsis/shared.nsh
+++ b/browser/installer/windows/nsis/shared.nsh
@@ -102,16 +102,21 @@
   ; Fix the distribution.ini file if applicable
   ${FixDistributionsINI}
 
   RmDir /r /REBOOTOK "$INSTDIR\${TO_BE_DELETED}"
 
   ; Register AccessibleHandler.dll with COM (this writes to HKLM)
   ${RegisterAccessibleHandler}
 
+!ifndef HAVE_64BIT_BUILD
+  ; Clean up any IAccessible registry corruption
+  ${FixCorruptOleAccRegistration}
+!endif
+
 !ifdef MOZ_MAINTENANCE_SERVICE
   Call IsUserAdmin
   Pop $R0
   ${If} $R0 == "true"
   ; Only proceed if we have HKLM write access
   ${AndIf} $TmpVal == "HKLM"
     ; We check to see if the maintenance service install was already attempted.
     ; Since the Maintenance service can be installed either x86 or x64,
@@ -917,16 +922,59 @@
 !define AddMaintCertKeys "!insertmacro AddMaintCertKeys"
 !endif
 
 !macro RegisterAccessibleHandler
   ${RegisterDLL} "$INSTDIR\AccessibleHandler.dll"
 !macroend
 !define RegisterAccessibleHandler "!insertmacro RegisterAccessibleHandler"
 
+!ifndef HAVE_64BIT_BUILD
+!define IID_IAccessible "{618736E0-3C3D-11CF-810C-00AA00389B71}"
+!define CLSID_UniversalMarshaler "{00020404-0000-0000-C000-000000000046}"
+!define OleAccTypeLib "{1EA4DBF0-3C3B-11CF-810C-00AA00389B71}"
+!define OleAccTypeLibVersion "1.1"
+Function FixCorruptOleAccRegistration
+  Push $0
+
+  ; Read IAccessible's ProxyStubClsid32. If it is not CLSID_UniversalMarshaler
+  ; then we must be running Windows 10 Creators Update which does not use a
+  ; type library.
+  ReadRegStr $0 HKCR "Interface\${IID_IAccessible}\ProxyStubClsid32" ""
+  ${Unless} "$0" == "${CLSID_UniversalMarshaler}"
+    Pop $0
+    Return
+  ${EndIf}
+
+  Push $1
+
+  ; IAccessible is using the universal marshler, therefore we expect a valid
+  ; TypeLib key to exist
+  ClearErrors
+  ReadRegStr $0 HKCR "Interface\${IID_IAccessible}\TypeLib" ""
+  ReadRegStr $1 HKCR "Interface\${IID_IAccessible}\TypeLib" "Version"
+  ReadRegStr $0 HKCR "TypeLib\$0\$1\0\win32" ""
+  Pop $1
+  ${IfNot} ${Errors}
+  ${AndIf} ${FileExists} "$0"
+    Pop $0
+    Return
+  ${EndIf}
+
+  Pop $0
+
+  ; Some third-party code has previously overridden system typelibs
+  ; with their own but did not clean itself up during uninstall.
+  ; Revert to the system typelib.
+  WriteRegStr HKCR "Interface\${IID_IAccessible}\TypeLib" "" "${OleAccTypeLib}"
+  WriteRegStr HKCR "Interface\${IID_IAccessible}\TypeLib" "Version" "${OleAccTypeLibVersion}"
+FunctionEnd
+!define FixCorruptOleAccRegistration "Call FixCorruptOleAccRegistration"
+!endif
+
 ; Removes various registry entries for reasons noted below (does not use SHCTX).
 !macro RemoveDeprecatedKeys
   StrCpy $0 "SOFTWARE\Classes"
   ; Remove support for launching chrome urls from the shell during install or
   ; update if the DefaultIcon is from firefox.exe (Bug 301073).
   ${RegCleanAppHandler} "chrome"
 
   ; Remove protocol handler registry keys added by the MS shim