| 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 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 } // namespace sandbox | 54 } // namespace sandbox |
| 55 | 55 |
| 56 // We must receive two arguments: the process id of the target to intercept and | 56 // We must receive two arguments: the process id of the target to intercept and |
| 57 // the address of a page of memory on that process that will be used for the | 57 // the address of a page of memory on that process that will be used for the |
| 58 // interception. We receive the address because the broker will cleanup the | 58 // interception. We receive the address because the broker will cleanup the |
| 59 // patch when the work is performed. | 59 // patch when the work is performed. |
| 60 // | 60 // |
| 61 // It should be noted that we don't wait until the real work is done; this | 61 // It should be noted that we don't wait until the real work is done; this |
| 62 // program quits as soon as the 64-bit interception is performed. | 62 // program quits as soon as the 64-bit interception is performed. |
| 63 int wWinMain(HINSTANCE, HINSTANCE, wchar_t* command_line, int) { | 63 int wWinMain(HINSTANCE, HINSTANCE, wchar_t* command_line, int) { |
| 64 COMPILE_ASSERT(sizeof(void*) > sizeof(DWORD), unsupported_32_bits); | 64 static_assert(sizeof(void*) > sizeof(DWORD), "unsupported 32 bits"); |
| 65 if (!command_line) | 65 if (!command_line) |
| 66 return 1; | 66 return 1; |
| 67 | 67 |
| 68 wchar_t* next; | 68 wchar_t* next; |
| 69 DWORD process_id = wcstoul(command_line, &next, 0); | 69 DWORD process_id = wcstoul(command_line, &next, 0); |
| 70 if (!process_id) | 70 if (!process_id) |
| 71 return 2; | 71 return 2; |
| 72 | 72 |
| 73 DWORD access = PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE; | 73 DWORD access = PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE; |
| 74 HANDLE child = ::OpenProcess(access, FALSE, process_id); | 74 HANDLE child = ::OpenProcess(access, FALSE, process_id); |
| 75 if (!child) | 75 if (!child) |
| 76 return 3; | 76 return 3; |
| 77 | 77 |
| 78 DWORD buffer = wcstoul(next, NULL, 0); | 78 DWORD buffer = wcstoul(next, NULL, 0); |
| 79 if (!buffer) | 79 if (!buffer) |
| 80 return 4; | 80 return 4; |
| 81 | 81 |
| 82 void* thunk = reinterpret_cast<void*>(static_cast<ULONG_PTR>(buffer)); | 82 void* thunk = reinterpret_cast<void*>(static_cast<ULONG_PTR>(buffer)); |
| 83 | 83 |
| 84 const size_t kPageSize = 4096; | 84 const size_t kPageSize = 4096; |
| 85 return sandbox::PatchNtdll(child, thunk, kPageSize); | 85 return sandbox::PatchNtdll(child, thunk, kPageSize); |
| 86 } | 86 } |
| OLD | NEW |