| OLD | NEW |
| 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 272 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 *process_information_out = response.process_information; | 283 *process_information_out = response.process_information; |
| 284 return true; | 284 return true; |
| 285 } | 285 } |
| 286 | 286 |
| 287 // Sends a remote process create request to the execution server. | 287 // Sends a remote process create request to the execution server. |
| 288 bool SendCreateProcessRequest( | 288 bool SendCreateProcessRequest( |
| 289 HANDLE pipe, | 289 HANDLE pipe, |
| 290 const base::FilePath::StringType& application_name, | 290 const base::FilePath::StringType& application_name, |
| 291 const CommandLine::StringType& command_line, | 291 const CommandLine::StringType& command_line, |
| 292 DWORD creation_flags, | 292 DWORD creation_flags, |
| 293 const char16* desktop_name) { | 293 const base::char16* desktop_name) { |
| 294 // |CreateProcessRequest| structure passes the same parameters to | 294 // |CreateProcessRequest| structure passes the same parameters to |
| 295 // the execution server as CreateProcessAsUser() function does. Strings are | 295 // the execution server as CreateProcessAsUser() function does. Strings are |
| 296 // stored as wide strings immediately after the structure. String pointers are | 296 // stored as wide strings immediately after the structure. String pointers are |
| 297 // represented as byte offsets to string data from the beginning of | 297 // represented as byte offsets to string data from the beginning of |
| 298 // the structure. | 298 // the structure. |
| 299 struct CreateProcessRequest { | 299 struct CreateProcessRequest { |
| 300 DWORD size; | 300 DWORD size; |
| 301 DWORD process_id; | 301 DWORD process_id; |
| 302 BOOL use_default_token; | 302 BOOL use_default_token; |
| 303 HANDLE token; | 303 HANDLE token; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 366 } | 366 } |
| 367 | 367 |
| 368 // Requests the execution server to create a process in the specified session | 368 // Requests the execution server to create a process in the specified session |
| 369 // using the default (i.e. Winlogon) token. This routine relies on undocumented | 369 // using the default (i.e. Winlogon) token. This routine relies on undocumented |
| 370 // OS functionality and will likely not work on anything but XP or W2K3. | 370 // OS functionality and will likely not work on anything but XP or W2K3. |
| 371 bool CreateRemoteSessionProcess( | 371 bool CreateRemoteSessionProcess( |
| 372 uint32 session_id, | 372 uint32 session_id, |
| 373 const base::FilePath::StringType& application_name, | 373 const base::FilePath::StringType& application_name, |
| 374 const CommandLine::StringType& command_line, | 374 const CommandLine::StringType& command_line, |
| 375 DWORD creation_flags, | 375 DWORD creation_flags, |
| 376 const char16* desktop_name, | 376 const base::char16* desktop_name, |
| 377 PROCESS_INFORMATION* process_information_out) | 377 PROCESS_INFORMATION* process_information_out) |
| 378 { | 378 { |
| 379 DCHECK_LT(base::win::GetVersion(), base::win::VERSION_VISTA); | 379 DCHECK_LT(base::win::GetVersion(), base::win::VERSION_VISTA); |
| 380 | 380 |
| 381 base::win::ScopedHandle pipe; | 381 base::win::ScopedHandle pipe; |
| 382 if (!ConnectToExecutionServer(session_id, &pipe)) | 382 if (!ConnectToExecutionServer(session_id, &pipe)) |
| 383 return false; | 383 return false; |
| 384 | 384 |
| 385 if (!SendCreateProcessRequest(pipe, application_name, command_line, | 385 if (!SendCreateProcessRequest(pipe, application_name, command_line, |
| 386 creation_flags, desktop_name)) { | 386 creation_flags, desktop_name)) { |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 449 return true; | 449 return true; |
| 450 } | 450 } |
| 451 | 451 |
| 452 bool LaunchProcessWithToken(const base::FilePath& binary, | 452 bool LaunchProcessWithToken(const base::FilePath& binary, |
| 453 const CommandLine::StringType& command_line, | 453 const CommandLine::StringType& command_line, |
| 454 HANDLE user_token, | 454 HANDLE user_token, |
| 455 SECURITY_ATTRIBUTES* process_attributes, | 455 SECURITY_ATTRIBUTES* process_attributes, |
| 456 SECURITY_ATTRIBUTES* thread_attributes, | 456 SECURITY_ATTRIBUTES* thread_attributes, |
| 457 bool inherit_handles, | 457 bool inherit_handles, |
| 458 DWORD creation_flags, | 458 DWORD creation_flags, |
| 459 const char16* desktop_name, | 459 const base::char16* desktop_name, |
| 460 ScopedHandle* process_out, | 460 ScopedHandle* process_out, |
| 461 ScopedHandle* thread_out) { | 461 ScopedHandle* thread_out) { |
| 462 base::FilePath::StringType application_name = binary.value(); | 462 base::FilePath::StringType application_name = binary.value(); |
| 463 | 463 |
| 464 STARTUPINFOW startup_info; | 464 STARTUPINFOW startup_info; |
| 465 memset(&startup_info, 0, sizeof(startup_info)); | 465 memset(&startup_info, 0, sizeof(startup_info)); |
| 466 startup_info.cb = sizeof(startup_info); | 466 startup_info.cb = sizeof(startup_info); |
| 467 if (desktop_name) | 467 if (desktop_name) |
| 468 startup_info.lpDesktop = const_cast<char16*>(desktop_name); | 468 startup_info.lpDesktop = const_cast<base::char16*>(desktop_name); |
| 469 | 469 |
| 470 PROCESS_INFORMATION temp_process_info = {}; | 470 PROCESS_INFORMATION temp_process_info = {}; |
| 471 BOOL result = CreateProcessAsUser(user_token, | 471 BOOL result = CreateProcessAsUser(user_token, |
| 472 application_name.c_str(), | 472 application_name.c_str(), |
| 473 const_cast<LPWSTR>(command_line.c_str()), | 473 const_cast<LPWSTR>(command_line.c_str()), |
| 474 process_attributes, | 474 process_attributes, |
| 475 thread_attributes, | 475 thread_attributes, |
| 476 inherit_handles, | 476 inherit_handles, |
| 477 creation_flags, | 477 creation_flags, |
| 478 NULL, | 478 NULL, |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 518 | 518 |
| 519 base::win::ScopedProcessInformation process_info(temp_process_info); | 519 base::win::ScopedProcessInformation process_info(temp_process_info); |
| 520 | 520 |
| 521 CHECK(process_info.IsValid()); | 521 CHECK(process_info.IsValid()); |
| 522 process_out->Set(process_info.TakeProcessHandle()); | 522 process_out->Set(process_info.TakeProcessHandle()); |
| 523 thread_out->Set(process_info.TakeThreadHandle()); | 523 thread_out->Set(process_info.TakeThreadHandle()); |
| 524 return true; | 524 return true; |
| 525 } | 525 } |
| 526 | 526 |
| 527 } // namespace remoting | 527 } // namespace remoting |
| OLD | NEW |