blob: 96c4a0c0f5a34050a19bbdd4a57c2129aaa0b24e [file] [log] [blame]
Timur Iskhodzhanov07bb9f12012-02-22 13:59:49 +00001//===-- 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
24namespace __interception {
Stephen Hines6d186232014-11-26 17:56:19 -080025// All the functions in the OverrideFunction() family return true on success,
26// false on failure (including "couldn't find the function").
Timur Iskhodzhanov2716a612012-03-12 11:45:09 +000027
Stephen Hines6d186232014-11-26 17:56:19 -080028// Overrides a function by its address.
29bool 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.
32bool OverrideFunction(const char *name, uptr new_func, uptr *orig_old_func = 0);
Pirama Arumuga Nainar799172d2016-03-03 15:50:30 -080033
34// Windows-only replacement for GetProcAddress. Useful for some sanitizers.
35uptr InternalGetProcAddress(void *module, const char *func_name);
36
Timur Iskhodzhanov07bb9f12012-02-22 13:59:49 +000037} // namespace __interception
38
Stephen Hines6d186232014-11-26 17:56:19 -080039#if defined(INTERCEPTION_DYNAMIC_CRT)
40#define INTERCEPT_FUNCTION_WIN(func) \
41 ::__interception::OverrideFunction(#func, \
42 (::__interception::uptr)WRAP(func), \
43 (::__interception::uptr *)&REAL(func))
Timur Iskhodzhanov2716a612012-03-12 11:45:09 +000044#else
Stephen Hines6d186232014-11-26 17:56:19 -080045#define INTERCEPT_FUNCTION_WIN(func) \
46 ::__interception::OverrideFunction((::__interception::uptr)func, \
47 (::__interception::uptr)WRAP(func), \
48 (::__interception::uptr *)&REAL(func))
Timur Iskhodzhanov2716a612012-03-12 11:45:09 +000049#endif
Timur Iskhodzhanov07bb9f12012-02-22 13:59:49 +000050
Stephen Hines6d186232014-11-26 17:56:19 -080051#define INTERCEPT_FUNCTION_VER_WIN(func, symver) INTERCEPT_FUNCTION_WIN(func)
Alexey Samsonov5e2d3772013-10-16 08:20:31 +000052
Timur Iskhodzhanov07bb9f12012-02-22 13:59:49 +000053#endif // INTERCEPTION_WIN_H
54#endif // _WIN32