[compiler-rt] [win/asan] Don't intercept memset etc. in ntdll (PR #120397)

Hans Wennborg via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 19 05:28:54 PST 2024


================
@@ -1281,9 +1280,22 @@ uptr InternalGetProcAddress(void *module, const char *func_name) {
 
 bool OverrideFunction(
     const char *func_name, uptr new_func, uptr *orig_old_func) {
+  static const char *kNtDllIgnore[] = {
+    "memcmp", "memcpy", "memmove", "memset"
+  };
+
   bool hooked = false;
   void **DLLs = InterestingDLLsAvailable();
   for (size_t i = 0; DLLs[i]; ++i) {
+    if (DLLs[i + 1] == nullptr) {
+      // This is the last DLL, i.e. NTDLL. It exports some functions that
+      // we only want to override in the CRT.
+      for (const char *ignored : kNtDllIgnore) {
+        if (strcmp(func_name, ignored) == 0)
----------------
zmodem wrote:

Done.

https://github.com/llvm/llvm-project/pull/120397


More information about the llvm-commits mailing list