Avoid mapping above 4gb on Windows 7 x64 (#19)

Windows 7 support is now confirmed to be working. However it comes at
the cost of needing to workaround this tragically oppressive behavior
which is imposed for reasons unknown.

Fixes #19
This commit is contained in:
Justine Tunney 2021-01-16 19:18:37 -08:00
parent f0600a898c
commit 2ad0d05d31
4 changed files with 25 additions and 6 deletions

View file

@ -43,6 +43,12 @@
#include "libc/sysv/consts/map.h"
#include "libc/sysv/consts/prot.h"
/*
* TODO: Why can't we allocate addresses above 4GB on Windows 7 x64?
* https://github.com/jart/cosmopolitan/issues/19
*/
#define ADDRESS 0x77700000 /*0000*/
struct WinArgs {
char *argv[512];
char *envp[512];
@ -128,7 +134,7 @@ static textwindows wontreturn void WinMainNew(void) {
NormalizeCmdExe();
*(/*unconst*/ int *)&__hostos = WINDOWS;
size = ROUNDUP(STACKSIZE + sizeof(struct WinArgs), FRAMESIZE);
data = (intptr_t)AllocateMemory((char *)0x777000000000, size, &_mmi.p[0].h);
data = (intptr_t)AllocateMemory((char *)ADDRESS, size, &_mmi.p[0].h);
_mmi.p[0].x = data >> 16;
_mmi.p[0].y = (data >> 16) + ((size >> 16) - 1);
_mmi.p[0].prot = PROT_READ | PROT_WRITE;