From 31789101eea7c1fdb2c4a4ff3cae37ba24e9637a Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 20 Oct 2002 14:54:34 +0000 Subject: [PATCH] Implemented RegisterServicesProcess() and ExitWindowsEx() partially. svn path=/trunk/; revision=3644 --- reactos/include/csrss/csrss.h | 19 ++++++- reactos/include/funcs.h | 3 + reactos/lib/user32/Makefile | 7 ++- reactos/lib/user32/misc/exit.c | 66 ++++++++++++++++++++++ reactos/lib/user32/misc/stubs.c | 16 +----- reactos/lib/user32/user32.def | 2 +- reactos/lib/user32/user32.edf | 2 +- reactos/subsys/csrss/api.h | 2 + reactos/subsys/csrss/api/user.c | 69 +++++++++++++++++++++++ reactos/subsys/csrss/api/wapi.c | 6 +- reactos/subsys/csrss/makefile | 5 +- reactos/subsys/system/services/makefile | 4 +- reactos/subsys/system/services/services.c | 6 +- 13 files changed, 177 insertions(+), 30 deletions(-) create mode 100644 reactos/lib/user32/misc/exit.c create mode 100644 reactos/subsys/csrss/api/user.c diff --git a/reactos/include/csrss/csrss.h b/reactos/include/csrss/csrss.h index b85b3a5c3c1..a4a0463fe79 100644 --- a/reactos/include/csrss/csrss.h +++ b/reactos/include/csrss/csrss.h @@ -282,6 +282,18 @@ typedef struct DWORD NumInputEvents; }CSRSS_GET_NUM_INPUT_EVENTS_REPLY, *PCSRSS_GET_NUM_INPUT_EVENTS_REPLY; +typedef struct +{ + DWORD ProcessId; +} CSRSS_REGISTER_SERVICES_PROCESS_REQUEST, *PCSRSS_REGISTER_SERVICES_PROCESS_REQUEST; + +typedef struct +{ + UINT Flags; + DWORD Reserved; +} CSRSS_EXIT_REACTOS_REQUEST, *PCSRSS_EXIT_REACTOS_REQUEST; + + #define CSRSS_MAX_WRITE_CONSOLE_REQUEST \ (MAX_MESSAGE_DATA - sizeof(ULONG) - sizeof(CSRSS_WRITE_CONSOLE_REQUEST)) @@ -328,7 +340,10 @@ typedef struct #define CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER (0x19) #define CSRSS_READ_CONSOLE_OUTPUT_CHAR (0x1A) #define CSRSS_READ_CONSOLE_OUTPUT_ATTRIB (0x1B) -#define CSRSS_GET_NUM_INPUT_EVENTS (0x1C) +#define CSRSS_GET_NUM_INPUT_EVENTS (0x1C) +#define CSRSS_REGISTER_SERVICES_PROCESS (0x1D) +#define CSRSS_EXIT_REACTOS (0x1E) + /* Keep in sync with definition below. */ @@ -367,6 +382,8 @@ typedef struct CSRSS_READ_CONSOLE_OUTPUT_CHAR_REQUEST ReadConsoleOutputCharRequest; CSRSS_READ_CONSOLE_OUTPUT_ATTRIB_REQUEST ReadConsoleOutputAttribRequest; CSRSS_GET_NUM_INPUT_EVENTS_REQUEST GetNumInputEventsRequest; + CSRSS_REGISTER_SERVICES_PROCESS_REQUEST RegisterServicesProcessRequest; + CSRSS_EXIT_REACTOS_REQUEST ExitReactosRequest; } Data; } CSRSS_API_REQUEST, *PCSRSS_API_REQUEST; diff --git a/reactos/include/funcs.h b/reactos/include/funcs.h index acc581a72a8..1d0902fb7b0 100644 --- a/reactos/include/funcs.h +++ b/reactos/include/funcs.h @@ -7582,6 +7582,9 @@ SwitchToFiber ( ); +WINBOOL STDCALL +RegisterServicesProcess(DWORD ServicesProcessId); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/reactos/lib/user32/Makefile b/reactos/lib/user32/Makefile index bbaba20bece..3e36a08f2c8 100644 --- a/reactos/lib/user32/Makefile +++ b/reactos/lib/user32/Makefile @@ -1,4 +1,4 @@ -# $Id: Makefile,v 1.6 2002/09/17 23:46:22 dwelch Exp $ +# $Id: Makefile,v 1.7 2002/10/20 14:53:02 ekohl Exp $ PATH_TO_TOP = ../.. @@ -26,16 +26,17 @@ CONTROLS_OBJECTS = \ controls/scrollbar.o MISC_OBJECTS = \ + misc/dde.o \ misc/desktop.o \ + misc/display.o \ misc/dllmain.o \ + misc/exit.o \ misc/sprintf.o \ misc/stubs.o \ misc/winhelp.o \ misc/win32k.o \ misc/winsta.o \ misc/resources.o \ - misc/dde.o \ - misc/display.o \ misc/object.o \ misc/timer.o diff --git a/reactos/lib/user32/misc/exit.c b/reactos/lib/user32/misc/exit.c new file mode 100644 index 00000000000..1b18a06459e --- /dev/null +++ b/reactos/lib/user32/misc/exit.c @@ -0,0 +1,66 @@ +/* $Id: exit.c,v 1.1 2002/10/20 14:52:45 ekohl Exp $ + * + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS user32.dll + * FILE: lib/user32/misc/exit.c + * PURPOSE: Shutdown related functions + * PROGRAMMER: Eric Kohl (ekohl@rz-online.de) + */ + +#include +//#include + +#include + + + +WINBOOL STDCALL +ExitWindowsEx(UINT uFlags, + DWORD dwReserved) +{ + CSRSS_API_REQUEST Request; + CSRSS_API_REPLY Reply; + NTSTATUS Status; + + Request.Type = CSRSS_EXIT_REACTOS; + Request.Data.ExitReactosRequest.Flags = uFlags; + Request.Data.ExitReactosRequest.Reserved = dwReserved; + + Status = CsrClientCallServer(&Request, + &Reply, + sizeof(CSRSS_API_REQUEST), + sizeof(CSRSS_API_REPLY)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return(FALSE); + } + + return(TRUE); +} + + +WINBOOL STDCALL +RegisterServicesProcess(DWORD ServicesProcessId) +{ + CSRSS_API_REQUEST Request; + CSRSS_API_REPLY Reply; + NTSTATUS Status; + + Request.Type = CSRSS_REGISTER_SERVICES_PROCESS; + Request.Data.RegisterServicesProcessRequest.ProcessId = ServicesProcessId; + + Status = CsrClientCallServer(&Request, + &Reply, + sizeof(CSRSS_API_REQUEST), + sizeof(CSRSS_API_REPLY)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Reply.Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return(FALSE); + } + + return(TRUE); +} + +/* EOF */ diff --git a/reactos/lib/user32/misc/stubs.c b/reactos/lib/user32/misc/stubs.c index fc91aabcbbe..da4f5b481f8 100644 --- a/reactos/lib/user32/misc/stubs.c +++ b/reactos/lib/user32/misc/stubs.c @@ -1,4 +1,4 @@ -/* $Id: stubs.c,v 1.15 2002/09/17 23:46:23 dwelch Exp $ +/* $Id: stubs.c,v 1.16 2002/10/20 14:52:45 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -122,8 +122,6 @@ DragDetect( return FALSE; } - - WINBOOL STDCALL EnableScrollBar( @@ -134,18 +132,6 @@ EnableScrollBar( return FALSE; } -WINBOOL -STDCALL -ExitWindowsEx( - UINT uFlags, - DWORD dwReserved) -{ - return FALSE; -} - - - - HWND STDCALL GetActiveWindow(VOID) diff --git a/reactos/lib/user32/user32.def b/reactos/lib/user32/user32.def index 1db3d93199b..2600cd9f3c3 100644 --- a/reactos/lib/user32/user32.def +++ b/reactos/lib/user32/user32.def @@ -514,7 +514,7 @@ RegisterClipboardFormatW@4 ;RegisterDeviceNotificationW@12 RegisterHotKey@16 ;RegisterLogonProcess -;RegisterServicesProcess +RegisterServicesProcess@4 ;RegisterShellHookWindow ;RegisterSystemThread ;RegisterTasklist diff --git a/reactos/lib/user32/user32.edf b/reactos/lib/user32/user32.edf index 7e2b56c2804..ea23e7a8c1a 100644 --- a/reactos/lib/user32/user32.edf +++ b/reactos/lib/user32/user32.edf @@ -514,7 +514,7 @@ RegisterClipboardFormatW=RegisterClipboardFormatW@4 ;RegisterDeviceNotificationW@12 RegisterHotKey=RegisterHotKey@16 ;RegisterLogonProcess -;RegisterServicesProcess +RegisterServicesProcess=RegisterServicesProcess@4 ;RegisterShellHookWindow ;RegisterSystemThread ;RegisterTasklist diff --git a/reactos/subsys/csrss/api.h b/reactos/subsys/csrss/api.h index 18220ab1e57..f5f407e26ed 100644 --- a/reactos/subsys/csrss/api.h +++ b/reactos/subsys/csrss/api.h @@ -122,6 +122,8 @@ CSR_API(CsrScrollConsoleScreenBuffer); CSR_API(CsrReadConsoleOutputChar); CSR_API(CsrReadConsoleOutputAttrib); CSR_API(CsrGetNumberOfConsoleInputEvents); +CSR_API(CsrRegisterServicesProcess); +CSR_API(CsrExitReactos); /* print.c */ VOID STDCALL DisplayString(LPCWSTR lpwString); diff --git a/reactos/subsys/csrss/api/user.c b/reactos/subsys/csrss/api/user.c new file mode 100644 index 00000000000..84f4a22ec69 --- /dev/null +++ b/reactos/subsys/csrss/api/user.c @@ -0,0 +1,69 @@ +/* $Id: user.c,v 1.1 2002/10/20 14:53:43 ekohl Exp $ + * + * reactos/subsys/csrss/api/user.c + * + * User functions + * + * ReactOS Operating System + */ + +/* INCLUDES ******************************************************************/ + +#include + +#include +#include "api.h" +#include + +#define NDEBUG +#include + + +/* GLOBALS *******************************************************************/ + +static BOOLEAN ServicesProcessIdValid = FALSE; +static ULONG ServicesProcessId; + + +/* FUNCTIONS *****************************************************************/ + +CSR_API(CsrRegisterServicesProcess) +{ + NTSTATUS Status; + + Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY); + Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) - + sizeof(LPC_MESSAGE_HEADER); + + if (ServicesProcessIdValid == TRUE) + { + /* Only accept a single call */ + Status = STATUS_INVALID_PARAMETER; + } + else + { + ServicesProcessId = (ULONG)Request->Data.RegisterServicesProcessRequest.ProcessId; + ServicesProcessIdValid = TRUE; + Status = STATUS_SUCCESS; + } + + Reply->Status = Status; + + return(Status); +} + + +CSR_API(CsrExitReactos) +{ + Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY); + Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) - + sizeof(LPC_MESSAGE_HEADER); + + + + Reply->Status = STATUS_NOT_IMPLEMENTED; + + return(STATUS_NOT_IMPLEMENTED); +} + +/* EOF */ diff --git a/reactos/subsys/csrss/api/wapi.c b/reactos/subsys/csrss/api/wapi.c index 285ba8ac343..45507b4126a 100644 --- a/reactos/subsys/csrss/api/wapi.c +++ b/reactos/subsys/csrss/api/wapi.c @@ -1,4 +1,4 @@ -/* $Id: wapi.c,v 1.20 2002/10/20 00:34:40 mdill Exp $ +/* $Id: wapi.c,v 1.21 2002/10/20 14:53:43 ekohl Exp $ * * reactos/subsys/csrss/api/wapi.c * @@ -55,7 +55,9 @@ static const CsrFunc CsrFuncs[] = { CsrScrollConsoleScreenBuffer, CsrReadConsoleOutputChar, CsrReadConsoleOutputAttrib, - CsrGetNumberOfConsoleInputEvents, + CsrGetNumberOfConsoleInputEvents, + CsrRegisterServicesProcess, + CsrExitReactos, 0 }; static void Thread_Api2(HANDLE ServerPort) diff --git a/reactos/subsys/csrss/makefile b/reactos/subsys/csrss/makefile index 8e85dcf8dec..3e0da4de099 100644 --- a/reactos/subsys/csrss/makefile +++ b/reactos/subsys/csrss/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.16 2002/08/26 13:06:03 dwelch Exp $ +# $Id: makefile,v 1.17 2002/10/20 14:53:59 ekohl Exp $ PATH_TO_TOP = ../.. @@ -16,7 +16,8 @@ OBJECTS_API = \ api/process.o \ api/wapi.o \ api/conio.o \ - api/handle.o + api/handle.o \ + api/user.o OBJECTS_MISC = \ $(TARGET_NAME).o \ diff --git a/reactos/subsys/system/services/makefile b/reactos/subsys/system/services/makefile index 89e01561383..7efa7a6df8c 100644 --- a/reactos/subsys/system/services/makefile +++ b/reactos/subsys/system/services/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.4 2002/06/07 20:09:56 ekohl Exp $ +# $Id: makefile,v 1.5 2002/10/20 14:54:34 ekohl Exp $ PATH_TO_TOP = ../../.. @@ -10,7 +10,7 @@ TARGET_NAME = services TARGET_INSTALLDIR = system32 -TARGET_SDKLIBS = ntdll.a kernel32.a +TARGET_SDKLIBS = ntdll.a kernel32.a user32.a TARGET_OBJECTS = $(TARGET_NAME).o database.o diff --git a/reactos/subsys/system/services/services.c b/reactos/subsys/system/services/services.c index c1ef3f47442..4ffaf78c801 100644 --- a/reactos/subsys/system/services/services.c +++ b/reactos/subsys/system/services/services.c @@ -1,4 +1,4 @@ -/* $Id: services.c,v 1.8 2002/09/08 10:23:47 chorns Exp $ +/* $Id: services.c,v 1.9 2002/10/20 14:54:34 ekohl Exp $ * * service control manager * @@ -265,8 +265,8 @@ WinMain(HINSTANCE hInstance, /* FIXME: create listener thread for pipe */ - /* FIXME: register process as service process */ -// RegisterServiceProcess(); + /* Register service process with CSRSS */ + RegisterServicesProcess(GetCurrentProcessId()); PrintString("SERVICES: Initialized.\n");