2016-09-08 Steven G. Kargl <kargl@gcc.gnu.org>
[official-gcc.git] / libsanitizer / interception / interception_win.h
blob6388209dcc160fdb1da6e5b81374a620ea6b64ae
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 //===----------------------------------------------------------------------===//
13 #ifdef _WIN32
15 #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
16 # error "interception_win.h should be included from interception library only"
17 #endif
19 #ifndef INTERCEPTION_WIN_H
20 #define INTERCEPTION_WIN_H
22 namespace __interception {
23 // All the functions in the OverrideFunction() family return true on success,
24 // false on failure (including "couldn't find the function").
26 // Overrides a function by its address.
27 bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func = 0);
29 // Overrides a function in a system DLL or DLL CRT by its exported name.
30 bool OverrideFunction(const char *name, uptr new_func, uptr *orig_old_func = 0);
32 // Windows-only replacement for GetProcAddress. Useful for some sanitizers.
33 uptr InternalGetProcAddress(void *module, const char *func_name);
35 } // namespace __interception
37 #if defined(INTERCEPTION_DYNAMIC_CRT)
38 #define INTERCEPT_FUNCTION_WIN(func) \
39 ::__interception::OverrideFunction(#func, \
40 (::__interception::uptr)WRAP(func), \
41 (::__interception::uptr *)&REAL(func))
42 #else
43 #define INTERCEPT_FUNCTION_WIN(func) \
44 ::__interception::OverrideFunction((::__interception::uptr)func, \
45 (::__interception::uptr)WRAP(func), \
46 (::__interception::uptr *)&REAL(func))
47 #endif
49 #define INTERCEPT_FUNCTION_VER_WIN(func, symver) INTERCEPT_FUNCTION_WIN(func)
51 #endif // INTERCEPTION_WIN_H
52 #endif // _WIN32