| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_H_ | 5 #ifndef CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_H_ |
| 6 #define CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_H_ | 6 #define CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_H_ |
| 7 | 7 |
| 8 #include <windows.h> | 8 #include <windows.h> |
| 9 | 9 |
| 10 #include "chrome/installer/mini_installer/exit_code.h" | 10 #include "chrome/installer/mini_installer/exit_code.h" |
| 11 #include "chrome/installer/mini_installer/mini_string.h" |
| 11 | 12 |
| 12 namespace mini_installer { | 13 namespace mini_installer { |
| 13 | 14 |
| 14 // A container of a process exit code (eventually passed to ExitProcess) and | 15 // A container of a process exit code (eventually passed to ExitProcess) and |
| 15 // a Windows error code for cases where the exit code is non-zero. | 16 // a Windows error code for cases where the exit code is non-zero. |
| 16 struct ProcessExitResult { | 17 struct ProcessExitResult { |
| 17 DWORD exit_code; | 18 DWORD exit_code; |
| 18 DWORD windows_error; | 19 DWORD windows_error; |
| 19 | 20 |
| 20 explicit ProcessExitResult(DWORD exit) : exit_code(exit), windows_error(0) {} | 21 explicit ProcessExitResult(DWORD exit) : exit_code(exit), windows_error(0) {} |
| 21 ProcessExitResult(DWORD exit, DWORD win) | 22 ProcessExitResult(DWORD exit, DWORD win) |
| 22 : exit_code(exit), windows_error(win) {} | 23 : exit_code(exit), windows_error(win) {} |
| 23 | 24 |
| 24 bool IsSuccess() const { return exit_code == SUCCESS_EXIT_CODE; } | 25 bool IsSuccess() const { return exit_code == SUCCESS_EXIT_CODE; } |
| 25 }; | 26 }; |
| 26 | 27 |
| 28 // A stack-based string large enough to hold an executable to run |
| 29 // (which is a path), two additional path arguments, plus a few extra |
| 30 // arguments. Figure that MAX_PATH (260) is sufficient breathing room for the |
| 31 // extra arguments. |
| 32 using CommandString = StackString<MAX_PATH * 4>; |
| 33 |
| 34 // Appends everything following the path to the executable in |command_line| |
| 35 // verbatim to |buffer|, including all whitespace, quoted arguments, |
| 36 // etc. |buffer| is unchanged in case of error. |
| 37 void AppendCommandLineFlags(const wchar_t* command_line, CommandString* buffer); |
| 38 |
| 27 // Main function for Chrome's mini_installer. First gets a working dir, unpacks | 39 // Main function for Chrome's mini_installer. First gets a working dir, unpacks |
| 28 // the resources, and finally executes setup.exe to do the install/update. Also | 40 // the resources, and finally executes setup.exe to do the install/update. Also |
| 29 // handles invoking a previous version's setup.exe to patch itself in the case | 41 // handles invoking a previous version's setup.exe to patch itself in the case |
| 30 // of differential updates. | 42 // of differential updates. |
| 31 ProcessExitResult WMain(HMODULE module); | 43 ProcessExitResult WMain(HMODULE module); |
| 32 | 44 |
| 33 } // namespace mini_installer | 45 } // namespace mini_installer |
| 34 | 46 |
| 35 #endif // CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_H_ | 47 #endif // CHROME_INSTALLER_MINI_INSTALLER_MINI_INSTALLER_H_ |
| OLD | NEW |