OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // Definition of PreamblePatcher | 5 // Definition of PreamblePatcher |
6 | 6 |
7 #ifndef SANDBOX_SRC_SIDESTEP_PREAMBLE_PATCHER_H__ | 7 #ifndef SANDBOX_SRC_SIDESTEP_PREAMBLE_PATCHER_H__ |
8 #define SANDBOX_SRC_SIDESTEP_PREAMBLE_PATCHER_H__ | 8 #define SANDBOX_SRC_SIDESTEP_PREAMBLE_PATCHER_H__ |
9 | 9 |
| 10 #include <stddef.h> |
| 11 |
10 namespace sidestep { | 12 namespace sidestep { |
11 | 13 |
12 // Maximum size of the preamble stub. We overwrite at least the first 5 | 14 // Maximum size of the preamble stub. We overwrite at least the first 5 |
13 // bytes of the function. Considering the worst case scenario, we need 4 | 15 // bytes of the function. Considering the worst case scenario, we need 4 |
14 // bytes + the max instruction size + 5 more bytes for our jump back to | 16 // bytes + the max instruction size + 5 more bytes for our jump back to |
15 // the original code. With that in mind, 32 is a good number :) | 17 // the original code. With that in mind, 32 is a good number :) |
16 const size_t kMaxPreambleStubSize = 32; | 18 const size_t kMaxPreambleStubSize = 32; |
17 | 19 |
18 // Possible results of patching/unpatching | 20 // Possible results of patching/unpatching |
19 enum SideStepError { | 21 enum SideStepError { |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 static SideStepError RawPatchWithStub(void* target_function, | 102 static SideStepError RawPatchWithStub(void* target_function, |
101 void *replacement_function, | 103 void *replacement_function, |
102 unsigned char* preamble_stub, | 104 unsigned char* preamble_stub, |
103 size_t stub_size, | 105 size_t stub_size, |
104 size_t* bytes_needed); | 106 size_t* bytes_needed); |
105 }; | 107 }; |
106 | 108 |
107 }; // namespace sidestep | 109 }; // namespace sidestep |
108 | 110 |
109 #endif // SANDBOX_SRC_SIDESTEP_PREAMBLE_PATCHER_H__ | 111 #endif // SANDBOX_SRC_SIDESTEP_PREAMBLE_PATCHER_H__ |
OLD | NEW |