OLD | NEW |
| (Empty) |
1 // Copyright 2007-2009 Google Inc. | |
2 // | |
3 // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 // you may not use this file except in compliance with the License. | |
5 // You may obtain a copy of the License at | |
6 // | |
7 // http://www.apache.org/licenses/LICENSE-2.0 | |
8 // | |
9 // Unless required by applicable law or agreed to in writing, software | |
10 // distributed under the License is distributed on an "AS IS" BASIS, | |
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
12 // See the License for the specific language governing permissions and | |
13 // limitations under the License. | |
14 // ======================================================================== | |
15 // | |
16 // Helper for the Google Update repair file. It launches the same repair file | |
17 // elevated using the MSP. | |
18 | |
19 #include "omaha/recovery/repair_exe/repair_goopdate.h" | |
20 #include "omaha/base/debug.h" | |
21 #include "omaha/base/logging.h" | |
22 #include "omaha/base/utils.h" | |
23 #include "omaha/base/vistautil.h" | |
24 #include "omaha/recovery/repair_exe/mspexecutableelevator.h" | |
25 | |
26 namespace omaha { | |
27 | |
28 // Returns without launching the repair file if is_machine is false, running | |
29 // on a pre-Windows Vista OS, or the current user is Local System. | |
30 // This method does not always launch the repair file because we expect this | |
31 // to be called from the repair file, and there is no reason to launch another | |
32 // process. | |
33 bool LaunchRepairFileElevated(bool is_machine, | |
34 const TCHAR* repair_file, | |
35 const TCHAR* args, | |
36 HRESULT* elevation_hr) { | |
37 ASSERT1(elevation_hr); | |
38 | |
39 *elevation_hr = S_OK; | |
40 | |
41 if (!is_machine) { | |
42 UTIL_LOG(L2, (_T("[user instance - not elevating]"))); | |
43 return false; | |
44 } | |
45 if (!vista_util::IsVistaOrLater()) { | |
46 UTIL_LOG(L2, (_T("[Pre-Windows Vista OS - not elevating]"))); | |
47 return false; | |
48 } | |
49 | |
50 bool is_user_local_system = false; | |
51 HRESULT hr = IsSystemProcess(&is_user_local_system); | |
52 if (SUCCEEDED(hr) && is_user_local_system) { | |
53 UTIL_LOG(L2, (_T("[User is already SYSTEM - not elevating]"))); | |
54 return false; | |
55 } | |
56 | |
57 HANDLE process = NULL; | |
58 *elevation_hr = msp_executable_elevator::ExecuteGoogleSignedExe( | |
59 repair_file, | |
60 args, | |
61 kHelperInstallerProductGuid, | |
62 kHelperPatchGuid, | |
63 kHelperPatchName, | |
64 &process); | |
65 // Our implementation of msp_executable_elevator does not set the process | |
66 // handle parameter, but we did not remove it from the borrowed code. | |
67 ASSERT1(!process); | |
68 | |
69 if (FAILED(*elevation_hr)) { | |
70 UTIL_LOG(LE, (_T("[ExecuteGoogleSignedExe failed][error 0x%08x]"), | |
71 *elevation_hr)); | |
72 return false; | |
73 } | |
74 | |
75 return true; | |
76 } | |
77 | |
78 } // namespace omaha | |
OLD | NEW |