another MZ_Exec() problem...

Ove Kaaven ovehk at
Wed Sep 25 10:29:28 CDT 2002

On Tue, 24 Sep 2002 chrismorgan at wrote:

> Inside of MZ_Exec() I call out to CreateProcessA() if the executable
> is PE.  I've set the lpEnvironment parameter of CreateProcessA() to
> null to have it inherit the environment of the caller but this isn't
> working correctly.  The path and other environment variables aren't
> being inherited.  Ideas on how to either get CreateProcessA() to
> inherit properly or where I can find the environment settings?  I
> noticed the env_ptr in the parmeter block but I'm unsure if this is
> what I'm looking for or where to find more information about it.

In the same fashion that MZ_Exec() extract the command line from the PSP

LPBYTE cmdline = PTR_REAL_TO_LIN(SELECTOROF(blk->cmdline),OFFSETOF(blk->cmdline));

you can get the environment block from the EXEC parameter block with

LPBYTE envblock = PTR_REAL_TO_LIN(blk->envseg,0);

(this is currently ignored by MZ_Exec, which is a bug, it should really be
passed to MZ_DoLoadImage and be used as "oldenv")

or, if desired, you can grab the current environment block from the
current PSP (which is currently what MZ_DoLoadImage does) with

PDB16 *psp = psp_start;
LPBYTE envblock = PTR_REAL_TO_LIN(psp->environment,0);

The format of the environment block should be the same as that returned by
GetEnvironmentStringsA(), so you can probably pass this pointer straight
to CreateProcessA(). (Letting CreateProcessA() just inherit from its idea
of the parent process doesn't work since its idea of the parent would be
the Wine process that runs the DOS VM, not the DOS app currently running

More information about the wine-devel mailing list