| OLD | NEW | 
|---|
| (Empty) |  | 
|  | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 
|  | 2 // Use of this source code is governed by a BSD-style license that can be | 
|  | 3 // found in the LICENSE file. | 
|  | 4 | 
|  | 5 #ifndef CHROME_FRAME_COMMON_VTABLE_PATCH_MANAGER_H_ | 
|  | 6 #define CHROME_FRAME_COMMON_VTABLE_PATCH_MANAGER_H_ | 
|  | 7 | 
|  | 8 #include <windows.h> | 
|  | 9 | 
|  | 10 struct FunctionStub; | 
|  | 11 // This namespace provides methods to patch VTable methods of COM interfaces. | 
|  | 12 namespace vtable_patch { | 
|  | 13 | 
|  | 14 // This structure represents information about one VTable method. | 
|  | 15 // We allocate an array of these structures per VTable that we patch to | 
|  | 16 // remember the original method. We also use this structure to actually | 
|  | 17 // describe the VTable patch functions | 
|  | 18 struct MethodPatchInfo { | 
|  | 19   int index_; | 
|  | 20   PROC method_; | 
|  | 21   FunctionStub* stub_; | 
|  | 22 }; | 
|  | 23 | 
|  | 24 // Patches methods in the passed in COM interface. The indexes of the | 
|  | 25 // methods to patch and the actual patch functions are described in the | 
|  | 26 // array pointed to by patches. | 
|  | 27 // @param[in] unknown  The pointer of the COM interface to patch | 
|  | 28 // @param[in] patches  An array of MethodPatchInfo structures describing | 
|  | 29 //  the methods to patch and the patch functions. | 
|  | 30 //  The last entry of patches must have index_ set to -1. | 
|  | 31 HRESULT PatchInterfaceMethods(void* unknown, MethodPatchInfo* patches); | 
|  | 32 | 
|  | 33 // Using the patch info provided in |patches| the function goes through the | 
|  | 34 // list of patched methods and modifies thunks so that they no longer point | 
|  | 35 // to a hook method but rather go straight through to the original target. | 
|  | 36 // The thunk itself is not destroyed to support chaining. | 
|  | 37 // @param[in] patches  An array of MethodPatchInfo structures describing | 
|  | 38 //  the methods to patch and the patch functions. | 
|  | 39 //  The last entry of patches must have index_ set to -1. | 
|  | 40 HRESULT UnpatchInterfaceMethods(MethodPatchInfo* patches); | 
|  | 41 | 
|  | 42 }  // namespace vtable_patch | 
|  | 43 | 
|  | 44 // Begins the declaration of a VTable patch | 
|  | 45 // @param IFName The name of the interface to patch | 
|  | 46 #define BEGIN_VTABLE_PATCHES(IFName) \ | 
|  | 47     vtable_patch::MethodPatchInfo IFName##_PatchInfo[] = { | 
|  | 48 | 
|  | 49 // Defines a single method patch in a VTable | 
|  | 50 // @param index The index of the method to patch | 
|  | 51 // @param PatchFunction The patch function | 
|  | 52 #define VTABLE_PATCH_ENTRY(index, PatchFunction) {\ | 
|  | 53       index, \ | 
|  | 54       reinterpret_cast<PROC>(PatchFunction), \ | 
|  | 55       NULL, \ | 
|  | 56     }, | 
|  | 57 | 
|  | 58 // Ends the declaration of a VTable patch by adding an entry with | 
|  | 59 // index set to -1. | 
|  | 60 #define END_VTABLE_PATCHES() \ | 
|  | 61       -1, NULL, NULL \ | 
|  | 62     }; | 
|  | 63 | 
|  | 64 #endif // CHROME_FRAME_COMMON_VTABLE_PATCH_MANAGER_H_ | 
| OLD | NEW | 
|---|