diff -urEb curl-8.9.0.orig/CMake/Macros.cmake curl-8.9.0/CMake/Macros.cmake
--- curl-8.9.0.orig/CMake/Macros.cmake	2025-02-18 16:04:59.818585107 +0100
+++ curl-8.9.0/CMake/Macros.cmake	2025-02-18 16:05:16.867458366 +0100
@@ -48,7 +48,7 @@
     message(STATUS "Performing Test ${CURL_TEST}")
     try_compile(${CURL_TEST}
       ${CMAKE_BINARY_DIR}
-      ${CMAKE_CURRENT_SOURCE_DIR}/CMake/CurlTests.c
+      ${CURL_SOURCES_DIR}/CMake/CurlTests.c
       CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
       "${CURL_TEST_ADD_LIBRARIES}"
       OUTPUT_VARIABLE OUTPUT)
diff -urEb curl-8.9.0.orig/lib/system_win32.c curl-8.9.0/lib/system_win32.c
--- curl-8.9.0.orig/lib/system_win32.c	2025-02-18 16:04:59.834584988 +0100
+++ curl-8.9.0/lib/system_win32.c	2025-02-18 16:06:26.448941452 +0100
@@ -273,7 +273,7 @@
 
 bool Curl_win32_impersonating(void)
 {
-#ifndef CURL_WINDOWS_APP
+#if !defined(CURL_WINDOWS_APP) && !defined(__MINGW32__)
   HANDLE token = NULL;
   if(OpenThreadToken(GetCurrentThread(), TOKEN_QUERY, TRUE, &token)) {
     CloseHandle(token);
