Bug 1129209 - Use a separate manifest for comctl32.dll. r=bbondy
authorRobert Strong <robert.bugzilla@gmail.com>
Thu, 05 Feb 2015 14:12:39 -0800
changeset 227767 6fcfaa95e84a754e125725747a8da9e0bcbf12d2
parent 227766 78af92a0f9452a46d26f9890871f38cc69eb9437
child 227768 4c7066e68109e45d4bd60a1c66699806a07cf89f
push id28239
push userryanvm@gmail.com
push dateFri, 06 Feb 2015 13:52:40 +0000
treeherdermozilla-central@03b0004eba32 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbbondy
bugs1129209
milestone38.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 1129209 - Use a separate manifest for comctl32.dll. r=bbondy
toolkit/mozapps/update/tests/unit_aus_update/head_update.js
toolkit/mozapps/update/updater/loaddlls.cpp
toolkit/mozapps/update/updater/progressui_win.cpp
toolkit/mozapps/update/updater/resource.h
toolkit/mozapps/update/updater/updater.exe.comctl32.manifest
toolkit/mozapps/update/updater/updater.exe.manifest
toolkit/mozapps/update/updater/updater.rc
--- a/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
+++ b/toolkit/mozapps/update/tests/unit_aus_update/head_update.js
@@ -2397,17 +2397,20 @@ function createUpdaterINI(aIsExeAsync) {
     if (aIsExeAsync) {
       exeAsync = "ExeAsync=true\n";
     } else {
       exeArg = "ExeArg=post-update-sync\n";
       exeAsync = "ExeAsync=false\n";
     }
   }
 
-  let updaterIniContents = "[PostUpdateMac]\n" +
+  let updaterIniContents = "[Strings]\n" +
+                           "Title=Update Test\n" +
+                           "Info=Running update test " + gTestID + "\n\n" +
+                           "[PostUpdateMac]\n" +
                            "ExeRelPath=" + DIR_RESOURCES + gPostUpdateBinFile + "\n" +
                            exeArg +
                            exeAsync +
                            "\n" +
                            "[PostUpdateWin]\n" +
                            "ExeRelPath=" + gPostUpdateBinFile + "\n" +
                            exeArg +
                            exeAsync;
--- a/toolkit/mozapps/update/updater/loaddlls.cpp
+++ b/toolkit/mozapps/update/updater/loaddlls.cpp
@@ -69,17 +69,17 @@ struct AutoLoadSystemDependencies
                                    L"ws2_32.dll",
                                    L"ws2help.dll",
                                    L"wsock32.dll" };
 #endif
 
     WCHAR systemDirectory[MAX_PATH + 1] = { L'\0' };
     // If GetSystemDirectory fails we accept that we'll load the DLLs from the
     // normal search path.
-    GetSystemDirectory(systemDirectory, MAX_PATH + 1);
+    GetSystemDirectoryW(systemDirectory, MAX_PATH + 1);
     size_t systemDirLen = wcslen(systemDirectory);
 
     // Make the system directory path terminate with a slash
     if (systemDirectory[systemDirLen - 1] != L'\\' && systemDirLen) {
       systemDirectory[systemDirLen] = L'\\';
       ++systemDirLen;
       // No need to re-null terminate
     }
--- a/toolkit/mozapps/update/updater/progressui_win.cpp
+++ b/toolkit/mozapps/update/updater/progressui_win.cpp
@@ -195,17 +195,17 @@ DialogProc(HWND hDlg, UINT message, WPAR
 
   case WM_COMMAND:
     return TRUE;
   }
   return FALSE;
 }
 
 int
