1 : // Copyright 2014 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 : #include "syzygy/agent/asan/system_interceptors.h"
16 :
17 : #include <intrin.h>
18 :
19 : #include <algorithm>
20 :
21 : #include "base/logging.h"
22 : #include "syzygy/agent/asan/error_info.h"
23 : #include "syzygy/agent/asan/rtl_utils.h"
24 : #include "syzygy/agent/asan/runtime.h"
25 : #include "syzygy/agent/asan/shadow.h"
26 :
27 : namespace {
28 :
29 : using agent::asan::Shadow;
30 : using agent::asan::TestMemoryRange;
31 :
32 : // The global shadow memory that is used by the system interceptors.
33 : Shadow* system_interceptor_shadow_ = nullptr;
34 :
35 : // A callback that will be used in the functions interceptors once the call
36 : // to the intercepted function has been done. This is for testing purposes
37 : // only.
38 : InterceptorTailCallback interceptor_tail_callback = NULL;
39 :
40 : } // namespace
41 :
42 : namespace agent {
43 : namespace asan {
44 :
45 E : Shadow* SetSystemInterceptorShadow(Shadow* shadow) {
46 E : Shadow* old_shadow = system_interceptor_shadow_;
47 E : system_interceptor_shadow_ = shadow;
48 E : return old_shadow;
49 E : }
50 :
51 : } // namespace asan
52 : } // namespace agent
53 :
54 : extern "C" {
55 :
56 E : void asan_SetInterceptorCallback(InterceptorTailCallback callback) {
57 E : interceptor_tail_callback = callback;
58 E : }
59 :
60 : // Bring in the implementation of the system interceptors that have been
61 : // automatically generated.
62 : #include "syzygy/agent/asan/gen/system_interceptors_impl.gen"
63 :
64 : } // extern "C"
|