Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(109)

Side by Side Diff: base/iat_patch.cc

Issue 21044: Hands off the intercept if 'unpatch' fails... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698