OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_FRAME_VTABLE_PATCH_MANAGER_H_ | 5 #ifndef CHROME_FRAME_VTABLE_PATCH_MANAGER_H_ |
6 #define CHROME_FRAME_VTABLE_PATCH_MANAGER_H_ | 6 #define CHROME_FRAME_VTABLE_PATCH_MANAGER_H_ |
7 | 7 |
8 #include <windows.h> | 8 #include <windows.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 | 11 |
12 #include "base/lock.h" | 12 #include "base/lock.h" |
13 | 13 |
14 struct FunctionStub; | 14 struct FunctionStub; |
| 15 |
15 // This namespace provides methods to patch VTable methods of COM interfaces. | 16 // This namespace provides methods to patch VTable methods of COM interfaces. |
16 namespace vtable_patch { | 17 namespace vtable_patch { |
17 | 18 |
| 19 // Internal implementation, exposed only for testing. |
| 20 namespace internal { |
| 21 |
| 22 // Replaces *entry with new_proc iff *entry is curr_proc. |
| 23 // Returns true iff *entry was rewritten. |
| 24 // Note: does not crash on access violation. |
| 25 bool ReplaceFunctionPointer(void** entry, void* new_proc, void* curr_proc); |
| 26 |
| 27 } // namespace internal |
| 28 |
18 // This structure represents information about one VTable method. | 29 // This structure represents information about one VTable method. |
19 // We allocate an array of these structures per VTable that we patch to | 30 // We allocate an array of these structures per VTable that we patch to |
20 // remember the original method. We also use this structure to actually | 31 // remember the original method. We also use this structure to actually |
21 // describe the VTable patch functions | 32 // describe the VTable patch functions |
22 struct MethodPatchInfo { | 33 struct MethodPatchInfo { |
23 int index_; | 34 int index_; |
24 PROC method_; | 35 PROC method_; |
25 FunctionStub* stub_; | 36 FunctionStub* stub_; |
26 }; | 37 }; |
27 | 38 |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 #define IS_PATCHED(IFName) \ | 120 #define IS_PATCHED(IFName) \ |
110 (IFName##_PatchInfo[0].stub_ != NULL) | 121 (IFName##_PatchInfo[0].stub_ != NULL) |
111 | 122 |
112 // Ends the declaration of a VTable patch by adding an entry with | 123 // Ends the declaration of a VTable patch by adding an entry with |
113 // index set to -1. | 124 // index set to -1. |
114 #define END_VTABLE_PATCHES() \ | 125 #define END_VTABLE_PATCHES() \ |
115 -1, NULL, NULL \ | 126 -1, NULL, NULL \ |
116 }; | 127 }; |
117 | 128 |
118 #endif // CHROME_FRAME_VTABLE_PATCH_MANAGER_H_ | 129 #endif // CHROME_FRAME_VTABLE_PATCH_MANAGER_H_ |
OLD | NEW |