diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 15:21:50 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-26 15:21:50 +0000 |
commit | 5418f47e35f5a6c1b6a3248a4927cb2fa4b5aee1 (patch) | |
tree | f51236e605d3c64067a8ee8aa4a4fc5d84d69d71 /base/iat_patch.h | |
parent | 33b6322f129fc660dbb1aa2e4ef20fe533aad439 (diff) | |
download | chromium_src-5418f47e35f5a6c1b6a3248a4927cb2fa4b5aee1.zip chromium_src-5418f47e35f5a6c1b6a3248a4927cb2fa4b5aee1.tar.gz chromium_src-5418f47e35f5a6c1b6a3248a4927cb2fa4b5aee1.tar.bz2 |
Try a new approach to fixing IAT unpatch crashes when the DLL is gone.
Have the IAT patcher take some "ownership" of the DLL, by taking a library name and then calling LoadLibrary() / FreeLibrary() to manage the reference count. This means as long is there isn't some other reference count balancing bug happening in the process, the DLL will never be unloaded while we are patched.
This effectively reverts r9929, the VirtualQuery additional checks are removed.
BUG=7701
Review URL: http://codereview.chromium.org/21453
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10467 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/iat_patch.h')
-rw-r--r-- | base/iat_patch.h | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/base/iat_patch.h b/base/iat_patch.h index 819037c..9e470d6 100644 --- a/base/iat_patch.h +++ b/base/iat_patch.h @@ -80,13 +80,19 @@ class IATPatchFunction { // during Unpatch // // Arguments: - // module_handle Module to be intercepted + // module Module to be intercepted // imported_from_module Module that exports the 'function_name' // function_name Name of the API to be intercepted // // Returns: Windows error code (winerror.h). NO_ERROR if successful // - DWORD Patch(HMODULE module_handle, + // Note: Patching a function will make the IAT patch take some "ownership" on + // |module|. It will LoadLibrary(module) to keep the DLL alive until a call + // to Unpatch(), which will call FreeLibrary() and allow the module to be + // unloaded. The idea is to help prevent the DLL from going away while a + // patch is still active. + // + DWORD Patch(const wchar_t* module, const char* imported_from_module, const char* function_name, void* new_function); @@ -103,6 +109,7 @@ class IATPatchFunction { } private: + HMODULE module_handle_; void* intercept_function_; void* original_function_; IMAGE_THUNK_DATA* iat_thunk_; |