[compiler-rt] [win/asan] AllocateMemoryForTrampoline within 2 GB of the module's base address (PR #108822)

via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 16 06:24:02 PDT 2024


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff cca54e347ac34912cdfb9983533c61836db135e0 bb222ba6859e493e7d61e1961b42b94179733e10 --extensions cpp -- compiler-rt/lib/interception/interception_win.cpp
``````````

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/compiler-rt/lib/interception/interception_win.cpp b/compiler-rt/lib/interception/interception_win.cpp
index b7979b271f..78854d344f 100644
--- a/compiler-rt/lib/interception/interception_win.cpp
+++ b/compiler-rt/lib/interception/interception_win.cpp
@@ -129,8 +129,8 @@
 #if SANITIZER_WINDOWS
 #include "sanitizer_common/sanitizer_platform.h"
 #define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <psapi.h>
+#  include <psapi.h>
+#  include <windows.h>
 
 namespace __interception {
 
@@ -389,7 +389,7 @@ void TestOnlyReleaseTrampolineRegions() {
 static uptr AllocateMemoryForTrampoline(uptr func_address, size_t size) {
   uptr image_address = func_address;
 
-#if SANITIZER_WINDOWS64
+#  if SANITIZER_WINDOWS64
   // Since we may copy code to the trampoline which could reference data
   // inside the original module, we really want the trampoline to be within
   // 2 GB of not just the original function, but within 2 GB of that function's
@@ -399,15 +399,15 @@ static uptr AllocateMemoryForTrampoline(uptr func_address, size_t size) {
   // func_address is in mmap'ed memory for example).
   HMODULE module;
   if (::GetModuleHandleExW(GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS |
-                           GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
+                               GET_MODULE_HANDLE_EX_FLAG_UNCHANGED_REFCOUNT,
                            (LPCWSTR)func_address, &module)) {
     MODULEINFO module_info;
-    if (::GetModuleInformation(::GetCurrentProcess(), module,
-                                &module_info, sizeof(module_info))) {
+    if (::GetModuleInformation(::GetCurrentProcess(), module, &module_info,
+                               sizeof(module_info))) {
       image_address = (uptr)module_info.lpBaseOfDll;
     }
   }
-#endif
+#  endif
 
   // Find a region within 2G with enough space to allocate |size| bytes.
   TrampolineMemoryRegion *region = nullptr;

``````````

</details>


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


More information about the llvm-commits mailing list