MZ_FillPSP() in dlls/winedos/module.c

Ove Kaaven ovehk at
Wed Sep 25 10:15:01 CDT 2002

On Tue, 24 Sep 2002 chrismorgan at wrote:

> I have a script that passes a long argument string when calling a
> command handler( or other comspec replacement).  This code
> inside of MZ_FillPSP()
> if(length > 126) {
>   ERR("Command line truncated! (length %d > maximum length 126)\n", length;
>   length = 126;
> }
> is breaking my application by truncating the 200+ character argument
> at 126 characters.  Do we still need to truncate at 126?

Yes, it's an intrinsic DOS limitation from the early DOS days. The PSP is
a fixed-length structure of 256 bytes, half of which is reserved for the
command line; the layout of it is the same as the PDB16 structure (which
is the Win16 version of the PSP) in include/task.h. There's no way to fit
a longer command line into it; even trying to make the PSP larger won't
help for long since the first byte is the command-line length, so it can't
be made longer than 255 characters this way anyway. So apps that need
unlimited command lines must use a different protocol to pass them. One
way could be to use environment variables - for example, I've noticed
before that NT's cmd.exe puts the last command line in the "_" environment
variable when invoking apps, so I can imagine that apps that take
advantage of this look something like

cmd = dos_cmdline();
env_cmd = getenv("_");
if (strncmp(cmd, env_cmd, strlen(env_cmd)) == 0) cmd = env_cmd;

This is only a guess, though, I don't know to what extent something like
this is supported by DOS or Windows itself, nor what protocol they really

More information about the wine-devel mailing list