mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
Don't wait for GUI processes to finish
svn path=/trunk/; revision=7898
This commit is contained in:
parent
b4446c11bb
commit
3d25387466
4 changed files with 101 additions and 14 deletions
|
@ -158,7 +158,9 @@ typedef struct _PEB
|
|||
BYTE __pad_1c[36]; /* 1c */
|
||||
PRTL_BITMAP TlsBitmap; /* 40 */
|
||||
ULONG TlsBitmapBits[2]; /* 44 */
|
||||
BYTE __pad_4c[156]; /* 4c */
|
||||
BYTE __pad_4c[104]; /* 4c */
|
||||
ULONG ImageSubSystem; /* b4 */
|
||||
BYTE __pad_b8[48]; /* b8 */
|
||||
PVOID Reserved3[59]; /* e8 */
|
||||
ULONG SessionId; /* 1d4 */
|
||||
} PEB, *PPEB;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: create.c,v 1.80 2004/01/23 21:16:04 ekohl Exp $
|
||||
/* $Id: create.c,v 1.81 2004/01/28 20:52:57 gvg Exp $
|
||||
*
|
||||
* COPYRIGHT: See COPYING in the top level directory
|
||||
* PROJECT: ReactOS system libraries
|
||||
|
@ -559,7 +559,8 @@ static NTSTATUS KlInitPeb
|
|||
(
|
||||
HANDLE ProcessHandle,
|
||||
PRTL_USER_PROCESS_PARAMETERS Ppb,
|
||||
PVOID * ImageBaseAddress
|
||||
PVOID * ImageBaseAddress,
|
||||
ULONG ImageSubSystem
|
||||
)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
|
@ -662,6 +663,14 @@ static NTSTATUS KlInitPeb
|
|||
sizeof(PpbBase),
|
||||
&BytesWritten);
|
||||
|
||||
/* Write image subsystem */
|
||||
Offset = FIELD_OFFSET(PEB, ImageSubSystem);
|
||||
NtWriteVirtualMemory(ProcessHandle,
|
||||
(PVOID)(PEB_BASE + Offset),
|
||||
&ImageSubSystem,
|
||||
sizeof(ImageSubSystem),
|
||||
&BytesWritten);
|
||||
|
||||
/* Read image base address. */
|
||||
Offset = FIELD_OFFSET(PEB, ImageBaseAddress);
|
||||
NtReadVirtualMemory(ProcessHandle,
|
||||
|
@ -1358,7 +1367,7 @@ CreateProcessW
|
|||
*/
|
||||
DPRINT("Creating peb\n");
|
||||
|
||||
KlInitPeb(hProcess, Ppb, &ImageBaseAddress);
|
||||
KlInitPeb(hProcess, Ppb, &ImageBaseAddress, Sii.Subsystem);
|
||||
|
||||
RtlDestroyProcessParameters (Ppb);
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: cmd.c,v 1.9 2003/12/26 09:52:37 navaraf Exp $
|
||||
/* $Id: cmd.c,v 1.10 2004/01/28 20:52:57 gvg Exp $
|
||||
*
|
||||
* CMD.C - command-line interface.
|
||||
*
|
||||
|
@ -129,10 +129,19 @@
|
|||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <winnt.h>
|
||||
#include <winternl.h>
|
||||
|
||||
#ifndef NT_SUCCESS
|
||||
#define NT_SUCCESS(StatCode) ((NTSTATUS)(StatCode) >= 0)
|
||||
#endif
|
||||
|
||||
#include "cmd.h"
|
||||
#include "batch.h"
|
||||
|
||||
typedef NTSTATUS (STDCALL *NtQueryInformationProcessProc)(HANDLE, PROCESSINFOCLASS,
|
||||
PVOID, ULONG, PULONG);
|
||||
typedef NTSTATUS (STDCALL *NtReadVirtualMemoryProc)(HANDLE, PVOID, PVOID, ULONG, PULONG);
|
||||
|
||||
BOOL bExit = FALSE; /* indicates EXIT was typed */
|
||||
BOOL bCanExit = TRUE; /* indicates if this shell is exitable */
|
||||
|
@ -146,6 +155,10 @@ HANDLE hIn;
|
|||
HANDLE hOut;
|
||||
HANDLE hConsole;
|
||||
|
||||
static NtQueryInformationProcessProc NtQueryInformationProcessPtr;
|
||||
static NtReadVirtualMemoryProc NtReadVirtualMemoryPtr;
|
||||
static BOOL NtDllChecked = FALSE;
|
||||
|
||||
#ifdef INCLUDE_CMD_COLOR
|
||||
WORD wColor; /* current color */
|
||||
WORD wDefColor; /* default color */
|
||||
|
@ -162,6 +175,65 @@ static BOOL IsDelimiter (TCHAR c)
|
|||
return (c == _T('/') || c == _T('=') || c == _T('\0') || _istspace (c));
|
||||
}
|
||||
|
||||
/*
|
||||
* Is a process a console process?
|
||||
*/
|
||||
static BOOL IsConsoleProcess(HANDLE Process)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PROCESS_BASIC_INFORMATION Info;
|
||||
PEB ProcessPeb;
|
||||
ULONG BytesRead;
|
||||
HMODULE NtDllModule;
|
||||
|
||||
/* Some people like to run ReactOS cmd.exe on Win98, it helps in the
|
||||
build process. So don't link implicitly against ntdll.dll, load it
|
||||
dynamically instead */
|
||||
if (! NtDllChecked)
|
||||
{
|
||||
NtDllChecked = TRUE;
|
||||
NtDllModule = LoadLibrary(_T("ntdll.dll"));
|
||||
if (NULL == NtDllModule)
|
||||
{
|
||||
/* Probably non-WinNT system. Just wait for the commands
|
||||
to finish. */
|
||||
NtQueryInformationProcessPtr = NULL;
|
||||
NtReadVirtualMemoryPtr = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
NtQueryInformationProcessPtr = (NtQueryInformationProcessProc)
|
||||
GetProcAddress(NtDllModule, "NtQueryInformationProcess");
|
||||
NtReadVirtualMemoryPtr = (NtReadVirtualMemoryProc)
|
||||
GetProcAddress(NtDllModule, "NtReadVirtualMemory");
|
||||
}
|
||||
|
||||
if (NULL == NtQueryInformationProcessPtr || NULL == NtReadVirtualMemoryPtr)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
Status = NtQueryInformationProcessPtr(Process, ProcessBasicInformation,
|
||||
&Info, sizeof(PROCESS_BASIC_INFORMATION), NULL);
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DebugPrintf (_T("NtQueryInformationProcess failed with status %08x\n"), Status);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
Status = NtReadVirtualMemoryPtr(Process, Info.PebBaseAddress, &ProcessPeb,
|
||||
sizeof(PEB), &BytesRead);
|
||||
if (! NT_SUCCESS(Status) || sizeof(PEB) != BytesRead)
|
||||
{
|
||||
#ifdef _DEBUG
|
||||
DebugPrintf (_T("Couldn't read virt mem status %08x bytes read %lu\n"), Status, BytesRead);
|
||||
#endif
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return IMAGE_SUBSYSTEM_WINDOWS_CUI == ProcessPeb.ImageSubSystem;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* This command (in first) was not found in the command table
|
||||
|
@ -260,17 +332,20 @@ Execute (LPTSTR first, LPTSTR rest)
|
|||
&stui,
|
||||
&prci))
|
||||
{
|
||||
/* FIXME: Protect this with critical section */
|
||||
bChildProcessRunning = TRUE;
|
||||
dwChildProcessId = prci.dwProcessId;
|
||||
if (IsConsoleProcess(prci.hProcess))
|
||||
{
|
||||
/* FIXME: Protect this with critical section */
|
||||
bChildProcessRunning = TRUE;
|
||||
dwChildProcessId = prci.dwProcessId;
|
||||
|
||||
WaitForSingleObject (prci.hProcess, INFINITE);
|
||||
WaitForSingleObject (prci.hProcess, INFINITE);
|
||||
|
||||
/* FIXME: Protect this with critical section */
|
||||
bChildProcessRunning = FALSE;
|
||||
/* FIXME: Protect this with critical section */
|
||||
bChildProcessRunning = FALSE;
|
||||
|
||||
GetExitCodeProcess (prci.hProcess, &dwExitCode);
|
||||
nErrorLevel = (INT)dwExitCode;
|
||||
GetExitCodeProcess (prci.hProcess, &dwExitCode);
|
||||
nErrorLevel = (INT)dwExitCode;
|
||||
}
|
||||
CloseHandle (prci.hThread);
|
||||
CloseHandle (prci.hProcess);
|
||||
}
|
||||
|
|
|
@ -15,7 +15,8 @@ TARGET_NAME = cmd
|
|||
|
||||
TARGET_INSTALLDIR = system32
|
||||
|
||||
TARGET_CFLAGS = -D__USE_W32API -DANONYMOUSUNIONS -Wall -Werror -I$(PATH_TO_TOP)/include -I$(PATH_TO_TOP)/include/msvcrt
|
||||
TARGET_CFLAGS = -D__USE_W32API -DANONYMOUSUNIONS -Wall -Werror -I$(PATH_TO_TOP)/include \
|
||||
-I$(PATH_TO_TOP)/include/msvcrt -D_WIN32_WINNT=0x0501
|
||||
|
||||
WINE_MODE = yes
|
||||
|
||||
|
|
Loading…
Reference in a new issue