Author: aandrejevic Date: Thu Apr 23 02:30:53 2015 New Revision: 67363
URL: http://svn.reactos.org/svn/reactos?rev=67363&view=rev Log: [NTVDM][KERNEL32] In DosCreateProcess, allocate space for the environment block dynamically and expand it if needed, just like we do in CommandThreadProc. In GetNextVDMCommand, remove the check that checks whether VDMState is one of VDM_NOT_LOADED, VDM_NOT_READY or VDM_READY - that check makes no sense whatsoever, since those aren't input values for that structure field. Their bit masks do correspond to valid input fields, but even then the check makes no sense.
Modified: trunk/reactos/dll/win32/kernel32/client/vdm.c trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c
Modified: trunk/reactos/dll/win32/kernel32/client/vdm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/v... ============================================================================== --- trunk/reactos/dll/win32/kernel32/client/vdm.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/client/vdm.c [iso-8859-1] Thu Apr 23 02:30:53 2015 @@ -1278,7 +1278,22 @@
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)); @@ -1545,26 +1560,6 @@
/* 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
Modified: trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/mvdm/ntvdm/dos/d... ============================================================================== --- trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/mvdm/ntvdm/dos/dos32krnl/dos.c [iso-8859-1] Thu Apr 23 02:30:53 2015 @@ -1039,7 +1039,8 @@ 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;
@@ -1098,16 +1099,24 @@ 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, @@ -1116,11 +1125,15 @@ 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; @@ -1133,6 +1146,8 @@ WaitForSingleObject(ProcessInfo.hProcess, INFINITE); } } + + RtlFreeHeap(RtlGetProcessHeap(), 0, Env);
/* Close the handles */ CloseHandle(ProcessInfo.hProcess);