OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "app/win/iat_patch_function.h" | 5 #include "app/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 | 9 |
9 namespace app { | 10 namespace app { |
10 namespace win { | 11 namespace win { |
11 | 12 |
12 namespace { | 13 namespace { |
13 | 14 |
14 struct InterceptFunctionInformation { | 15 struct InterceptFunctionInformation { |
15 bool finished_operation; | 16 bool finished_operation; |
16 const char* imported_from_module; | 17 const char* imported_from_module; |
17 const char* function_name; | 18 const char* function_name; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 old_page_protection, | 73 old_page_protection, |
73 &old_page_protection); | 74 &old_page_protection); |
74 } else { | 75 } else { |
75 error = GetLastError(); | 76 error = GetLastError(); |
76 NOTREACHED(); | 77 NOTREACHED(); |
77 } | 78 } |
78 | 79 |
79 return error; | 80 return error; |
80 } | 81 } |
81 | 82 |
82 bool InterceptEnumCallback(const PEImage &image, const char* module, | 83 bool InterceptEnumCallback(const base::win::PEImage& image, const char* module, |
83 DWORD ordinal, const char* name, DWORD hint, | 84 DWORD ordinal, const char* name, DWORD hint, |
84 IMAGE_THUNK_DATA* iat, void* cookie) { | 85 IMAGE_THUNK_DATA* iat, void* cookie) { |
85 InterceptFunctionInformation* intercept_information = | 86 InterceptFunctionInformation* intercept_information = |
86 reinterpret_cast<InterceptFunctionInformation*>(cookie); | 87 reinterpret_cast<InterceptFunctionInformation*>(cookie); |
87 | 88 |
88 if (NULL == intercept_information) { | 89 if (NULL == intercept_information) { |
89 NOTREACHED(); | 90 NOTREACHED(); |
90 return false; | 91 return false; |
91 } | 92 } |
92 | 93 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 const char* imported_from_module, | 141 const char* imported_from_module, |
141 const char* function_name, void* new_function, | 142 const char* function_name, void* new_function, |
142 void** old_function, | 143 void** old_function, |
143 IMAGE_THUNK_DATA** iat_thunk) { | 144 IMAGE_THUNK_DATA** iat_thunk) { |
144 if ((NULL == module_handle) || (NULL == imported_from_module) || | 145 if ((NULL == module_handle) || (NULL == imported_from_module) || |
145 (NULL == function_name) || (NULL == new_function)) { | 146 (NULL == function_name) || (NULL == new_function)) { |
146 NOTREACHED(); | 147 NOTREACHED(); |
147 return ERROR_INVALID_PARAMETER; | 148 return ERROR_INVALID_PARAMETER; |
148 } | 149 } |
149 | 150 |
150 PEImage target_image(module_handle); | 151 base::win::PEImage target_image(module_handle); |
151 if (!target_image.VerifyMagic()) { | 152 if (!target_image.VerifyMagic()) { |
152 NOTREACHED(); | 153 NOTREACHED(); |
153 return ERROR_INVALID_PARAMETER; | 154 return ERROR_INVALID_PARAMETER; |
154 } | 155 } |
155 | 156 |
156 InterceptFunctionInformation intercept_information = { | 157 InterceptFunctionInformation intercept_information = { |
157 false, | 158 false, |
158 imported_from_module, | 159 imported_from_module, |
159 function_name, | 160 function_name, |
160 new_function, | 161 new_function, |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 module_handle_ = NULL; | 269 module_handle_ = NULL; |
269 intercept_function_ = NULL; | 270 intercept_function_ = NULL; |
270 original_function_ = NULL; | 271 original_function_ = NULL; |
271 iat_thunk_ = NULL; | 272 iat_thunk_ = NULL; |
272 | 273 |
273 return error; | 274 return error; |
274 } | 275 } |
275 | 276 |
276 } // namespace win | 277 } // namespace win |
277 } // namespace app | 278 } // namespace app |
OLD | NEW |