1 : // Copyright 2012 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 : // Dummy CRT interceptors for the memory profiler. This is simply for
16 : // maintaining ABI compatibility.
17 :
18 m : extern "C" {
19 :
20 : // Memory probes are called with EDX on the stack, and the address to be
21 : // checked in EDX. Thus, the top of the stack is the return address and below
22 : // that is the original value of EDX.
23 : #define DEFINE_NULL_MEMORY_PROBE(name) \
24 m : void __declspec(naked) name() { \
25 m : /* Restore the value of EDX. */ \
26 m : __asm mov edx, DWORD PTR[esp + 4] \
27 m : /* Return and pop the saved EDX value off the stack. */ \
28 m : __asm ret 4 \
29 m : }
30 :
31 : // Special instruction takes their addresses directly in some known registers,
32 : // so no extra information gets pushed onto the stack and there's nothing to
33 : // clean, we can simply return.
34 : #define DEFINE_NULL_SPECIAL_PROBE(name) \
35 m : void __declspec(naked) name() { \
36 m : __asm ret \
37 m : }
38 :
39 : // Define all of the null memory probes.
40 m : DEFINE_NULL_MEMORY_PROBE(asan_check_1_byte_read_access);
41 m : DEFINE_NULL_MEMORY_PROBE(asan_check_2_byte_read_access);
42 m : DEFINE_NULL_MEMORY_PROBE(asan_check_4_byte_read_access);
43 m : DEFINE_NULL_MEMORY_PROBE(asan_check_8_byte_read_access);
44 m : DEFINE_NULL_MEMORY_PROBE(asan_check_10_byte_read_access);
45 m : DEFINE_NULL_MEMORY_PROBE(asan_check_16_byte_read_access);
46 m : DEFINE_NULL_MEMORY_PROBE(asan_check_32_byte_read_access);
47 m : DEFINE_NULL_MEMORY_PROBE(asan_check_1_byte_write_access);
48 m : DEFINE_NULL_MEMORY_PROBE(asan_check_2_byte_write_access);
49 m : DEFINE_NULL_MEMORY_PROBE(asan_check_4_byte_write_access);
50 m : DEFINE_NULL_MEMORY_PROBE(asan_check_8_byte_write_access);
51 m : DEFINE_NULL_MEMORY_PROBE(asan_check_10_byte_write_access);
52 m : DEFINE_NULL_MEMORY_PROBE(asan_check_16_byte_write_access);
53 m : DEFINE_NULL_MEMORY_PROBE(asan_check_32_byte_write_access);
54 m : DEFINE_NULL_MEMORY_PROBE(asan_check_1_byte_read_access_no_flags);
55 m : DEFINE_NULL_MEMORY_PROBE(asan_check_2_byte_read_access_no_flags);
56 m : DEFINE_NULL_MEMORY_PROBE(asan_check_4_byte_read_access_no_flags);
57 m : DEFINE_NULL_MEMORY_PROBE(asan_check_8_byte_read_access_no_flags);
58 m : DEFINE_NULL_MEMORY_PROBE(asan_check_10_byte_read_access_no_flags);
59 m : DEFINE_NULL_MEMORY_PROBE(asan_check_16_byte_read_access_no_flags);
60 m : DEFINE_NULL_MEMORY_PROBE(asan_check_32_byte_read_access_no_flags);
61 m : DEFINE_NULL_MEMORY_PROBE(asan_check_1_byte_write_access_no_flags);
62 m : DEFINE_NULL_MEMORY_PROBE(asan_check_2_byte_write_access_no_flags);
63 m : DEFINE_NULL_MEMORY_PROBE(asan_check_4_byte_write_access_no_flags);
64 m : DEFINE_NULL_MEMORY_PROBE(asan_check_8_byte_write_access_no_flags);
65 m : DEFINE_NULL_MEMORY_PROBE(asan_check_10_byte_write_access_no_flags);
66 m : DEFINE_NULL_MEMORY_PROBE(asan_check_16_byte_write_access_no_flags);
67 m : DEFINE_NULL_MEMORY_PROBE(asan_check_32_byte_write_access_no_flags);
68 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_repz_1_byte_cmps_access);
69 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_repz_2_byte_cmps_access);
70 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_repz_4_byte_cmps_access);
71 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_repz_1_byte_movs_access);
72 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_repz_2_byte_movs_access);
73 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_repz_4_byte_movs_access);
74 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_repz_1_byte_stos_access);
75 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_repz_2_byte_stos_access);
76 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_repz_4_byte_stos_access);
77 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_1_byte_cmps_access);
78 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_2_byte_cmps_access);
79 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_4_byte_cmps_access);
80 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_1_byte_movs_access);
81 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_2_byte_movs_access);
82 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_4_byte_movs_access);
83 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_1_byte_stos_access);
84 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_2_byte_stos_access);
85 m : DEFINE_NULL_SPECIAL_PROBE(asan_check_4_byte_stos_access);
86 : #undef DEFINE_NULL_MEMORY_PROBE
87 : #undef DEFINE_NULL_STRING_PROBE
88 :
89 m : } // extern "C"
|