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

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

Issue 10951038: Remove GetModuleHandleHelper(), which was only needed for Win2k (which we don't support). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 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 | Annotate | Revision Log
« no previous file with comments | « sandbox/win/src/sandbox_utils.cc ('k') | sandbox/win/tests/common/controller.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) 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_utils.h"
9 #include "sandbox/win/src/win_utils.h" 8 #include "sandbox/win/src/win_utils.h"
10 9
11 namespace { 10 namespace {
12 #pragma pack(push, 1) 11 #pragma pack(push, 1)
13 12
14 const BYTE kMovEax = 0xB8; 13 const BYTE kMovEax = 0xB8;
15 const BYTE kMovEdx = 0xBA; 14 const BYTE kMovEdx = 0xBA;
16 const USHORT kMovEdxEsp = 0xD48B; 15 const USHORT kMovEdxEsp = 0xD48B;
17 const USHORT kCallPtrEdx = 0x12FF; 16 const USHORT kCallPtrEdx = 0x12FF;
18 const USHORT kCallEdx = 0xD2FF; 17 const USHORT kCallEdx = 0xD2FF;
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (!::ReadProcessMemory(process_, 202 if (!::ReadProcessMemory(process_,
204 bit_cast<const void*>(function_code.stub), 203 bit_cast<const void*>(function_code.stub),
205 &ki_system_call, sizeof(ki_system_call), &read)) 204 &ki_system_call, sizeof(ki_system_call), &read))
206 return false; 205 return false;
207 206
208 if (sizeof(ki_system_call) != read) 207 if (sizeof(ki_system_call) != read)
209 return false; 208 return false;
210 209
211 HMODULE module_1, module_2; 210 HMODULE module_1, module_2;
212 // last check, call_stub should point to a KiXXSystemCall function on ntdll 211 // last check, call_stub should point to a KiXXSystemCall function on ntdll
213 if (!GetModuleHandleHelper(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | 212 if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
214 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, 213 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
215 bit_cast<const wchar_t*>(ki_system_call), 214 bit_cast<const wchar_t*>(ki_system_call), &module_1))
216 &module_1))
217 return false; 215 return false;
218 216
219 if (NULL != ntdll_base_) { 217 if (NULL != ntdll_base_) {
220 // This path is only taken when running the unit tests. We want to be 218 // This path is only taken when running the unit tests. We want to be
221 // able to patch a buffer in memory, so target_ is not inside ntdll. 219 // able to patch a buffer in memory, so target_ is not inside ntdll.
222 module_2 = ntdll_base_; 220 module_2 = ntdll_base_;
223 } else { 221 } else {
224 if (!GetModuleHandleHelper( 222 if (!GetModuleHandleEx(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
225 GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | 223 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
226 GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT, 224 reinterpret_cast<const wchar_t*>(target_),
227 reinterpret_cast<const wchar_t*>(target_), 225 &module_2))
228 &module_2)) {
229 return false; 226 return false;
230 }
231 } 227 }
232 228
233 if (module_1 != module_2) 229 if (module_1 != module_2)
234 return false; 230 return false;
235 } 231 }
236 232
237 // Save the verified code 233 // Save the verified code
238 memcpy(local_thunk, &function_code, sizeof(function_code)); 234 memcpy(local_thunk, &function_code, sizeof(function_code));
239 235
240 return true; 236 return true;
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 return false; 411 return false;
416 } 412 }
417 413
418 // Save the verified code 414 // Save the verified code
419 memcpy(local_thunk, &function_code, sizeof(function_code)); 415 memcpy(local_thunk, &function_code, sizeof(function_code));
420 416
421 return true; 417 return true;
422 } 418 }
423 419
424 } // namespace sandbox 420 } // namespace sandbox
OLDNEW
« no previous file with comments | « sandbox/win/src/sandbox_utils.cc ('k') | sandbox/win/tests/common/controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698