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

Side by Side Diff: remoting/host/win/launch_process_with_token.cc

Issue 290173011: Cleanup: Use base::CommandLine in remoting/ (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « remoting/host/win/host_service.cc ('k') | remoting/host/win/unprivileged_process_delegate.cc » ('j') | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "remoting/host/win/launch_process_with_token.h" 5 #include "remoting/host/win/launch_process_with_token.h"
6 6
7 #include <windows.h> 7 #include <windows.h>
8 #include <winternl.h> 8 #include <winternl.h>
9 9
10 #include <limits> 10 #include <limits>
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 } 280 }
281 281
282 *process_information_out = response.process_information; 282 *process_information_out = response.process_information;
283 return true; 283 return true;
284 } 284 }
285 285
286 // Sends a remote process create request to the execution server. 286 // Sends a remote process create request to the execution server.
287 bool SendCreateProcessRequest( 287 bool SendCreateProcessRequest(
288 HANDLE pipe, 288 HANDLE pipe,
289 const base::FilePath::StringType& application_name, 289 const base::FilePath::StringType& application_name,
290 const CommandLine::StringType& command_line, 290 const base::CommandLine::StringType& command_line,
291 DWORD creation_flags, 291 DWORD creation_flags,
292 const base::char16* desktop_name) { 292 const base::char16* desktop_name) {
293 // |CreateProcessRequest| structure passes the same parameters to 293 // |CreateProcessRequest| structure passes the same parameters to
294 // the execution server as CreateProcessAsUser() function does. Strings are 294 // the execution server as CreateProcessAsUser() function does. Strings are
295 // stored as wide strings immediately after the structure. String pointers are 295 // stored as wide strings immediately after the structure. String pointers are
296 // represented as byte offsets to string data from the beginning of 296 // represented as byte offsets to string data from the beginning of
297 // the structure. 297 // the structure.
298 struct CreateProcessRequest { 298 struct CreateProcessRequest {
299 DWORD size; 299 DWORD size;
300 DWORD process_id; 300 DWORD process_id;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 363
364 return true; 364 return true;
365 } 365 }
366 366
367 // Requests the execution server to create a process in the specified session 367 // Requests the execution server to create a process in the specified session
368 // using the default (i.e. Winlogon) token. This routine relies on undocumented 368 // using the default (i.e. Winlogon) token. This routine relies on undocumented
369 // OS functionality and will likely not work on anything but XP or W2K3. 369 // OS functionality and will likely not work on anything but XP or W2K3.
370 bool CreateRemoteSessionProcess( 370 bool CreateRemoteSessionProcess(
371 uint32 session_id, 371 uint32 session_id,
372 const base::FilePath::StringType& application_name, 372 const base::FilePath::StringType& application_name,
373 const CommandLine::StringType& command_line, 373 const base::CommandLine::StringType& command_line,
374 DWORD creation_flags, 374 DWORD creation_flags,
375 const base::char16* desktop_name, 375 const base::char16* desktop_name,
376 PROCESS_INFORMATION* process_information_out) 376 PROCESS_INFORMATION* process_information_out) {
377 {
378 DCHECK_LT(base::win::GetVersion(), base::win::VERSION_VISTA); 377 DCHECK_LT(base::win::GetVersion(), base::win::VERSION_VISTA);
379 378
380 base::win::ScopedHandle pipe; 379 base::win::ScopedHandle pipe;
381 if (!ConnectToExecutionServer(session_id, &pipe)) 380 if (!ConnectToExecutionServer(session_id, &pipe))
382 return false; 381 return false;
383 382
384 if (!SendCreateProcessRequest(pipe, application_name, command_line, 383 if (!SendCreateProcessRequest(pipe, application_name, command_line,
385 creation_flags, desktop_name)) { 384 creation_flags, desktop_name)) {
386 return false; 385 return false;
387 } 386 }
388 387
389 PROCESS_INFORMATION process_information; 388 PROCESS_INFORMATION process_information;
390 if (!ReceiveCreateProcessResponse(pipe, &process_information)) 389 if (!ReceiveCreateProcessResponse(pipe, &process_information))
391 return false; 390 return false;
392 391
393 if (!ProcessCreateProcessResponse(creation_flags, &process_information)) { 392 if (!ProcessCreateProcessResponse(creation_flags, &process_information)) {
394 CloseHandlesAndTerminateProcess(&process_information); 393 CloseHandlesAndTerminateProcess(&process_information);
395 return false; 394 return false;
396 } 395 }
397 396
398 *process_information_out = process_information; 397 *process_information_out = process_information;
399 return true; 398 return true;
400 } 399 }
401 400
402 } // namespace 401 } // namespace
403 402
404 namespace remoting { 403 namespace remoting {
405 404
406 base::LazyInstance<base::Lock>::Leaky g_inherit_handles_lock = 405 base::LazyInstance<base::Lock>::Leaky g_inherit_handles_lock =
407 LAZY_INSTANCE_INITIALIZER; 406 LAZY_INSTANCE_INITIALIZER;
408 407
409 // Creates a copy of the current process token for the given |session_id| so 408 // Creates a copy of the current process token for the given |session_id| so
410 // it can be used to launch a process in that session. 409 // it can be used to launch a process in that session.
411 bool CreateSessionToken(uint32 session_id, ScopedHandle* token_out) { 410 bool CreateSessionToken(uint32 session_id, ScopedHandle* token_out) {
412 ScopedHandle session_token; 411 ScopedHandle session_token;
(...skipping 28 matching lines...) Expand all
441 } 440 }
442 441
443 // Revert to the default token. 442 // Revert to the default token.
444 CHECK(RevertToSelf()); 443 CHECK(RevertToSelf());
445 444
446 *token_out = session_token.Pass(); 445 *token_out = session_token.Pass();
447 return true; 446 return true;
448 } 447 }
449 448
450 bool LaunchProcessWithToken(const base::FilePath& binary, 449 bool LaunchProcessWithToken(const base::FilePath& binary,
451 const CommandLine::StringType& command_line, 450 const base::CommandLine::StringType& command_line,
452 HANDLE user_token, 451 HANDLE user_token,
453 SECURITY_ATTRIBUTES* process_attributes, 452 SECURITY_ATTRIBUTES* process_attributes,
454 SECURITY_ATTRIBUTES* thread_attributes, 453 SECURITY_ATTRIBUTES* thread_attributes,
455 bool inherit_handles, 454 bool inherit_handles,
456 DWORD creation_flags, 455 DWORD creation_flags,
457 const base::char16* desktop_name, 456 const base::char16* desktop_name,
458 ScopedHandle* process_out, 457 ScopedHandle* process_out,
459 ScopedHandle* thread_out) { 458 ScopedHandle* thread_out) {
460 base::FilePath::StringType application_name = binary.value(); 459 base::FilePath::StringType application_name = binary.value();
461 460
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 } 513 }
515 514
516 base::win::ScopedProcessInformation process_info(temp_process_info); 515 base::win::ScopedProcessInformation process_info(temp_process_info);
517 516
518 CHECK(process_info.IsValid()); 517 CHECK(process_info.IsValid());
519 process_out->Set(process_info.TakeProcessHandle()); 518 process_out->Set(process_info.TakeProcessHandle());
520 thread_out->Set(process_info.TakeThreadHandle()); 519 thread_out->Set(process_info.TakeThreadHandle());
521 return true; 520 return true;
522 } 521 }
523 522
524 } // namespace remoting 523 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/win/host_service.cc ('k') | remoting/host/win/unprivileged_process_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698