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 <stddef.h> | 8 #include <stddef.h> |
9 #include <winternl.h> | 9 #include <winternl.h> |
10 | 10 |
11 #include <limits> | 11 #include <limits> |
| 12 #include <memory> |
12 #include <utility> | 13 #include <utility> |
13 | 14 |
14 #include "base/logging.h" | 15 #include "base/logging.h" |
15 #include "base/memory/scoped_ptr.h" | |
16 #include "base/rand_util.h" | 16 #include "base/rand_util.h" |
17 #include "base/scoped_native_library.h" | 17 #include "base/scoped_native_library.h" |
18 #include "base/strings/string16.h" | 18 #include "base/strings/string16.h" |
19 #include "base/strings/stringprintf.h" | 19 #include "base/strings/stringprintf.h" |
20 #include "base/strings/utf_string_conversions.h" | 20 #include "base/strings/utf_string_conversions.h" |
21 #include "base/win/scoped_handle.h" | 21 #include "base/win/scoped_handle.h" |
22 #include "base/win/scoped_process_information.h" | 22 #include "base/win/scoped_process_information.h" |
23 #include "base/win/windows_version.h" | 23 #include "base/win/windows_version.h" |
24 | 24 |
25 using base::win::ScopedHandle; | 25 using base::win::ScopedHandle; |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 }; | 316 }; |
317 | 317 |
318 base::string16 desktop; | 318 base::string16 desktop; |
319 if (desktop_name) | 319 if (desktop_name) |
320 desktop = desktop_name; | 320 desktop = desktop_name; |
321 | 321 |
322 // Allocate a large enough buffer to hold the CreateProcessRequest structure | 322 // Allocate a large enough buffer to hold the CreateProcessRequest structure |
323 // and three nullptr-terminated string parameters. | 323 // and three nullptr-terminated string parameters. |
324 size_t size = sizeof(CreateProcessRequest) + sizeof(wchar_t) * | 324 size_t size = sizeof(CreateProcessRequest) + sizeof(wchar_t) * |
325 (application_name.size() + command_line.size() + desktop.size() + 3); | 325 (application_name.size() + command_line.size() + desktop.size() + 3); |
326 scoped_ptr<char[]> buffer(new char[size]); | 326 std::unique_ptr<char[]> buffer(new char[size]); |
327 memset(buffer.get(), 0, size); | 327 memset(buffer.get(), 0, size); |
328 | 328 |
329 // Marshal the input parameters. | 329 // Marshal the input parameters. |
330 CreateProcessRequest* request = | 330 CreateProcessRequest* request = |
331 reinterpret_cast<CreateProcessRequest*>(buffer.get()); | 331 reinterpret_cast<CreateProcessRequest*>(buffer.get()); |
332 request->size = size; | 332 request->size = size; |
333 request->process_id = GetCurrentProcessId(); | 333 request->process_id = GetCurrentProcessId(); |
334 request->use_default_token = TRUE; | 334 request->use_default_token = TRUE; |
335 // Always pass CREATE_SUSPENDED to avoid a race between the created process | 335 // Always pass CREATE_SUSPENDED to avoid a race between the created process |
336 // exiting too soon and OpenProcess() call below. | 336 // exiting too soon and OpenProcess() call below. |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 | 517 |
518 base::win::ScopedProcessInformation process_info(temp_process_info); | 518 base::win::ScopedProcessInformation process_info(temp_process_info); |
519 | 519 |
520 CHECK(process_info.IsValid()); | 520 CHECK(process_info.IsValid()); |
521 process_out->Set(process_info.TakeProcessHandle()); | 521 process_out->Set(process_info.TakeProcessHandle()); |
522 thread_out->Set(process_info.TakeThreadHandle()); | 522 thread_out->Set(process_info.TakeThreadHandle()); |
523 return true; | 523 return true; |
524 } | 524 } |
525 | 525 |
526 } // namespace remoting | 526 } // namespace remoting |
OLD | NEW |