Mcb->OwnerPsp = NewOwner;
}
-static WORD DosCopyEnvironmentBlock(LPCVOID Environment, LPCSTR ProgramName)
+static WORD DosCopyEnvironmentBlock(LPCSTR Environment, LPCSTR ProgramName)
{
PCHAR Ptr, DestBuffer = NULL;
ULONG TotalSize = 0;
Ptr = (PCHAR)Environment;
/* Calculate the size of the environment block */
- while (*Ptr)
- {
- TotalSize += strlen(Ptr) + 1;
- Ptr += strlen(Ptr) + 1;
- }
- TotalSize++;
+ while (*Ptr) Ptr += strlen(Ptr) + 1;
+ TotalSize = (ULONG_PTR)Ptr - (ULONG_PTR)Environment + 1; // Add final NULL-terminator
/* Add the string buffer size */
TotalSize += strlen(ProgramName) + 1;
DestBuffer = (PCHAR)SEG_OFF_TO_PTR(DestSegment, 0);
while (*Ptr)
{
- /* Copy the string */
+ /* Copy the string and NULL-terminate it */
strcpy(DestBuffer, Ptr);
-
- /* Advance to the next string */
DestBuffer += strlen(Ptr);
- Ptr += strlen(Ptr) + 1;
+ *(DestBuffer++) = '\0';
- /* Put a zero after the string */
- *(DestBuffer++) = 0;
+ /* Move to the next string */
+ Ptr += strlen(Ptr) + 1;
}
-
- /* Set the final zero */
- *(DestBuffer++) = 0;
+ /* NULL-terminate the environment block */
+ *(DestBuffer++) = '\0';
/* Store the special program name tag */
*(DestBuffer++) = LOBYTE(DOS_PROGRAM_NAME_TAG);
DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType,
IN LPCSTR ExecutablePath,
IN LPCSTR CommandLine,
- IN PVOID Environment,
+ IN LPCSTR Environment,
OUT PDWORD StackLocation OPTIONAL,
OUT PDWORD EntryPoint OPTIONAL)
{
PWORD RelocWord;
LPSTR CmdLinePtr = (LPSTR)CommandLine;
- DPRINT1("DosLoadExecutable(%d, %s, %s, %s, 0x%08X, 0x%08X)\n",
+ DPRINT("DosLoadExecutable(%d, %s, %s, %s, 0x%08X, 0x%08X)\n",
LoadType,
ExecutablePath,
CommandLine,
DWORD DosStartProcess(IN LPCSTR ExecutablePath,
IN LPCSTR CommandLine,
- IN PVOID Environment)
+ IN LPCSTR Environment)
{
DWORD Result;