summaryrefslogtreecommitdiffstats
path: root/compiler-rt/lib/asan/interception/interception_win.cc
diff options
context:
space:
mode:
authorTimur Iskhodzhanov <timurrrr@google.com>2012-02-22 13:59:49 +0000
committerTimur Iskhodzhanov <timurrrr@google.com>2012-02-22 13:59:49 +0000
commit36d297d27f9cd9999f0e785b9c2f5988beca693e (patch)
tree3c5773d6b015efc861b7b552bb24102d5bdd64da /compiler-rt/lib/asan/interception/interception_win.cc
parent453173f09a7961ed77d4cf4e33c956e42dd480b3 (diff)
downloadbcm5719-llvm-36d297d27f9cd9999f0e785b9c2f5988beca693e.tar.gz
bcm5719-llvm-36d297d27f9cd9999f0e785b9c2f5988beca693e.zip
[ASan] Intercept functions on Windows - first version
llvm-svn: 151161
Diffstat (limited to 'compiler-rt/lib/asan/interception/interception_win.cc')
-rw-r--r--compiler-rt/lib/asan/interception/interception_win.cc36
1 files changed, 36 insertions, 0 deletions
diff --git a/compiler-rt/lib/asan/interception/interception_win.cc b/compiler-rt/lib/asan/interception/interception_win.cc
new file mode 100644
index 00000000000..a3f0f2b0c0b
--- /dev/null
+++ b/compiler-rt/lib/asan/interception/interception_win.cc
@@ -0,0 +1,36 @@
+//===-- interception_linux.cc -----------------------------------*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// This file is a part of AddressSanitizer, an address sanity checker.
+//
+// Windows-specific interception methods.
+//===----------------------------------------------------------------------===//
+
+#ifdef _WIN32
+
+#include <windows.h>
+
+namespace __interception {
+
+bool GetRealFunctionAddress(const char *func_name, void **func_addr) {
+ const char *DLLS[] = {
+ "msvcr80.dll",
+ "msvcr90.dll",
+ "kernel32.dll",
+ NULL
+ };
+ *func_addr = NULL;
+ for (size_t i = 0; *func_addr == NULL && DLLS[i]; ++i) {
+ *func_addr = GetProcAddress(GetModuleHandleA(DLLS[i]), func_name);
+ }
+ return (*func_addr != NULL);
+}
+} // namespace __interception
+
+#endif // _WIN32
OpenPOWER on IntegriCloud