OLD | NEW |
1 // Copyright (c) 2006-2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2010 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/target_process.h" | 5 #include "sandbox/src/target_process.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/pe_image.h" | |
9 #include "base/scoped_ptr.h" | 8 #include "base/scoped_ptr.h" |
| 9 #include "base/win/pe_image.h" |
10 #include "sandbox/src/crosscall_server.h" | 10 #include "sandbox/src/crosscall_server.h" |
11 #include "sandbox/src/crosscall_client.h" | 11 #include "sandbox/src/crosscall_client.h" |
12 #include "sandbox/src/policy_low_level.h" | 12 #include "sandbox/src/policy_low_level.h" |
13 #include "sandbox/src/sandbox_types.h" | 13 #include "sandbox/src/sandbox_types.h" |
14 #include "sandbox/src/sharedmem_ipc_server.h" | 14 #include "sandbox/src/sharedmem_ipc_server.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 void TerminateTarget(PROCESS_INFORMATION* pi) { | 18 void TerminateTarget(PROCESS_INFORMATION* pi) { |
19 ::CloseHandle(pi->hThread); | 19 ::CloseHandle(pi->hThread); |
(...skipping 27 matching lines...) Expand all Loading... |
47 SANDBOX_INTERCEPT size_t g_shared_IPC_size; | 47 SANDBOX_INTERCEPT size_t g_shared_IPC_size; |
48 SANDBOX_INTERCEPT size_t g_shared_policy_size; | 48 SANDBOX_INTERCEPT size_t g_shared_policy_size; |
49 | 49 |
50 // Returns the address of the main exe module in memory taking in account | 50 // Returns the address of the main exe module in memory taking in account |
51 // address space layout randomization. | 51 // address space layout randomization. |
52 void* GetBaseAddress(const wchar_t* exe_name, void* entry_point) { | 52 void* GetBaseAddress(const wchar_t* exe_name, void* entry_point) { |
53 HMODULE exe = ::LoadLibrary(exe_name); | 53 HMODULE exe = ::LoadLibrary(exe_name); |
54 if (NULL == exe) | 54 if (NULL == exe) |
55 return exe; | 55 return exe; |
56 | 56 |
57 PEImage pe(exe); | 57 base::win::PEImage pe(exe); |
58 if (!pe.VerifyMagic()) { | 58 if (!pe.VerifyMagic()) { |
59 ::FreeLibrary(exe); | 59 ::FreeLibrary(exe); |
60 return exe; | 60 return exe; |
61 } | 61 } |
62 PIMAGE_NT_HEADERS nt_header = pe.GetNTHeaders(); | 62 PIMAGE_NT_HEADERS nt_header = pe.GetNTHeaders(); |
63 char* base = reinterpret_cast<char*>(entry_point) - | 63 char* base = reinterpret_cast<char*>(entry_point) - |
64 nt_header->OptionalHeader.AddressOfEntryPoint; | 64 nt_header->OptionalHeader.AddressOfEntryPoint; |
65 | 65 |
66 ::FreeLibrary(exe); | 66 ::FreeLibrary(exe); |
67 return base; | 67 return base; |
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 | 320 |
321 | 321 |
322 TargetProcess* MakeTestTargetProcess(HANDLE process, HMODULE base_address) { | 322 TargetProcess* MakeTestTargetProcess(HANDLE process, HMODULE base_address) { |
323 TargetProcess* target = new TargetProcess(NULL, NULL, NULL, NULL); | 323 TargetProcess* target = new TargetProcess(NULL, NULL, NULL, NULL); |
324 target->sandbox_process_ = process; | 324 target->sandbox_process_ = process; |
325 target->base_address_ = base_address; | 325 target->base_address_ = base_address; |
326 return target; | 326 return target; |
327 } | 327 } |
328 | 328 |
329 } // namespace sandbox | 329 } // namespace sandbox |
OLD | NEW |