Author: hbelusca
Date: Fri Nov 21 02:26:53 2014
New Revision: 65438
URL:
http://svn.reactos.org/svn/reactos?rev=65438&view=rev
Log:
[NTVDM]: Make the environment strings list optional for some Dos app start functions.
Modified:
trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c
trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h
Modified: trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/dos32…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] Fri Nov 21 02:26:53
2014
@@ -403,40 +403,60 @@
Mcb->OwnerPsp = NewOwner;
}
-static WORD DosCopyEnvironmentBlock(LPCSTR Environment, LPCSTR ProgramName)
+static WORD DosCopyEnvironmentBlock(LPCSTR Environment OPTIONAL,
+ LPCSTR ProgramName)
{
PCHAR Ptr, DestBuffer = NULL;
ULONG TotalSize = 0;
WORD DestSegment;
- Ptr = (PCHAR)Environment;
-
- /* Calculate the size of the environment block */
- while (*Ptr) Ptr += strlen(Ptr) + 1;
- TotalSize = (ULONG_PTR)Ptr - (ULONG_PTR)Environment + 1; // Add final
NULL-terminator
+ /* If we have an environment strings list, compute its size */
+ if (Environment)
+ {
+ /* Calculate the size of the environment block */
+ Ptr = (PCHAR)Environment;
+ while (*Ptr) Ptr += strlen(Ptr) + 1;
+ TotalSize = (ULONG_PTR)Ptr - (ULONG_PTR)Environment;
+ }
+ else
+ {
+ /* Empty environment string */
+ TotalSize = 1;
+ }
+ /* Add the final environment block NULL-terminator */
+ TotalSize++;
+
+ /* Add the two bytes for the program name tag */
+ TotalSize += 2;
/* Add the string buffer size */
TotalSize += strlen(ProgramName) + 1;
-
- /* Add the two extra bytes */
- TotalSize += 2;
/* Allocate the memory for the environment block */
DestSegment = DosAllocateMemory((WORD)((TotalSize + 0x0F) >> 4), NULL);
if (!DestSegment) return 0;
- Ptr = (PCHAR)Environment;
-
DestBuffer = (PCHAR)SEG_OFF_TO_PTR(DestSegment, 0);
- while (*Ptr)
- {
- /* Copy the string and NULL-terminate it */
- strcpy(DestBuffer, Ptr);
- DestBuffer += strlen(Ptr);
+
+ /* If we have an environment strings list, copy it */
+ if (Environment)
+ {
+ Ptr = (PCHAR)Environment;
+ while (*Ptr)
+ {
+ /* Copy the string and NULL-terminate it */
+ strcpy(DestBuffer, Ptr);
+ DestBuffer += strlen(Ptr);
+ *(DestBuffer++) = '\0';
+
+ /* Move to the next string */
+ Ptr += strlen(Ptr) + 1;
+ }
+ }
+ else
+ {
+ /* Empty environment string */
*(DestBuffer++) = '\0';
-
- /* Move to the next string */
- Ptr += strlen(Ptr) + 1;
}
/* NULL-terminate the environment block */
*(DestBuffer++) = '\0';
@@ -900,7 +920,7 @@
DWORD DosLoadExecutable(IN DOS_EXEC_TYPE LoadType,
IN LPCSTR ExecutablePath,
IN LPCSTR CommandLine,
- IN LPCSTR Environment,
+ IN LPCSTR Environment OPTIONAL,
OUT PDWORD StackLocation OPTIONAL,
OUT PDWORD EntryPoint OPTIONAL)
{
@@ -920,7 +940,7 @@
LoadType,
ExecutablePath,
CommandLine,
- Environment,
+ Environment ? Environment : "n/a",
StackLocation,
EntryPoint);
@@ -1144,7 +1164,7 @@
DWORD DosStartProcess(IN LPCSTR ExecutablePath,
IN LPCSTR CommandLine,
- IN LPCSTR Environment)
+ IN LPCSTR Environment OPTIONAL)
{
DWORD Result;
Modified: trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/ntvdm/dos/dos32…
==============================================================================
--- trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/ntvdm/dos/dos32krnl/dos.h [iso-8859-1] Fri Nov 21 02:26:53
2014
@@ -224,7 +224,7 @@
IN DOS_EXEC_TYPE LoadType,
IN LPCSTR ExecutablePath,
IN LPCSTR CommandLine,
- IN LPCSTR Environment,
+ IN LPCSTR Environment OPTIONAL,
OUT PDWORD StackLocation OPTIONAL,
OUT PDWORD EntryPoint OPTIONAL
);
@@ -236,7 +236,7 @@
DWORD DosStartProcess(
IN LPCSTR ExecutablePath,
IN LPCSTR CommandLine,
- IN LPCSTR Environment
+ IN LPCSTR Environment OPTIONAL
);
VOID DosTerminateProcess(WORD Psp, BYTE ReturnCode);
BOOLEAN DosHandleIoctl(BYTE ControlCode, WORD FileHandle);