--- emacs-28.1/nt/cmdproxy.c.orig	2022-06-23 19:24:10.845481100 +0200
+++ emacs-28.1/nt/cmdproxy.c	2022-06-23 19:24:19.271132900 +0200
@@ -35,6 +35,10 @@
 #include <string.h>  /* strlen */
 #include <ctype.h>   /* isspace, isalpha */
 
+#ifdef _UCRT
+#define _snprintf snprintf
+#endif
+
 /* We don't want to include stdio.h because we are already duplicating
    lots of it here */
 extern int _snprintf (char *buffer, size_t count, const char *format, ...);
--- emacs-30.1/src/sysdep.c.orig	2025-02-18 19:31:36.000000000 +0100
+++ emacs-30.1/src/sysdep.c	2025-02-23 19:26:04.314287100 +0100
@@ -2984,8 +2984,10 @@
 #else /* !__ANDROID__ */
   if (close_stream (stdout) != 0)
     {
+#ifndef _UCRT // XXX: close_stream(stdout) fails for some reason
       emacs_perror ("Write error to standard output");
       _exit (EXIT_FAILURE);
+#endif
     }
 
   /* Do not close stderr if addresses are being sanitized, as the
@@ -2994,7 +2996,11 @@
   if (err | (ADDRESS_SANITIZER
 	     ? fflush (stderr) != 0 || ferror (stderr)
 	     : close_stream (stderr) != 0))
+#ifndef _UCRT // XXX: close_stream(stderr) fails for some reason
     _exit (EXIT_FAILURE);
+#else
+    ;
+#endif
 #endif /* __ANDROID__ */
 }
 
