diff options
author | slightlyoff@chromium.org <slightlyoff@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 05:11:58 +0000 |
---|---|---|
committer | slightlyoff@chromium.org <slightlyoff@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-24 05:11:58 +0000 |
commit | f781782dd67077478e117c61dca4ea5eefce3544 (patch) | |
tree | 4801f724123cfdcbb69c4e7fe40a565b331723ae /chrome_frame/vtable_patch_manager.h | |
parent | 63cf4759efa2373e33436fb5df6849f930081226 (diff) | |
download | chromium_src-f781782dd67077478e117c61dca4ea5eefce3544.zip chromium_src-f781782dd67077478e117c61dca4ea5eefce3544.tar.gz chromium_src-f781782dd67077478e117c61dca4ea5eefce3544.tar.bz2 |
Initial import of the Chrome Frame codebase. Integration in chrome.gyp coming in a separate CL.
BUG=None
TEST=None
Review URL: http://codereview.chromium.org/218019
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@27042 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/vtable_patch_manager.h')
-rw-r--r-- | chrome_frame/vtable_patch_manager.h | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/chrome_frame/vtable_patch_manager.h b/chrome_frame/vtable_patch_manager.h new file mode 100644 index 0000000..944b9ef --- /dev/null +++ b/chrome_frame/vtable_patch_manager.h @@ -0,0 +1,64 @@ +// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CHROME_FRAME_COMMON_VTABLE_PATCH_MANAGER_H_ +#define CHROME_FRAME_COMMON_VTABLE_PATCH_MANAGER_H_ + +#include <windows.h> + +struct FunctionStub; +// This namespace provides methods to patch VTable methods of COM interfaces. +namespace vtable_patch { + +// This structure represents information about one VTable method. +// We allocate an array of these structures per VTable that we patch to +// remember the original method. We also use this structure to actually +// describe the VTable patch functions +struct MethodPatchInfo { + int index_; + PROC method_; + FunctionStub* stub_; +}; + +// Patches methods in the passed in COM interface. The indexes of the +// methods to patch and the actual patch functions are described in the +// array pointed to by patches. +// @param[in] unknown The pointer of the COM interface to patch +// @param[in] patches An array of MethodPatchInfo structures describing +// the methods to patch and the patch functions. +// The last entry of patches must have index_ set to -1. +HRESULT PatchInterfaceMethods(void* unknown, MethodPatchInfo* patches); + +// Using the patch info provided in |patches| the function goes through the +// list of patched methods and modifies thunks so that they no longer point +// to a hook method but rather go straight through to the original target. +// The thunk itself is not destroyed to support chaining. +// @param[in] patches An array of MethodPatchInfo structures describing +// the methods to patch and the patch functions. +// The last entry of patches must have index_ set to -1. +HRESULT UnpatchInterfaceMethods(MethodPatchInfo* patches); + +} // namespace vtable_patch + +// Begins the declaration of a VTable patch +// @param IFName The name of the interface to patch +#define BEGIN_VTABLE_PATCHES(IFName) \ + vtable_patch::MethodPatchInfo IFName##_PatchInfo[] = { + +// Defines a single method patch in a VTable +// @param index The index of the method to patch +// @param PatchFunction The patch function +#define VTABLE_PATCH_ENTRY(index, PatchFunction) {\ + index, \ + reinterpret_cast<PROC>(PatchFunction), \ + NULL, \ + }, + +// Ends the declaration of a VTable patch by adding an entry with +// index set to -1. +#define END_VTABLE_PATCHES() \ + -1, NULL, NULL \ + }; + +#endif // CHROME_FRAME_COMMON_VTABLE_PATCH_MANAGER_H_ |