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/win/src/resolver.h" | 5 #include "sandbox/win/src/resolver.h" |
6 | 6 |
| 7 // For placement new. This file must not depend on the CRT at runtime, but |
| 8 // placement operator new is inline. |
| 9 #include <new> |
| 10 |
7 #include "sandbox/win/src/sandbox_nt_util.h" | 11 #include "sandbox/win/src/sandbox_nt_util.h" |
8 | 12 |
9 namespace { | 13 namespace { |
10 | 14 |
11 const BYTE kPushRax = 0x50; | 15 const BYTE kPushRax = 0x50; |
12 const USHORT kMovRax = 0xB848; | 16 const USHORT kMovRax = 0xB848; |
13 const ULONG kMovRspRax = 0x24048948; | 17 const ULONG kMovRspRax = 0x24048948; |
14 const BYTE kRetNp = 0xC3; | 18 const BYTE kRetNp = 0xC3; |
15 | 19 |
16 #pragma pack(push, 1) | 20 #pragma pack(push, 1) |
(...skipping 29 matching lines...) Expand all Loading... |
46 size_t ResolverThunk::GetInternalThunkSize() const { | 50 size_t ResolverThunk::GetInternalThunkSize() const { |
47 return sizeof(InternalThunk); | 51 return sizeof(InternalThunk); |
48 } | 52 } |
49 | 53 |
50 bool ResolverThunk::SetInternalThunk(void* storage, size_t storage_bytes, | 54 bool ResolverThunk::SetInternalThunk(void* storage, size_t storage_bytes, |
51 const void* original_function, | 55 const void* original_function, |
52 const void* interceptor) { | 56 const void* interceptor) { |
53 if (storage_bytes < sizeof(InternalThunk)) | 57 if (storage_bytes < sizeof(InternalThunk)) |
54 return false; | 58 return false; |
55 | 59 |
56 InternalThunk* thunk = new(storage, NT_PLACE) InternalThunk; | 60 InternalThunk* thunk = new(storage) InternalThunk; |
57 thunk->interceptor_function = reinterpret_cast<ULONG_PTR>(interceptor); | 61 thunk->interceptor_function = reinterpret_cast<ULONG_PTR>(interceptor); |
58 | 62 |
59 return true; | 63 return true; |
60 } | 64 } |
61 | 65 |
62 NTSTATUS ResolverThunk::ResolveTarget(const void* module, | 66 NTSTATUS ResolverThunk::ResolveTarget(const void* module, |
63 const char* function_name, | 67 const char* function_name, |
64 void** address) { | 68 void** address) { |
65 // We don't support sidestep & co. | 69 // We don't support sidestep & co. |
66 return STATUS_NOT_IMPLEMENTED; | 70 return STATUS_NOT_IMPLEMENTED; |
67 } | 71 } |
68 | 72 |
69 } // namespace sandbox | 73 } // namespace sandbox |
OLD | NEW |