1 : // Copyright 2015 Google Inc. All Rights Reserved.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Declares a helper function for in-place patching the memory interceptors
16 : // to point to a new shadow memory array.
17 :
18 : #ifndef SYZYGY_AGENT_ASAN_MEMORY_INTERCEPTORS_PATCHER_H_
19 : #define SYZYGY_AGENT_ASAN_MEMORY_INTERCEPTORS_PATCHER_H_
20 :
21 : #include <windows.h>
22 : #include <cstdint>
23 :
24 m : namespace agent {
25 m : namespace asan {
26 :
27 : // Patches the memory interceptors found in the .probes section of the current
28 : // module.
29 : // @param new_shadow_memory The shadow memory that is to be patched into the
30 : // probes.
31 : // @param old_shadow_memory The shadow memory that the probe should currently
32 : // be referring to.
33 : // @note This function is BYOL - bring your own locking.
34 : // @note Patching is inherently racy. It's wise to call this function from
35 : // under a lock that prevents concurrent patching on the same module, and
36 : // the caller must guarantee that the module is not unloaded during
37 : // patching.
38 : // @returns true on success, false otherwise. Logs verbosely on failure.
39 m : bool PatchMemoryInterceptorShadowReferences(const uint8_t* old_shadow_memory,
40 m : const uint8_t* new_shadow_memory);
41 :
42 m : } // namespace asan
43 m : } // namespace agent
44 :
45 : #endif // SYZYGY_AGENT_ASAN_MEMORY_INTERCEPTORS_PATCHER_H_
|