mirror of
https://github.com/reactos/reactos.git
synced 2024-07-06 20:55:16 +00:00
Don't wait for GUI processes to finish
svn path=/trunk/; revision=7898
This commit is contained in:
parent
b4446c11bb
commit
3d25387466
|
@ -158,7 +158,9 @@ typedef struct _PEB
|
||||||
BYTE __pad_1c[36]; /* 1c */
|
BYTE __pad_1c[36]; /* 1c */
|
||||||
PRTL_BITMAP TlsBitmap; /* 40 */
|
PRTL_BITMAP TlsBitmap; /* 40 */
|
||||||
ULONG TlsBitmapBits[2]; /* 44 */
|
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 */
|
PVOID Reserved3[59]; /* e8 */
|
||||||
ULONG SessionId; /* 1d4 */
|
ULONG SessionId; /* 1d4 */
|
||||||
} PEB, *PPEB;
|
} 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
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -559,7 +559,8 @@ static NTSTATUS KlInitPeb
|
||||||
(
|
(
|
||||||
HANDLE ProcessHandle,
|
HANDLE ProcessHandle,
|
||||||
PRTL_USER_PROCESS_PARAMETERS Ppb,
|
PRTL_USER_PROCESS_PARAMETERS Ppb,
|
||||||
PVOID * ImageBaseAddress
|
PVOID * ImageBaseAddress,
|
||||||
|
ULONG ImageSubSystem
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -662,6 +663,14 @@ static NTSTATUS KlInitPeb
|
||||||
sizeof(PpbBase),
|
sizeof(PpbBase),
|
||||||
&BytesWritten);
|
&BytesWritten);
|
||||||
|
|
||||||
|
/* Write image subsystem */
|
||||||
|
Offset = FIELD_OFFSET(PEB, ImageSubSystem);
|
||||||
|
NtWriteVirtualMemory(ProcessHandle,
|
||||||
|
(PVOID)(PEB_BASE + Offset),
|
||||||
|
&ImageSubSystem,
|
||||||
|
sizeof(ImageSubSystem),
|
||||||
|
&BytesWritten);
|
||||||
|
|
||||||
/* Read image base address. */
|
/* Read image base address. */
|
||||||
Offset = FIELD_OFFSET(PEB, ImageBaseAddress);
|
Offset = FIELD_OFFSET(PEB, ImageBaseAddress);
|
||||||
NtReadVirtualMemory(ProcessHandle,
|
NtReadVirtualMemory(ProcessHandle,
|
||||||
|
@ -1358,7 +1367,7 @@ CreateProcessW
|
||||||
*/
|
*/
|
||||||
DPRINT("Creating peb\n");
|
DPRINT("Creating peb\n");
|
||||||
|
|
||||||
KlInitPeb(hProcess, Ppb, &ImageBaseAddress);
|
KlInitPeb(hProcess, Ppb, &ImageBaseAddress, Sii.Subsystem);
|
||||||
|
|
||||||
RtlDestroyProcessParameters (Ppb);
|
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.
|
* CMD.C - command-line interface.
|
||||||
*
|
*
|
||||||
|
@ -129,10 +129,19 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdio.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 "cmd.h"
|
||||||
#include "batch.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 bExit = FALSE; /* indicates EXIT was typed */
|
||||||
BOOL bCanExit = TRUE; /* indicates if this shell is exitable */
|
BOOL bCanExit = TRUE; /* indicates if this shell is exitable */
|
||||||
|
@ -146,6 +155,10 @@ HANDLE hIn;
|
||||||
HANDLE hOut;
|
HANDLE hOut;
|
||||||
HANDLE hConsole;
|
HANDLE hConsole;
|
||||||
|
|
||||||
|
static NtQueryInformationProcessProc NtQueryInformationProcessPtr;
|
||||||
|
static NtReadVirtualMemoryProc NtReadVirtualMemoryPtr;
|
||||||
|
static BOOL NtDllChecked = FALSE;
|
||||||
|
|
||||||
#ifdef INCLUDE_CMD_COLOR
|
#ifdef INCLUDE_CMD_COLOR
|
||||||
WORD wColor; /* current color */
|
WORD wColor; /* current color */
|
||||||
WORD wDefColor; /* default color */
|
WORD wDefColor; /* default color */
|
||||||
|
@ -162,6 +175,65 @@ static BOOL IsDelimiter (TCHAR c)
|
||||||
return (c == _T('/') || c == _T('=') || c == _T('\0') || _istspace (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
|
* This command (in first) was not found in the command table
|
||||||
|
@ -259,6 +331,8 @@ Execute (LPTSTR first, LPTSTR rest)
|
||||||
NULL,
|
NULL,
|
||||||
&stui,
|
&stui,
|
||||||
&prci))
|
&prci))
|
||||||
|
{
|
||||||
|
if (IsConsoleProcess(prci.hProcess))
|
||||||
{
|
{
|
||||||
/* FIXME: Protect this with critical section */
|
/* FIXME: Protect this with critical section */
|
||||||
bChildProcessRunning = TRUE;
|
bChildProcessRunning = TRUE;
|
||||||
|
@ -271,6 +345,7 @@ Execute (LPTSTR first, LPTSTR rest)
|
||||||
|
|
||||||
GetExitCodeProcess (prci.hProcess, &dwExitCode);
|
GetExitCodeProcess (prci.hProcess, &dwExitCode);
|
||||||
nErrorLevel = (INT)dwExitCode;
|
nErrorLevel = (INT)dwExitCode;
|
||||||
|
}
|
||||||
CloseHandle (prci.hThread);
|
CloseHandle (prci.hThread);
|
||||||
CloseHandle (prci.hProcess);
|
CloseHandle (prci.hProcess);
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,8 @@ TARGET_NAME = cmd
|
||||||
|
|
||||||
TARGET_INSTALLDIR = system32
|
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
|
WINE_MODE = yes
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue