From 81a5adf88569eeddb6ba91ace8e1db58e88ad6ab Mon Sep 17 00:00:00 2001 From: Aleksandar Andrejevic Date: Sat, 9 Nov 2013 18:10:21 +0000 Subject: [PATCH] [NTVDM] Allow COM programs to exit with a simple near return to PSP:0000. Spotted by Thomas Faber. svn path=/branches/ntvdm/; revision=60904 --- subsystems/ntvdm/dos.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/subsystems/ntvdm/dos.c b/subsystems/ntvdm/dos.c index df65a78c193..f56ed764d98 100644 --- a/subsystems/ntvdm/dos.c +++ b/subsystems/ntvdm/dos.c @@ -1203,6 +1203,12 @@ BOOLEAN DosCreateProcess(LPCSTR CommandLine, WORD EnvBlock) /* Set the stack to the last word of the segment */ EmulatorSetStack(Segment, 0xFFFE); + /* + * Set the value on the stack to 0, so that a near return + * jumps to PSP:0000 which has the exit code. + */ + *((LPWORD)SEG_OFF_TO_PTR(Segment, 0xFFFE)) = 0; + /* Execute */ CurrentPsp = Segment; DiskTransferArea = MAKELONG(0x80, Segment);