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

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

Issue 12163003: Add FilePath to base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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
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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 57 }
58 } 58 }
59 59
60 // Connects to the executor server corresponding to |session_id|. 60 // Connects to the executor server corresponding to |session_id|.
61 bool ConnectToExecutionServer(uint32 session_id, 61 bool ConnectToExecutionServer(uint32 session_id,
62 base::win::ScopedHandle* pipe_out) { 62 base::win::ScopedHandle* pipe_out) {
63 string16 pipe_name; 63 string16 pipe_name;
64 64
65 // Use winsta!WinStationQueryInformationW() to determine the process creation 65 // Use winsta!WinStationQueryInformationW() to determine the process creation
66 // pipe name for the session. 66 // pipe name for the session.
67 FilePath winsta_path(base::GetNativeLibraryName(UTF8ToUTF16("winsta"))); 67 base::FilePath winsta_path(base::GetNativeLibraryName(UTF8ToUTF16("winsta")));
68 base::ScopedNativeLibrary winsta(winsta_path); 68 base::ScopedNativeLibrary winsta(winsta_path);
69 if (winsta.is_valid()) { 69 if (winsta.is_valid()) {
70 PWINSTATIONQUERYINFORMATIONW win_station_query_information = 70 PWINSTATIONQUERYINFORMATIONW win_station_query_information =
71 static_cast<PWINSTATIONQUERYINFORMATIONW>( 71 static_cast<PWINSTATIONQUERYINFORMATIONW>(
72 winsta.GetFunctionPointer("WinStationQueryInformationW")); 72 winsta.GetFunctionPointer("WinStationQueryInformationW"));
73 if (win_station_query_information) { 73 if (win_station_query_information) {
74 wchar_t name[MAX_PATH]; 74 wchar_t name[MAX_PATH];
75 ULONG name_length; 75 ULONG name_length;
76 if (win_station_query_information(0, 76 if (win_station_query_information(0,
77 session_id, 77 session_id,
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 return false; 286 return false;
287 } 287 }
288 288
289 *process_information_out = response.process_information; 289 *process_information_out = response.process_information;
290 return true; 290 return true;
291 } 291 }
292 292
293 // Sends a remote process create request to the execution server. 293 // Sends a remote process create request to the execution server.
294 bool SendCreateProcessRequest( 294 bool SendCreateProcessRequest(
295 HANDLE pipe, 295 HANDLE pipe,
296 const FilePath::StringType& application_name, 296 const base::FilePath::StringType& application_name,
297 const CommandLine::StringType& command_line, 297 const CommandLine::StringType& command_line,
298 DWORD creation_flags, 298 DWORD creation_flags,
299 const char16* desktop_name) { 299 const char16* desktop_name) {
300 // |CreateProcessRequest| structure passes the same parameters to 300 // |CreateProcessRequest| structure passes the same parameters to
301 // the execution server as CreateProcessAsUser() function does. Strings are 301 // the execution server as CreateProcessAsUser() function does. Strings are
302 // stored as wide strings immediately after the structure. String pointers are 302 // stored as wide strings immediately after the structure. String pointers are
303 // represented as byte offsets to string data from the beginning of 303 // represented as byte offsets to string data from the beginning of
304 // the structure. 304 // the structure.
305 struct CreateProcessRequest { 305 struct CreateProcessRequest {
306 DWORD size; 306 DWORD size;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 } 369 }
370 370
371 return true; 371 return true;
372 } 372 }
373 373
374 // Requests the execution server to create a process in the specified session 374 // Requests the execution server to create a process in the specified session
375 // using the default (i.e. Winlogon) token. This routine relies on undocumented 375 // using the default (i.e. Winlogon) token. This routine relies on undocumented
376 // OS functionality and will likely not work on anything but XP or W2K3. 376 // OS functionality and will likely not work on anything but XP or W2K3.
377 bool CreateRemoteSessionProcess( 377 bool CreateRemoteSessionProcess(
378 uint32 session_id, 378 uint32 session_id,
379 const FilePath::StringType& application_name, 379 const base::FilePath::StringType& application_name,
380 const CommandLine::StringType& command_line, 380 const CommandLine::StringType& command_line,
381 DWORD creation_flags, 381 DWORD creation_flags,
382 const char16* desktop_name, 382 const char16* desktop_name,
383 PROCESS_INFORMATION* process_information_out) 383 PROCESS_INFORMATION* process_information_out)
384 { 384 {
385 DCHECK_LT(base::win::GetVersion(), base::win::VERSION_VISTA); 385 DCHECK_LT(base::win::GetVersion(), base::win::VERSION_VISTA);
386 386
387 base::win::ScopedHandle pipe; 387 base::win::ScopedHandle pipe;
388 if (!ConnectToExecutionServer(session_id, &pipe)) 388 if (!ConnectToExecutionServer(session_id, &pipe))
389 return false; 389 return false;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
545 return false; 545 return false;
546 } 546 }
547 547
548 // Revert to the default token. 548 // Revert to the default token.
549 CHECK(RevertToSelf()); 549 CHECK(RevertToSelf());
550 550
551 *token_out = session_token.Pass(); 551 *token_out = session_token.Pass();
552 return true; 552 return true;
553 } 553 }
554 554
555 bool LaunchProcessWithToken(const FilePath& binary, 555 bool LaunchProcessWithToken(const base::FilePath& binary,
556 const CommandLine::StringType& command_line, 556 const CommandLine::StringType& command_line,
557 HANDLE user_token, 557 HANDLE user_token,
558 SECURITY_ATTRIBUTES* process_attributes, 558 SECURITY_ATTRIBUTES* process_attributes,
559 SECURITY_ATTRIBUTES* thread_attributes, 559 SECURITY_ATTRIBUTES* thread_attributes,
560 bool inherit_handles, 560 bool inherit_handles,
561 DWORD creation_flags, 561 DWORD creation_flags,
562 const char16* desktop_name, 562 const char16* desktop_name,
563 ScopedHandle* process_out, 563 ScopedHandle* process_out,
564 ScopedHandle* thread_out) { 564 ScopedHandle* thread_out) {
565 FilePath::StringType application_name = binary.value(); 565 base::FilePath::StringType application_name = binary.value();
566 566
567 STARTUPINFOW startup_info; 567 STARTUPINFOW startup_info;
568 memset(&startup_info, 0, sizeof(startup_info)); 568 memset(&startup_info, 0, sizeof(startup_info));
569 startup_info.cb = sizeof(startup_info); 569 startup_info.cb = sizeof(startup_info);
570 if (desktop_name) 570 if (desktop_name)
571 startup_info.lpDesktop = const_cast<char16*>(desktop_name); 571 startup_info.lpDesktop = const_cast<char16*>(desktop_name);
572 572
573 base::win::ScopedProcessInformation process_info; 573 base::win::ScopedProcessInformation process_info;
574 BOOL result = CreateProcessAsUser(user_token, 574 BOOL result = CreateProcessAsUser(user_token,
575 application_name.c_str(), 575 application_name.c_str(),
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
OLDNEW
« no previous file with comments | « remoting/host/win/launch_process_with_token.h ('k') | remoting/host/win/unprivileged_process_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698