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

Unified Diff: base/iat_patch.cc

Issue 21434: Don't unpatch an unloaded module. We verify if the original function address ... (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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/iat_patch.cc
===================================================================
--- base/iat_patch.cc (revision 9881)
+++ base/iat_patch.cc (working copy)
@@ -205,9 +205,25 @@
}
DWORD IATPatchFunction::Unpatch() {
- DWORD error = RestoreImportedFunction(intercept_function_,
- original_function_,
- iat_thunk_);
+ DWORD error = 0;
+ MEMORY_BASIC_INFORMATION memory_info = {0};
+
+ // If the module has already unloaded, no point trying to unpatch.
+ if (!VirtualQuery(original_function_, &memory_info,
+ sizeof(memory_info))) {
+ error = GetLastError();
+ NOTREACHED();
+ return error;
+ }
Dean McNamee 2009/02/18 11:35:38 Shouldn't you set all of the functions to NULL her
+
+ if ((memory_info.State & MEM_COMMIT) != MEM_COMMIT) {
+ NOTREACHED();
+ return ERROR_ACCESS_DENIED;
+ }
+
+ error = RestoreImportedFunction(intercept_function_,
+ original_function_,
+ iat_thunk_);
DCHECK(NO_ERROR == error);
// Hands off the intercept if we fail to unpatch.
« 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