| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 // Wow_helper.exe is a simple Win32 64-bit executable designed to help to | 5 // Wow_helper.exe is a simple Win32 64-bit executable designed to help to |
| 6 // sandbox a 32 bit application running on a 64 bit OS. The basic idea is to | 6 // sandbox a 32 bit application running on a 64 bit OS. The basic idea is to |
| 7 // perform a 64 bit interception of the target process and notify the 32-bit | 7 // perform a 64 bit interception of the target process and notify the 32-bit |
| 8 // broker process whenever a DLL is being loaded. This allows the broker to | 8 // broker process whenever a DLL is being loaded. This allows the broker to |
| 9 // setup the interceptions (32-bit) properly on the target. | 9 // setup the interceptions (32-bit) properly on the target. |
| 10 | 10 |
| 11 #include <windows.h> | 11 #include <windows.h> |
| 12 | 12 |
| 13 #include <string> | 13 #include <string> |
| 14 | 14 |
| 15 #include "base/logging.h" | |
| 16 #include "sandbox/wow_helper/service64_resolver.h" | 15 #include "sandbox/wow_helper/service64_resolver.h" |
| 17 #include "sandbox/wow_helper/target_code.h" | 16 #include "sandbox/wow_helper/target_code.h" |
| 18 | 17 |
| 19 namespace { | 18 namespace { |
| 20 | 19 |
| 21 // Grabbed from chrome/common/string_util.h | 20 // Grabbed from chrome/common/string_util.h |
| 22 template <class char_type> | 21 template <class char_type> |
| 23 inline char_type* WriteInto( | 22 inline char_type* WriteInto( |
| 24 std::basic_string<char_type, std::char_traits<char_type>, | 23 std::basic_string<char_type, std::char_traits<char_type>, |
| 25 std::allocator<char_type> >* str, | 24 std::allocator<char_type> >* str, |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 if (!command_line) | 104 if (!command_line) |
| 106 return 1; | 105 return 1; |
| 107 | 106 |
| 108 wchar_t* next; | 107 wchar_t* next; |
| 109 DWORD process_id = wcstoul(command_line, &next, 0); | 108 DWORD process_id = wcstoul(command_line, &next, 0); |
| 110 if (!process_id) | 109 if (!process_id) |
| 111 return 2; | 110 return 2; |
| 112 | 111 |
| 113 DWORD access = PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE; | 112 DWORD access = PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE; |
| 114 HANDLE child = ::OpenProcess(access, FALSE, process_id); | 113 HANDLE child = ::OpenProcess(access, FALSE, process_id); |
| 115 DCHECK(child); | |
| 116 if (!child) | 114 if (!child) |
| 117 return 3; | 115 return 3; |
| 118 | 116 |
| 119 DWORD buffer = wcstoul(next, NULL, 0); | 117 DWORD buffer = wcstoul(next, NULL, 0); |
| 120 if (!buffer) | 118 if (!buffer) |
| 121 return 4; | 119 return 4; |
| 122 | 120 |
| 123 void* thunk = reinterpret_cast<void*>(static_cast<ULONG_PTR>(buffer)); | 121 void* thunk = reinterpret_cast<void*>(static_cast<ULONG_PTR>(buffer)); |
| 124 | 122 |
| 125 const size_t kPageSize = 4096; | 123 const size_t kPageSize = 4096; |
| 126 return sandbox::PatchNtdll(child, thunk, kPageSize); | 124 return sandbox::PatchNtdll(child, thunk, kPageSize); |
| 127 } | 125 } |
| 128 | 126 |
| OLD | NEW |