[vlc-commits] contrib: gcrypt: clean the Winstore patches

Steve Lhomme git at videolan.org
Fri Jun 19 12:00:17 CEST 2020


vlc | branch: master | Steve Lhomme <robux4 at ycbcr.xyz> | Fri Jun 19 11:13:48 2020 +0200| [d401ac307acaa1705f2552506acd23065a8bfee8] | committer: Steve Lhomme

contrib: gcrypt: clean the Winstore patches

Use wincrypt/CryptAPI via winstorecompat to retain WinXP compatibility.

> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=d401ac307acaa1705f2552506acd23065a8bfee8
---

 ...t-use-API-s-that-are-forbidden-in-UWP-app.patch | 158 +++++++++++
 ...-use-wincrypt-in-UWP-builds-if-WINSTORECO.patch |  75 ++++++
 contrib/src/gcrypt/rules.mak                       |   5 +-
 contrib/src/gcrypt/winrt.patch                     | 292 ---------------------
 4 files changed, 235 insertions(+), 295 deletions(-)

diff --git a/contrib/src/gcrypt/0007-random-don-t-use-API-s-that-are-forbidden-in-UWP-app.patch b/contrib/src/gcrypt/0007-random-don-t-use-API-s-that-are-forbidden-in-UWP-app.patch
new file mode 100644
index 0000000000..7d888e5fba
--- /dev/null
+++ b/contrib/src/gcrypt/0007-random-don-t-use-API-s-that-are-forbidden-in-UWP-app.patch
@@ -0,0 +1,158 @@
+From 95cc768cce8de579d0414830fe1d93c15f9594a7 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Fri, 19 Jun 2020 10:40:06 +0200
+Subject: [PATCH 7/9] random: don't use API's that are forbidden in UWP apps to
+ init the random generator
+
+---
+ random/rndw32.c | 29 +++++++++++++++++++++++++----
+ 1 file changed, 25 insertions(+), 4 deletions(-)
+
+diff --git a/random/rndw32.c b/random/rndw32.c
+index aefc7275..45d1e7e7 100644
+--- a/random/rndw32.c
++++ b/random/rndw32.c
+@@ -337,6 +337,7 @@ read_mbm_data (void (*add)(const void*, size_t, enum random_origins),
+   HANDLE hMBMData;
+   SharedData *mbmDataPtr;
+ 
++#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+   hMBMData = OpenFileMapping (FILE_MAP_READ, FALSE, "$M$B$M$5$S$D$" );
+   if (hMBMData)
+     {
+@@ -351,6 +352,7 @@ read_mbm_data (void (*add)(const void*, size_t, enum random_origins),
+         }
+       CloseHandle (hMBMData);
+     }
++#endif /* WINAPI_PARTITION_DESKTOP */
+ }
+ 
+ 
+@@ -359,6 +361,7 @@ static void
+ registry_poll (void (*add)(const void*, size_t, enum random_origins),
+                enum random_origins requester)
+ {
++#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+   static int cbPerfData = PERFORMANCE_BUFFER_SIZE;
+   int iterations;
+   DWORD dwSize, status;
+@@ -478,6 +481,7 @@ registry_poll (void (*add)(const void*, size_t, enum random_origins),
+      isn't done then any system components which provide performance data
+      can't be removed or changed while the handle remains active.  */
+   RegCloseKey (HKEY_PERFORMANCE_DATA);
++#endif /* WINAPI_PARTITION_DESKTOP */
+ }
+ 
+ 
+@@ -496,6 +500,7 @@ slow_gatherer ( void (*add)(const void*, size_t, enum random_origins),
+ 
+   if ( !is_initialized )
+     {
++#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+       HKEY hKey;
+ 
+       if ( debug_me )
+@@ -565,6 +570,10 @@ slow_gatherer ( void (*add)(const void*, size_t, enum random_origins),
+           if (!pNtQuerySystemInformation || !pNtQueryInformationProcess)
+             hNTAPI = NULL;
+         }
++#else /* !WINAPI_PARTITION_DESKTOP */
++      hNetAPI32 = NULL;
++      hNTAPI = NULL;
++#endif /* !WINAPI_PARTITION_DESKTOP */
+ 
+ 
+       is_initialized = 1;
+@@ -594,6 +603,7 @@ slow_gatherer ( void (*add)(const void*, size_t, enum random_origins),
+       }
+   }
+ 
++#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+   /* Get disk I/O statistics for all the hard drives.  100 is an
+      arbitrary failsafe limit.  */
+   for (drive_no = 0; drive_no < 100 ; drive_no++)
+@@ -628,6 +638,7 @@ slow_gatherer ( void (*add)(const void*, size_t, enum random_origins),
+         }
+       CloseHandle (hDevice);
+     }
++#endif /* WINAPI_PARTITION_DESKTOP */
+ 
+   /* In theory we should be using the Win32 performance query API to obtain
+      unpredictable data from the system, however this is so unreliable (see
+@@ -786,12 +797,16 @@ _gcry_rndw32_gather_random (void (*add)(const void*, size_t,
+ 
+   if (!is_initialized)
+     {
++#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+       OSVERSIONINFO osvi = { sizeof( osvi ) };
+ 
+       GetVersionEx( &osvi );
+       if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT)
+         log_fatal ("can only run on a Windows NT platform\n" );
+       system_is_w2000 = (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0);
++#else /* !WINAPI_PARTITION_DESKTOP */
++      system_is_w2000 = 0;
++#endif /* !WINAPI_PARTITION_DESKTOP */
+       init_system_rng ();
+       is_initialized = 1;
+     }
+@@ -842,14 +857,11 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
+                         ADDINT((SIZE_T)aptr);                      \
+                       } while (0)
+ 
++#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+     ADDPTR ( GetActiveWindow ());
+     ADDPTR ( GetCapture ());
+     ADDPTR ( GetClipboardOwner ());
+     ADDPTR ( GetClipboardViewer ());
+-    ADDPTR ( GetCurrentProcess ());
+-    ADDINT ( GetCurrentProcessId ());
+-    ADDPTR ( GetCurrentThread ());
+-    ADDINT ( GetCurrentThreadId ());
+     ADDPTR ( GetDesktopWindow ());
+     ADDPTR ( GetFocus ());
+     ADDINT ( GetInputState ());
+@@ -858,6 +870,11 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
+     ADDPTR ( GetOpenClipboardWindow ());
+     ADDPTR ( GetProcessHeap ());
+     ADDPTR ( GetProcessWindowStation ());
++#endif /* WINAPI_PARTITION_DESKTOP */
++    ADDPTR ( GetCurrentProcess ());
++    ADDINT ( GetCurrentProcessId ());
++    ADDPTR ( GetCurrentThread ());
++    ADDINT ( GetCurrentThreadId ());
+     /* Following function in some cases stops returning events, and cannot
+        be used as an entropy source.  */
+     /*ADDINT ( GetQueueStatus (QS_ALLEVENTS));*/
+@@ -871,6 +888,7 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
+ 
+   /* Get multiword system information: Current caret position, current
+      mouse cursor position.  */
++#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+   {
+     POINT point;
+ 
+@@ -922,10 +940,12 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
+     (*add) ( &minimumWorkingSetSize, sizeof (int), origin );
+     (*add) ( &maximumWorkingSetSize, sizeof (int), origin );
+   }
++#endif /* WINAPI_PARTITION_DESKTOP */
+ 
+ 
+   /* The following are fixed for the lifetime of the process so we only
+    * add them once */
++#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
+   if (!addedFixedItems)
+     {
+       STARTUPINFO startupInfo;
+@@ -938,6 +958,7 @@ _gcry_rndw32_gather_random_fast (void (*add)(const void*, size_t,
+       (*add) ( &startupInfo, sizeof (STARTUPINFO), origin );
+       addedFixedItems = 1;
+     }
++#endif /* WINAPI_PARTITION_DESKTOP */
+ 
+   /* The performance of QPC varies depending on the architecture it's
+      running on and on the OS, the MS documentation is vague about the
+-- 
+2.26.0.windows.1
+
diff --git a/contrib/src/gcrypt/0008-random-only-use-wincrypt-in-UWP-builds-if-WINSTORECO.patch b/contrib/src/gcrypt/0008-random-only-use-wincrypt-in-UWP-builds-if-WINSTORECO.patch
new file mode 100644
index 0000000000..fdc59b8041
--- /dev/null
+++ b/contrib/src/gcrypt/0008-random-only-use-wincrypt-in-UWP-builds-if-WINSTORECO.patch
@@ -0,0 +1,75 @@
+From 1b09aa078628e93c0f95f0d5e20e708f81068bf5 Mon Sep 17 00:00:00 2001
+From: Steve Lhomme <robux4 at ycbcr.xyz>
+Date: Fri, 19 Jun 2020 10:37:50 +0200
+Subject: [PATCH 8/9] random: only use wincrypt in UWP builds if WINSTORECOMPAT
+ is set
+
+This is a compatibility library to use older APIs that are forbidden in UWP apps.
+
+bcrypt is supposed to be used instead of wincrypt but is only available since
+Vista.
+---
+ random/rndw32.c | 17 +++++++++++++++++
+ src/Makefile.am |  4 +++-
+ 2 files changed, 20 insertions(+), 1 deletion(-)
+
+diff --git a/random/rndw32.c b/random/rndw32.c
+index 45d1e7e7..8b0a38fa 100644
+--- a/random/rndw32.c
++++ b/random/rndw32.c
+@@ -98,6 +98,9 @@
+ 
+ /* We don't include wincrypt.h so define it here.  */
+ #define HCRYPTPROV  HANDLE
++#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && defined(WINSTORECOMPAT)
++#include <wincrypt.h>
++#endif
+ 
+ 
+ /* When we query the performance counters, we allocate an initial buffer and
+@@ -259,6 +262,7 @@ init_system_rng (void)
+   system_rng_available = 0;
+   hRNGProv = NULL;
+ 
++#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
+   hAdvAPI32 = GetModuleHandle ("AdvAPI32.dll");
+   if (!hAdvAPI32)
+     return;
+@@ -274,6 +278,19 @@ init_system_rng (void)
+      This isn't exported by name, so we have to get it by ordinal.  */
+   pRtlGenRandom = (RTLGENRANDOM)
+     GetProcAddress (hAdvAPI32, "SystemFunction036");
++#elif defined(WINSTORECOMPAT)
++  hAdvAPI32 = NULL;
++  pCryptAcquireContext = CryptAcquireContextA;
++  pCryptGenRandom = CryptGenRandom;
++  pCryptReleaseContext = CryptReleaseContext;
++  pRtlGenRandom = NULL;
++#else /* !WINAPI_PARTITION_DESKTOP && !WINSTORECOMPAT */
++  hAdvAPI32 = NULL;
++  pCryptAcquireContext = NULL;
++  pCryptGenRandom = NULL;
++  pCryptReleaseContext = NULL;
++  pRtlGenRandom = NULL;
++#endif /* WINSTORECOMPAT */
+ 
+   /* Try and connect to the PIII RNG CSP.  The AMD 768 southbridge (from
+      the 760 MP chipset) also has a hardware RNG, but there doesn't appear
+diff --git a/src/Makefile.am b/src/Makefile.am
+index 3cc4a552..a22acd41 100644
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -123,7 +123,9 @@ libgcrypt_la_LIBADD = $(gcrypt_res) \
+ 	../random/librandom.la \
+ 	../mpi/libmpi.la \
+ 	../compat/libcompat.la  $(GPG_ERROR_LIBS)
+-
++if HAVE_W32_SYSTEM
++libgcrypt_la_LIBADD += -lbcrypt
++endif
+ 
+ dumpsexp_SOURCES = dumpsexp.c
+ dumpsexp_CFLAGS = $(arch_gpg_error_cflags)
+-- 
+2.26.0.windows.1
+
diff --git a/contrib/src/gcrypt/rules.mak b/contrib/src/gcrypt/rules.mak
index 625ff30d71..d778cf0b9a 100644
--- a/contrib/src/gcrypt/rules.mak
+++ b/contrib/src/gcrypt/rules.mak
@@ -19,9 +19,8 @@ gcrypt: libgcrypt-$(GCRYPT_VERSION).tar.bz2 .sum-gcrypt
 	$(APPLY) $(SRC)/gcrypt/0001-random-Don-t-assume-that-_WIN64-implies-x86_64.patch
 	$(APPLY) $(SRC)/gcrypt/0002-aarch64-mpi-Fix-building-the-mpi-aarch64-assembly-fo.patch
 	$(APPLY) $(SRC)/gcrypt/0001-compat-provide-a-getpid-replacement-that-works-on-Wi.patch
-ifdef HAVE_WINSTORE
-	$(APPLY) $(SRC)/gcrypt/winrt.patch
-endif
+	$(APPLY) $(SRC)/gcrypt/0007-random-don-t-use-API-s-that-are-forbidden-in-UWP-app.patch
+	$(APPLY) $(SRC)/gcrypt/0008-random-only-use-wincrypt-in-UWP-builds-if-WINSTORECO.patch
 ifdef HAVE_WIN64
 	$(APPLY) $(SRC)/gcrypt/64bits-relocation.patch
 endif
diff --git a/contrib/src/gcrypt/winrt.patch b/contrib/src/gcrypt/winrt.patch
deleted file mode 100644
index c01ec2d3ba..0000000000
--- a/contrib/src/gcrypt/winrt.patch
+++ /dev/null
@@ -1,292 +0,0 @@
---- gcrypt/random/rndw32.c	2017-05-03 12:45:22.000000000 +0200
-+++ gcrypt/random/rndw32.c.bcrypt	2018-04-05 13:11:54.339814800 +0200
-@@ -96,8 +96,8 @@
-    value in a newer release. So we use a far larger value. */
- #define SIZEOF_DISK_PERFORMANCE_STRUCT 256
-
--/* We don't include wincrypt.h so define it here.  */
--#define HCRYPTPROV  HANDLE
-+#include <winapifamily.h>
-+#include <bcrypt.h>
-
-
- /* When we query the performance counters, we allocate an initial buffer and
-@@ -140,25 +140,13 @@ typedef DWORD (WINAPI *NTPOWERINFORMATIO
-       ULONG inputBufferLength, PVOID outputBuffer, ULONG outputBufferLength );
-
- /* Type definitions for function pointers to call CryptoAPI functions. */
--typedef BOOL (WINAPI *CRYPTACQUIRECONTEXT)(HCRYPTPROV *phProv,
--                                           LPCTSTR pszContainer,
--                                           LPCTSTR pszProvider,
--                                           DWORD dwProvType,
--                                           DWORD dwFlags);
--typedef BOOL (WINAPI *CRYPTGENRANDOM)(HCRYPTPROV hProv, DWORD dwLen,
--                                      BYTE *pbBuffer);
--typedef BOOL (WINAPI *CRYPTRELEASECONTEXT)(HCRYPTPROV hProv, DWORD dwFlags);
--
--/* Somewhat alternative functionality available as a direct call, for
--   Windows XP and newer.  This is the CryptoAPI RNG, which isn't anywhere
--   near as good as the HW RNG, but we use it if it's present on the basis
--   that at least it can't make things any worse.  This direct access version
--   is only available under Windows XP, we don't go out of our way to access
--   the more general CryptoAPI one since the main purpose of using it is to
--   take advantage of any possible future hardware RNGs that may be added,
--   for example via TCPA devices.  */
--typedef BOOL (WINAPI *RTLGENRANDOM)(PVOID RandomBuffer,
--                                    ULONG RandomBufferLength);
-+typedef NTSTATUS (WINAPI *CRYPTOPENALGORITHMPROVIDER)(BCRYPT_ALG_HANDLE *phAlgorithm,
-+                                                     LPCWSTR pszAlgId,
-+                                                     LPCWSTR pszImplementation,
-+                                                     DWORD dwFlags);
-+typedef NTSTATUS (WINAPI *CRYPTGENRANDOM)(BCRYPT_ALG_HANDLE hAlgorithm, UCHAR *pbBuffer,
-+                                          ULONG cbBuffer, ULONG dwFlags);
-+typedef BOOL (WINAPI *CRYPTCLOSEALGORITHMPROVIDER)(BCRYPT_ALG_HANDLE hAlgorithm, DWORD dwFlags);
-
-
-
-@@ -234,16 +222,17 @@ static NTQUERYSYSTEMINFORMATION  pNtQuer
- static NTQUERYINFORMATIONPROCESS pNtQueryInformationProcess;
- static NTPOWERINFORMATION        pNtPowerInformation;
-
--static HANDLE hAdvAPI32;
--static CRYPTACQUIRECONTEXT pCryptAcquireContext;
--static CRYPTGENRANDOM      pCryptGenRandom;
--static CRYPTRELEASECONTEXT pCryptReleaseContext;
--static RTLGENRANDOM        pRtlGenRandom;
-+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-+static HANDLE hBcrypt;
-+#endif
-+static CRYPTOPENALGORITHMPROVIDER pBCryptOpenAlgorithmProvider;
-+static CRYPTGENRANDOM      pBCryptGenRandom;
-+static CRYPTCLOSEALGORITHMPROVIDER pBCryptCloseAlgorithmProvider;
-
-
- /* Other module global variables.  */
- static int system_rng_available; /* Whether a system RNG is available.  */
--static HCRYPTPROV hRNGProv;      /* Handle to Intel RNG CSP. */
-+static BCRYPT_ALG_HANDLE hRNGProv;  /* Handle to Intel RNG CSP. */
-
- static int debug_me;  /* Debug flag.  */
-
-@@ -259,21 +248,22 @@ init_system_rng (void)
-   system_rng_available = 0;
-   hRNGProv = NULL;
-
--  hAdvAPI32 = GetModuleHandle ("AdvAPI32.dll");
--  if (!hAdvAPI32)
-+#if !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-+    pBCryptOpenAlgorithmProvider = (CRYPTOPENALGORITHMPROVIDER) BCryptOpenAlgorithmProvider;
-+    pBCryptGenRandom      = (CRYPTGENRANDOM) BCryptGenRandom;
-+    pBCryptCloseAlgorithmProvider = (CRYPTCLOSEALGORITHMPROVIDER) BCryptCloseAlgorithmProvider;
-+#else
-+  hBcrypt = GetModuleHandle ("bcrypt.dll");
-+  if (!hBcrypt)
-     return;
-
--  pCryptAcquireContext = (CRYPTACQUIRECONTEXT)
--    GetProcAddress (hAdvAPI32, "CryptAcquireContextA");
--  pCryptGenRandom = (CRYPTGENRANDOM)
--    GetProcAddress (hAdvAPI32, "CryptGenRandom");
--  pCryptReleaseContext = (CRYPTRELEASECONTEXT)
--    GetProcAddress (hAdvAPI32, "CryptReleaseContext");
--
--  /* Get a pointer to the native randomness function if it's available.
--     This isn't exported by name, so we have to get it by ordinal.  */
--  pRtlGenRandom = (RTLGENRANDOM)
--    GetProcAddress (hAdvAPI32, "SystemFunction036");
-+  pBCryptOpenAlgorithmProvider = (CRYPTOPENALGORITHMPROVIDER)
-+    GetProcAddress (hBcrypt, "BCryptOpenAlgorithmProvider");
-+  pBCryptGenRandom = (CRYPTGENRANDOM)
-+    GetProcAddress (hBcrypt, "BCryptGenRandom");
-+  pBCryptCloseAlgorithmProvider = (CRYPTCLOSEALGORITHMPROVIDER)
-+    GetProcAddress (hBcrypt, "BCryptCloseAlgorithmProvider");
-+#endif
-
-   /* Try and connect to the PIII RNG CSP.  The AMD 768 southbridge (from
-      the 760 MP chipset) also has a hardware RNG, but there doesn't appear
-@@ -281,12 +271,13 @@ init_system_rng (void)
-      can't do much with it.  OTOH the Intel RNG is also effectively dead
-      as well, mostly due to virtually nonexistent support/marketing by
-      Intel, it's included here mostly for form's sake.  */
--  if ( (!pCryptAcquireContext || !pCryptGenRandom || !pCryptReleaseContext
--        || !pCryptAcquireContext (&hRNGProv, NULL, INTEL_DEF_PROV,
--                                  PROV_INTEL_SEC, 0) )
--       && !pRtlGenRandom)
--    {
--      hAdvAPI32 = NULL;
-+  if ( (!pBCryptOpenAlgorithmProvider || !pBCryptGenRandom || !pBCryptCloseAlgorithmProvider
-+        || !pBCryptOpenAlgorithmProvider (&hRNGProv, BCRYPT_RNG_ALGORITHM,
-+                                          MS_PRIMITIVE_PROVIDER, 0) ) )
-+    {
-+#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-+      hBcrypt = NULL;
-+#endif
-     }
-   else
-     system_rng_available = 1;
-@@ -309,14 +300,9 @@ read_system_rng (void (*add)(const void*
-      software RNG) in case it's broken in some way.  */
-   if (hRNGProv)
-     {
--      if (pCryptGenRandom (hRNGProv, SYSTEMRNG_BYTES, buffer))
-+      if (pBCryptGenRandom (hRNGProv, buffer, SYSTEMRNG_BYTES, 0))
-         quality = 80;
-     }
--  else if (pRtlGenRandom)
--    {
--      if ( pRtlGenRandom (buffer, SYSTEMRNG_BYTES))
--        quality = 50;
--    }
-   if (quality > 0)
-     {
-       if (debug_me)
-@@ -337,6 +323,7 @@ read_mbm_data (void (*add)(const void*,
-   HANDLE hMBMData;
-   SharedData *mbmDataPtr;
-
-+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
-   hMBMData = OpenFileMapping (FILE_MAP_READ, FALSE, "$M$B$M$5$S$D$" );
-   if (hMBMData)
-     {
-@@ -351,6 +338,7 @@ read_mbm_data (void (*add)(const void*,
-         }
-       CloseHandle (hMBMData);
-     }
-+#endif
- }
-
-
-@@ -359,6 +347,7 @@ static void
- registry_poll (void (*add)(const void*, size_t, enum random_origins),
-                enum random_origins requester)
- {
-+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
-   static int cbPerfData = PERFORMANCE_BUFFER_SIZE;
-   int iterations;
-   DWORD dwSize, status;
-@@ -478,6 +467,7 @@ registry_poll (void (*add)(const void*,
-      isn't done then any system components which provide performance data
-      can't be removed or changed while the handle remains active.  */
-   RegCloseKey (HKEY_PERFORMANCE_DATA);
-+#endif
- }
-
-
-@@ -496,6 +486,7 @@ slow_gatherer ( void (*add)(const void*,
-
-   if ( !is_initialized )
-     {
-+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
-       HKEY hKey;
-
-       if ( debug_me )
-@@ -565,6 +556,7 @@ slow_gatherer ( void (*add)(const void*,
-           if (!pNtQuerySystemInformation || !pNtQueryInformationProcess)
-             hNTAPI = NULL;
-         }
-+#endif
-
-
-       is_initialized = 1;
-@@ -594,6 +586,7 @@ slow_gatherer ( void (*add)(const void*,
-       }
-   }
-
-+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
-   /* Get disk I/O statistics for all the hard drives.  100 is an
-      arbitrary failsafe limit.  */
-   for (drive_no = 0; drive_no < 100 ; drive_no++)
-@@ -628,6 +621,7 @@ slow_gatherer ( void (*add)(const void*,
-         }
-       CloseHandle (hDevice);
-     }
-+#endif
-
-   /* In theory we should be using the Win32 performance query API to obtain
-      unpredictable data from the system, however this is so unreliable (see
-@@ -786,12 +780,16 @@ _gcry_rndw32_gather_random (void (*add)(
-
-   if (!is_initialized)
-     {
-+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
-       OSVERSIONINFO osvi = { sizeof( osvi ) };
-
-       GetVersionEx( &osvi );
-       if (osvi.dwPlatformId != VER_PLATFORM_WIN32_NT)
-         log_fatal ("can only run on a Windows NT platform\n" );
-       system_is_w2000 = (osvi.dwMajorVersion == 5 && osvi.dwMinorVersion == 0);
-+#else
-+      system_is_w2000 = 0;
-+#endif
-       init_system_rng ();
-       is_initialized = 1;
-     }
-@@ -842,14 +840,11 @@ _gcry_rndw32_gather_random_fast (void (*
-                         ADDINT((SIZE_T)aptr);                      \
-                       } while (0)
-
-+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
-     ADDPTR ( GetActiveWindow ());
-     ADDPTR ( GetCapture ());
-     ADDPTR ( GetClipboardOwner ());
-     ADDPTR ( GetClipboardViewer ());
--    ADDPTR ( GetCurrentProcess ());
--    ADDINT ( GetCurrentProcessId ());
--    ADDPTR ( GetCurrentThread ());
--    ADDINT ( GetCurrentThreadId ());
-     ADDPTR ( GetDesktopWindow ());
-     ADDPTR ( GetFocus ());
-     ADDINT ( GetInputState ());
-@@ -858,6 +853,11 @@ _gcry_rndw32_gather_random_fast (void (*
-     ADDPTR ( GetOpenClipboardWindow ());
-     ADDPTR ( GetProcessHeap ());
-     ADDPTR ( GetProcessWindowStation ());
-+#endif
-+    ADDPTR ( GetCurrentProcess ());
-+    ADDINT ( GetCurrentProcessId ());
-+    ADDPTR ( GetCurrentThread ());
-+    ADDINT ( GetCurrentThreadId ());
-     /* Following function in some cases stops returning events, and cannot
-        be used as an entropy source.  */
-     /*ADDINT ( GetQueueStatus (QS_ALLEVENTS));*/
-@@ -871,6 +871,7 @@ _gcry_rndw32_gather_random_fast (void (*
-
-   /* Get multiword system information: Current caret position, current
-      mouse cursor position.  */
-+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
-   {
-     POINT point;
-
-@@ -922,10 +923,12 @@ _gcry_rndw32_gather_random_fast (void (*
-     (*add) ( &minimumWorkingSetSize, sizeof (int), origin );
-     (*add) ( &maximumWorkingSetSize, sizeof (int), origin );
-   }
-+#endif
-
-
-   /* The following are fixed for the lifetime of the process so we only
-    * add them once */
-+#if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_DESKTOP)
-   if (!addedFixedItems)
-     {
-       STARTUPINFO startupInfo;
-@@ -938,6 +941,7 @@ _gcry_rndw32_gather_random_fast (void (*
-       (*add) ( &startupInfo, sizeof (STARTUPINFO), origin );
-       addedFixedItems = 1;
-     }
-+#endif
-
-   /* The performance of QPC varies depending on the architecture it's
-      running on and on the OS, the MS documentation is vague about the
---- gcrypt/src/Makefile.am.bcrypt	2020-04-28 09:01:19.967622400 +0200
-+++ gcrypt/src/Makefile.am	2020-04-28 09:01:57.814996100 +0200
-@@ -123,6 +123,9 @@ libgcrypt_la_LIBADD = $(gcrypt_res) \
- 	../random/librandom.la \
- 	../mpi/libmpi.la \
- 	../compat/libcompat.la  $(GPG_ERROR_LIBS)
-+if HAVE_W32_SYSTEM
-+libgcrypt_la_LIBADD += -lbcrypt
-+endif
-
-
- dumpsexp_SOURCES = dumpsexp.c



More information about the vlc-commits mailing list