Implemented [Get/Set]ProcessShutdownParameters().

svn path=/trunk/; revision=3645
This commit is contained in:
Eric Kohl 2002-10-20 16:40:12 +00:00
parent 31789101ee
commit bb4e509794
5 changed files with 266 additions and 208 deletions

View file

@ -293,6 +293,13 @@ typedef struct
DWORD Reserved;
} CSRSS_EXIT_REACTOS_REQUEST, *PCSRSS_EXIT_REACTOS_REQUEST;
typedef struct
{
DWORD Level;
DWORD Flags;
} CSRSS_SHUTDOWN_PARAMETERS, *PCSRSS_SHUTDOWN_PARAMETERS;
#define CSRSS_MAX_WRITE_CONSOLE_REQUEST \
(MAX_MESSAGE_DATA - sizeof(ULONG) - sizeof(CSRSS_WRITE_CONSOLE_REQUEST))
@ -343,7 +350,8 @@ typedef struct
#define CSRSS_GET_NUM_INPUT_EVENTS (0x1C)
#define CSRSS_REGISTER_SERVICES_PROCESS (0x1D)
#define CSRSS_EXIT_REACTOS (0x1E)
#define CSRSS_GET_SHUTDOWN_PARAMETERS (0x1F)
#define CSRSS_SET_SHUTDOWN_PARAMETERS (0x20)
/* Keep in sync with definition below. */
@ -384,6 +392,7 @@ typedef struct
CSRSS_GET_NUM_INPUT_EVENTS_REQUEST GetNumInputEventsRequest;
CSRSS_REGISTER_SERVICES_PROCESS_REQUEST RegisterServicesProcessRequest;
CSRSS_EXIT_REACTOS_REQUEST ExitReactosRequest;
CSRSS_SHUTDOWN_PARAMETERS SetShutdownParametersRequest;
} Data;
} CSRSS_API_REQUEST, *PCSRSS_API_REQUEST;
@ -410,6 +419,7 @@ typedef struct
CSRSS_READ_CONSOLE_OUTPUT_CHAR_REPLY ReadConsoleOutputCharReply;
CSRSS_READ_CONSOLE_OUTPUT_ATTRIB_REPLY ReadConsoleOutputAttribReply;
CSRSS_GET_NUM_INPUT_EVENTS_REPLY GetNumInputEventsReply;
CSRSS_SHUTDOWN_PARAMETERS GetShutdownParametersReply;
} Data;
} CSRSS_API_REPLY, *PCSRSS_API_REPLY;

View file

