Skip to content

Commit 329b38c

Browse files
authored
Merge pull request #2203 from jamescowens/enforce_no_earlier_than_win_7
build, util: Prevent execution for Windows versions less than Windows 7
2 parents eb08c25 + 2ec4432 commit 329b38c

File tree

6 files changed

+6
-28
lines changed

6 files changed

+6
-28
lines changed

configure.ac

+3-1
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ case $host in
413413
AC_MSG_ERROR("windres not found")
414414
fi
415415

416-
CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB"
416+
CPPFLAGS="$CPPFLAGS -D_MT -DWIN32 -D_WINDOWS -DBOOST_THREAD_USE_LIB -D_WIN32_WINNT=0x0601"
417417
LEVELDB_TARGET_FLAGS="-DOS_WINDOWS"
418418
if test "x$CXXFLAGS_overridden" = "xno"; then
419419
CXXFLAGS="$CXXFLAGS -w"
@@ -433,6 +433,8 @@ case $host in
433433
archive_cmds_CXX="\$CC -shared \$libobjs \$deplibs \$compiler_flags -static -o \$output_objdir/\$soname \${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker \$lib"
434434
postdeps_CXX=
435435

436+
dnl We require Windows 7 (NT 6.1) or later
437+
AX_CHECK_LINK_FLAG([[-Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1]],[LDFLAGS="$LDFLAGS -Wl,--major-subsystem-version -Wl,6 -Wl,--minor-subsystem-version -Wl,1"],,[[$LDFLAG_WERROR]])
436438
;;
437439
*darwin*)
438440
TARGET_OS=darwin

src/compat.h

-4
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,6 @@
1616
#endif
1717

1818
#ifdef WIN32
19-
#ifdef _WIN32_WINNT
20-
#undef _WIN32_WINNT
21-
#endif
22-
#define _WIN32_WINNT 0x0501
2319
#ifndef WIN32_LEAN_AND_MEAN
2420
#define WIN32_LEAN_AND_MEAN 1
2521
#endif

src/init.cpp

+2-11
Original file line numberDiff line numberDiff line change
@@ -738,17 +738,8 @@ bool AppInit2(ThreadHandlerPtr threads)
738738
_set_abort_behavior(0, _WRITE_ABORT_MSG | _CALL_REPORTFAULT);
739739
#endif
740740
#ifdef WIN32
741-
// Enable Data Execution Prevention (DEP)
742-
// Minimum supported OS versions: WinXP SP3, WinVista >= SP1, Win Server 2008
743-
// A failure is non-critical and needs no further attention!
744-
#ifndef PROCESS_DEP_ENABLE
745-
// We define this here, because GCCs winbase.h limits this to _WIN32_WINNT >= 0x0601 (Windows 7),
746-
// which is not correct. Can be removed, when GCCs winbase.h is fixed!
747-
#define PROCESS_DEP_ENABLE 0x00000001
748-
#endif
749-
typedef BOOL (WINAPI *PSETPROCDEPPOL)(DWORD);
750-
PSETPROCDEPPOL setProcDEPPol = (PSETPROCDEPPOL)GetProcAddress(GetModuleHandleA("Kernel32.dll"), "SetProcessDEPPolicy");
751-
if (setProcDEPPol != nullptr) setProcDEPPol(PROCESS_DEP_ENABLE);
741+
// Enable heap terminate-on-corruption
742+
HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0);
752743
#endif
753744
#ifndef WIN32
754745
umask(077);

src/netbase.cpp

+1-4
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ bool static LookupIntern(const char *pszName, std::vector<CNetAddr>& vIP, unsign
5656
aiHint.ai_socktype = SOCK_STREAM;
5757
aiHint.ai_protocol = IPPROTO_TCP;
5858
aiHint.ai_family = AF_UNSPEC;
59-
#ifdef WIN32
60-
aiHint.ai_flags = fAllowLookup ? 0 : AI_NUMERICHOST;
61-
#else
6259
aiHint.ai_flags = fAllowLookup ? AI_ADDRCONFIG : AI_NUMERICHOST;
63-
#endif
60+
6461
struct addrinfo* aiRes = nullptr;
6562
int nErr = getaddrinfo(pszName, nullptr, &aiHint, &aiRes);
6663
if (nErr)

src/qt/guiutil.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,6 @@
2121
#include <QThread>
2222

2323
#ifdef WIN32
24-
#ifdef _WIN32_WINNT
25-
#undef _WIN32_WINNT
26-
#endif
27-
#define _WIN32_WINNT 0x0501
2824
#ifdef _WIN32_IE
2925
#undef _WIN32_IE
3026
#endif

src/util/system.cpp

-4
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,6 @@
2424
#pragma warning(disable:4805)
2525
#pragma warning(disable:4717)
2626
#endif
27-
#ifdef _WIN32_WINNT
28-
#undef _WIN32_WINNT
29-
#endif
30-
#define _WIN32_WINNT 0x0501
3127
#ifdef _WIN32_IE
3228
#undef _WIN32_IE
3329
#endif

0 commit comments

Comments
 (0)