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

Side by Side Diff: app/win/iat_patch_function.cc

Issue 6880166: Improving logging in /app, /base, /crypto and /ipc. Updating plain DCHECK() usages for DCHECK_EQ/LE/ (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Static casting to DWORD to fix type mismatch Created 9 years, 8 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 | base/at_exit.cc » ('j') | 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) 2010 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 "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 #include "base/win/pe_image.h"
9 9
10 namespace app { 10 namespace app {
11 namespace win { 11 namespace win {
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 IATPatchFunction::IATPatchFunction() 208 IATPatchFunction::IATPatchFunction()
209 : module_handle_(NULL), 209 : module_handle_(NULL),
210 original_function_(NULL), 210 original_function_(NULL),
211 iat_thunk_(NULL), 211 iat_thunk_(NULL),
212 intercept_function_(NULL) { 212 intercept_function_(NULL) {
213 } 213 }
214 214
215 IATPatchFunction::~IATPatchFunction() { 215 IATPatchFunction::~IATPatchFunction() {
216 if (NULL != intercept_function_) { 216 if (NULL != intercept_function_) {
217 DWORD error = Unpatch(); 217 DWORD error = Unpatch();
218 DCHECK(error == NO_ERROR); 218 DCHECK_EQ(static_cast<DWORD>(NO_ERROR), error);
219 } 219 }
220 } 220 }
221 221
222 DWORD IATPatchFunction::Patch(const wchar_t* module, 222 DWORD IATPatchFunction::Patch(const wchar_t* module,
223 const char* imported_from_module, 223 const char* imported_from_module,
224 const char* function_name, 224 const char* function_name,
225 void* new_function) { 225 void* new_function) {
226 DCHECK_EQ(static_cast<void*>(NULL), original_function_); 226 DCHECK_EQ(static_cast<void*>(NULL), original_function_);
227 DCHECK_EQ(static_cast<IMAGE_THUNK_DATA*>(NULL), iat_thunk_); 227 DCHECK_EQ(static_cast<IMAGE_THUNK_DATA*>(NULL), iat_thunk_);
228 DCHECK_EQ(static_cast<void*>(NULL), intercept_function_); 228 DCHECK_EQ(static_cast<void*>(NULL), intercept_function_);
(...skipping 20 matching lines...) Expand all
249 FreeLibrary(module_handle); 249 FreeLibrary(module_handle);
250 } 250 }
251 251
252 return error; 252 return error;
253 } 253 }
254 254
255 DWORD IATPatchFunction::Unpatch() { 255 DWORD IATPatchFunction::Unpatch() {
256 DWORD error = RestoreImportedFunction(intercept_function_, 256 DWORD error = RestoreImportedFunction(intercept_function_,
257 original_function_, 257 original_function_,
258 iat_thunk_); 258 iat_thunk_);
259 DCHECK(NO_ERROR == error); 259 DCHECK_EQ(static_cast<DWORD>(NO_ERROR), error);
260 260
261 // Hands off the intercept if we fail to unpatch. 261 // Hands off the intercept if we fail to unpatch.
262 // If IATPatchFunction::Unpatch fails during RestoreImportedFunction 262 // If IATPatchFunction::Unpatch fails during RestoreImportedFunction
263 // it means that we cannot safely unpatch the import address table 263 // it means that we cannot safely unpatch the import address table
264 // patch. In this case its better to be hands off the intercept as 264 // patch. In this case its better to be hands off the intercept as
265 // trying to unpatch again in the destructor of IATPatchFunction is 265 // trying to unpatch again in the destructor of IATPatchFunction is
266 // not going to be any safer 266 // not going to be any safer
267 if (module_handle_) 267 if (module_handle_)
268 FreeLibrary(module_handle_); 268 FreeLibrary(module_handle_);
269 module_handle_ = NULL; 269 module_handle_ = NULL;
270 intercept_function_ = NULL; 270 intercept_function_ = NULL;
271 original_function_ = NULL; 271 original_function_ = NULL;
272 iat_thunk_ = NULL; 272 iat_thunk_ = NULL;
273 273
274 return error; 274 return error;
275 } 275 }
276 276
277 } // namespace win 277 } // namespace win
278 } // namespace app 278 } // namespace app
OLDNEW
« no previous file with comments | « no previous file | base/at_exit.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698