-InitProgressUI(int *argc, NS_tchar ***argv)
+InitProgressUI(int *argc, WCHAR ***argv)
 {
   return 0;
 }
 
 /**
  * Initializes the progress UI strings
  * 
  * @return 0 on success, -1 on error
@@ -240,30 +240,74 @@ ShowProgressUI(bool indeterminate, bool 
     // time where a significant amount of time is defined as .5 seconds after
     // ShowProgressUI is called sProgress is less than 70.
     Sleep(500);
 
     if (sQuit || sProgress > 70.0f)
       return 0;
   }
 
+  // Don't load the UI if there's an <exe_name>.Local directory for redirection.
+  WCHAR appPath[MAX_PATH + 1] = { L'\0' };
+  if (!GetModuleFileNameW(nullptr, appPath, MAX_PATH)) {
+    return -1;
+  }
+
+  if (wcslen(appPath) + wcslen(L".Local") >= MAX_PATH) {
+    return -1;
+  }
+
+  wcscat(appPath, L".Local");
+
+  if (!_waccess(appPath, 04)) {
+    return -1;
+  }
+
+  // Don't load the UI if the strings for the UI are not provided.
   if (initUIStrings && InitProgressUIStrings() == -1) {
     return -1;
   }
 
+  if (!GetModuleFileNameW(nullptr, appPath, MAX_PATH)) {
+    return -1;
+  }
+
+  // Use an activation context that supports visual styles for the controls.
+  ACTCTXW actx = {0};
+  actx.cbSize = sizeof(ACTCTXW);
+  actx.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID | ACTCTX_FLAG_HMODULE_VALID;
+  actx.hModule = GetModuleHandle(NULL); // Use the embedded manifest
+  // This is needed only for Win XP but doesn't cause a problem with other
+  // versions of Windows.
+  actx.lpSource = appPath;
+  actx.lpResourceName = MAKEINTRESOURCE(IDR_COMCTL32_MANIFEST);
+
+  HANDLE hactx = INVALID_HANDLE_VALUE;
+  hactx = CreateActCtxW(&actx);
+  ULONG_PTR actxCookie = NULL;
+  if (hactx != INVALID_HANDLE_VALUE) {
+    // Push the specified activation context to the top of the activation stack.
+    ActivateActCtx(hactx, &actxCookie);
+  }
+
   INITCOMMONCONTROLSEX icc = {
     sizeof(INITCOMMONCONTROLSEX),
     ICC_PROGRESS_CLASS
   };
   InitCommonControlsEx(&icc);
 
   DialogBox(GetModuleHandle(nullptr),
             MAKEINTRESOURCE(IDD_DIALOG), nullptr,
             (DLGPROC) DialogProc);
 
+  if (hactx != INVALID_HANDLE_VALUE) {
+    // Deactivate the context now that the comctl32.dll is loaded.
+    DeactivateActCtx(0, actxCookie);
+  }
+
   return 0;
 }
 
 void
 QuitProgressUI()
 {
   sQuit = TRUE;
 }
--- a/toolkit/mozapps/update/updater/resource.h
+++ b/toolkit/mozapps/update/updater/resource.h
@@ -10,16 +10,17 @@
 #define IDC_PROGRESS                    1000
 #define IDC_INFO                        1002
 #define IDI_DIALOG                      1003
 #define TYPE_CERT                       512
 #define IDR_PRIMARY_CERT                1004
 #define IDR_BACKUP_CERT                 1005
 #define IDS_UPDATER_IDENTITY            1006
 #define IDR_XPCSHELL_CERT               1007
+#define IDR_COMCTL32_MANIFEST           17
 
 // Next default values for new objects
 // 
 #ifdef APSTUDIO_INVOKED
 #ifndef APSTUDIO_READONLY_SYMBOLS
 #define _APS_NEXT_RESOURCE_VALUE        102
 #define _APS_NEXT_COMMAND_VALUE         40001
 #define _APS_NEXT_CONTROL_VALUE         1008
new file mode 100644
--- /dev/null
+++ b/toolkit/mozapps/update/updater/updater.exe.comctl32.manifest
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
+<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
+<assemblyIdentity
+        version="1.0.0.0"
+        processorArchitecture="*"
+        name="Updater"
+        type="win32"
+/>
+<description>Updater</description>
+<dependency>
+  <dependentAssembly>
+    <assemblyIdentity
+            type="win32"
+            name="Microsoft.Windows.Common-Controls"
+            version="6.0.0.0"
+            processorArchitecture="*"
+            publicKeyToken="6595b64144ccf1df"
+            language="*"
+    />
+  </dependentAssembly>
+</dependency>
+<ms_asmv3:trustInfo xmlns:ms_asmv3="urn:schemas-microsoft-com:asm.v3">
+  <ms_asmv3:security>
+    <ms_asmv3:requestedPrivileges>
+      <ms_asmv3:requestedExecutionLevel level="asInvoker" uiAccess="false" />
+    </ms_asmv3:requestedPrivileges>
+  </ms_asmv3:security>
+</ms_asmv3:trustInfo>
+  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
+    <application>
+      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
+      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
+      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
+      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
+      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
+    </application>
+  </compatibility>
+</assembly>
--- a/toolkit/mozapps/update/updater/updater.exe.manifest
+++ b/toolkit/mozapps/update/updater/updater.exe.manifest
@@ -2,28 +2,16 @@
 <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
 <assemblyIdentity
         version="1.0.0.0"
         processorArchitecture="*"
         name="Updater"
         type="win32"
 />
 <description>Updater</description>
-<dependency>
-        <dependentAssembly>
-                <assemblyIdentity
-                        type="win32"
-                        name="Microsoft.Windows.Common-Controls"
-                        version="6.0.0.0"
-                        processorArchitecture="*"
-                        publicKeyToken="6595b64144ccf1df"
-                        language="*"
-                />
-        </dependentAssembly>
-</dependency>
 <ms_asmv3:trustInfo xmlns:ms_asmv3="urn:schemas-microsoft-com:asm.v3">
   <ms_asmv3:security>
     <ms_asmv3:requestedPrivileges>
       <ms_asmv3:requestedExecutionLevel level="asInvoker" uiAccess="false" />
     </ms_asmv3:requestedPrivileges>
   </ms_asmv3:security>
 </ms_asmv3:trustInfo>
   <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
--- a/toolkit/mozapps/update/updater/updater.rc
+++ b/toolkit/mozapps/update/updater/updater.rc
@@ -26,16 +26,17 @@ LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_U
 #endif //_WIN32
 
 /////////////////////////////////////////////////////////////////////////////
 //
 // RT_MANIFEST
 //
 
 1                       RT_MANIFEST             "updater.exe.manifest"
+IDR_COMCTL32_MANIFEST   RT_MANIFEST             "updater.exe.comctl32.manifest"
 
 /////////////////////////////////////////////////////////////////////////////
 //
 // Icon
 //
 
 IDI_DIALOG ICON "updater.ico"