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