@ -1,4 +1,4 @@
/* $Id: proc.c,v 1.47 2002/10/20 11:56:00 chorns Exp $
/* $Id: proc.c,v 1.48 2002/10/20 16:39:06 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -44,75 +44,96 @@ RegisterWaitForInputIdle (WaitForInputIdleType lpfnRegisterWaitForInputIdle);
WINBOOL STDCALL
GetProcessId (HANDLE hProcess, LPDWORD lpProcessId);
WINBOOL
STDCALL
GetProcessAffinityMask (
HANDLE hProcess,
WINBOOL STDCALL
GetProcessAffinityMask(HANDLE hProcess,
LPDWORD lpProcessAffinityMask,
LPDWORD lpSystemAffinityMask
)
LPDWORD lpSystemAffinityMask)
{
if ((NULL == lpProcessAffinityMask)
|| (NULL == lpSystemAffinityMask)
)
|| (NULL == lpSystemAffinityMask))
{
SetLastError(ERROR_BAD_ARGUMENTS);
return FALSE;
return(FALSE);
}
/* FIXME: check hProcess is actually a process */
/* FIXME: query the kernel process object */
*lpProcessAffinityMask = 0x00000001;
*lpSystemAffinityMask = 0x00000001;
return TRUE;
return(TRUE);
}
WINBOOL
STDCALL
GetProcessShutdownParameters (
LPDWORD lpdwLevel,
LPDWORD lpdwFlags
)
WINBOOL STDCALL
GetProcessShutdownParameters(LPDWORD lpdwLevel,
LPDWORD lpdwFlags)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
CSRSS_API_REQUEST CsrRequest;
CSRSS_API_REPLY CsrReply;
NTSTATUS Status;
CsrRequest.Type = CSRSS_GET_SHUTDOWN_PARAMETERS;
Status = CsrClientCallServer(&CsrRequest,
&CsrReply,
sizeof(CSRSS_API_REQUEST),
sizeof(CSRSS_API_REPLY));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrReply.Status))
{
SetLastError(Status);
return(FALSE);
}
*lpdwLevel = CsrReply.Data.GetShutdownParametersReply.Level;
*lpdwFlags = CsrReply.Data.GetShutdownParametersReply.Flags;
return(TRUE);
}
WINBOOL
STDCALL
GetProcessWorkingSetSize (
HANDLE hProcess,
WINBOOL STDCALL
SetProcessShutdownParameters(DWORD dwLevel,
DWORD dwFlags)
{
CSRSS_API_REQUEST CsrRequest;
CSRSS_API_REPLY CsrReply;
NTSTATUS Status;
CsrRequest.Data.SetShutdownParametersRequest.Level = dwLevel;
CsrRequest.Data.SetShutdownParametersRequest.Flags = dwFlags;
CsrRequest.Type = CSRSS_SET_SHUTDOWN_PARAMETERS;
Status = CsrClientCallServer(&CsrRequest,
&CsrReply,
sizeof(CSRSS_API_REQUEST),
sizeof(CSRSS_API_REPLY));
if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrReply.Status))
{
SetLastError(Status);
return(FALSE);
}
return(TRUE);
}
WINBOOL STDCALL
GetProcessWorkingSetSize(HANDLE hProcess,
LPDWORD lpMinimumWorkingSetSize,
LPDWORD lpMaximumWorkingSetSize
)
LPDWORD lpMaximumWorkingSetSize)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
WINBOOL
STDCALL
SetProcessShutdownParameters (
DWORD dwLevel,
DWORD dwFlags
)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
return(FALSE);
}
WINBOOL
STDCALL
SetProcessWorkingSetSize (
HANDLE hProcess,
WINBOOL STDCALL
SetProcessWorkingSetSize(HANDLE hProcess,
DWORD dwMinimumWorkingSetSize,
DWORD dwMaximumWorkingSetSize
)
DWORD dwMaximumWorkingSetSize)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
return(FALSE);
}
@ -123,15 +144,14 @@ GetProcessTimes (HANDLE hProcess,
LPFILETIME lpKernelTime,
LPFILETIME lpUserTime)
{
NTSTATUS Status;
KERNEL_USER_TIMES Kut;
NTSTATUS Status;
Status = NtQueryInformationProcess(hProcess,
ProcessTimes,
&Kut,
sizeof(Kut),
NULL
);
NULL);
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus(Status);
@ -154,56 +174,55 @@ GetProcessTimes (HANDLE hProcess,
}
HANDLE STDCALL GetCurrentProcess (VOID)
HANDLE STDCALL
GetCurrentProcess(VOID)
{
return((HANDLE)NtCurrentProcess());
}
HANDLE STDCALL GetCurrentThread (VOID)
HANDLE STDCALL
GetCurrentThread(VOID)
{
return((HANDLE)NtCurrentThread());
}
DWORD STDCALL GetCurrentProcessId (VOID)
DWORD STDCALL
GetCurrentProcessId(VOID)
{
return((DWORD)GetTeb()->Cid.UniqueProcess);
}
WINBOOL
STDCALL
GetExitCodeProcess (
HANDLE hProcess,
LPDWORD lpExitCode
)
WINBOOL STDCALL
GetExitCodeProcess(HANDLE hProcess,
LPDWORD lpExitCode)
{
NTSTATUS errCode;
PROCESS_BASIC_INFORMATION ProcessBasic;
ULONG BytesWritten;
NTSTATUS Status;
errCode = NtQueryInformationProcess(hProcess,
Status = NtQueryInformationProcess(hProcess,
ProcessBasicInformation,
&ProcessBasic,
sizeof(PROCESS_BASIC_INFORMATION),
&BytesWritten);
if (!NT_SUCCESS(errCode))
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus (errCode);
return FALSE;
SetLastErrorByStatus(Status);
return(FALSE);
}
memcpy(lpExitCode, &ProcessBasic.ExitStatus, sizeof(DWORD));
return TRUE;
return(TRUE);
}
WINBOOL
STDCALL
GetProcessId (
HANDLE hProcess,
LPDWORD lpProcessId
)
WINBOOL STDCALL
GetProcessId(HANDLE hProcess,
LPDWORD lpProcessId)
{
NTSTATUS errCode;
PROCESS_BASIC_INFORMATION ProcessBasic;
@ -224,13 +243,10 @@ GetProcessId (
}
HANDLE
STDCALL
OpenProcess (
DWORD dwDesiredAccess,
HANDLE STDCALL
OpenProcess(DWORD dwDesiredAccess,
WINBOOL bInheritHandle,
DWORD dwProcessId
)
DWORD dwProcessId)
{
NTSTATUS errCode;
HANDLE ProcessHandle;
@ -264,12 +280,9 @@ OpenProcess (
}
UINT
STDCALL
WinExec (
LPCSTR lpCmdLine,
UINT uCmdShow
)
UINT STDCALL
WinExec(LPCSTR lpCmdLine,
UINT uCmdShow)
{
STARTUPINFOA StartupInfo;
PROCESS_INFORMATION ProcessInformation;
@ -308,8 +321,7 @@ WinExec (
}
VOID
STDCALL
VOID STDCALL
RegisterWaitForInputIdle (
WaitForInputIdleType lpfnRegisterWaitForInputIdle
)
@ -319,8 +331,7 @@ RegisterWaitForInputIdle (
}
DWORD
STDCALL
DWORD STDCALL
WaitForInputIdle (
HANDLE hProcess,
DWORD dwMilliseconds
@ -330,11 +341,8 @@ WaitForInputIdle (
}
VOID
STDCALL
Sleep (
DWORD dwMilliseconds
)
VOID STDCALL
Sleep(DWORD dwMilliseconds)
{
SleepEx(dwMilliseconds, FALSE);
return;
@ -482,14 +490,14 @@ FlushInstructionCache (HANDLE hProcess,
LPCVOID lpBaseAddress,
DWORD dwSize)
{
NTSTATUS errCode;
NTSTATUS Status;
errCode = NtFlushInstructionCache (hProcess,
Status = NtFlushInstructionCache(hProcess,
(PVOID)lpBaseAddress,
dwSize);
if (!NT_SUCCESS(errCode))
if (!NT_SUCCESS(Status))
{
SetLastErrorByStatus (errCode);
SetLastErrorByStatus(Status);
return FALSE;
}
return TRUE;
@ -528,8 +536,9 @@ WINBOOL STDCALL
TerminateProcess (HANDLE hProcess,
UINT uExitCode)
{
NTSTATUS Status = NtTerminateProcess (hProcess, uExitCode);
NTSTATUS Status;
Status = NtTerminateProcess (hProcess, uExitCode);
if (NT_SUCCESS(Status))
{
return TRUE;

View file

@ -79,6 +79,8 @@ typedef struct
ULONG HandleTableSize;
Object_t ** HandleTable;
ULONG ProcessId;
ULONG ShutdownLevel;
ULONG ShutdownFlags;
HANDLE ConsoleEvent;
PVOID CsrSectionViewBase;
ULONG CsrSectionViewSize;
@ -124,6 +126,8 @@ CSR_API(CsrReadConsoleOutputAttrib);
CSR_API(CsrGetNumberOfConsoleInputEvents);
CSR_API(CsrRegisterServicesProcess);
CSR_API(CsrExitReactos);
CSR_API(CsrGetShutdownParameters);
CSR_API(CsrSetShutdownParameters);
/* print.c */
VOID STDCALL DisplayString(LPCWSTR lpwString);

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.20 2002/10/01 06:41:56 ei Exp $
/* $Id: process.c,v 1.21 2002/10/20 16:40:12 ekohl Exp $
*
* reactos/subsys/csrss/api/process.c
*
@ -134,6 +134,10 @@ CSR_API(CsrCreateProcess)
return(STATUS_NO_MEMORY);
}
/* Set default shutdown parameters */
NewProcessData->ShutdownLevel = 0x280;
NewProcessData->ShutdownFlags = 0;
if (Request->Data.CreateProcessRequest.Flags & DETACHED_PROCESS)
{
NewProcessData->Console = NULL;
@ -225,4 +229,33 @@ CSR_API(CsrConnectProcess)
return(STATUS_SUCCESS);
}
CSR_API(CsrGetShutdownParameters)
{
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) -
sizeof(LPC_MESSAGE_HEADER);
Reply->Data.GetShutdownParametersReply.Level = ProcessData->ShutdownLevel;
Reply->Data.GetShutdownParametersReply.Flags = ProcessData->ShutdownFlags;
Reply->Status = STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
CSR_API(CsrSetShutdownParameters)
{
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) -
sizeof(LPC_MESSAGE_HEADER);
ProcessData->ShutdownLevel = Request->Data.SetShutdownParametersRequest.Level;
ProcessData->ShutdownFlags = Request->Data.SetShutdownParametersRequest.Flags;
Reply->Status = STATUS_SUCCESS;
return(STATUS_SUCCESS);
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: wapi.c,v 1.21 2002/10/20 14:53:43 ekohl Exp $
/* $Id: wapi.c,v 1.22 2002/10/20 16:40:12 ekohl Exp $
*
* reactos/subsys/csrss/api/wapi.c
*
@ -58,6 +58,8 @@ static const CsrFunc CsrFuncs[] = {
CsrGetNumberOfConsoleInputEvents,
CsrRegisterServicesProcess,
CsrExitReactos,
CsrGetShutdownParameters,
CsrSetShutdownParameters,
0 };
static void Thread_Api2(HANDLE ServerPort)