Increase Windows stack size (#32)

We're now using the same values CMD.EXE uses.
This commit is contained in:
Justine Tunney 2021-01-30 10:08:08 -08:00
parent 95173645a1
commit 393a642c22
2 changed files with 6 additions and 4 deletions

View file

@ -783,8 +783,8 @@ ape.pe: .ascin "PE",4
.long 0 # Checksum .long 0 # Checksum
.short v_ntsubsystem # Subsystem: 0=Neutral,2=GUI,3=Console .short v_ntsubsystem # Subsystem: 0=Neutral,2=GUI,3=Console
.short .LDLLEXE # DllCharacteristics .short .LDLLEXE # DllCharacteristics
.quad 0x0000000000020000 # StackReserve .quad 0x0000000000100000 # StackReserve
.quad 0x0000000000020000 # StackCommit .quad 0x00000000000fc000 # StackCommit
.quad 0 # HeapReserve .quad 0 # HeapReserve
.quad 0 # HeapCommit .quad 0 # HeapCommit
.long 0 # LoaderFlags .long 0 # LoaderFlags

View file

@ -49,6 +49,8 @@
* TODO: How can we ensure we never overlap with KERNEL32.DLL? * TODO: How can we ensure we never overlap with KERNEL32.DLL?
*/ */
#define WINSTACK 0x100000
struct WinArgs { struct WinArgs {
char *argv[4096]; char *argv[4096];
char *envp[4096]; char *envp[4096];
@ -107,7 +109,7 @@ static textwindows wontreturn void WinMainNew(void) {
NormalizeCmdExe(); NormalizeCmdExe();
*(/*unconst*/ int *)&__hostos = WINDOWS; *(/*unconst*/ int *)&__hostos = WINDOWS;
addr = NtGetVersion() < kNtVersionWindows10 ? 0xff00000 : 0x777000000000; addr = NtGetVersion() < kNtVersionWindows10 ? 0xff00000 : 0x777000000000;
size = ROUNDUP(STACKSIZE + sizeof(struct WinArgs), FRAMESIZE); size = ROUNDUP(WINSTACK + sizeof(struct WinArgs), FRAMESIZE);
_mmi.p[0].h = _mmi.p[0].h =
__mmap$nt((char *)addr, size, PROT_READ | PROT_WRITE | PROT_EXEC, -1, 0) __mmap$nt((char *)addr, size, PROT_READ | PROT_WRITE | PROT_EXEC, -1, 0)
.maphandle; .maphandle;
@ -128,7 +130,7 @@ static textwindows wontreturn void WinMainNew(void) {
FreeEnvironmentStrings(env16); FreeEnvironmentStrings(env16);
auxv[0][0] = pushpop(0L); auxv[0][0] = pushpop(0L);
auxv[0][1] = pushpop(0L); auxv[0][1] = pushpop(0L);
_jmpstack((char *)addr + STACKSIZE, _executive, count, wa->argv, wa->envp, _jmpstack((char *)addr + WINSTACK, _executive, count, wa->argv, wa->envp,
auxv); auxv);
} }