DOS EXEC command line fix
Jukka Heinonen
jhei at iki.fi
Sun Apr 28 13:34:32 CDT 2002
After this patch and the previous DOS patch, Fantasy General
installer works perfectly. Getting the game itself
to work is probably much more difficult.
Changelog:
When DOS program executes another DOS program,
the last character in command line is carriage return
and the first character is length. Added check
for too long command lines.
Index: dlls/winedos/module.c
===================================================================
RCS file: /home/wine/wine/dlls/winedos/module.c,v
retrieving revision 1.14
diff -u -r1.14 module.c
--- dlls/winedos/module.c 26 Apr 2002 19:05:17 -0000 1.14
+++ dlls/winedos/module.c 28 Apr 2002 18:25:05 -0000
@@ -119,13 +119,23 @@
/* copy parameters */
if (cmd) {
+ int count = 0;
+
#if 0
/* command.com doesn't do this */
while (*cmd == ' ') cmd++;
#endif
- psp->cmdLine[0]=strlen(cmd);
- strcpy(psp->cmdLine+1,cmd);
- psp->cmdLine[psp->cmdLine[0]+1]='\r';
+
+ /* GetCommandLineA and INT 21 EXEC have different last characters. */
+ while(cmd[count] != 0 && cmd[count] != 13)
+ count++;
+
+ if(count > 127)
+ ERR("Command line is too long! (%d > 127)\n", count);
+
+ psp->cmdLine[0]=count;
+ memmove(psp->cmdLine+1,cmd,count);
+ psp->cmdLine[count+1]='\r';
} else psp->cmdLine[1]='\r';
/* FIXME: more PSP stuff */
}
@@ -356,7 +366,8 @@
* let's work on the new values now */
LPBYTE psp_start = (LPBYTE)((DWORD)DOSVM_psp << 4);
ExecBlock *blk = (ExecBlock *)paramblk;
- MZ_FillPSP(psp_start, DOSMEM_MapRealToLinear(blk->cmdline));
+ /* we skip length here, command tail should always end with CR */
+ MZ_FillPSP(psp_start, DOSMEM_MapRealToLinear(blk->cmdline) + 1);
/* the lame MS-DOS engineers decided that the return address should be in int22 */
DOSVM_SetRMHandler(0x22, (FARPROC16)MAKESEGPTR(context->SegCs, LOWORD(context->Eip)));
if (func) {
--
Jukka Heinonen <http://www.iki.fi/jhei/>
More information about the wine-patches
mailing list