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/eat_resolver.h" | 5 #include "sandbox/win/src/eat_resolver.h" |
6 | 6 |
7 #include "base/win/pe_image.h" | 7 #include "base/win/pe_image.h" |
8 #include "sandbox/win/src/sandbox_nt_util.h" | 8 #include "sandbox/win/src/sandbox_nt_util.h" |
9 | 9 |
10 namespace sandbox { | 10 namespace sandbox { |
(...skipping 27 matching lines...) Expand all Loading... |
38 | 38 |
39 if (!SetInternalThunk(thunk_storage, storage_bytes, target_, interceptor_)) | 39 if (!SetInternalThunk(thunk_storage, storage_bytes, target_, interceptor_)) |
40 return STATUS_BUFFER_TOO_SMALL; | 40 return STATUS_BUFFER_TOO_SMALL; |
41 | 41 |
42 AutoProtectMemory memory; | 42 AutoProtectMemory memory; |
43 ret = memory.ChangeProtection(eat_entry_, sizeof(DWORD), PAGE_READWRITE); | 43 ret = memory.ChangeProtection(eat_entry_, sizeof(DWORD), PAGE_READWRITE); |
44 if (!NT_SUCCESS(ret)) | 44 if (!NT_SUCCESS(ret)) |
45 return ret; | 45 return ret; |
46 | 46 |
47 // Perform the patch. | 47 // Perform the patch. |
48 #pragma warning(push) | 48 *eat_entry_ = static_cast<DWORD>(reinterpret_cast<uintptr_t>(thunk_storage)) - |
49 #pragma warning(disable: 4311) | 49 static_cast<DWORD>(reinterpret_cast<uintptr_t>(target_module)); |
50 // These casts generate warnings because they are 32 bit specific. | |
51 *eat_entry_ = reinterpret_cast<DWORD>(thunk_storage) - | |
52 reinterpret_cast<DWORD>(target_module); | |
53 #pragma warning(pop) | |
54 | 50 |
55 if (NULL != storage_used) | 51 if (NULL != storage_used) |
56 *storage_used = GetThunkSize(); | 52 *storage_used = GetThunkSize(); |
57 | 53 |
58 return ret; | 54 return ret; |
59 } | 55 } |
60 | 56 |
61 NTSTATUS EatResolverThunk::ResolveTarget(const void* module, | 57 NTSTATUS EatResolverThunk::ResolveTarget(const void* module, |
62 const char* function_name, | 58 const char* function_name, |
63 void** address) { | 59 void** address) { |
(...skipping 17 matching lines...) Expand all Loading... |
81 | 77 |
82 size_t EatResolverThunk::GetThunkSize() const { | 78 size_t EatResolverThunk::GetThunkSize() const { |
83 #if defined(_WIN64) | 79 #if defined(_WIN64) |
84 return GetInternalThunkSize() * 2; | 80 return GetInternalThunkSize() * 2; |
85 #else | 81 #else |
86 return GetInternalThunkSize(); | 82 return GetInternalThunkSize(); |
87 #endif | 83 #endif |
88 } | 84 } |
89 | 85 |
90 } // namespace sandbox | 86 } // namespace sandbox |
OLD | NEW |