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 : // Implement the Asan RTL functions.
16 : #ifndef SYZYGY_AGENT_ASAN_RTL_IMPL_H_
17 : #define SYZYGY_AGENT_ASAN_RTL_IMPL_H_
18 :
19 : #include <windows.h>
20 :
21 m : namespace agent {
22 m : namespace asan {
23 :
24 m : class AsanRuntime;
25 m : struct AsanErrorInfo;
26 :
27 : // Initialize the Asan runtime library global variables.
28 : // @param runtime The Asan runtime manager.
29 m : void SetUpRtl(AsanRuntime* runtime);
30 :
31 : // Tear down the runtime library.
32 m : void TearDownRtl();
33 :
34 m : } // namespace asan
35 m : } // namespace agent
36 :
37 : // Exposes the Asan Rtl functions.
38 m : extern "C" {
39 :
40 : // This function isn't intercepted anymore (after v0.8.6.1), it's just here for
41 : // backward compatibility.
42 m : HANDLE WINAPI asan_GetProcessHeap();
43 :
44 m : HANDLE WINAPI asan_HeapCreate(DWORD options,
45 m : SIZE_T initial_size,
46 m : SIZE_T maximum_size);
47 :
48 m : BOOL WINAPI asan_HeapDestroy(HANDLE heap);
49 :
50 m : LPVOID WINAPI asan_HeapAlloc(HANDLE heap,
51 m : DWORD flags,
52 m : SIZE_T bytes);
53 :
54 m : LPVOID WINAPI asan_HeapReAlloc(HANDLE heap,
55 m : DWORD flags,
56 m : LPVOID mem,
57 m : SIZE_T bytes);
58 :
59 m : BOOL WINAPI asan_HeapFree(HANDLE heap,
60 m : DWORD flags,
61 m : LPVOID mem);
62 :
63 m : SIZE_T WINAPI asan_HeapSize(HANDLE heap,
64 m : DWORD flags,
65 m : LPCVOID mem);
66 :
67 m : BOOL WINAPI asan_HeapValidate(HANDLE heap,
68 m : DWORD flags,
69 m : LPCVOID mem);
70 :
71 m : SIZE_T WINAPI asan_HeapCompact(HANDLE heap,
72 m : DWORD flags);
73 :
74 m : BOOL WINAPI asan_HeapLock(HANDLE heap);
75 :
76 m : BOOL WINAPI asan_HeapUnlock(HANDLE heap);
77 :
78 m : BOOL WINAPI asan_HeapWalk(HANDLE heap,
79 m : LPPROCESS_HEAP_ENTRY entry);
80 :
81 m : BOOL WINAPI asan_HeapSetInformation(
82 m : HANDLE heap, HEAP_INFORMATION_CLASS info_class,
83 m : PVOID info, SIZE_T info_length);
84 :
85 m : BOOL WINAPI asan_HeapQueryInformation(
86 m : HANDLE heap, HEAP_INFORMATION_CLASS info_class,
87 m : PVOID info, SIZE_T info_length, PSIZE_T return_length);
88 :
89 : // @name Testing seams.
90 : // @{
91 m : typedef void (*AsanErrorCallBack)(agent::asan::AsanErrorInfo*);
92 m : void WINAPI asan_SetCallBack(AsanErrorCallBack callback);
93 : // Allows specifying a callback that will be called by the OnException handler
94 : // in block.h utility funtions.
95 m : typedef void (*OnExceptionCallback)(EXCEPTION_POINTERS*);
96 m : void WINAPI asan_SetOnExceptionCallback(OnExceptionCallback callback);
97 : // @}
98 :
99 m : int asan_CrashForException(EXCEPTION_POINTERS* exception);
100 :
101 m : } // extern "C"
102 :
103 : #endif // SYZYGY_AGENT_ASAN_RTL_IMPL_H_
|