Skip to content

Commit e4d25d6

Browse files
committed
Drop support for Windows 8
Microsoft caused some very gentle breakages for Cosmopolitan. They removed the version information from the PEB which caused uname to report WINDOWS 0.0.0. We should have called GetVersionExW but that doesn't really exist anymore either. Windows policy is now to give whatever version we used in ape/ape.S. Windows8 has been EOL since 2023-01-10 so lets avoid our modern executables being relegated to legacy infrastructure. Requiring Windows 10+ going forward lets us remove runtime compatibility bloat from the codebase. Further note Cosmopolitan maintains a Windows Vista branch on GitHub, so anyone preferring the older versions, can still have a future with Cosmo. Another neat thing this fixes is UTF-8 support in the console. The changes Microsoft made broke the if statement that enabled UTF8 in terminals. This explains why bug reports had broken arrows. In the future this should be less of an issue, since the PEB code is gone which means we more strictly conform to only Microsoft's WIN32 API
1 parent f31a98d commit e4d25d6

File tree

26 files changed

+17
-942
lines changed

26 files changed

+17
-942
lines changed

ape/ape.S

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1036,7 +1036,7 @@ ape_pe: .ascin "PE",4
10361036
.quad ape_pe_base // ImageBase
10371037
.long ape_pe_sectionalignment // SectionAlignment
10381038
.long ape_pe_filealignment // FileAlignment
1039-
.short v_ntversion // MajorOperatingSystemVersion
1039+
.short 10 // MajorOperatingSystemVersion
10401040
.short 0 // MinorOperatingSystemVersion
10411041
.short 0 // MajorImageVersion
10421042
.short 0 // MinorImageVersion

