summaryrefslogtreecommitdiff
path: root/lib/interception/interception_win.h
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2014-08-25 13:19:05 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2014-08-25 13:19:05 +0000
commit8f87bbd7f4aa60f6a7204d9ab293552a7f42d228 (patch)
treede85f8898bfc8ad14655139d624f65f5c76eea0d /lib/interception/interception_win.h
parenta8f7b8f6831806cd382bf5dc913360bcf53f58f6 (diff)
[ASan/Win] Intercept memory allocation functions in the MD CRT
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@216382 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/interception/interception_win.h')
-rw-r--r--lib/interception/interception_win.h28
1 files changed, 17 insertions, 11 deletions
diff --git a/lib/interception/interception_win.h b/lib/interception/interception_win.h
index 1f866a1e0..ba768a723 100644
--- a/lib/interception/interception_win.h
+++ b/lib/interception/interception_win.h
@@ -22,23 +22,29 @@
#define INTERCEPTION_WIN_H
namespace __interception {
+// All the functions in the OverrideFunction() family return true on success,
+// false on failure (including "couldn't find the function").
-// returns true if the old function existed, false on failure.
-bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func);
+// Overrides a function by its address.
+bool OverrideFunction(uptr old_func, uptr new_func, uptr *orig_old_func = 0);
+
+// Overrides a function in a system DLL or DLL CRT by its exported name.
+bool OverrideFunction(const char *name, uptr new_func, uptr *orig_old_func = 0);
} // namespace __interception
-#if defined(_DLL)
-# error Not implemented yet
+#if defined(INTERCEPTION_DYNAMIC_CRT)
+#define INTERCEPT_FUNCTION_WIN(func) \
+ ::__interception::OverrideFunction(#func, \
+ (::__interception::uptr)WRAP(func), \
+ (::__interception::uptr *)&REAL(func))
#else
-# define INTERCEPT_FUNCTION_WIN(func) \
- ::__interception::OverrideFunction( \
- (::__interception::uptr)func, \
- (::__interception::uptr)WRAP(func), \
- (::__interception::uptr*)&REAL(func))
+#define INTERCEPT_FUNCTION_WIN(func) \
+ ::__interception::OverrideFunction((::__interception::uptr)func, \
+ (::__interception::uptr)WRAP(func), \
+ (::__interception::uptr *)&REAL(func))
#endif
-#define INTERCEPT_FUNCTION_VER_WIN(func, symver) \
- INTERCEPT_FUNCTION_WIN(func)
+#define INTERCEPT_FUNCTION_VER_WIN(func, symver) INTERCEPT_FUNCTION_WIN(func)
#endif // INTERCEPTION_WIN_H
#endif // _WIN32