Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(72)

Side by Side Diff: sandbox/win/tools/launcher/launcher.cc

Issue 1337223002: Fixes to possible GetLastError bugs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Removed some sandbox changes Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sandbox/win/src/restricted_token_utils.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 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 #include "base/win/scoped_handle.h" 5 #include "base/win/scoped_handle.h"
6 #include "base/win/scoped_process_information.h" 6 #include "base/win/scoped_process_information.h"
7 #include "base/win/windows_version.h" 7 #include "base/win/windows_version.h"
8 #include "sandbox/win/src/restricted_token_utils.h" 8 #include "sandbox/win/src/restricted_token_utils.h"
9 9
10 // launcher.exe is an application used to launch another application with a 10 // launcher.exe is an application used to launch another application with a
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 &temp_process_info)) { 95 &temp_process_info)) {
96 return ::GetLastError(); 96 return ::GetLastError();
97 } 97 }
98 base::win::ScopedProcessInformation process_info(temp_process_info); 98 base::win::ScopedProcessInformation process_info(temp_process_info);
99 99
100 // Change the token of the main thread of the new process for the 100 // Change the token of the main thread of the new process for the
101 // impersonation token with more rights. 101 // impersonation token with more rights.
102 { 102 {
103 HANDLE temp_thread = process_info.thread_handle(); 103 HANDLE temp_thread = process_info.thread_handle();
104 if (!::SetThreadToken(&temp_thread, impersonation_token.Get())) { 104 if (!::SetThreadToken(&temp_thread, impersonation_token.Get())) {
105 auto last_error = ::GetLastError();
105 ::TerminateProcess(process_info.process_handle(), 106 ::TerminateProcess(process_info.process_handle(),
106 0); // exit code 107 0); // exit code
107 return ::GetLastError(); 108 return last_error;
108 } 109 }
109 } 110 }
110 111
111 err_code = job.AssignProcessToJob(process_info.process_handle()); 112 err_code = job.AssignProcessToJob(process_info.process_handle());
112 if (ERROR_SUCCESS != err_code) { 113 if (ERROR_SUCCESS != err_code) {
114 auto last_error = ::GetLastError();
113 ::TerminateProcess(process_info.process_handle(), 115 ::TerminateProcess(process_info.process_handle(),
114 0); // exit code 116 0); // exit code
115 return ::GetLastError(); 117 return last_error;
116 } 118 }
117 119
118 // Start the application 120 // Start the application
119 ::ResumeThread(process_info.thread_handle()); 121 ::ResumeThread(process_info.thread_handle());
120 122
121 *job_handle = job.Take(); 123 *job_handle = job.Take();
122 124
123 return ERROR_SUCCESS; 125 return ERROR_SUCCESS;
124 } 126 }
125 127
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
259 return -1; 261 return -1;
260 } 262 }
261 263
262 wprintf(L"\nPress any key to continue."); 264 wprintf(L"\nPress any key to continue.");
263 while(!_kbhit()) { 265 while(!_kbhit()) {
264 Sleep(100); 266 Sleep(100);
265 } 267 }
266 268
267 return 0; 269 return 0;
268 } 270 }
OLDNEW
« no previous file with comments | « sandbox/win/src/restricted_token_utils.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698