| 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 "base/iat_patch.h" | 5 #include "base/iat_patch.h" |
| 6 #include "base/logging.h" | 6 #include "base/logging.h" |
| 7 | 7 |
| 8 namespace iat_patch { | 8 namespace iat_patch { |
| 9 | 9 |
| 10 struct InterceptFunctionInformation { | 10 struct InterceptFunctionInformation { |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 intercept_function_ = new_function; | 201 intercept_function_ = new_function; |
| 202 } | 202 } |
| 203 | 203 |
| 204 return error; | 204 return error; |
| 205 } | 205 } |
| 206 | 206 |
| 207 DWORD IATPatchFunction::Unpatch() { | 207 DWORD IATPatchFunction::Unpatch() { |
| 208 DWORD error = RestoreImportedFunction(intercept_function_, | 208 DWORD error = RestoreImportedFunction(intercept_function_, |
| 209 original_function_, | 209 original_function_, |
| 210 iat_thunk_); | 210 iat_thunk_); |
| 211 DCHECK(NO_ERROR == error); |
| 211 | 212 |
| 212 if (NO_ERROR == error) { | 213 // Hands off the intercept if we fail to unpatch. |
| 213 intercept_function_ = NULL; | 214 // If IATPatchFunction::Unpatch fails during RestoreImportedFunction |
| 214 original_function_ = NULL; | 215 // it means that we cannot safely unpatch the import address table |
| 215 iat_thunk_ = NULL; | 216 // patch. In this case its better to be hands off the intercept as |
| 216 } | 217 // trying to unpatch again in the destructor of IATPatchFunction is |
| 218 // not going to be any safer |
| 219 intercept_function_ = NULL; |
| 220 original_function_ = NULL; |
| 221 iat_thunk_ = NULL; |
| 217 | 222 |
| 218 return error; | 223 return error; |
| 219 } | 224 } |
| 220 | 225 |
| 221 } // namespace iat_patch | 226 } // namespace iat_patch |
| 222 | 227 |
| OLD | NEW |