]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Have fallback in case GetProcAddress fails 597/head
authorRose <83477269+AtariDreams@users.noreply.github.com>
Sat, 21 Jan 2023 19:01:43 +0000 (14:01 -0500)
committerRose <83477269+AtariDreams@users.noreply.github.com>
Sat, 21 Jan 2023 19:03:27 +0000 (14:03 -0500)
cups/usersys.c

index 21352bbe465523eb51d67b319424b15d6c46a4e6..977f6ef80b5af7275346faad880bf81e1b5915a8 100644 (file)
@@ -548,7 +548,7 @@ cupsSetUserAgent(const char *user_agent)/* I - User-Agent string or @code NULL@
                                        /* Thread globals */
 #ifdef _WIN32
   SYSTEM_INFO          sysinfo;        /* System information */
-  OSVERSIONINFOA       version;        /* OS version info */
+  OSVERSIONINFOW       version;        /* OS version info */
   const char           *machine;       /* Hardware/machine name */
 #elif defined(__APPLE__)
   struct utsname       name;           /* uname info */
@@ -595,15 +595,19 @@ cupsSetUserAgent(const char *user_agent)/* I - User-Agent string or @code NULL@
 
   typedef NTSTATUS(WINAPI * RtlGetVersionPtr)(PRTL_OSVERSIONINFOW);
 
+  memset(&version, 0, sizeof(version))
+  version.dwOSVersionInfoSize = sizeof(version);
+
+  /* RtlGetVersion gets the current native version of Windows, even when running in compatibility mode */
   RtlGetVersionPtr RtlGetVersionInternal = (RtlGetVersionPtr)GetProcAddress(GetModuleHandleW(L"ntdll.dll"), "RtlGetVersion");
   if (RtlGetVersionInternal)
   {
-    version.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
     RtlGetVersionInternal((PRTL_OSVERSIONINFOW)&version);
   }
   else
   {
-    ZeroMemory(&version, sizeof(version));
+    /* Should not happen, but just in case, fallback to deprecated GetVersionExW */
+    GetVersionExW(&version);
   }
   GetNativeSystemInfo(&sysinfo);