xref: /netbsd-src/external/gpl3/gcc/dist/libsanitizer/interception/interception_win.h (revision 413d532bcc3f62d122e56d92e13ac64825a40baf)
1 //===-- interception_linux.h ------------------------------------*- C++ -*-===//
2 //
3 // This file is distributed under the University of Illinois Open Source
4 // License. See LICENSE.TXT for details.
5 //
6 //===----------------------------------------------------------------------===//
7 //
8 // This file is a part of AddressSanitizer, an address sanity checker.
9 //
10 // Windows-specific interception methods.
11 //===----------------------------------------------------------------------===//
12 
13 #ifdef _WIN32
14 
15 #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
16 # error "interception_win.h should be included from interception library only"
17 #endif
18 
19 #ifndef INTERCEPTION_WIN_H
20 #define INTERCEPTION_WIN_H
21 
22 namespace __interception {
23 // returns true if a function with the given name was found.
24 bool GetRealFunctionAddress(const char *func_name, uptr *func_addr);
25 
26 // returns true if the old function existed, false on failure.
27 bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func);
28 }  // namespace __interception
29 
30 #if defined(_DLL)
31 # define INTERCEPT_FUNCTION_WIN(func) \
32     ::__interception::GetRealFunctionAddress( \
33         #func, (::__interception::uptr*)&REAL(func))
34 #else
35 # define INTERCEPT_FUNCTION_WIN(func) \
36     ::__interception::OverrideFunction( \
37         (::__interception::uptr)func, \
38         (::__interception::uptr)WRAP(func), \
39         (::__interception::uptr*)&REAL(func))
40 #endif
41 
42 #endif  // INTERCEPTION_WIN_H
43 #endif  // _WIN32
44