commit 331b52d98163a4a3a985ccec6e2987453e08d5bd
Author: ANightly <anightlya>
Date:   Sun Feb 9 10:40:25 2025 +0200

    Fix Building for Windows 7

diff --git a/deps/uv/src/win/thread.c b/deps/uv/src/win/thread.c
index 436846a716..cdf57b76c6 100644
--- a/deps/uv/src/win/thread.c
+++ b/deps/uv/src/win/thread.c
@@ -278,70 +278,66 @@ int uv_thread_equal(const uv_thread_t* t1, const uv_thread_t* t2) {
 }
 
 
+static DWORD tls_index = TLS_OUT_OF_INDEXES;
+
 int uv_thread_setname(const char* name) {
-  HRESULT hr;
-  WCHAR* namew;
-  int err;
-  char namebuf[UV_PTHREAD_MAX_NAMELEN_NP];
+    if (name == NULL) {
+        return UV_EINVAL;
+    }
 
-  if (name == NULL)
-    return UV_EINVAL;
+    char namebuf[UV_PTHREAD_MAX_NAMELEN_NP];
+    strncpy(namebuf, name, sizeof(namebuf) - 1);
+    namebuf[sizeof(namebuf) - 1] = '\0';
 
-  strncpy(namebuf, name, sizeof(namebuf) - 1);
-  namebuf[sizeof(namebuf) - 1] = '\0';
+    if (tls_index == TLS_OUT_OF_INDEXES) {
+        tls_index = TlsAlloc();
+        if (tls_index == TLS_OUT_OF_INDEXES) {
+            return UV_EINVAL;
+        }
+    }
 
-  namew = NULL;
-  err = uv__convert_utf8_to_utf16(namebuf, &namew);
-  if (err)
-    return err;
+    // Allocate memory for the thread name
+    char* name_copy = (char*)LocalAlloc(LPTR, strlen(namebuf) + 1);
+    if (name_copy == NULL) {
+        return UV_EINVAL;
+    }
 
-  hr = SetThreadDescription(GetCurrentThread(), namew);
-  uv__free(namew);
-  if (FAILED(hr))
-    return uv_translate_sys_error(HRESULT_CODE(hr));
+    strcpy(name_copy, namebuf);
 
-  return 0;
-}
+    if (!TlsSetValue(tls_index, name_copy)) {
+        LocalFree(name_copy);
+        return UV_EINVAL;
+    }
 
