OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/wow_helper/service64_resolver.h" | 5 #include "sandbox/wow_helper/service64_resolver.h" |
6 | 6 |
7 #include "base/logging.h" | |
8 #include "base/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
9 #include "sandbox/wow_helper/target_code.h" | 8 #include "sandbox/wow_helper/target_code.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 kCallPtrEdx = 0x12FF; | 15 const USHORT kCallPtrEdx = 0x12FF; |
17 const BYTE kRet = 0xC2; | 16 const BYTE kRet = 0xC2; |
(...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 // action is the same as for a target function. | 233 // action is the same as for a target function. |
235 return ResolveTarget(interceptor_module, interceptor_name, | 234 return ResolveTarget(interceptor_module, interceptor_name, |
236 const_cast<void**>(address)); | 235 const_cast<void**>(address)); |
237 } | 236 } |
238 | 237 |
239 // In this case all the work is done from the parent, so resolve is | 238 // In this case all the work is done from the parent, so resolve is |
240 // just a simple GetProcAddress. | 239 // just a simple GetProcAddress. |
241 NTSTATUS Service64ResolverThunk::ResolveTarget(const void* module, | 240 NTSTATUS Service64ResolverThunk::ResolveTarget(const void* module, |
242 const char* function_name, | 241 const char* function_name, |
243 void** address) { | 242 void** address) { |
244 DCHECK(address); | |
245 if (NULL == module) | 243 if (NULL == module) |
246 return STATUS_UNSUCCESSFUL; | 244 return STATUS_UNSUCCESSFUL; |
247 | 245 |
248 *address = ::GetProcAddress(bit_cast<HMODULE>(module), function_name); | 246 *address = ::GetProcAddress(bit_cast<HMODULE>(module), function_name); |
249 | 247 |
250 if (NULL == *address) | 248 if (NULL == *address) |
251 return STATUS_UNSUCCESSFUL; | 249 return STATUS_UNSUCCESSFUL; |
252 | 250 |
253 return STATUS_SUCCESS; | 251 return STATUS_SUCCESS; |
254 } | 252 } |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 // and now change the function to intercept, on the child | 336 // and now change the function to intercept, on the child |
339 if (!::WriteProtectedChildMemory(process_, target_, &local_service, | 337 if (!::WriteProtectedChildMemory(process_, target_, &local_service, |
340 sizeof(local_service))) | 338 sizeof(local_service))) |
341 return STATUS_UNSUCCESSFUL; | 339 return STATUS_UNSUCCESSFUL; |
342 | 340 |
343 return STATUS_SUCCESS; | 341 return STATUS_SUCCESS; |
344 } | 342 } |
345 | 343 |
346 } // namespace sandbox | 344 } // namespace sandbox |
347 | 345 |
OLD | NEW |