| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/wow_helper/service64_resolver.h" | 5 #include "sandbox/win/wow_helper/service64_resolver.h" |
| 6 | 6 |
| 7 #include <limits.h> | 7 #include <limits.h> |
| 8 #include <stddef.h> | 8 #include <stddef.h> |
| 9 | 9 |
| 10 #include <memory> |
| 11 |
| 10 #include "base/bit_cast.h" | 12 #include "base/bit_cast.h" |
| 11 #include "base/memory/scoped_ptr.h" | |
| 12 #include "sandbox/win/wow_helper/target_code.h" | 13 #include "sandbox/win/wow_helper/target_code.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 #pragma pack(push, 1) | 16 #pragma pack(push, 1) |
| 16 | 17 |
| 17 const BYTE kMovEax = 0xB8; | 18 const BYTE kMovEax = 0xB8; |
| 18 const BYTE kMovEdx = 0xBA; | 19 const BYTE kMovEdx = 0xBA; |
| 19 const USHORT kCallPtrEdx = 0x12FF; | 20 const USHORT kCallPtrEdx = 0x12FF; |
| 20 const BYTE kRet = 0xC2; | 21 const BYTE kRet = 0xC2; |
| 21 const BYTE kNop = 0x90; | 22 const BYTE kNop = 0x90; |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 void* thunk_storage, | 208 void* thunk_storage, |
| 208 size_t storage_bytes, | 209 size_t storage_bytes, |
| 209 size_t* storage_used) { | 210 size_t* storage_used) { |
| 210 NTSTATUS ret = Init(target_module, interceptor_module, target_name, | 211 NTSTATUS ret = Init(target_module, interceptor_module, target_name, |
| 211 interceptor_name, interceptor_entry_point, | 212 interceptor_name, interceptor_entry_point, |
| 212 thunk_storage, storage_bytes); | 213 thunk_storage, storage_bytes); |
| 213 if (!NT_SUCCESS(ret)) | 214 if (!NT_SUCCESS(ret)) |
| 214 return ret; | 215 return ret; |
| 215 | 216 |
| 216 size_t thunk_bytes = GetThunkSize(); | 217 size_t thunk_bytes = GetThunkSize(); |
| 217 scoped_ptr<char[]> thunk_buffer(new char[thunk_bytes]); | 218 std::unique_ptr<char[]> thunk_buffer(new char[thunk_bytes]); |
| 218 ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>( | 219 ServiceFullThunk* thunk = reinterpret_cast<ServiceFullThunk*>( |
| 219 thunk_buffer.get()); | 220 thunk_buffer.get()); |
| 220 | 221 |
| 221 if (!IsFunctionAService(&thunk->original)) | 222 if (!IsFunctionAService(&thunk->original)) |
| 222 return STATUS_UNSUCCESSFUL; | 223 return STATUS_UNSUCCESSFUL; |
| 223 | 224 |
| 224 ret = PerformPatch(thunk, thunk_storage); | 225 ret = PerformPatch(thunk, thunk_storage); |
| 225 | 226 |
| 226 if (NULL != storage_used) | 227 if (NULL != storage_used) |
| 227 *storage_used = thunk_bytes; | 228 *storage_used = thunk_bytes; |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 338 |
| 338 // and now change the function to intercept, on the child | 339 // and now change the function to intercept, on the child |
| 339 if (!::WriteProtectedChildMemory(process_, target_, &local_service, | 340 if (!::WriteProtectedChildMemory(process_, target_, &local_service, |
| 340 sizeof(local_service))) | 341 sizeof(local_service))) |
| 341 return STATUS_UNSUCCESSFUL; | 342 return STATUS_UNSUCCESSFUL; |
| 342 | 343 |
| 343 return STATUS_SUCCESS; | 344 return STATUS_SUCCESS; |
| 344 } | 345 } |
| 345 | 346 |
| 346 } // namespace sandbox | 347 } // namespace sandbox |
| OLD | NEW |