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

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

Issue 183833004: Make chrome_elf use thunks instead of function pointers. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address comments, add scoped ptr Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/win/src/service_resolver_32.cc ('k') | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/service_resolver.h" 5 #include "sandbox/win/src/service_resolver.h"
6 6
7 #include "base/memory/scoped_ptr.h" 7 #include "base/memory/scoped_ptr.h"
8 #include "sandbox/win/src/sandbox_nt_util.h" 8 #include "sandbox/win/src/sandbox_nt_util.h"
9 #include "sandbox/win/src/win_utils.h" 9 #include "sandbox/win/src/win_utils.h"
10 10
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 if (NULL != storage_used) 109 if (NULL != storage_used)
110 *storage_used = thunk_bytes; 110 *storage_used = thunk_bytes;
111 111
112 return ret; 112 return ret;
113 } 113 }
114 114
115 size_t ServiceResolverThunk::GetThunkSize() const { 115 size_t ServiceResolverThunk::GetThunkSize() const {
116 return sizeof(ServiceFullThunk); 116 return sizeof(ServiceFullThunk);
117 } 117 }
118 118
119 NTSTATUS ServiceResolverThunk::CopyThunk(const void* target_module,
120 const char* target_name,
121 BYTE* thunk_storage,
122 size_t storage_bytes,
123 size_t* storage_used) {
124 NTSTATUS ret = ResolveTarget(target_module, target_name, &target_);
125 if (!NT_SUCCESS(ret))
126 return ret;
127
128 size_t thunk_bytes = GetThunkSize();
129 if (storage_bytes < thunk_bytes)
130 return STATUS_UNSUCCESSFUL;
131
132 ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>(thunk_storage);
133
134 if (!IsFunctionAService(&thunk->original))
135 return STATUS_UNSUCCESSFUL;
136
137 if (NULL != storage_used)
138 *storage_used = thunk_bytes;
139
140 return ret;
141 }
142
119 bool ServiceResolverThunk::IsFunctionAService(void* local_thunk) const { 143 bool ServiceResolverThunk::IsFunctionAService(void* local_thunk) const {
120 ServiceFullThunk function_code; 144 ServiceFullThunk function_code;
121 SIZE_T read; 145 SIZE_T read;
122 if (!::ReadProcessMemory(process_, target_, &function_code, 146 if (!::ReadProcessMemory(process_, target_, &function_code,
123 sizeof(function_code), &read)) 147 sizeof(function_code), &read))
124 return false; 148 return false;
125 149
126 if (sizeof(function_code) != read) 150 if (sizeof(function_code) != read)
127 return false; 151 return false;
128 152
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 NOTREACHED_NT(); 208 NOTREACHED_NT();
185 return false; 209 return false;
186 } 210 }
187 211
188 bool Win2kResolverThunk::IsFunctionAService(void* local_thunk) const { 212 bool Win2kResolverThunk::IsFunctionAService(void* local_thunk) const {
189 NOTREACHED_NT(); 213 NOTREACHED_NT();
190 return false; 214 return false;
191 } 215 }
192 216
193 } // namespace sandbox 217 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/service_resolver_32.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698