Timur Iskhodzhanov | 36d297d | 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 { |
| 25 | // returns true if a function with the given name was found. |
Alexey Samsonov | 9d742950 | 2012-08-02 11:29:14 +0000 | [diff] [blame] | 26 | bool GetRealFunctionAddress(const char *func_name, uptr *func_addr); |
Timur Iskhodzhanov | 2f48b87 | 2012-03-12 11:45:09 +0000 | [diff] [blame] | 27 | |
| 28 | // returns true if the old function existed, false on failure. |
Alexey Samsonov | 9d742950 | 2012-08-02 11:29:14 +0000 | [diff] [blame] | 29 | bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func); |
Timur Iskhodzhanov | 36d297d | 2012-02-22 13:59:49 +0000 | [diff] [blame] | 30 | } // namespace __interception |
| 31 | |
Timur Iskhodzhanov | 2f48b87 | 2012-03-12 11:45:09 +0000 | [diff] [blame] | 32 | #if defined(_DLL) |
| 33 | # define INTERCEPT_FUNCTION_WIN(func) \ |
Alexey Samsonov | 9d742950 | 2012-08-02 11:29:14 +0000 | [diff] [blame] | 34 | ::__interception::GetRealFunctionAddress( \ |
| 35 | #func, (::__interception::uptr*)&REAL(func)) |
Timur Iskhodzhanov | 2f48b87 | 2012-03-12 11:45:09 +0000 | [diff] [blame] | 36 | #else |
| 37 | # define INTERCEPT_FUNCTION_WIN(func) \ |
Alexey Samsonov | 9d742950 | 2012-08-02 11:29:14 +0000 | [diff] [blame] | 38 | ::__interception::OverrideFunction( \ |
| 39 | (::__interception::uptr)func, \ |
| 40 | (::__interception::uptr)WRAP(func), \ |
| 41 | (::__interception::uptr*)&REAL(func)) |
Timur Iskhodzhanov | 2f48b87 | 2012-03-12 11:45:09 +0000 | [diff] [blame] | 42 | #endif |
Timur Iskhodzhanov | 36d297d | 2012-02-22 13:59:49 +0000 | [diff] [blame] | 43 | |
| 44 | #endif // INTERCEPTION_WIN_H |
| 45 | #endif // _WIN32 |