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

Unified Diff: base/win/iat_patch_function.cc

Issue 587923002: Extend the CloseHandle interception to all DLLs loaded in the process. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Review comments Created 6 years, 3 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 | « base/win/iat_patch_function.h ('k') | chrome/app/close_handle_hook_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/win/iat_patch_function.cc
diff --git a/base/win/iat_patch_function.cc b/base/win/iat_patch_function.cc
index 765592782fda3e0e1d0ca24a73c7c6bc9e87963b..13acd65ee4d0644454839ff19459da460825ba05 100644
--- a/base/win/iat_patch_function.cc
+++ b/base/win/iat_patch_function.cc
@@ -235,18 +235,33 @@ DWORD IATPatchFunction::Patch(const wchar_t* module,
const char* imported_from_module,
const char* function_name,
void* new_function) {
- DCHECK_EQ(static_cast<void*>(NULL), original_function_);
- DCHECK_EQ(static_cast<IMAGE_THUNK_DATA*>(NULL), iat_thunk_);
- DCHECK_EQ(static_cast<void*>(NULL), intercept_function_);
-
HMODULE module_handle = LoadLibraryW(module);
-
if (module_handle == NULL) {
NOTREACHED();
return GetLastError();
}
- DWORD error = InterceptImportedFunction(module_handle,
+ DWORD error = PatchFromModule(module_handle, imported_from_module,
+ function_name, new_function);
+ if (NO_ERROR == error) {
+ module_handle_ = module_handle;
+ } else {
+ FreeLibrary(module_handle);
+ }
+
+ return error;
+}
+
+DWORD IATPatchFunction::PatchFromModule(HMODULE module,
+ const char* imported_from_module,
+ const char* function_name,
+ void* new_function) {
+ DCHECK_EQ(static_cast<void*>(NULL), original_function_);
+ DCHECK_EQ(static_cast<IMAGE_THUNK_DATA*>(NULL), iat_thunk_);
+ DCHECK_EQ(static_cast<void*>(NULL), intercept_function_);
+ DCHECK(module);
+
+ DWORD error = InterceptImportedFunction(module,
imported_from_module,
function_name,
new_function,
@@ -255,10 +270,7 @@ DWORD IATPatchFunction::Patch(const wchar_t* module,
if (NO_ERROR == error) {
DCHECK_NE(original_function_, intercept_function_);
- module_handle_ = module_handle;
intercept_function_ = new_function;
- } else {
- FreeLibrary(module_handle);
}
return error;
« no previous file with comments | « base/win/iat_patch_function.h ('k') | chrome/app/close_handle_hook_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698