ape/ape.lds

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -715,7 +715,6 @@ ape_idataz = LINK_WINDOWS ? RVA(ape_idata_iat) : 0;
715715
ape_idata_iatsize = LINK_WINDOWS ? ape_idata_iatend - ape_idata_iat : 0;
716716
ape_idata = LINK_WINDOWS ? RVA(ape_idata_idt) : 0;
717717
ape_idata_idtsize = LINK_WINDOWS ? ape_idata_idtend - ape_idata_idt : 0;
718-
v_ntversion = LINK_WINDOWS ? 6 : 1;
719718
v_ntdllchar = LINK_WINDOWS ? 288 : 0;
720719
v_ntsubversion = LINK_WINDOWS ? 6 : 5;
721720
v_ntsubsystem = (LINK_WINDOWS

libc/calls/reboot.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#include "libc/calls/calls.h"
2020
#include "libc/calls/struct/framebuffervirtualscreeninfo.h"
2121
#include "libc/dce.h"
22-
#include "libc/nt/enum/version.h"
2322
#include "libc/nt/system.h"
2423
#include "libc/runtime/runtime.h"
2524
#include "libc/sysv/errfuns.h"
@@ -72,9 +71,7 @@ int reboot(int howto) {
7271
} else {
7372
howto |= kNtShutdownForceSelf;
7473
howto |= kNtShutdownForceOthers;
75-
if (NtGetVersion() >= kNtVersionWindows8) {
76-
howto |= kNtShutdownHybrid;
77-
}
74+
howto |= kNtShutdownHybrid;
7875
if (immediately) {
7976
ok = !!InitiateShutdown(0, 0, 0, howto | kNtShutdownGraceOverride, 0);
8077
} else {

libc/calls/tcsetattr-nt.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "libc/intrin/nomultics.internal.h"
2626
#include "libc/nt/console.h"
2727
#include "libc/nt/enum/consolemodeflags.h"
28-
#include "libc/nt/version.h"
2928
#include "libc/str/str.h"
3029
#include "libc/sysv/consts/baud.internal.h"
3130
#include "libc/sysv/consts/termios.h"
@@ -96,9 +95,7 @@ textwindows int tcsetattr_nt(int fd, int opt, const struct termios *tio) {
9695
if (!(tio->c_oflag & ONLCR)) {
9796
outmode |= kNtDisableNewlineAutoReturn;
9897
}
99-
if (IsAtLeastWindows10()) {
100-
outmode |= kNtEnableVirtualTerminalProcessing;
101-
}
98+
outmode |= kNtEnableVirtualTerminalProcessing;
10299

103100
// tune the win32 configuration
104101
unassert(SetConsoleMode(hInput, inmode));

libc/calls/uname.c

Lines changed: 6 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#include "libc/log/log.h"
3131
#include "libc/macros.internal.h"
3232
#include "libc/nt/enum/computernameformat.h"
33-
#include "libc/nt/struct/teb.h"
3433
#include "libc/nt/systeminfo.h"
3534
#include "libc/runtime/runtime.h"
3635
#include "libc/str/str.h"
@@ -81,34 +80,13 @@ static textwindows void GetNtName(char *name, int kind) {
8180
}
8281
}
8382

84-
static inline textwindows int GetNtMajorVersion(void) {
85-
#ifdef __x86_64__
86-
return NtGetPeb()->OSMajorVersion;
87-
#else
88-
return 0;
89-
#endif
90-
}
91-
92-
static inline textwindows int GetNtMinorVersion(void) {
93-
#ifdef __x86_64__
94-
return NtGetPeb()->OSMinorVersion;
95-
#else
96-
return 0;
97-
#endif
98-
}
99-
100-
static inline textwindows int GetNtBuildNumber(void) {
101-
#ifdef __x86_64__
102-
return NtGetPeb()->OSBuildNumber;
103-
#else
104-
return 0;
105-
#endif
106-
}
107-
10883
static textwindows void GetNtVersion(char *p) {
109-
p = FormatUint32(p, GetNtMajorVersion()), *p++ = '.';
110-
p = FormatUint32(p, GetNtMinorVersion()), *p++ = '-';
111-
p = FormatUint32(p, GetNtBuildNumber());
84+
// We could ask GetVersionExW() for this information, but it'll simply
85+
// report what we put in the MajorOperatingSystemVersion of the PE ape
86+
// header fields. Windows doesn't want us detecting versions it seems.
87+
// Chances are they bake all old versions of Windows into Windows, and
88+
// run us on the intended one, like some kind of Docker container. Heh
89+
strcpy(p, "10.0");
11290
}
11391

11492
static const char *Str(int rc, const char *s) {

libc/intrin/asan.c

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
#include "libc/mem/mem.h"
4040
#include "libc/nexgen32e/gc.internal.h"
4141
#include "libc/nexgen32e/stackframe.h"
42-
#include "libc/nt/enum/version.h"
4342
#include "libc/runtime/memtrack.internal.h"
4443
#include "libc/runtime/runtime.h"
4544
#include "libc/runtime/stack.h"
@@ -1500,10 +1499,6 @@ void __asan_init(int argc, char **argv, char **envp, unsigned long *auxv) {
15001499
static bool once;
15011500
if (!_cmpxchg(&once, false, true))
15021501
return;
1503-
if (IsWindows() && NtGetVersion() < kNtVersionWindows10) {
1504-
__write_str("error: asan binaries require windows10\r\n");
1505-
_Exit(0); /* So `make MODE=dbg test` passes w/ Windows7 */
1506-
}
15071502
if (_weaken(hook_malloc) || _weaken(hook_calloc) || _weaken(hook_realloc) ||
15081503
_weaken(hook_realloc_in_place) || _weaken(hook_free) ||
15091504
_weaken(hook_malloc_usable_size)) {

libc/intrin/isatleastwindows10.c

Lines changed: 0 additions & 27 deletions
This file was deleted.

libc/intrin/isdebuggerpresent.c

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,22 +24,13 @@
2424
#include "libc/intrin/promises.internal.h"
2525
#include "libc/log/libfatal.internal.h"
2626
#include "libc/log/log.h"
27-
#include "libc/nt/struct/teb.h"
2827
#include "libc/runtime/runtime.h"
2928
#include "libc/sysv/consts/at.h"
3029
#include "libc/sysv/consts/o.h"
3130

3231
#define kBufSize 1024
3332
#define kPid "TracerPid:\t"
3433

35-
static textwindows bool IsBeingDebugged(void) {
36-
#ifdef __x86_64__
37-
return !!NtGetPeb()->BeingDebugged;
38-
#else
39-
return false;
40-
#endif
41-
}
42-
4334
/**
4435
* Determines if gdb, strace, windbg, etc. is controlling process.
4536
* @return non-zero if attached, otherwise 0
@@ -54,7 +45,7 @@ bool32 IsDebuggerPresent(bool32 force) {
5445
if (!force && environ && __getenv(environ, "HEISENDEBUG").s)
5546
return 0;
5647
if (IsWindows())
57-
return IsBeingDebugged();
48+
return false; // make virus scanners happy
5849
if (__isworker)
5950
return false;
6051
if (!PLEDGED(RPATH))

libc/intrin/nocolor.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
╚─────────────────────────────────────────────────────────────────────────────*/
1919
#include "libc/dce.h"
2020
#include "libc/log/internal.h"
21-
#include "libc/nt/version.h"
2221
#include "libc/runtime/runtime.h"
2322

2423
#define IsDumb(s) \
@@ -51,6 +50,5 @@ bool __nocolor;
5150
__attribute__((__constructor__(20))) optimizesize textstartup void
5251
__nocolor_init(int argc, char **argv, char **envp, intptr_t *auxv) {
5352
char *s;
54-
__nocolor = (IsWindows() && !IsAtLeastWindows10()) ||
55-
((s = getenv("TERM")) && IsDumb(s));
53+
__nocolor = IsWindows() || ((s = getenv("TERM")) && IsDumb(s));
5654
}

libc/intrin/ntgetversion.c

Lines changed: 0 additions & 34 deletions
This file was deleted.

0 commit comments

Comments
 (0)