Timur Iskhodzhanov | 07bb9f1 | 2012-02-22 13:59:49 +0000 | [diff] [blame] | 1 | //===-- interception_linux.h ------------------------------------*- C++ -*-===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file is a part of AddressSanitizer, an address sanity checker. |
| 11 | // |
| 12 | // Windows-specific interception methods. |
| 13 | //===----------------------------------------------------------------------===// |
| 14 | |
| 15 | #ifdef _WIN32 |
| 16 | |
| 17 | #if !defined(INCLUDED_FROM_INTERCEPTION_LIB) |
| 18 | # error "interception_win.h should be included from interception library only" |
| 19 | #endif |
| 20 | |
| 21 | #ifndef INTERCEPTION_WIN_H |
| 22 | #define INTERCEPTION_WIN_H |
| 23 | |
| 24 | namespace __interception { |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 25 | // All the functions in the OverrideFunction() family return true on success, |
| 26 | // false on failure (including "couldn't find the function"). |
Timur Iskhodzhanov | 2716a61 | 2012-03-12 11:45:09 +0000 | [diff] [blame] | 27 | |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 28 | // Overrides a function by its address. |
| 29 | bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func = 0); |
| 30 | |
| 31 | // Overrides a function in a system DLL or DLL CRT by its exported name. |
| 32 | bool OverrideFunction(const char *name, uptr new_func, uptr *orig_old_func = 0); |
Timur Iskhodzhanov | 07bb9f1 | 2012-02-22 13:59:49 +0000 | [diff] [blame] | 33 | } // namespace __interception |
| 34 | |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 35 | #if defined(INTERCEPTION_DYNAMIC_CRT) |
| 36 | #define INTERCEPT_FUNCTION_WIN(func) \ |
| 37 | ::__interception::OverrideFunction(#func, \ |
| 38 | (::__interception::uptr)WRAP(func), \ |
| 39 | (::__interception::uptr *)&REAL(func)) |
Timur Iskhodzhanov | 2716a61 | 2012-03-12 11:45:09 +0000 | [diff] [blame] | 40 | #else |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 41 | #define INTERCEPT_FUNCTION_WIN(func) \ |
| 42 | ::__interception::OverrideFunction((::__interception::uptr)func, \ |
| 43 | (::__interception::uptr)WRAP(func), \ |
| 44 | (::__interception::uptr *)&REAL(func)) |
Timur Iskhodzhanov | 2716a61 | 2012-03-12 11:45:09 +0000 | [diff] [blame] | 45 | #endif |
Timur Iskhodzhanov | 07bb9f1 | 2012-02-22 13:59:49 +0000 | [diff] [blame] | 46 | |
Stephen Hines | 6d18623 | 2014-11-26 17:56:19 -0800 | [diff] [blame] | 47 | #define INTERCEPT_FUNCTION_VER_WIN(func, symver) INTERCEPT_FUNCTION_WIN(func) |
Alexey Samsonov | 5e2d377 | 2013-10-16 08:20:31 +0000 | [diff] [blame] | 48 | |
Timur Iskhodzhanov | 07bb9f1 | 2012-02-22 13:59:49 +0000 | [diff] [blame] | 49 | #endif // INTERCEPTION_WIN_H |
| 50 | #endif // _WIN32 |