| 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/scoped_ptr.h" | 7 #include "base/scoped_ptr.h" |
| 8 #include "sandbox/wow_helper/target_code.h" | 8 #include "sandbox/wow_helper/target_code.h" |
| 9 | 9 |
| 10 namespace { | 10 namespace { |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 ServiceEntry function_code; | 259 ServiceEntry function_code; |
| 260 SIZE_T read; | 260 SIZE_T read; |
| 261 if (!::ReadProcessMemory(process_, target_, &function_code, | 261 if (!::ReadProcessMemory(process_, target_, &function_code, |
| 262 sizeof(function_code), &read)) | 262 sizeof(function_code), &read)) |
| 263 return false; | 263 return false; |
| 264 | 264 |
| 265 if (sizeof(function_code) != read) | 265 if (sizeof(function_code) != read) |
| 266 return false; | 266 return false; |
| 267 | 267 |
| 268 if (kMmovR10EcxMovEax != function_code.mov_r10_ecx_mov_eax || | 268 if (kMmovR10EcxMovEax != function_code.mov_r10_ecx_mov_eax || |
| 269 kSyscall != function_code.syscall || kRetNp != function_code.ret || | 269 kSyscall != function_code.syscall || kRetNp != function_code.ret) |
| 270 kPad != function_code.pad || kNop16 != function_code.xchg_ax_ax1 || | |
| 271 kNop16 != function_code.xchg_ax_ax1) | |
| 272 return false; | 270 return false; |
| 273 | 271 |
| 274 // Save the verified code | 272 // Save the verified code |
| 275 memcpy(local_thunk, &function_code, sizeof(function_code)); | 273 memcpy(local_thunk, &function_code, sizeof(function_code)); |
| 276 | 274 |
| 277 return true; | 275 return true; |
| 278 } | 276 } |
| 279 | 277 |
| 280 NTSTATUS Service64ResolverThunk::PerformPatch(void* local_thunk, | 278 NTSTATUS Service64ResolverThunk::PerformPatch(void* local_thunk, |
| 281 void* remote_thunk) { | 279 void* remote_thunk) { |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 336 // and now change the function to intercept, on the child | 334 // and now change the function to intercept, on the child |
| 337 if (!::WriteProtectedChildMemory(process_, target_, &local_service, | 335 if (!::WriteProtectedChildMemory(process_, target_, &local_service, |
| 338 sizeof(local_service))) | 336 sizeof(local_service))) |
| 339 return STATUS_UNSUCCESSFUL; | 337 return STATUS_UNSUCCESSFUL; |
| 340 | 338 |
| 341 return STATUS_SUCCESS; | 339 return STATUS_SUCCESS; |
| 342 } | 340 } |
| 343 | 341 |
| 344 } // namespace sandbox | 342 } // namespace sandbox |
| 345 | 343 |
| OLD | NEW |