| 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 "base/win/iat_patch_function.h" | 5 #include "base/win/iat_patch_function.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/win/pe_image.h" | 8 #include "base/win/pe_image.h" |
| 9 | 9 |
| 10 namespace base { | 10 namespace base { |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 60 // Save the old pointer. | 60 // Save the old pointer. |
| 61 if (NULL != intercept_information->old_function) { | 61 if (NULL != intercept_information->old_function) { |
| 62 *(intercept_information->old_function) = GetIATFunction(iat); | 62 *(intercept_information->old_function) = GetIATFunction(iat); |
| 63 } | 63 } |
| 64 | 64 |
| 65 if (NULL != intercept_information->iat_thunk) { | 65 if (NULL != intercept_information->iat_thunk) { |
| 66 *(intercept_information->iat_thunk) = iat; | 66 *(intercept_information->iat_thunk) = iat; |
| 67 } | 67 } |
| 68 | 68 |
| 69 // portability check | 69 // portability check |
| 70 COMPILE_ASSERT(sizeof(iat->u1.Function) == | 70 static_assert( |
| 71 sizeof(intercept_information->new_function), unknown_IAT_thunk_format); | 71 sizeof(iat->u1.Function) == sizeof(intercept_information->new_function), |
| 72 "unknown IAT thunk format"); |
| 72 | 73 |
| 73 // Patch the function. | 74 // Patch the function. |
| 74 intercept_information->return_code = | 75 intercept_information->return_code = |
| 75 ModifyCode(&(iat->u1.Function), | 76 ModifyCode(&(iat->u1.Function), |
| 76 &(intercept_information->new_function), | 77 &(intercept_information->new_function), |
| 77 sizeof(intercept_information->new_function)); | 78 sizeof(intercept_information->new_function)); |
| 78 | 79 |
| 79 // Terminate further enumeration. | 80 // Terminate further enumeration. |
| 80 intercept_information->finished_operation = true; | 81 intercept_information->finished_operation = true; |
| 81 return false; | 82 return false; |
| (...skipping 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 return error; | 299 return error; |
| 299 } | 300 } |
| 300 | 301 |
| 301 void* IATPatchFunction::original_function() const { | 302 void* IATPatchFunction::original_function() const { |
| 302 DCHECK(is_patched()); | 303 DCHECK(is_patched()); |
| 303 return original_function_; | 304 return original_function_; |
| 304 } | 305 } |
| 305 | 306 |
| 306 } // namespace win | 307 } // namespace win |
| 307 } // namespace base | 308 } // namespace base |
| OLD | NEW |