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 : // Defines the list of functions to be intercepted by Asan instrumentation.
16 :
17 : #include "syzygy/instrument/transforms/asan_intercepts.h"
18 :
19 : #include <stddef.h>
20 :
21 m : namespace instrument {
22 m : namespace transforms {
23 :
24 m : const MD5Hash kHashes_memchr[] = {
25 m : {"3549cc2f365403c679287c34325b8925"}, // VS2010 and VS2013.
26 m : {""} };
27 m : const MD5Hash kHashes_strcspn[] = {
28 m : {"c2e8480d30ceeeb2e9e39b545c82c98c"}, // VS2010 and VS2013.
29 m : {""} };
30 m : const MD5Hash kHashes_strlen[] = {
31 m : {"20e07f6e772c47e6cbfc13db5eafa757"}, // VS2010 and VS2013.
32 m : {""} };
33 m : const MD5Hash kHashes_strpbrk[] = {
34 m : {"9af2e6d499d25ad4628c58a25dbcde1e"}, // VS2010 and VS2013.
35 m : {""} };
36 m : const MD5Hash kHashes_strspn[] = {
37 m : {"79b6a33a1b03b482be14afff061d7c68"}, // VS2010 and VS2013.
38 m : {""} };
39 m : const MD5Hash kHashes_strncpy[] = {
40 m : {"aed1dd2372364f66f4d126eefb073070"}, // VS2010 and VS2013.
41 m : {""} };
42 m : const MD5Hash kHashes_strncat[] = {
43 m : {"9cc9e9a57cdd695606caf6cbf532d88e"}, // VS2010 and VS2013.
44 m : {""} };
45 m : const MD5Hash kHashes_memcpy[] = {
46 m : {"da1805f40d6e92f6ac497c66ac969e61"}, // VS2010.
47 m : {"270406ea8a9e931f2c0db8a7f0b5d698"}, // VS2013.
48 m : {""} };
49 m : const MD5Hash kHashes_memmove[] = {
50 m : {"da1805f40d6e92f6ac497c66ac969e61"}, // VS2010.
51 m : {"270406ea8a9e931f2c0db8a7f0b5d698"}, // VS2013.
52 m : {""} };
53 m : const MD5Hash kHashes_memset[] = {
54 m : {"5fcb11b79692c753845cf26dfa42e74c"}, // VS2010.
55 m : {"4900d834c35bb195ab8af6f91d648d6d"}, // VS2013.
56 m : {""} };
57 m : const MD5Hash kHashes_strrchr[] = {
58 m : {"f849347be44ddb17a4fc3c64b90f8cca"}, // VS2010.
59 m : {"17575b2dc3a7fd3b277d0cd798f507df"}, // VS2013.
60 m : {""} };
61 m : const MD5Hash kHashes_strcmp[] = {
62 m : {"865502e059de8a9dc6cee8ef05b1a586"}, // VS2010.
63 m : {"3de87a84bf545bd485f846c1b9456bcb"}, // VS2013.
64 m : {""} };
65 m : const MD5Hash kHashes_strstr[] = {
66 m : {"cdfbaae199dcc8272681c021fab9d664"}, // VS2010.
67 m : {"1926bd8c94118f97819d604ec5afee30"}, // VS2013.
68 m : {""} };
69 m : const MD5Hash kHashes_wcsrchr[] = {
70 m : {"dc474260def9e341659230dc2edd13e6"}, // VS2013.
71 m : {""} };
72 m : const MD5Hash kHashes_wcschr[] = {
73 m : {"3fae79785ec4de9951eac512bc62a27e"}, // VS2013.
74 m : {""} };
75 m : const MD5Hash kHashes_wcsstr[] = {
76 m : {"2301f403b55567eae76f3dc58dd777f4"}, // VS2013.
77 m : {""} };
78 :
79 : // List of module names.
80 m : const char kKernel32[] = "kernel32.dll";
81 :
82 : // Functions with the same value for |module| must be consecutive in this
83 : // array.
84 m : const AsanIntercept kAsanIntercepts[] = {
85 : // Heap related kernel32 functions.
86 m : { "HeapCreate", "_HeapCreate@12", kKernel32, NULL, false },
87 m : { "HeapDestroy", "_HeapDestroy@4", kKernel32, NULL, false },
88 m : { "HeapAlloc", "_HeapAlloc@12", kKernel32, NULL, false },
89 m : { "HeapReAlloc", "_HeapReAlloc@16", kKernel32, NULL, false },
90 m : { "HeapFree", "_HeapFree@12", kKernel32, NULL, false },
91 m : { "HeapSize", "_HeapSize@12", kKernel32, NULL, false },
92 m : { "HeapValidate", "_HeapValidate@12", kKernel32, NULL, false },
93 m : { "HeapCompact", "_HeapCompact@8", kKernel32, NULL, false },
94 m : { "HeapLock", "_HeapLock@4", kKernel32, NULL, false },
95 m : { "HeapUnlock", "_HeapUnlock@4", kKernel32, NULL, false },
96 m : { "HeapWalk", "_HeapWalk@8", kKernel32, NULL, false },
97 m : { "HeapSetInformation", "_HeapSetInformation@16", kKernel32, NULL, false },
98 m : { "HeapQueryInformation", "_HeapQueryInformation@20", kKernel32, NULL,
99 m : false },
100 :
101 : // Bring in the list of system interceptors that have been automatically
102 : // generated.
103 : #include "syzygy/agent/asan/gen/system_interceptors_instrumentation_filter.gen"
104 :
105 : // C-runtime functions. For Chrome these are always statically linked, but
106 : // they *could* be imported from one of several different versions of the
107 : // runtime library.
108 : // TODO(chrisha): Add support for intercepting these via import redirection?
109 : // This might involve handling multiple possible module names per
110 : // function.
111 m : { "memchr", "_memchr", NULL, kHashes_memchr, true },
112 m : { "memcpy", "_memcpy", NULL, kHashes_memcpy, true },
113 m : { "memmove", "_memmove", NULL, kHashes_memmove, true },
114 m : { "memset", "_memset", NULL, kHashes_memset, true },
115 m : { "strlen", "_strlen", NULL, kHashes_strlen, true },
116 m : { "strncpy", "_strncpy", NULL, kHashes_strncpy, true },
117 m : { "strncat", "_strncat", NULL, kHashes_strncat, true },
118 m : { "strrchr", "_strrchr", NULL, kHashes_strrchr, true },
119 m : { "wcsrchr", "_wcsrchr", NULL, kHashes_wcsrchr, true },
120 m : { "wcschr", "_wcschr", NULL, kHashes_wcschr, true },
121 m : { "wcsstr", "_wcsstr", NULL, kHashes_wcsstr, true },
122 :
123 : // Terminating entry.
124 m : { NULL, NULL, NULL, NULL, false },
125 m : };
126 :
127 m : const char kUndecoratedAsanInterceptPrefix[] = "asan_";
128 m : const char kDecoratedAsanInterceptPrefix[] = "_asan";
129 m : const char kDecoratedImportPrefix[] = "__imp_";
130 :
131 m : const char kUndecoratedHotPatchingAsanInterceptPrefix[] = "hp_asan_";
132 :
133 m : } // namespace transforms
134 m : } // namespace instrument
|