+    return 0;
+}
 
 int uv_thread_getname(uv_thread_t* tid, char* name, size_t size) {
-  HRESULT hr;
-  WCHAR* namew;
-  char* thread_name;
-  size_t buf_size;
-  int r;
-  DWORD exit_code;
-
-  if (name == NULL || size == 0)
-    return UV_EINVAL;
+    if (name == NULL || size == 0) {
+        return UV_EINVAL;
+    }
 
-  if (tid == NULL || *tid == NULL)
-    return UV_EINVAL;
+    if (tid == NULL || *tid == NULL) {
+        return UV_EINVAL;
+    }
 
-  /* Check if the thread handle is valid */
-  if (!GetExitCodeThread(*tid, &exit_code) || exit_code != STILL_ACTIVE)
-    return UV_ENOENT;
-
-  namew = NULL;
-  thread_name = NULL;
-  hr = GetThreadDescription(*tid, &namew);
-  if (FAILED(hr))
-    return uv_translate_sys_error(HRESULT_CODE(hr));
-
-  buf_size = size;
-  r = uv__copy_utf16_to_utf8(namew, -1, name, &buf_size);
-  if (r == UV_ENOBUFS) {
-    r = uv__convert_utf16_to_utf8(namew, wcslen(namew), &thread_name);
-    if (r == 0) {
-      uv__strscpy(name, thread_name, size);
-      uv__free(thread_name);
+    // Check if TLS index is valid
+    if (tls_index == TLS_OUT_OF_INDEXES) {
+        return UV_ENOENT;
     }
-  }
 
-  LocalFree(namew);
-  return r;
-}
+    // Retrieve the thread name from TLS
+    char* thread_name = (char*)TlsGetValue(tls_index);
+    if (thread_name == NULL) {
+        return UV_ENOENT;
+    }
 
+    // Copy the thread name to the provided buffer
+    strncpy(name, thread_name, size - 1);
+    name[size - 1] = '\0';
+
+    return 0;
+}
 
 int uv_mutex_init(uv_mutex_t* mutex) {
   InitializeCriticalSection(mutex);
diff --git a/deps/uv/src/win/util.c b/deps/uv/src/win/util.c
index 1d1b2837e1..82263c6154 100644
--- a/deps/uv/src/win/util.c
+++ b/deps/uv/src/win/util.c
@@ -440,14 +440,7 @@ int uv_clock_gettime(uv_clock_id clock_id, uv_timespec64_t* ts) {
       ts->tv_nsec = t % 1000000000;
       return 0;
     case UV_CLOCK_REALTIME:
-      GetSystemTimePreciseAsFileTime(&ft);
-      /* In 100-nanosecond increments from 1601-01-01 UTC because why not? */
-      t = (int64_t) ft.dwHighDateTime << 32 | ft.dwLowDateTime;
-      /* Convert to UNIX epoch, 1970-01-01. Still in 100 ns increments. */
-      t -= 116444736000000000ll;
-      /* Now convert to seconds and nanoseconds. */
-      ts->tv_sec = t / 10000000;
-      ts->tv_nsec = t % 10000000 * 100;
+      GetSystemTimeAsFileTime(&ft);
       return 0;
   }
 
@@ -1405,22 +1398,29 @@ int uv_os_unsetenv(const char* name) {
 
 
 int uv_os_gethostname(char* buffer, size_t* size) {
-  WCHAR buf[UV_MAXHOSTNAMESIZE];
+  char buf[UV_MAXHOSTNAMESIZE];
+  size_t len;
 
   if (buffer == NULL || size == NULL || *size == 0)
     return UV_EINVAL;
 
   uv__once_init(); /* Initialize winsock */
 
-  if (pGetHostNameW == NULL)
-    return UV_ENOSYS;
-
-  if (pGetHostNameW(buf, UV_MAXHOSTNAMESIZE) != 0)
+  if (gethostname(buf, sizeof(buf)) != 0)
     return uv_translate_sys_error(WSAGetLastError());
 
-  return uv__copy_utf16_to_utf8(buf, -1, buffer, size);
-}
+  buf[sizeof(buf) - 1] = '\0';
+  len = strlen(buf);
 
+  if (len >= *size) {
+    *size = len + 1;
+    return UV_ENOBUFS;
+  }
+
+  memcpy(buffer, buf, len + 1);
+  *size = len;
+  return 0;
+}
 
 static int uv__get_handle(uv_pid_t pid, int access, HANDLE* handle) {
   int r;
diff --git a/deps/uv/src/win/winapi.h b/deps/uv/src/win/winapi.h
index 4e0ccc61ba..47c34622ff 100644
--- a/deps/uv/src/win/winapi.h
+++ b/deps/uv/src/win/winapi.h
@@ -4828,13 +4828,4 @@ typedef int (WINAPI *uv_sGetHostNameW)
              int);
 extern uv_sGetHostNameW pGetHostNameW;
 
-/* processthreadsapi.h */
-#if defined(__MINGW32__)
-WINBASEAPI
-HRESULT WINAPI GetThreadDescription(HANDLE hThread,
-                                    PWSTR *ppszThreadDescription);
-WINBASEAPI
-HRESULT WINAPI SetThreadDescription(HANDLE hThread, PCWSTR lpThreadDescription);
-#endif
-
 #endif /* UV_WIN_WINAPI_H_ */
diff --git a/deps/v8/src/maglev/maglev-assembler-inl.h b/deps/v8/src/maglev/maglev-assembler-inl.h
index a885ba9d36..63ddc1d26d 100644
--- a/deps/v8/src/maglev/maglev-assembler-inl.h
+++ b/deps/v8/src/maglev/maglev-assembler-inl.h
@@ -506,11 +506,11 @@ void CheckArgs(Args&&... args) {}
 
 #endif  // DEBUG
 
-template <typename Descriptor, typename... Args>
+template <typename Descriptor2, typename... Args>
 void PushArgumentsForBuiltin(MaglevAssembler* masm, std::tuple<Args...> args) {
   std::apply(
       [&](auto&&... stack_args) {
-        if (Descriptor::kStackArgumentOrder == StackArgumentOrder::kDefault) {
+        if (Descriptor2::kStackArgumentOrder == StackArgumentOrder::kDefault) {
           masm->Push(std::forward<decltype(stack_args)>(stack_args)...);
         } else {
           masm->PushReverse(std::forward<decltype(stack_args)>(stack_args)...);
diff --git a/src/node_main.cc b/src/node_main.cc
index 3295121b87..471cae8556 100644
--- a/src/node_main.cc
+++ b/src/node_main.cc
@@ -32,22 +32,7 @@
 #define SKIP_CHECK_STRLEN (sizeof(SKIP_CHECK_VALUE) - 1)
 
 int wmain(int argc, wchar_t* wargv[]) {
-  // Windows Server 2012 (not R2) is supported until 10/10/2023, so we allow it
-  // to run in the experimental support tier.
   char buf[SKIP_CHECK_STRLEN + 1];
-  if (!IsWindows10OrGreater() &&
-      (GetEnvironmentVariableA(SKIP_CHECK_VAR, buf, sizeof(buf)) !=
-           SKIP_CHECK_STRLEN ||
-       strncmp(buf, SKIP_CHECK_VALUE, SKIP_CHECK_STRLEN) != 0)) {
-    fprintf(stderr,
-            "Node.js is only supported on Windows 10, Windows "
-            "Server 2016, or higher.\n"
-            "Setting the " SKIP_CHECK_VAR " environment variable "
-            "to 1 skips this\ncheck, but Node.js might not execute "
-            "correctly. Any issues encountered on\nunsupported "
-            "platforms will not be fixed.");
-    exit(ERROR_EXE_MACHINE_TYPE_MISMATCH);
-  }
 
   // Convert argv to UTF8
   char** argv = new char*[argc + 1];
diff --git a/tools/msvs/msi/nodemsi/product.wxs b/tools/msvs/msi/nodemsi/product.wxs
index ff66ade681..3d4c4030e0 100644
--- a/tools/msvs/msi/nodemsi/product.wxs
+++ b/tools/msvs/msi/nodemsi/product.wxs
@@ -19,8 +19,6 @@
            InstallerVersion="200"
            Compressed="yes">
 
-    <Launch Condition="Installed OR (VersionNT &gt;= 603) OR (VersionNT &gt;= 602 AND MsiNTProductType &lt;&gt; 1)" Message="This application is only supported on Windows 8.1, Windows Server 2012 R2, or higher." />
-
     <Media Id="1" Cabinet="media1.cab" EmbedCab="yes"/>
 
     <MajorUpgrade AllowSameVersionUpgrades="yes"
diff --git a/vcbuild.bat b/vcbuild.bat
index f93998d2b1..545e973266 100644
--- a/vcbuild.bat
+++ b/vcbuild.bat
@@ -252,9 +252,36 @@ set vcvarsall_arg=%msvs_host_arch%_%target_arch%
 if %target_arch%==x64 if %msvs_host_arch%==amd64 set vcvarsall_arg=amd64
 if %target_arch%==%msvs_host_arch% set vcvarsall_arg=%target_arch%
 
+@rem Look for Visual Studio 2019
+:vs-set-2019
+if defined target_env if "%target_env%" NEQ "vs2019" goto msbuild-not-found
+echo Looking for Visual Studio 2019
+@rem VCINSTALLDIR may be set if run from a VS Command Prompt and needs to be
+@rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to
+@rem detect the version searched for
+if not defined target_env set "VCINSTALLDIR="
+call tools\msvs\vswhere_usability_wrapper.cmd "[16.0,17.0)" %target_arch% "prerelease"
+if "_%VCINSTALLDIR%_" == "__" goto msbuild-not-found
+@rem check if VS2019 is already setup, and for the requested arch
+if "_%VisualStudioVersion%_" == "_16.0_" if "_%VSCMD_ARG_TGT_ARCH%_"=="_%target_arch%_" goto found_vs2019
+@rem need to clear VSINSTALLDIR for vcvarsall to work as expected
+set "VSINSTALLDIR="
+@rem prevent VsDevCmd.bat from changing the current working directory
+set "VSCMD_START_DIR=%CD%"
+set vcvars_call="%VCINSTALLDIR%\Auxiliary\Build\vcvarsall.bat" %vcvarsall_arg%
+echo calling: %vcvars_call%
+call %vcvars_call%
+if errorlevel 1 goto msbuild-not-found
+if defined DEBUG_HELPER @ECHO ON
+:found_vs2019
+echo Found MSVS version %VisualStudioVersion%
+set GYP_MSVS_VERSION=2019
+set PLATFORM_TOOLSET=v142
+goto msbuild-found
+
 @rem Look for Visual Studio 2022
 :vs-set-2022
-if defined target_env if "%target_env%" NEQ "vs2022" goto msbuild-not-found
+if defined target_env if "%target_env%" NEQ "vs2022" goto vs-set-2019
 echo Looking for Visual Studio 2022
 @rem VCINSTALLDIR may be set if run from a VS Command Prompt and needs to be
 @rem cleared first as vswhere_usability_wrapper.cmd doesn't when it fails to
