Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(212)

Side by Side Diff: sandbox/win/src/resolver_32.cc

Issue 544333002: Remove NT_PLACE, it's not really used. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comment Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | sandbox/win/src/resolver_64.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #pragma pack(push, 1) 15 #pragma pack(push, 1)
12 struct InternalThunk { 16 struct InternalThunk {
13 // This struct contains roughly the following code: 17 // This struct contains roughly the following code:
14 // sub esp, 8 // Create working space 18 // sub esp, 8 // Create working space
15 // push edx // Save register 19 // push edx // Save register
16 // mov edx, [esp + 0xc] // Get return adddress 20 // mov edx, [esp + 0xc] // Get return adddress
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 }; // namespace 59 }; // namespace
56 60
57 namespace sandbox { 61 namespace sandbox {
58 62
59 bool ResolverThunk::SetInternalThunk(void* storage, size_t storage_bytes, 63 bool ResolverThunk::SetInternalThunk(void* storage, size_t storage_bytes,
60 const void* original_function, 64 const void* original_function,
61 const void* interceptor) { 65 const void* interceptor) {
62 if (storage_bytes < sizeof(InternalThunk)) 66 if (storage_bytes < sizeof(InternalThunk))
63 return false; 67 return false;
64 68
65 InternalThunk* thunk = new(storage, NT_PLACE) InternalThunk; 69 InternalThunk* thunk = new(storage) InternalThunk;
66 70
67 #pragma warning(push) 71 #pragma warning(push)
68 #pragma warning(disable: 4311) 72 #pragma warning(disable: 4311)
69 // These casts generate warnings because they are 32 bit specific. 73 // These casts generate warnings because they are 32 bit specific.
70 thunk->interceptor_function = reinterpret_cast<ULONG>(interceptor); 74 thunk->interceptor_function = reinterpret_cast<ULONG>(interceptor);
71 thunk->extra_argument = reinterpret_cast<ULONG>(original_function); 75 thunk->extra_argument = reinterpret_cast<ULONG>(original_function);
72 #pragma warning(pop) 76 #pragma warning(pop)
73 77
74 return true; 78 return true;
75 } 79 }
76 80
77 size_t ResolverThunk::GetInternalThunkSize() const { 81 size_t ResolverThunk::GetInternalThunkSize() const {
78 return sizeof(InternalThunk); 82 return sizeof(InternalThunk);
79 } 83 }
80 84
81 NTSTATUS ResolverThunk::ResolveTarget(const void* module, 85 NTSTATUS ResolverThunk::ResolveTarget(const void* module,
82 const char* function_name, 86 const char* function_name,
83 void** address) { 87 void** address) {
84 const void** casted = const_cast<const void**>(address); 88 const void** casted = const_cast<const void**>(address);
85 return ResolverThunk::ResolveInterceptor(module, function_name, casted); 89 return ResolverThunk::ResolveInterceptor(module, function_name, casted);
86 } 90 }
87 91
88 } // namespace sandbox 92 } // namespace sandbox
OLDNEW
« no previous file with comments | « no previous file | sandbox/win/src/resolver_64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698