Bug 1423958 - Check for problematic third-party software before automatically installing a 64-bit build. r=agashlin a=jcristau
authorMatt Howell <mhowell@mozilla.com>
Thu, 07 Dec 2017 11:23:13 -0800
changeset 445376 53a39de339937734359ec90afc44dfd0b97c0bfc
parent 445375 873f72d1eeb98e866ba1a8d3217352dda8d3450e
child 445377 5b2c850b512167b1dc56194d2e1e82072a7f7c3a
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersagashlin, jcristau
bugs1423958
milestone58.0
Bug 1423958 - Check for problematic third-party software before automatically installing a 64-bit build. r=agashlin a=jcristau MozReview-Commit-ID: ZzXuSmY7k3
browser/installer/windows/nsis/stub.nsi
--- a/browser/installer/windows/nsis/stub.nsi
+++ b/browser/installer/windows/nsis/stub.nsi
@@ -315,24 +315,18 @@ Function .onInit
 
   ; SSE2 CPU support
   ${If} "$R7" == "0"
     MessageBox MB_OKCANCEL|MB_ICONSTOP "$(WARN_MIN_SUPPORTED_CPU_MSG)" IDCANCEL +2
     ExecShell "open" "${URLSystemRequirements}"
     Quit
   ${EndIf}
 
-  ; Check if we meet the RAM requirement for the 64-bit build.
-  System::Call "*(i 64, i, l 0, l, l, l, l, l, l)p.r0"
-  System::Call "Kernel32::GlobalMemoryStatusEx(p r0)"
-  System::Call "*$0(i, i, l.r1, l, l, l, l, l, l)"
-  System::Free $0
-
-  ${If} ${RunningX64}
-  ${AndIf} $1 L> ${RAM_NEEDED_FOR_64BIT}
+  Call ShouldInstall64Bit
+  ${If} $0 == 1
     StrCpy $DroplistArch "$(VERSION_64BIT)"
     StrCpy $INSTDIR "${DefaultInstDir64bit}"
   ${Else}
     StrCpy $DroplistArch "$(VERSION_32BIT)"
     StrCpy $INSTDIR "${DefaultInstDir32bit}"
   ${EndIf}
 
   ; Require elevation if the user can elevate
@@ -1866,10 +1860,44 @@ Function GetLatestReleasedVersion
   ${EndSelect}
   nsJSON::Get "Output" $1 /end
   IfErrors end
   Pop $1
 
   end:
 FunctionEnd
 
+; Returns 1 in $0 if we should install the 64-bit build, or 0 if not.
+; The requirements for selecting the 64-bit build to install are:
+; 1) Running a 64-bit OS (we've already checked the OS version).
+; 2) An amount of RAM strictly greater than RAM_NEEDED_FOR_64BIT
+; 3) No third-party products installed that cause issues with the 64-bit build.
+;    Currently this includes Lenovo OneKey Theater and Lenovo Energy Management.
+Function ShouldInstall64Bit
+  StrCpy $0 0
+
+  ${IfNot} ${RunningX64}
+    Return
+  ${EndIf}
+
+  System::Call "*(i 64, i, l 0, l, l, l, l, l, l)p.r1"
+  System::Call "Kernel32::GlobalMemoryStatusEx(p r1)"
+  System::Call "*$1(i, i, l.r2, l, l, l, l, l, l)"
+  System::Free $1
+  ${If} $2 L<= ${RAM_NEEDED_FOR_64BIT}
+    Return
+  ${EndIf}
+
+  ; Lenovo OneKey Theater can theoretically be in a directory other than this
+  ; one, because some installer versions let you change it, but it's unlikely.
+  ${If} ${FileExists} "C:\Program Files (x86)\Lenovo\Onekey Theater\windowsapihookdll64.dll"
+    Return
+  ${EndIf}
+
+  ${If} ${FileExists} "C:\Program Files (x86)\Lenovo\Energy Management\Energy Management.exe"
+    Return
+  ${EndIf}
+
+  StrCpy $0 1
+FunctionEnd
+
 Section
 SectionEnd