| 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 <sddl.h> | 8 #include <sddl.h> |
| 9 #include <winternl.h> | 9 #include <winternl.h> |
| 10 | 10 |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 // Requests the execution server to create a process in the specified session | 373 // Requests the execution server to create a process in the specified session |
| 374 // using the default (i.e. Winlogon) token. This routine relies on undocumented | 374 // using the default (i.e. Winlogon) token. This routine relies on undocumented |
| 375 // OS functionality and will likely not work on anything but XP or W2K3. | 375 // OS functionality and will likely not work on anything but XP or W2K3. |
| 376 bool CreateRemoteSessionProcess( | 376 bool CreateRemoteSessionProcess( |
| 377 uint32 session_id, | 377 uint32 session_id, |
| 378 const FilePath::StringType& application_name, | 378 const FilePath::StringType& application_name, |
| 379 const CommandLine::StringType& command_line, | 379 const CommandLine::StringType& command_line, |
| 380 DWORD creation_flags, | 380 DWORD creation_flags, |
| 381 PROCESS_INFORMATION* process_information_out) | 381 PROCESS_INFORMATION* process_information_out) |
| 382 { | 382 { |
| 383 DCHECK(base::win::GetVersion() == base::win::VERSION_XP); | 383 DCHECK_LT(base::win::GetVersion(), base::win::VERSION_VISTA); |
| 384 | 384 |
| 385 base::win::ScopedHandle pipe; | 385 base::win::ScopedHandle pipe; |
| 386 if (!ConnectToExecutionServer(session_id, &pipe)) | 386 if (!ConnectToExecutionServer(session_id, &pipe)) |
| 387 return false; | 387 return false; |
| 388 | 388 |
| 389 if (!SendCreateProcessRequest(pipe, application_name, command_line, | 389 if (!SendCreateProcessRequest(pipe, application_name, command_line, |
| 390 creation_flags)) { | 390 creation_flags)) { |
| 391 return false; | 391 return false; |
| 392 } | 392 } |
| 393 | 393 |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 585 process_info.Receive()); | 585 process_info.Receive()); |
| 586 | 586 |
| 587 // CreateProcessAsUser will fail on XP and W2K3 with ERROR_PIPE_NOT_CONNECTED | 587 // CreateProcessAsUser will fail on XP and W2K3 with ERROR_PIPE_NOT_CONNECTED |
| 588 // if the user hasn't logged to the target session yet. In such a case | 588 // if the user hasn't logged to the target session yet. In such a case |
| 589 // we try to talk to the execution server directly emulating what | 589 // we try to talk to the execution server directly emulating what |
| 590 // the undocumented and not-exported advapi32!CreateRemoteSessionProcessW() | 590 // the undocumented and not-exported advapi32!CreateRemoteSessionProcessW() |
| 591 // function does. The created process will run under Winlogon'a token instead | 591 // function does. The created process will run under Winlogon'a token instead |
| 592 // of |user_token|. Since Winlogon runs as SYSTEM, this suits our needs. | 592 // of |user_token|. Since Winlogon runs as SYSTEM, this suits our needs. |
| 593 if (!result && | 593 if (!result && |
| 594 GetLastError() == ERROR_PIPE_NOT_CONNECTED && | 594 GetLastError() == ERROR_PIPE_NOT_CONNECTED && |
| 595 base::win::GetVersion() == base::win::VERSION_XP) { | 595 base::win::GetVersion() < base::win::VERSION_VISTA) { |
| 596 DWORD session_id; | 596 DWORD session_id; |
| 597 DWORD return_length; | 597 DWORD return_length; |
| 598 result = GetTokenInformation(user_token, | 598 result = GetTokenInformation(user_token, |
| 599 TokenSessionId, | 599 TokenSessionId, |
| 600 &session_id, | 600 &session_id, |
| 601 sizeof(session_id), | 601 sizeof(session_id), |
| 602 &return_length); | 602 &return_length); |
| 603 if (result && session_id != 0) { | 603 if (result && session_id != 0) { |
| 604 result = CreateRemoteSessionProcess(session_id, | 604 result = CreateRemoteSessionProcess(session_id, |
| 605 application_name, | 605 application_name, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 619 return false; | 619 return false; |
| 620 } | 620 } |
| 621 | 621 |
| 622 CHECK(process_info.IsValid()); | 622 CHECK(process_info.IsValid()); |
| 623 process_out->Set(process_info.TakeProcessHandle()); | 623 process_out->Set(process_info.TakeProcessHandle()); |
| 624 thread_out->Set(process_info.TakeThreadHandle()); | 624 thread_out->Set(process_info.TakeThreadHandle()); |
| 625 return true; | 625 return true; |
| 626 } | 626 } |
| 627 | 627 |
| 628 } // namespace remoting | 628 } // namespace remoting |
| OLD | NEW |