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

Side by Side Diff: test/win/child_launcher.cc

Issue 1352323002: win: Make reading NT_IMAGE_HEADERS work cross-bitness (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@cleanup-crashpad-info
Patch Set: . Created 5 years, 3 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
OLDNEW
(Empty)
1 // Copyright 2015 The Crashpad Authors. All rights reserved.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 #include "test/win/child_launcher.h"
16
17 #include "gtest/gtest.h"
18
19 namespace crashpad {
20
21 ChildLauncher::ChildLauncher(const std::wstring& executable,
22 const std::wstring& command_line)
23 : executable_(executable),
24 command_line_(command_line),
25 process_handle_(),
26 main_thread_handle_(),
27 stdout_read_handle_() {
28 }
29
30 ChildLauncher::~ChildLauncher() {
31 EXPECT_EQ(WAIT_OBJECT_0,
32 WaitForSingleObject(process_handle_.get(), INFINITE));
33 }
34
35 void ChildLauncher::Start() {
36 // Create a pipe for the stdout of the child.
37 SECURITY_ATTRIBUTES security_attributes = {0};
38 security_attributes.nLength = sizeof(SECURITY_ATTRIBUTES);
39 security_attributes.bInheritHandle = true;
40 HANDLE stdout_read;
41 HANDLE stdout_write;
42 ASSERT_TRUE(CreatePipe(&stdout_read, &stdout_write, &security_attributes, 0));
43 stdout_read_handle_.reset(stdout_read);
Mark Mentovai 2015/09/19 03:02:47 ASSERT_FALSE(stdout_read_handle_) first to ensure
scottmg 2015/09/19 04:24:41 Done.
44 ScopedFileHANDLE write_handle(stdout_write);
45 ASSERT_TRUE(
46 SetHandleInformation(stdout_read_handle_.get(), HANDLE_FLAG_INHERIT, 0));
47
48 STARTUPINFO startup_info = {0};
49 startup_info.cb = sizeof(startup_info);
50 startup_info.hStdInput = GetStdHandle(STD_INPUT_HANDLE);
51 startup_info.hStdOutput = write_handle.get();
52 startup_info.hStdError = GetStdHandle(STD_ERROR_HANDLE);
53 startup_info.dwFlags = STARTF_USESTDHANDLES;
54 PROCESS_INFORMATION process_information;
55 std::wstring command_line = executable_ + L" " + command_line_;
Mark Mentovai 2015/09/19 03:02:47 Some sort of escaping (CRT-compatible, I guess) sh
scottmg 2015/09/19 04:24:41 Done.
56 ASSERT_TRUE(CreateProcess(executable_.c_str(),
57 &command_line[0],
58 nullptr,
59 nullptr,
60 true,
61 0,
62 nullptr,
63 nullptr,
64 &startup_info,
65 &process_information));
66 // Take ownership of the two process handles returned.
67 main_thread_handle_.reset(process_information.hThread);
68 process_handle_.reset(process_information.hProcess);
69 }
70
71 } // namespace crashpad
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698