Fixed Windows 7 compatibility
Some checks failed
Microsoft C++ Code Analysis / Analyze (push) Has been cancelled
C/C++ CI / build-alpine-static (map[arch:aarch64 branch:latest-stable flags:-ffunction-sections -Wno-error=inline -mfix-cortex-a53-835769 -mfix-cortex-a53-843419]) (push) Has been cancelled
C/C++ CI / build-alpine-static (map[arch:riscv64 branch:edge flags:-ffunction-sections -Wno-error=inline]) (push) Has been cancelled
C/C++ CI / build-alpine-static (map[arch:x86_64 branch:latest-stable flags:-ffunction-sections -Wno-error=inline]) (push) Has been cancelled
C/C++ CI / build-ubuntu (map[c:gcc-11 cpp:g++-11 flags: os:ubuntu-20.04]) (push) Has been cancelled
C/C++ CI / build-ubuntu (map[c:gcc-12 cpp:g++-12 flags: os:ubuntu-22.04]) (push) Has been cancelled
C/C++ CI / build-ubuntu (map[c:gcc-8 cpp:g++-8 flags: os:ubuntu-20.04]) (push) Has been cancelled
C/C++ CI / build-ubuntu-static-libs (map[flags:-fuse-linker-plugin -ffunction-sections -Wno-error=inline]) (push) Has been cancelled
C/C++ CI / build-ubuntu-aarch64 (map[flags:-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 os:ubuntu-20.04]) (push) Has been cancelled
C/C++ CI / build-ubuntu-aarch64 (map[flags:-fuse-linker-plugin -ffunction-sections -mfix-cortex-a53-835769 -mfix-cortex-a53-843419 os:ubuntu-22.04]) (push) Has been cancelled
C/C++ CI / build-windows-msys2 (map[c:clang cxx:clang++ flags:-fuse-ld=lld -Wno-unused-command-line-argument -Wno-nan-infinity-disabled]) (push) Has been cancelled
C/C++ CI / build-windows-msys2 (map[c:gcc cxx:g++ flags:-ffunction-sections -Wno-error=maybe-uninitialized -Wno-error=attributes]) (push) Has been cancelled
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:OFF upnp:OFF vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Has been cancelled
clang-tidy / clang-tidy (push) Has been cancelled
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:ON upnp:OFF vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Has been cancelled
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:OFF tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Has been cancelled
C/C++ CI / build-windows-msbuild (map[grpc:OFF os:2019 rx:ON tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Has been cancelled
C/C++ CI / build-windows-msbuild (map[grpc:ON os:2019 rx:ON tls:ON upnp:ON vs:Visual Studio 16 2019 vspath:C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise]) (push) Has been cancelled
source-snapshot / source-snapshot (push) Has been cancelled
C/C++ CI / build-windows-msbuild (map[grpc:ON os:2022 rx:ON tls:ON upnp:ON vs:Visual Studio 17 2022 vspath:C:\Program Files\Microsoft Visual Studio\2022\Enterprise]) (push) Has been cancelled
C/C++ CI / build-macos (push) Has been cancelled
C/C++ CI / build-macos-aarch64 (push) Has been cancelled
C/C++ CI / build-freebsd (map[architecture:x86-64 host:ubuntu-latest name:freebsd version:13.3]) (push) Has been cancelled
cppcheck / cppcheck-ubuntu (push) Has been cancelled
C/C++ CI / build-openbsd (map[architecture:x86-64 host:ubuntu-latest name:openbsd version:7.4]) (push) Has been cancelled
CodeQL / Analyze (push) Has been cancelled
cppcheck / cppcheck-windows (push) Has been cancelled
Sync test (old) / sync-test-windows-debug-asan (push) Has been cancelled
Sync test (old) / sync-test-windows-leaks (push) Has been cancelled
Sync test / sync-test-ubuntu-tsan (push) Has been cancelled
Sync test / sync-test-ubuntu-msan (push) Has been cancelled
Sync test / sync-test-ubuntu-ubsan (push) Has been cancelled
Sync test / sync-test-ubuntu-asan (push) Has been cancelled
Sync test / sync-test-macos (map[flags:-Og -ftrapv -target arm64-apple-macos-11 os:macos-14]) (push) Has been cancelled
Sync test / sync-test-macos (map[flags:-Og -ftrapv os:macos-13]) (push) Has been cancelled
Sync test / sync-test-windows-debug-asan (push) Has been cancelled
Sync test / sync-test-windows-leaks (push) Has been cancelled
Sync test (old) / sync-test-ubuntu-tsan (push) Has been cancelled
Sync test (old) / sync-test-ubuntu-msan (push) Has been cancelled
Sync test (old) / sync-test-ubuntu-ubsan (push) Has been cancelled
Sync test (old) / sync-test-ubuntu-asan (push) Has been cancelled
Sync test (old) / sync-test-macos (map[flags:-Og -ftrapv -target arm64-apple-macos-11 os:macos-14]) (push) Has been cancelled
Sync test (old) / sync-test-macos (map[flags:-Og -ftrapv os:macos-13]) (push) Has been cancelled

This commit is contained in:
SChernykh 2024-10-01 10:31:53 +02:00
parent 4dfdaf5447
commit 210ae3f9df
4 changed files with 64 additions and 1 deletions

View file

@ -439,6 +439,10 @@ jobs:
- name: Setup cmake - name: Setup cmake
uses: lukka/get-cmake@latest uses: lukka/get-cmake@latest
- name: Apply patch
run: |
git apply --verbose --ignore-whitespace --directory=external/src/grpc/third_party/boringssl-with-bazel patches/boringssl/win7.patch
- name: Build p2pool - name: Build p2pool
run: | run: |
mkdir build mkdir build

View file

@ -215,7 +215,7 @@ if (WITH_UPNP)
endif() endif()
if (WIN32) if (WIN32)
set(LIBS ${LIBS} ws2_32 iphlpapi userenv psapi dnsapi dbghelp) set(LIBS ${LIBS} ws2_32 iphlpapi userenv psapi dnsapi dbghelp advapi32)
if (CMAKE_CXX_COMPILER_ID MATCHES GNU) if (CMAKE_CXX_COMPILER_ID MATCHES GNU)
set(LIBS ${LIBS} bcrypt) set(LIBS ${LIBS} bcrypt)
endif() endif()

View file

@ -0,0 +1,58 @@
diff --git a/src/crypto/rand_extra/windows.c b/src/crypto/rand_extra/windows.c
index a44774d23..09cf10942 100644
--- a/src/crypto/rand_extra/windows.c
+++ b/src/crypto/rand_extra/windows.c
@@ -26,6 +26,7 @@
OPENSSL_MSVC_PRAGMA(warning(push, 3))
#include <windows.h>
+#include <wincrypt.h>
#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && \
!WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
@@ -61,16 +62,40 @@ void CRYPTO_sysrand(uint8_t *out, size_t requested) {
// See: https://learn.microsoft.com/en-us/windows/win32/seccng/processprng
typedef BOOL (WINAPI *ProcessPrngFunction)(PBYTE pbData, SIZE_T cbData);
static ProcessPrngFunction g_processprng_fn = NULL;
+static HCRYPTPROV g_hCryptProv = NULL;
+
+static BOOL WINAPI wrapper_CryptGenRandom(PBYTE pbData, SIZE_T cbData)
+{
+ return CryptGenRandom(g_hCryptProv, cbData, pbData);
+}
static void init_processprng(void) {
HMODULE hmod = LoadLibraryW(L"bcryptprimitives");
- if (hmod == NULL) {
- abort();
+
+ if (hmod) {
+ g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng");
+ if (g_processprng_fn) {
+ return;
+ }
}
- g_processprng_fn = (ProcessPrngFunction)GetProcAddress(hmod, "ProcessPrng");
- if (g_processprng_fn == NULL) {
- abort();
+
+ if (CryptAcquireContext(&g_hCryptProv, NULL, NULL, PROV_RSA_FULL, 0)) {
+ g_processprng_fn = &wrapper_CryptGenRandom;
+ return;
+ }
+
+ DWORD err = GetLastError();
+ if (err == NTE_BAD_KEYSET) {
+ if (CryptAcquireContext(&g_hCryptProv, NULL, NULL, PROV_RSA_FULL, CRYPT_NEWKEYSET)) {
+ g_processprng_fn = &wrapper_CryptGenRandom;
+ return;
+ }
+ else {
+ err = GetLastError();
+ }
}
+
+ abort();
}
void CRYPTO_init_sysrand(void) {

View file

@ -293,6 +293,7 @@ allowedAPIs = {
"GetFileAttributesA", "GetFileAttributesA",
"OpenThreadToken", "OpenThreadToken",
"GetOverlappedResult", "GetOverlappedResult",
"CryptGenRandom",
} }
f = open(sys.argv[1], 'r') f = open(sys.argv[1], 'r')