| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "sandbox/src/wow64.h" | 5 #include "sandbox/src/wow64.h" |
| 6 | 6 |
| 7 #include <sstream> | 7 #include <sstream> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "base/win/scoped_process_information.h" |
| 11 #include "base/win/windows_version.h" | 12 #include "base/win/windows_version.h" |
| 12 #include "sandbox/src/target_process.h" | 13 #include "sandbox/src/target_process.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 // Holds the information needed for the interception of NtMapViewOfSection on | 17 // Holds the information needed for the interception of NtMapViewOfSection on |
| 17 // 64 bits. | 18 // 64 bits. |
| 18 // Warning: do not modify this definition without changing also the code on the | 19 // Warning: do not modify this definition without changing also the code on the |
| 19 // 64 bit helper process. | 20 // 64 bit helper process. |
| 20 struct PatchInfo32 { | 21 struct PatchInfo32 { |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 | 150 |
| 150 std::wstringstream command; | 151 std::wstringstream command; |
| 151 command << std::hex << std::showbase << L"\"" << path << | 152 command << std::hex << std::showbase << L"\"" << path << |
| 152 L"wow_helper.exe\" " << child_->ProcessId() << " " << | 153 L"wow_helper.exe\" " << child_->ProcessId() << " " << |
| 153 bit_cast<ULONG>(buffer); | 154 bit_cast<ULONG>(buffer); |
| 154 | 155 |
| 155 scoped_ptr_malloc<wchar_t> writable_command(_wcsdup(command.str().c_str())); | 156 scoped_ptr_malloc<wchar_t> writable_command(_wcsdup(command.str().c_str())); |
| 156 | 157 |
| 157 STARTUPINFO startup_info = {0}; | 158 STARTUPINFO startup_info = {0}; |
| 158 startup_info.cb = sizeof(startup_info); | 159 startup_info.cb = sizeof(startup_info); |
| 159 PROCESS_INFORMATION process_info; | 160 base::win::ScopedProcessInformation process_info; |
| 160 if (!::CreateProcess(NULL, writable_command.get(), NULL, NULL, FALSE, 0, NULL, | 161 if (!::CreateProcess(NULL, writable_command.get(), NULL, NULL, FALSE, 0, NULL, |
| 161 NULL, &startup_info, &process_info)) | 162 NULL, &startup_info, process_info.Receive())) |
| 162 return false; | 163 return false; |
| 163 | 164 |
| 164 DWORD reason = ::WaitForSingleObject(process_info.hProcess, INFINITE); | 165 DWORD reason = ::WaitForSingleObject(process_info.process_handle(), INFINITE); |
| 165 | 166 |
| 166 DWORD code; | 167 DWORD code; |
| 167 bool ok = ::GetExitCodeProcess(process_info.hProcess, &code) ? true : false; | 168 bool ok = |
| 168 | 169 ::GetExitCodeProcess(process_info.process_handle(), &code) ? true : false; |
| 169 ::CloseHandle(process_info.hProcess); | |
| 170 ::CloseHandle(process_info.hThread); | |
| 171 | 170 |
| 172 if (WAIT_TIMEOUT == reason) | 171 if (WAIT_TIMEOUT == reason) |
| 173 return false; | 172 return false; |
| 174 | 173 |
| 175 return ok && (0 == code); | 174 return ok && (0 == code); |
| 176 } | 175 } |
| 177 | 176 |
| 178 // First we must wake up the child, then wait for dll loads on the child until | 177 // First we must wake up the child, then wait for dll loads on the child until |
| 179 // the one we care is loaded; at that point we must suspend the child again. | 178 // the one we care is loaded; at that point we must suspend the child again. |
| 180 bool Wow64::DllMapped() { | 179 bool Wow64::DllMapped() { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 211 SIZE_T read; | 210 SIZE_T read; |
| 212 if (!::ReadProcessMemory(child_->Process(), ntdll_, &buffer, kBufferSize, | 211 if (!::ReadProcessMemory(child_->Process(), ntdll_, &buffer, kBufferSize, |
| 213 &read)) | 212 &read)) |
| 214 return false; | 213 return false; |
| 215 if (kBufferSize != read) | 214 if (kBufferSize != read) |
| 216 return false; | 215 return false; |
| 217 return true; | 216 return true; |
| 218 } | 217 } |
| 219 | 218 |
| 220 } // namespace sandbox | 219 } // namespace sandbox |
| OLD | NEW |