interception_win.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  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. #ifdef _WIN32
  13. #if !defined(INCLUDED_FROM_INTERCEPTION_LIB)
  14. # error "interception_win.h should be included from interception library only"
  15. #endif
  16. #ifndef INTERCEPTION_WIN_H
  17. #define INTERCEPTION_WIN_H
  18. namespace __interception {
  19. // All the functions in the OverrideFunction() family return true on success,
  20. // false on failure (including "couldn't find the function").
  21. // Overrides a function by its address.
  22. bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func = 0);
  23. // Overrides a function in a system DLL or DLL CRT by its exported name.
  24. bool OverrideFunction(const char *name, uptr new_func, uptr *orig_old_func = 0);
  25. } // namespace __interception
  26. #if defined(INTERCEPTION_DYNAMIC_CRT)
  27. #define INTERCEPT_FUNCTION_WIN(func) \
  28. ::__interception::OverrideFunction(#func, \
  29. (::__interception::uptr)WRAP(func), \
  30. (::__interception::uptr *)&REAL(func))
  31. #else
  32. #define INTERCEPT_FUNCTION_WIN(func) \
  33. ::__interception::OverrideFunction((::__interception::uptr)func, \
  34. (::__interception::uptr)WRAP(func), \
  35. (::__interception::uptr *)&REAL(func))
  36. #endif
  37. #define INTERCEPT_FUNCTION_VER_WIN(func, symver) INTERCEPT_FUNCTION_WIN(func)
  38. #endif // INTERCEPTION_WIN_H
  39. #endif // _WIN32