if (CommandData != NULL)
{
- if (CommandData->VDMState & (VDM_NOT_LOADED | VDM_NOT_READY | VDM_READY))
+ if ((CommandData->VDMState == VDM_INC_REENTER_COUNT)
+ || (CommandData->VDMState == VDM_DEC_REENTER_COUNT))
+ {
+ /* Setup the input parameters */
+ SetReenterCount->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ SetReenterCount->fIncDec = CommandData->VDMState;
+
+ /* Call CSRSS */
+ Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepSetReenterCount),
+ sizeof(BASE_SET_REENTER_COUNT));
+ BaseSetLastNTError(Status);
+ Result = NT_SUCCESS(Status);
+ }
+ else
{
/* Clear the structure */
ZeroMemory(GetNextVdmCommand, sizeof(*GetNextVdmCommand));
/* It was successful */
Result = TRUE;
}
- else if ((CommandData->VDMState == VDM_INC_REENTER_COUNT)
- || (CommandData->VDMState == VDM_DEC_REENTER_COUNT))
- {
- /* Setup the input parameters */
- SetReenterCount->ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
- SetReenterCount->fIncDec = CommandData->VDMState;
-
- /* Call CSRSS */
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(BASESRV_SERVERDLL_INDEX, BasepSetReenterCount),
- sizeof(BASE_SET_REENTER_COUNT));
- BaseSetLastNTError(Status);
- Result = NT_SUCCESS(Status);
- }
- else
- {
- BaseSetLastNTError(STATUS_INVALID_PARAMETER);
- Result = FALSE;
- }
}
else
{
CHAR PifFile[MAX_PATH];
CHAR Desktop[MAX_PATH];
CHAR Title[MAX_PATH];
- CHAR Env[MAX_PATH];
+ ULONG EnvSize = 256;
+ PVOID Env = RtlAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, EnvSize);
STARTUPINFOA StartupInfo;
PROCESS_INFORMATION ProcessInfo;
CommandInfo.Env = Env;
CommandInfo.EnvLen = sizeof(Env);
+Command:
/* Get the VDM command information */
if (!GetNextVDMCommand(&CommandInfo))
{
+ if (CommandInfo.EnvLen > EnvSize)
+ {
+ /* Expand the environment size */
+ EnvSize = CommandInfo.EnvLen;
+ CommandInfo.Env = Env = RtlReAllocateHeap(RtlGetProcessHeap(), HEAP_ZERO_MEMORY, Env, EnvSize);
+
+ /* Repeat the request */
+ CommandInfo.VDMState |= VDM_FLAG_RETRY;
+ goto Command;
+ }
+
/* Shouldn't happen */
ASSERT(FALSE);
}
- /* Increment the re-entry count */
- CommandInfo.VDMState = VDM_INC_REENTER_COUNT;
- GetNextVDMCommand(&CommandInfo);
-
/* Load the executable */
Result = DosLoadExecutable(LoadType,
AppName,
Env,
&Parameters->StackLocation,
&Parameters->EntryPoint);
- if (Result != ERROR_SUCCESS)
+ if (Result == ERROR_SUCCESS)
+ {
+ /* Increment the re-entry count */
+ CommandInfo.VDMState = VDM_INC_REENTER_COUNT;
+ GetNextVDMCommand(&CommandInfo);
+ }
+ else
{
DisplayMessage(L"Could not load '%S'. Error: %u", AppName, Result);
- // FIXME: Decrement the reenter count. Or, instead, just increment
- // the VDM reenter count *only* if this call succeeds...
}
break;
}
}
+ RtlFreeHeap(RtlGetProcessHeap(), 0, Env);
+
/* Close the handles */
CloseHandle(ProcessInfo.hProcess);
CloseHandle(ProcessInfo.hThread);