From: Emanuele Aliberti Date: Sun, 22 May 2005 16:10:10 +0000 (+0000) Subject: svn propset {keyword, eol-type} X-Git-Tag: backups/xmlbuildsystem@15601~1^2~70 X-Git-Url: https://git.reactos.org/?p=reactos.git;a=commitdiff_plain;h=5b45accaef9d3c0c5d7df11310a555e517a42b7f svn propset {keyword, eol-type} svn path=/trunk/; revision=15468 --- diff --git a/reactos/subsys/smss/client.c b/reactos/subsys/smss/client.c index 94e52b7a37b..5e2bb5f6e6a 100644 --- a/reactos/subsys/smss/client.c +++ b/reactos/subsys/smss/client.c @@ -1,448 +1,448 @@ -/* $Id: smss.c 12852 2005-01-06 13:58:04Z mf $ - * - * client.c - Session Manager client Management - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ -#define NTOS_MODE_USER -#include -#include "smss.h" -#include - -#define NDEBUG -#include - -/* Private ADT */ - - -struct _SM_CLIENT_DIRECTORY -{ - RTL_CRITICAL_SECTION Lock; - ULONG Count; - PSM_CLIENT_DATA Client; - PSM_CLIENT_DATA CandidateClient; - -} SmpClientDirectory; - - -/********************************************************************** - * SmInitializeClientManagement/0 - */ -NTSTATUS -SmInitializeClientManagement (VOID) -{ - DPRINT("SM: %s called\n", __FUNCTION__); - RtlInitializeCriticalSection(& SmpClientDirectory.Lock); - SmpClientDirectory.Count = 0; - SmpClientDirectory.Client = NULL; - SmpClientDirectory.CandidateClient = NULL; - return STATUS_SUCCESS; - -} -/********************************************************************** - * SmpSetClientInitialized/1 - */ -VOID FASTCALL -SmpSetClientInitialized (PSM_CLIENT_DATA Client) -{ - Client->Flags |= SM_CLIENT_FLAG_INITIALIZED; -} -/********************************************************************** - * SmpLookupClient/2 PRIVATE - * - * DESCRIPTION - * Lookup the subsystem server descriptor given its image ID. - * - * ARGUMENTS - * SubsystemId: IMAGE_SUBSYSTEM_xxx - * Parent: optional: caller provided storage for the - * the pointer to the SM_CLIENT_DATA which - * Next field contains the value returned by - * the function (on success). - * - * RETURN VALUES - * NULL on error; otherwise a pointer to the SM_CLIENT_DATA - * looked up object. - * - * WARNING - * SmpClientDirectory.Lock must be held by the caller. - */ -static PSM_CLIENT_DATA FASTCALL -SmpLookupClient (USHORT SubsystemId, - PSM_CLIENT_DATA * Parent) -{ - PSM_CLIENT_DATA Client = NULL; - - DPRINT("SM: %s(%d) called\n", __FUNCTION__, SubsystemId); - - if(NULL != Parent) - { - *Parent = NULL; - } - if (SmpClientDirectory.Count > 0) - { - Client = SmpClientDirectory.Client; - while (NULL != Client) - { - if (SubsystemId == Client->SubsystemId) - { - break; - } - if(NULL != Parent) - { - *Parent = Client; - } - Client = Client->Next; - } - } - return Client; -} -/********************************************************************** - * SmBeginClientInitialization/1 - * - * DESCRIPTION - * Check if the candidate client matches the begin session - * message from the subsystem process. - * - * ARGUMENTS - * Request: message received by \SmApiPort - * ClientData: - * - * RETURN VALUES - * NTSTATUS - */ -NTSTATUS STDCALL -SmBeginClientInitialization (IN PSM_PORT_MESSAGE Request, - OUT PSM_CLIENT_DATA * ClientData) -{ - NTSTATUS Status = STATUS_SUCCESS; - PSM_CONNECT_DATA ConnectData = SmpGetConnectData (Request); - ULONG SbApiPortNameSize = SM_CONNECT_DATA_SIZE(*Request); - - - DPRINT("SM: %s called\n", __FUNCTION__); - - RtlEnterCriticalSection (& SmpClientDirectory.Lock); - /* - * Is there a subsystem bootstrap in progress? - */ - if (SmpClientDirectory.CandidateClient) - { - PROCESS_BASIC_INFORMATION pbi; - - RtlZeroMemory (& pbi, sizeof pbi); - Status = NtQueryInformationProcess (Request->Header.ClientId.UniqueProcess, - ProcessBasicInformation, - & pbi, - sizeof pbi, - NULL); - if (NT_SUCCESS(Status)) - { - SmpClientDirectory.CandidateClient->ServerProcessId = - (ULONG) pbi.UniqueProcessId; - } - } - else - { - RtlFreeHeap (SmpHeap, 0, SmpClientDirectory.CandidateClient); - DPRINT1("SM: %s: subsys booting with no descriptor!\n", __FUNCTION__); - Status = STATUS_NOT_FOUND; - RtlLeaveCriticalSection (& SmpClientDirectory.Lock); - return Status; - } - /* - * Check if a client for the ID already exist. - */ - if (SmpLookupClient(ConnectData->SubSystemId, NULL)) - { - DPRINT("SM: %s: attempt to register again subsystem %d.\n", - __FUNCTION__, - ConnectData->SubSystemId); - return STATUS_UNSUCCESSFUL; - } - DPRINT("SM: %s: registering subsystem ID=%d \n", - __FUNCTION__, ConnectData->SubSystemId); - - /* - * Initialize the client data - */ - SmpClientDirectory.CandidateClient->SubsystemId = ConnectData->SubSystemId; - /* SM && DBG auto-initializes; other subsystems are required to call - * SM_API_COMPLETE_SESSION via SMDLL. */ - if ((IMAGE_SUBSYSTEM_NATIVE == SmpClientDirectory.CandidateClient->SubsystemId) || - (IMAGE_SUBSYSTEM_UNKNOWN == SmpClientDirectory.CandidateClient->SubsystemId)) - { - SmpSetClientInitialized (SmpClientDirectory.CandidateClient); - } - if (SbApiPortNameSize > 0) - { - RtlCopyMemory (SmpClientDirectory.CandidateClient->SbApiPortName, - ConnectData->SbName, - SbApiPortNameSize); - } - /* - * Insert the new descriptor in the - * client directory. - */ - if (NULL == SmpClientDirectory.Client) - { - SmpClientDirectory.Client = SmpClientDirectory.CandidateClient; - } else { - PSM_CLIENT_DATA pCD = NULL; - - for (pCD=SmpClientDirectory.Client; - (NULL != pCD->Next); - pCD = pCD->Next); - pCD->Next = SmpClientDirectory.CandidateClient; - } - SmpClientDirectory.CandidateClient->Next = NULL; - /* - * Increment the number of active subsystems. - */ - ++ SmpClientDirectory.Count; - /* - * Notify to the caller the reference to the client data. - */ - if (ClientData) - { - *ClientData = SmpClientDirectory.CandidateClient; - } - /* - * Free the slot for the candidate subsystem. - */ - SmpClientDirectory.CandidateClient = NULL; - - RtlLeaveCriticalSection (& SmpClientDirectory.Lock); - - return STATUS_SUCCESS; -} -/********************************************************************** - * SmCompleteClientInitialization/1 - * - * DESCRIPTION - * Lookup the subsystem server descriptor given the process ID - * of the subsystem server process. - */ -NTSTATUS STDCALL -SmCompleteClientInitialization (ULONG ProcessId) -{ - NTSTATUS Status = STATUS_SUCCESS; - PSM_CLIENT_DATA Client = NULL; - - DPRINT("SM: %s called\n", __FUNCTION__); - - RtlEnterCriticalSection (& SmpClientDirectory.Lock); - if (SmpClientDirectory.Count > 0) - { - Client = SmpClientDirectory.Client; - while (NULL != Client) - { - if (ProcessId == Client->ServerProcessId) - { - SmpSetClientInitialized (Client); - break; - } - Client = Client->Next; - } - Status = STATUS_NOT_FOUND; - } - RtlLeaveCriticalSection (& SmpClientDirectory.Lock); - return Status; -} - -/********************************************************************** - * SmpCreateClient/1 - * - * DESCRIPTION - * Create a "candidate" client. Client descriptor will enter the - * client directory only at the end of the registration - * procedure. Otherwise, we will kill the associated process. - * - * ARGUMENTS - * ProcessHandle: handle of the subsystem server process. - * - * RETURN VALUE - * NTSTATUS: - */ -NTSTATUS STDCALL -SmCreateClient (PRTL_PROCESS_INFO ProcessInfo, PWSTR ProgramName) -{ - NTSTATUS Status = STATUS_SUCCESS; - - - DPRINT("SM: %s(%lx) called\n", __FUNCTION__, ProcessInfo->ProcessHandle); - RtlEnterCriticalSection (& SmpClientDirectory.Lock); - /* - * Check if the candidate client slot is empty. - */ - if (NULL != SmpClientDirectory.CandidateClient) - { - DPRINT1("SM: %s: CandidateClient pending!\n", __FUNCTION__); - RtlLeaveCriticalSection (& SmpClientDirectory.Lock); - return STATUS_UNSUCCESSFUL; - } - /* - * Allocate the storage for client data - */ - SmpClientDirectory.CandidateClient = - RtlAllocateHeap (SmpHeap, - HEAP_ZERO_MEMORY, - sizeof (SM_CLIENT_DATA)); - if (NULL == SmpClientDirectory.CandidateClient) - { - DPRINT("SM: %s(%lx): out of memory!\n", - __FUNCTION__, ProcessInfo->ProcessHandle); - Status = STATUS_NO_MEMORY; - } - else - { - /* Initialize the candidate client. */ - RtlInitializeCriticalSection(& SmpClientDirectory.CandidateClient->Lock); - SmpClientDirectory.CandidateClient->ServerProcess = - (HANDLE) ProcessInfo->ProcessHandle; - SmpClientDirectory.CandidateClient->ServerProcessId = - (ULONG) ProcessInfo->ClientId.UniqueProcess; - } - /* - * Copy the program name - */ - RtlCopyMemory (SmpClientDirectory.CandidateClient->ProgramName, - ProgramName, - SM_SB_NAME_MAX_LENGTH); - RtlLeaveCriticalSection (& SmpClientDirectory.Lock); - return Status; -} - -/********************************************************************** - * SmpDestroyClient/1 - * - * 1. close any handle - * 2. kill client process - * 3. release resources - */ -NTSTATUS STDCALL -SmDestroyClient (ULONG SubsystemId) -{ - NTSTATUS Status = STATUS_SUCCESS; - PSM_CLIENT_DATA Parent = NULL; - PSM_CLIENT_DATA Client = NULL; - - DPRINT("SM: %s called\n", __FUNCTION__); - - RtlEnterCriticalSection (& SmpClientDirectory.Lock); - Client = SmpLookupClient (SubsystemId, & Parent); - if(NULL == Client) - { - DPRINT1("SM: %s: del req for non existent subsystem (id=%d)\n", - __FUNCTION__, SubsystemId); - Status = STATUS_NOT_FOUND; - } - else - { - /* 1st in the list? */ - if(NULL == Parent) - { - SmpClientDirectory.Client = Client->Next; - } - else - { - if(NULL != Parent) - { - Parent->Next = Client->Next; - } else { - DPRINT1("SM: %s: n-th has no parent!\n", __FUNCTION__); - Status = STATUS_UNSUCCESSFUL; /* FIXME */ - } - } - /* TODO: send shutdown or kill */ - NtTerminateProcess (Client->ServerProcess, 0); //FIXME - RtlFreeHeap (SmpHeap, 0, Client); - -- SmpClientDirectory.Count; - } - RtlLeaveCriticalSection (& SmpClientDirectory.Lock); - return Status; -} - -/* === Utilities for SmQryInfo === */ - -/********************************************************************** - * SmGetClientBasicInformation/1 - */ -NTSTATUS FASTCALL -SmGetClientBasicInformation (PSM_BASIC_INFORMATION i) -{ - INT Index = 0; - PSM_CLIENT_DATA ClientData = NULL; - - DPRINT("SM: %s called\n", __FUNCTION__); - - RtlEnterCriticalSection (& SmpClientDirectory.Lock); - - i->SubSystemCount = SmpClientDirectory.Count; - i->Unused = 0; - - if (SmpClientDirectory.Count > 0) - { - ClientData = SmpClientDirectory.Client; - while ((NULL != ClientData) && (Index < SM_QRYINFO_MAX_SS_COUNT)) - { - i->SubSystem[Index].Id = ClientData->SubsystemId; - i->SubSystem[Index].Flags = ClientData->Flags; - i->SubSystem[Index].ProcessId = ClientData->ServerProcessId; - ClientData = ClientData->Next; - } - } - - RtlLeaveCriticalSection (& SmpClientDirectory.Lock); - return STATUS_SUCCESS; -} - -/********************************************************************** - * SmGetSubSystemInformation/1 - */ -NTSTATUS FASTCALL -SmGetSubSystemInformation (PSM_SUBSYSTEM_INFORMATION i) -{ - NTSTATUS Status = STATUS_SUCCESS; - PSM_CLIENT_DATA ClientData = NULL; - - DPRINT("SM: %s called\n", __FUNCTION__); - - RtlEnterCriticalSection (& SmpClientDirectory.Lock); - ClientData = SmpLookupClient (i->SubSystemId, NULL); - if (NULL == ClientData) - { - Status = STATUS_NOT_FOUND; - } - else - { - i->Flags = ClientData->Flags; - i->ProcessId = ClientData->ServerProcessId; - RtlCopyMemory (i->NameSpaceRootNode, - ClientData->SbApiPortName, - (SM_QRYINFO_MAX_ROOT_NODE * sizeof(i->NameSpaceRootNode[0]))); - } - RtlLeaveCriticalSection (& SmpClientDirectory.Lock); - return Status; -} - -/* EOF */ +/* $Id$ + * + * client.c - Session Manager client Management + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#define NTOS_MODE_USER +#include +#include "smss.h" +#include + +#define NDEBUG +#include + +/* Private ADT */ + + +struct _SM_CLIENT_DIRECTORY +{ + RTL_CRITICAL_SECTION Lock; + ULONG Count; + PSM_CLIENT_DATA Client; + PSM_CLIENT_DATA CandidateClient; + +} SmpClientDirectory; + + +/********************************************************************** + * SmInitializeClientManagement/0 + */ +NTSTATUS +SmInitializeClientManagement (VOID) +{ + DPRINT("SM: %s called\n", __FUNCTION__); + RtlInitializeCriticalSection(& SmpClientDirectory.Lock); + SmpClientDirectory.Count = 0; + SmpClientDirectory.Client = NULL; + SmpClientDirectory.CandidateClient = NULL; + return STATUS_SUCCESS; + +} +/********************************************************************** + * SmpSetClientInitialized/1 + */ +VOID FASTCALL +SmpSetClientInitialized (PSM_CLIENT_DATA Client) +{ + Client->Flags |= SM_CLIENT_FLAG_INITIALIZED; +} +/********************************************************************** + * SmpLookupClient/2 PRIVATE + * + * DESCRIPTION + * Lookup the subsystem server descriptor given its image ID. + * + * ARGUMENTS + * SubsystemId: IMAGE_SUBSYSTEM_xxx + * Parent: optional: caller provided storage for the + * the pointer to the SM_CLIENT_DATA which + * Next field contains the value returned by + * the function (on success). + * + * RETURN VALUES + * NULL on error; otherwise a pointer to the SM_CLIENT_DATA + * looked up object. + * + * WARNING + * SmpClientDirectory.Lock must be held by the caller. + */ +static PSM_CLIENT_DATA FASTCALL +SmpLookupClient (USHORT SubsystemId, + PSM_CLIENT_DATA * Parent) +{ + PSM_CLIENT_DATA Client = NULL; + + DPRINT("SM: %s(%d) called\n", __FUNCTION__, SubsystemId); + + if(NULL != Parent) + { + *Parent = NULL; + } + if (SmpClientDirectory.Count > 0) + { + Client = SmpClientDirectory.Client; + while (NULL != Client) + { + if (SubsystemId == Client->SubsystemId) + { + break; + } + if(NULL != Parent) + { + *Parent = Client; + } + Client = Client->Next; + } + } + return Client; +} +/********************************************************************** + * SmBeginClientInitialization/1 + * + * DESCRIPTION + * Check if the candidate client matches the begin session + * message from the subsystem process. + * + * ARGUMENTS + * Request: message received by \SmApiPort + * ClientData: + * + * RETURN VALUES + * NTSTATUS + */ +NTSTATUS STDCALL +SmBeginClientInitialization (IN PSM_PORT_MESSAGE Request, + OUT PSM_CLIENT_DATA * ClientData) +{ + NTSTATUS Status = STATUS_SUCCESS; + PSM_CONNECT_DATA ConnectData = SmpGetConnectData (Request); + ULONG SbApiPortNameSize = SM_CONNECT_DATA_SIZE(*Request); + + + DPRINT("SM: %s called\n", __FUNCTION__); + + RtlEnterCriticalSection (& SmpClientDirectory.Lock); + /* + * Is there a subsystem bootstrap in progress? + */ + if (SmpClientDirectory.CandidateClient) + { + PROCESS_BASIC_INFORMATION pbi; + + RtlZeroMemory (& pbi, sizeof pbi); + Status = NtQueryInformationProcess (Request->Header.ClientId.UniqueProcess, + ProcessBasicInformation, + & pbi, + sizeof pbi, + NULL); + if (NT_SUCCESS(Status)) + { + SmpClientDirectory.CandidateClient->ServerProcessId = + (ULONG) pbi.UniqueProcessId; + } + } + else + { + RtlFreeHeap (SmpHeap, 0, SmpClientDirectory.CandidateClient); + DPRINT1("SM: %s: subsys booting with no descriptor!\n", __FUNCTION__); + Status = STATUS_NOT_FOUND; + RtlLeaveCriticalSection (& SmpClientDirectory.Lock); + return Status; + } + /* + * Check if a client for the ID already exist. + */ + if (SmpLookupClient(ConnectData->SubSystemId, NULL)) + { + DPRINT("SM: %s: attempt to register again subsystem %d.\n", + __FUNCTION__, + ConnectData->SubSystemId); + return STATUS_UNSUCCESSFUL; + } + DPRINT("SM: %s: registering subsystem ID=%d \n", + __FUNCTION__, ConnectData->SubSystemId); + + /* + * Initialize the client data + */ + SmpClientDirectory.CandidateClient->SubsystemId = ConnectData->SubSystemId; + /* SM && DBG auto-initializes; other subsystems are required to call + * SM_API_COMPLETE_SESSION via SMDLL. */ + if ((IMAGE_SUBSYSTEM_NATIVE == SmpClientDirectory.CandidateClient->SubsystemId) || + (IMAGE_SUBSYSTEM_UNKNOWN == SmpClientDirectory.CandidateClient->SubsystemId)) + { + SmpSetClientInitialized (SmpClientDirectory.CandidateClient); + } + if (SbApiPortNameSize > 0) + { + RtlCopyMemory (SmpClientDirectory.CandidateClient->SbApiPortName, + ConnectData->SbName, + SbApiPortNameSize); + } + /* + * Insert the new descriptor in the + * client directory. + */ + if (NULL == SmpClientDirectory.Client) + { + SmpClientDirectory.Client = SmpClientDirectory.CandidateClient; + } else { + PSM_CLIENT_DATA pCD = NULL; + + for (pCD=SmpClientDirectory.Client; + (NULL != pCD->Next); + pCD = pCD->Next); + pCD->Next = SmpClientDirectory.CandidateClient; + } + SmpClientDirectory.CandidateClient->Next = NULL; + /* + * Increment the number of active subsystems. + */ + ++ SmpClientDirectory.Count; + /* + * Notify to the caller the reference to the client data. + */ + if (ClientData) + { + *ClientData = SmpClientDirectory.CandidateClient; + } + /* + * Free the slot for the candidate subsystem. + */ + SmpClientDirectory.CandidateClient = NULL; + + RtlLeaveCriticalSection (& SmpClientDirectory.Lock); + + return STATUS_SUCCESS; +} +/********************************************************************** + * SmCompleteClientInitialization/1 + * + * DESCRIPTION + * Lookup the subsystem server descriptor given the process ID + * of the subsystem server process. + */ +NTSTATUS STDCALL +SmCompleteClientInitialization (ULONG ProcessId) +{ + NTSTATUS Status = STATUS_SUCCESS; + PSM_CLIENT_DATA Client = NULL; + + DPRINT("SM: %s called\n", __FUNCTION__); + + RtlEnterCriticalSection (& SmpClientDirectory.Lock); + if (SmpClientDirectory.Count > 0) + { + Client = SmpClientDirectory.Client; + while (NULL != Client) + { + if (ProcessId == Client->ServerProcessId) + { + SmpSetClientInitialized (Client); + break; + } + Client = Client->Next; + } + Status = STATUS_NOT_FOUND; + } + RtlLeaveCriticalSection (& SmpClientDirectory.Lock); + return Status; +} + +/********************************************************************** + * SmpCreateClient/1 + * + * DESCRIPTION + * Create a "candidate" client. Client descriptor will enter the + * client directory only at the end of the registration + * procedure. Otherwise, we will kill the associated process. + * + * ARGUMENTS + * ProcessHandle: handle of the subsystem server process. + * + * RETURN VALUE + * NTSTATUS: + */ +NTSTATUS STDCALL +SmCreateClient (PRTL_PROCESS_INFO ProcessInfo, PWSTR ProgramName) +{ + NTSTATUS Status = STATUS_SUCCESS; + + + DPRINT("SM: %s(%lx) called\n", __FUNCTION__, ProcessInfo->ProcessHandle); + RtlEnterCriticalSection (& SmpClientDirectory.Lock); + /* + * Check if the candidate client slot is empty. + */ + if (NULL != SmpClientDirectory.CandidateClient) + { + DPRINT1("SM: %s: CandidateClient pending!\n", __FUNCTION__); + RtlLeaveCriticalSection (& SmpClientDirectory.Lock); + return STATUS_UNSUCCESSFUL; + } + /* + * Allocate the storage for client data + */ + SmpClientDirectory.CandidateClient = + RtlAllocateHeap (SmpHeap, + HEAP_ZERO_MEMORY, + sizeof (SM_CLIENT_DATA)); + if (NULL == SmpClientDirectory.CandidateClient) + { + DPRINT("SM: %s(%lx): out of memory!\n", + __FUNCTION__, ProcessInfo->ProcessHandle); + Status = STATUS_NO_MEMORY; + } + else + { + /* Initialize the candidate client. */ + RtlInitializeCriticalSection(& SmpClientDirectory.CandidateClient->Lock); + SmpClientDirectory.CandidateClient->ServerProcess = + (HANDLE) ProcessInfo->ProcessHandle; + SmpClientDirectory.CandidateClient->ServerProcessId = + (ULONG) ProcessInfo->ClientId.UniqueProcess; + } + /* + * Copy the program name + */ + RtlCopyMemory (SmpClientDirectory.CandidateClient->ProgramName, + ProgramName, + SM_SB_NAME_MAX_LENGTH); + RtlLeaveCriticalSection (& SmpClientDirectory.Lock); + return Status; +} + +/********************************************************************** + * SmpDestroyClient/1 + * + * 1. close any handle + * 2. kill client process + * 3. release resources + */ +NTSTATUS STDCALL +SmDestroyClient (ULONG SubsystemId) +{ + NTSTATUS Status = STATUS_SUCCESS; + PSM_CLIENT_DATA Parent = NULL; + PSM_CLIENT_DATA Client = NULL; + + DPRINT("SM: %s called\n", __FUNCTION__); + + RtlEnterCriticalSection (& SmpClientDirectory.Lock); + Client = SmpLookupClient (SubsystemId, & Parent); + if(NULL == Client) + { + DPRINT1("SM: %s: del req for non existent subsystem (id=%d)\n", + __FUNCTION__, SubsystemId); + Status = STATUS_NOT_FOUND; + } + else + { + /* 1st in the list? */ + if(NULL == Parent) + { + SmpClientDirectory.Client = Client->Next; + } + else + { + if(NULL != Parent) + { + Parent->Next = Client->Next; + } else { + DPRINT1("SM: %s: n-th has no parent!\n", __FUNCTION__); + Status = STATUS_UNSUCCESSFUL; /* FIXME */ + } + } + /* TODO: send shutdown or kill */ + NtTerminateProcess (Client->ServerProcess, 0); //FIXME + RtlFreeHeap (SmpHeap, 0, Client); + -- SmpClientDirectory.Count; + } + RtlLeaveCriticalSection (& SmpClientDirectory.Lock); + return Status; +} + +/* === Utilities for SmQryInfo === */ + +/********************************************************************** + * SmGetClientBasicInformation/1 + */ +NTSTATUS FASTCALL +SmGetClientBasicInformation (PSM_BASIC_INFORMATION i) +{ + INT Index = 0; + PSM_CLIENT_DATA ClientData = NULL; + + DPRINT("SM: %s called\n", __FUNCTION__); + + RtlEnterCriticalSection (& SmpClientDirectory.Lock); + + i->SubSystemCount = SmpClientDirectory.Count; + i->Unused = 0; + + if (SmpClientDirectory.Count > 0) + { + ClientData = SmpClientDirectory.Client; + while ((NULL != ClientData) && (Index < SM_QRYINFO_MAX_SS_COUNT)) + { + i->SubSystem[Index].Id = ClientData->SubsystemId; + i->SubSystem[Index].Flags = ClientData->Flags; + i->SubSystem[Index].ProcessId = ClientData->ServerProcessId; + ClientData = ClientData->Next; + } + } + + RtlLeaveCriticalSection (& SmpClientDirectory.Lock); + return STATUS_SUCCESS; +} + +/********************************************************************** + * SmGetSubSystemInformation/1 + */ +NTSTATUS FASTCALL +SmGetSubSystemInformation (PSM_SUBSYSTEM_INFORMATION i) +{ + NTSTATUS Status = STATUS_SUCCESS; + PSM_CLIENT_DATA ClientData = NULL; + + DPRINT("SM: %s called\n", __FUNCTION__); + + RtlEnterCriticalSection (& SmpClientDirectory.Lock); + ClientData = SmpLookupClient (i->SubSystemId, NULL); + if (NULL == ClientData) + { + Status = STATUS_NOT_FOUND; + } + else + { + i->Flags = ClientData->Flags; + i->ProcessId = ClientData->ServerProcessId; + RtlCopyMemory (i->NameSpaceRootNode, + ClientData->SbApiPortName, + (SM_QRYINFO_MAX_ROOT_NODE * sizeof(i->NameSpaceRootNode[0]))); + } + RtlLeaveCriticalSection (& SmpClientDirectory.Lock); + return Status; +} + +/* EOF */ diff --git a/reactos/subsys/smss/debug.c b/reactos/subsys/smss/debug.c index abff1600955..562985311d3 100644 --- a/reactos/subsys/smss/debug.c +++ b/reactos/subsys/smss/debug.c @@ -1,173 +1,173 @@ -/* $Id: smss.c 12852 2005-01-06 13:58:04Z mf $ - * - * debug.c - Session Manager debug messages switch and router - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ -#define NTOS_MODE_USER -#include -#include -#include "smss.h" - -#define NDEBUG -#include - - -/* GLOBALS ***********************************************************/ - -HANDLE DbgSsApiPort = (HANDLE) 0; -HANDLE DbgUiApiPort = (HANDLE) 0; - -/* FUNCTIONS *********************************************************/ - -static VOID STDCALL -DbgSsApiPortThread (PVOID dummy) -{ - NTSTATUS Status = STATUS_SUCCESS; - LPC_MAX_MESSAGE Request = {{0}}; - - while (TRUE) - { - Status = NtListenPort (DbgSsApiPort, & Request.Header); - if (!NT_SUCCESS(Status)) - { - DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status); - break; - } - /* TODO */ - } - NtTerminateThread(NtCurrentThread(),Status); -} - -static VOID STDCALL -DbgUiApiPortThread (PVOID dummy) -{ - NTSTATUS Status = STATUS_SUCCESS; - LPC_MAX_MESSAGE Request = {{0}}; - - while (TRUE) - { - Status = NtListenPort (DbgUiApiPort, & Request.Header); - if (!NT_SUCCESS(Status)) - { - DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status); - break; - } - /* TODO */ - } - NtTerminateThread(NtCurrentThread(),Status); -} - -static NTSTATUS STDCALL -SmpCreatePT (IN OUT PHANDLE hPort, - IN LPWSTR wcPortName, - IN ULONG ulMaxDataSize, - IN ULONG ulMaxMessageSize, - IN ULONG ulPoolCharge OPTIONAL, - IN VOID (STDCALL * procServingThread)(PVOID) OPTIONAL, - IN OUT PHANDLE phServingThread OPTIONAL) -{ - NTSTATUS Status = STATUS_SUCCESS; - UNICODE_STRING PortName = {0}; - OBJECT_ATTRIBUTES ObjectAttributes; - HANDLE Thread = (HANDLE) 0; - CLIENT_ID Cid = {0, 0}; - - RtlInitUnicodeString (& PortName, wcPortName); - InitializeObjectAttributes (& ObjectAttributes, - & PortName, - PORT_ALL_ACCESS, - NULL, - NULL); - Status = NtCreatePort (hPort, - & ObjectAttributes, - ulMaxDataSize, - ulMaxMessageSize, - ulPoolCharge); - if(STATUS_SUCCESS != Status) - { - return Status; - } - /* Create thread for DbgSsApiPort */ - RtlCreateUserThread(NtCurrentProcess(), - NULL, - FALSE, - 0, - NULL, - NULL, - (PTHREAD_START_ROUTINE) procServingThread, - hPort, - & Thread, - & Cid); - if((HANDLE) 0 == Thread) - { - NtClose(*hPort); - Status = STATUS_UNSUCCESSFUL; - } - if(NULL != phServingThread) - { - *phServingThread = Thread; - } - return Status; -} - -NTSTATUS -SmInitializeDbgSs (VOID) -{ - NTSTATUS Status = STATUS_SUCCESS; - HANDLE hDbgSsApiPortThread = (HANDLE) 0; - - DPRINT("SM: %s called\n", __FUNCTION__); - - /* Create the \DbgSsApiPort object (LPC) */ - Status = SmpCreatePT(& DbgSsApiPort, - SM_DBGSS_PORT_NAME, - 0, /* MaxDataSize */ - 0, /* MaxMessageSize */ - 0, /* PoolCharge */ - DbgSsApiPortThread, - & hDbgSsApiPortThread); - if(!NT_SUCCESS(Status)) - { - DPRINT("SM: %s: DBGSS port not created\n",__FUNCTION__); - return Status; - } - /* Create the \DbgUiApiPort object (LPC) */ - Status = SmpCreatePT(& DbgUiApiPort, - SM_DBGUI_PORT_NAME, - 0, /* MaxDataSize */ - 0, /* MaxMessageSize */ - 0, /* PoolCharge */ - DbgUiApiPortThread, - NULL); - if(!NT_SUCCESS(Status)) - { - DPRINT("SM: %s: DBGUI port not created\n",__FUNCTION__); - NtClose (hDbgSsApiPortThread); - NtClose (DbgSsApiPort); - return Status; - } - return STATUS_SUCCESS; -} - -/* EOF */ - +/* $Id$ + * + * debug.c - Session Manager debug messages switch and router + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#define NTOS_MODE_USER +#include +#include +#include "smss.h" + +#define NDEBUG +#include + + +/* GLOBALS ***********************************************************/ + +HANDLE DbgSsApiPort = (HANDLE) 0; +HANDLE DbgUiApiPort = (HANDLE) 0; + +/* FUNCTIONS *********************************************************/ + +static VOID STDCALL +DbgSsApiPortThread (PVOID dummy) +{ + NTSTATUS Status = STATUS_SUCCESS; + LPC_MAX_MESSAGE Request = {{0}}; + + while (TRUE) + { + Status = NtListenPort (DbgSsApiPort, & Request.Header); + if (!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status); + break; + } + /* TODO */ + } + NtTerminateThread(NtCurrentThread(),Status); +} + +static VOID STDCALL +DbgUiApiPortThread (PVOID dummy) +{ + NTSTATUS Status = STATUS_SUCCESS; + LPC_MAX_MESSAGE Request = {{0}}; + + while (TRUE) + { + Status = NtListenPort (DbgUiApiPort, & Request.Header); + if (!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status); + break; + } + /* TODO */ + } + NtTerminateThread(NtCurrentThread(),Status); +} + +static NTSTATUS STDCALL +SmpCreatePT (IN OUT PHANDLE hPort, + IN LPWSTR wcPortName, + IN ULONG ulMaxDataSize, + IN ULONG ulMaxMessageSize, + IN ULONG ulPoolCharge OPTIONAL, + IN VOID (STDCALL * procServingThread)(PVOID) OPTIONAL, + IN OUT PHANDLE phServingThread OPTIONAL) +{ + NTSTATUS Status = STATUS_SUCCESS; + UNICODE_STRING PortName = {0}; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE Thread = (HANDLE) 0; + CLIENT_ID Cid = {0, 0}; + + RtlInitUnicodeString (& PortName, wcPortName); + InitializeObjectAttributes (& ObjectAttributes, + & PortName, + PORT_ALL_ACCESS, + NULL, + NULL); + Status = NtCreatePort (hPort, + & ObjectAttributes, + ulMaxDataSize, + ulMaxMessageSize, + ulPoolCharge); + if(STATUS_SUCCESS != Status) + { + return Status; + } + /* Create thread for DbgSsApiPort */ + RtlCreateUserThread(NtCurrentProcess(), + NULL, + FALSE, + 0, + NULL, + NULL, + (PTHREAD_START_ROUTINE) procServingThread, + hPort, + & Thread, + & Cid); + if((HANDLE) 0 == Thread) + { + NtClose(*hPort); + Status = STATUS_UNSUCCESSFUL; + } + if(NULL != phServingThread) + { + *phServingThread = Thread; + } + return Status; +} + +NTSTATUS +SmInitializeDbgSs (VOID) +{ + NTSTATUS Status = STATUS_SUCCESS; + HANDLE hDbgSsApiPortThread = (HANDLE) 0; + + DPRINT("SM: %s called\n", __FUNCTION__); + + /* Create the \DbgSsApiPort object (LPC) */ + Status = SmpCreatePT(& DbgSsApiPort, + SM_DBGSS_PORT_NAME, + 0, /* MaxDataSize */ + 0, /* MaxMessageSize */ + 0, /* PoolCharge */ + DbgSsApiPortThread, + & hDbgSsApiPortThread); + if(!NT_SUCCESS(Status)) + { + DPRINT("SM: %s: DBGSS port not created\n",__FUNCTION__); + return Status; + } + /* Create the \DbgUiApiPort object (LPC) */ + Status = SmpCreatePT(& DbgUiApiPort, + SM_DBGUI_PORT_NAME, + 0, /* MaxDataSize */ + 0, /* MaxMessageSize */ + 0, /* PoolCharge */ + DbgUiApiPortThread, + NULL); + if(!NT_SUCCESS(Status)) + { + DPRINT("SM: %s: DBGUI port not created\n",__FUNCTION__); + NtClose (hDbgSsApiPortThread); + NtClose (DbgSsApiPort); + return Status; + } + return STATUS_SUCCESS; +} + +/* EOF */ + diff --git a/reactos/subsys/smss/initdosdev.c b/reactos/subsys/smss/initdosdev.c index f2698e94f57..091af25b4cf 100644 --- a/reactos/subsys/smss/initdosdev.c +++ b/reactos/subsys/smss/initdosdev.c @@ -1,109 +1,109 @@ -/* $Id: init.c 13449 2005-02-06 21:55:07Z ea $ - * - * initdosdev.c - Define symbolic links to kernel devices (MS-DOS names). - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ - -#include "smss.h" - -#define NDEBUG -#include - -static NTSTATUS STDCALL -SmpDosDevicesQueryRoutine(PWSTR ValueName, - ULONG ValueType, - PVOID ValueData, - ULONG ValueLength, - PVOID Context, - PVOID EntryContext) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING DeviceName; - UNICODE_STRING LinkName; - HANDLE LinkHandle; - WCHAR LinkBuffer[80]; - NTSTATUS Status; - - DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); - DPRINT("ValueData '%S'\n", (PWSTR)ValueData); - - if (ValueType != REG_SZ) - { - return(STATUS_SUCCESS); - } - - swprintf(LinkBuffer, - L"\\??\\%s", - ValueName); - RtlInitUnicodeString(&LinkName, - LinkBuffer); - RtlInitUnicodeString(&DeviceName, - (PWSTR)ValueData); - - DPRINT("SM: Linking %wZ --> %wZ\n", - &LinkName, - &DeviceName); - - /* create symbolic link */ - InitializeObjectAttributes(&ObjectAttributes, - &LinkName, - OBJ_PERMANENT, - NULL, - NULL); - Status = NtCreateSymbolicLinkObject(&LinkHandle, - SYMBOLIC_LINK_ALL_ACCESS, - &ObjectAttributes, - &DeviceName); - if (!NT_SUCCESS(Status)) - { - DPRINT1("%s: NtCreateSymbolicLink( %wZ --> %wZ ) failed!\n", - __FUNCTION__, - &LinkName, - &DeviceName); - } - NtClose(LinkHandle); - - return(Status); -} - - -NTSTATUS -SmInitDosDevices(VOID) -{ - RTL_QUERY_REGISTRY_TABLE QueryTable[2]; - NTSTATUS Status; - - RtlZeroMemory(&QueryTable, - sizeof(QueryTable)); - - QueryTable[0].QueryRoutine = SmpDosDevicesQueryRoutine; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, - L"\\Session Manager\\DOS Devices", - QueryTable, - NULL, - NULL); - return(Status); -} - -/* EOF */ +/* $Id$ + * + * initdosdev.c - Define symbolic links to kernel devices (MS-DOS names). + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ + +#include "smss.h" + +#define NDEBUG +#include + +static NTSTATUS STDCALL +SmpDosDevicesQueryRoutine(PWSTR ValueName, + ULONG ValueType, + PVOID ValueData, + ULONG ValueLength, + PVOID Context, + PVOID EntryContext) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING DeviceName; + UNICODE_STRING LinkName; + HANDLE LinkHandle; + WCHAR LinkBuffer[80]; + NTSTATUS Status; + + DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); + DPRINT("ValueData '%S'\n", (PWSTR)ValueData); + + if (ValueType != REG_SZ) + { + return(STATUS_SUCCESS); + } + + swprintf(LinkBuffer, + L"\\??\\%s", + ValueName); + RtlInitUnicodeString(&LinkName, + LinkBuffer); + RtlInitUnicodeString(&DeviceName, + (PWSTR)ValueData); + + DPRINT("SM: Linking %wZ --> %wZ\n", + &LinkName, + &DeviceName); + + /* create symbolic link */ + InitializeObjectAttributes(&ObjectAttributes, + &LinkName, + OBJ_PERMANENT, + NULL, + NULL); + Status = NtCreateSymbolicLinkObject(&LinkHandle, + SYMBOLIC_LINK_ALL_ACCESS, + &ObjectAttributes, + &DeviceName); + if (!NT_SUCCESS(Status)) + { + DPRINT1("%s: NtCreateSymbolicLink( %wZ --> %wZ ) failed!\n", + __FUNCTION__, + &LinkName, + &DeviceName); + } + NtClose(LinkHandle); + + return(Status); +} + + +NTSTATUS +SmInitDosDevices(VOID) +{ + RTL_QUERY_REGISTRY_TABLE QueryTable[2]; + NTSTATUS Status; + + RtlZeroMemory(&QueryTable, + sizeof(QueryTable)); + + QueryTable[0].QueryRoutine = SmpDosDevicesQueryRoutine; + + Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, + L"\\Session Manager\\DOS Devices", + QueryTable, + NULL, + NULL); + return(Status); +} + +/* EOF */ diff --git a/reactos/subsys/smss/initenv.c b/reactos/subsys/smss/initenv.c index 97341d30b5a..28c4160da9e 100644 --- a/reactos/subsys/smss/initenv.c +++ b/reactos/subsys/smss/initenv.c @@ -1,139 +1,139 @@ -/* $Id: init.c 13449 2005-02-06 21:55:07Z ea $ - * - * initenv.c - Environment initialization - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ - -#include "smss.h" - -#define NDEBUG -#include - -/* GLOBALS */ - -PWSTR SmSystemEnvironment = NULL; - - -/* FUNCTIONS */ - -NTSTATUS -SmCreateEnvironment(VOID) -{ - return RtlCreateEnvironment(FALSE, &SmSystemEnvironment); -} - - -static NTSTATUS -SmpSetEnvironmentVariable(PVOID Context, - PWSTR ValueName, - PVOID ValueData) -{ - UNICODE_STRING EnvVariable; - UNICODE_STRING EnvValue; - - RtlInitUnicodeString(&EnvVariable, - ValueName); - RtlInitUnicodeString(&EnvValue, - (PWSTR)ValueData); - RtlSetEnvironmentVariable(Context, - &EnvVariable, - &EnvValue); - - return(STATUS_SUCCESS); -} - - -static NTSTATUS STDCALL -SmpEnvironmentQueryRoutine(PWSTR ValueName, - ULONG ValueType, - PVOID ValueData, - ULONG ValueLength, - PVOID Context, - PVOID EntryContext) -{ - DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); - DPRINT("ValueData '%S'\n", (PWSTR)ValueData); - - if (ValueType != REG_SZ) - { - return(STATUS_SUCCESS); - } - return SmpSetEnvironmentVariable(Context,ValueName,ValueData); -} - - -NTSTATUS -SmSetEnvironmentVariables(VOID) -{ - RTL_QUERY_REGISTRY_TABLE QueryTable[2]; - WCHAR ValueBuffer[MAX_PATH]; - NTSTATUS Status; - - /* - * The following environment variables must be set prior to reading - * other variables from the registry. - * - * Variables (example): - * SystemRoot = "C:\reactos" - * SystemDrive = "C:" - */ - - /* Copy system root into value buffer */ - wcscpy(ValueBuffer, - SharedUserData->NtSystemRoot); - - /* Set SystemRoot = "C:\reactos" */ - SmpSetEnvironmentVariable(&SmSystemEnvironment,L"SystemRoot",ValueBuffer); - - /* Cut off trailing path */ - ValueBuffer[2] = 0; - - /* Set SystemDrive = "C:" */ - SmpSetEnvironmentVariable(&SmSystemEnvironment,L"SystemDrive",ValueBuffer); - - /* Read system environment from the registry. */ - RtlZeroMemory(&QueryTable, - sizeof(QueryTable)); - - QueryTable[0].QueryRoutine = SmpEnvironmentQueryRoutine; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, - L"\\Session Manager\\Environment", - QueryTable, - &SmSystemEnvironment, - SmSystemEnvironment); - - return(Status); -} - -/********************************************************************** - * Set environment variables from registry - */ -NTSTATUS -SmUpdateEnvironment(VOID) -{ - /* TODO */ - return STATUS_SUCCESS; -} - -/* EOF */ +/* $Id$ + * + * initenv.c - Environment initialization + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ + +#include "smss.h" + +#define NDEBUG +#include + +/* GLOBALS */ + +PWSTR SmSystemEnvironment = NULL; + + +/* FUNCTIONS */ + +NTSTATUS +SmCreateEnvironment(VOID) +{ + return RtlCreateEnvironment(FALSE, &SmSystemEnvironment); +} + + +static NTSTATUS +SmpSetEnvironmentVariable(PVOID Context, + PWSTR ValueName, + PVOID ValueData) +{ + UNICODE_STRING EnvVariable; + UNICODE_STRING EnvValue; + + RtlInitUnicodeString(&EnvVariable, + ValueName); + RtlInitUnicodeString(&EnvValue, + (PWSTR)ValueData); + RtlSetEnvironmentVariable(Context, + &EnvVariable, + &EnvValue); + + return(STATUS_SUCCESS); +} + + +static NTSTATUS STDCALL +SmpEnvironmentQueryRoutine(PWSTR ValueName, + ULONG ValueType, + PVOID ValueData, + ULONG ValueLength, + PVOID Context, + PVOID EntryContext) +{ + DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); + DPRINT("ValueData '%S'\n", (PWSTR)ValueData); + + if (ValueType != REG_SZ) + { + return(STATUS_SUCCESS); + } + return SmpSetEnvironmentVariable(Context,ValueName,ValueData); +} + + +NTSTATUS +SmSetEnvironmentVariables(VOID) +{ + RTL_QUERY_REGISTRY_TABLE QueryTable[2]; + WCHAR ValueBuffer[MAX_PATH]; + NTSTATUS Status; + + /* + * The following environment variables must be set prior to reading + * other variables from the registry. + * + * Variables (example): + * SystemRoot = "C:\reactos" + * SystemDrive = "C:" + */ + + /* Copy system root into value buffer */ + wcscpy(ValueBuffer, + SharedUserData->NtSystemRoot); + + /* Set SystemRoot = "C:\reactos" */ + SmpSetEnvironmentVariable(&SmSystemEnvironment,L"SystemRoot",ValueBuffer); + + /* Cut off trailing path */ + ValueBuffer[2] = 0; + + /* Set SystemDrive = "C:" */ + SmpSetEnvironmentVariable(&SmSystemEnvironment,L"SystemDrive",ValueBuffer); + + /* Read system environment from the registry. */ + RtlZeroMemory(&QueryTable, + sizeof(QueryTable)); + + QueryTable[0].QueryRoutine = SmpEnvironmentQueryRoutine; + + Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, + L"\\Session Manager\\Environment", + QueryTable, + &SmSystemEnvironment, + SmSystemEnvironment); + + return(Status); +} + +/********************************************************************** + * Set environment variables from registry + */ +NTSTATUS +SmUpdateEnvironment(VOID) +{ + /* TODO */ + return STATUS_SUCCESS; +} + +/* EOF */ diff --git a/reactos/subsys/smss/initheap.c b/reactos/subsys/smss/initheap.c index 7d62ed4919f..87b0eb70451 100644 --- a/reactos/subsys/smss/initheap.c +++ b/reactos/subsys/smss/initheap.c @@ -1,47 +1,47 @@ -/* $Id: init.c 13449 2005-02-06 21:55:07Z ea $ - * - * initenv.c - Create the SM private heap - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ - -#include "smss.h" - -#define NDEBUG -#include - -HANDLE SmpHeap = NULL; - -NTSTATUS -SmCreateHeap(VOID) -{ - /* Create our own heap */ - SmpHeap = RtlCreateHeap(HEAP_GROWABLE, - NULL, - 65536, - 65536, - NULL, - NULL); - return (NULL == SmpHeap) ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS; -} - -/* EOF */ +/* $Id$ + * + * initenv.c - Create the SM private heap + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ + +#include "smss.h" + +#define NDEBUG +#include + +HANDLE SmpHeap = NULL; + +NTSTATUS +SmCreateHeap(VOID) +{ + /* Create our own heap */ + SmpHeap = RtlCreateHeap(HEAP_GROWABLE, + NULL, + 65536, + 65536, + NULL, + NULL); + return (NULL == SmpHeap) ? STATUS_UNSUCCESSFUL : STATUS_SUCCESS; +} + +/* EOF */ diff --git a/reactos/subsys/smss/initmv.c b/reactos/subsys/smss/initmv.c index 786a298913f..d4e132334b5 100644 --- a/reactos/subsys/smss/initmv.c +++ b/reactos/subsys/smss/initmv.c @@ -1,52 +1,52 @@ -/* $Id: init.c 13449 2005-02-06 21:55:07Z ea $ - * - * initmv.c - Process the file rename list - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ - - -#include "smss.h" - -#define NDEBUG -#include - -NTSTATUS -SmProcessFileRenameList(VOID) -{ - DPRINT("SmProcessFileRenameList() called\n"); - - /* FIXME: implement it! */ -/* - * open HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\FileRenameOperations - * for each item in its value - * clone the old file in the new name, - * delete the source. - * - */ - - DPRINT("SmProcessFileRenameList() done\n"); - - return(STATUS_SUCCESS); -} - -/* EOF */ +/* $Id$ + * + * initmv.c - Process the file rename list + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ + + +#include "smss.h" + +#define NDEBUG +#include + +NTSTATUS +SmProcessFileRenameList(VOID) +{ + DPRINT("SmProcessFileRenameList() called\n"); + + /* FIXME: implement it! */ +/* + * open HKLM\SYSTEM\CurrentControlSet\Control\Session Manager\FileRenameOperations + * for each item in its value + * clone the old file in the new name, + * delete the source. + * + */ + + DPRINT("SmProcessFileRenameList() done\n"); + + return(STATUS_SUCCESS); +} + +/* EOF */ diff --git a/reactos/subsys/smss/initobdir.c b/reactos/subsys/smss/initobdir.c index 0a1c6ad558e..1eb45a0d0ae 100644 --- a/reactos/subsys/smss/initobdir.c +++ b/reactos/subsys/smss/initobdir.c @@ -1,91 +1,91 @@ -/* $Id: init.c 13449 2005-02-06 21:55:07Z ea $ - * - * initobdir.c - Session Manager object directories - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ -#include "smss.h" - -#define NDEBUG -#include - -static NTSTATUS STDCALL -SmpObjectDirectoryQueryRoutine(PWSTR ValueName, - ULONG ValueType, - PVOID ValueData, - ULONG ValueLength, - PVOID Context, - PVOID EntryContext) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - UNICODE_STRING UnicodeString; - HANDLE WindowsDirectory; - NTSTATUS Status = STATUS_SUCCESS; - -#ifndef NDEBUG - DbgPrint("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); - DbgPrint("ValueData '%S'\n", (PWSTR)ValueData); -#endif - if (ValueType != REG_SZ) - { - return(STATUS_SUCCESS); - } - - RtlInitUnicodeString(&UnicodeString, - (PWSTR)ValueData); - - InitializeObjectAttributes(&ObjectAttributes, - &UnicodeString, - 0, - NULL, - NULL); - - Status = ZwCreateDirectoryObject(&WindowsDirectory, - 0, - &ObjectAttributes); - - return(Status); -} - - -NTSTATUS -SmCreateObjectDirectories(VOID) -{ - RTL_QUERY_REGISTRY_TABLE QueryTable[2]; - NTSTATUS Status; - - RtlZeroMemory(&QueryTable, - sizeof(QueryTable)); - - QueryTable[0].Name = L"ObjectDirectories"; - QueryTable[0].QueryRoutine = SmpObjectDirectoryQueryRoutine; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, - SM_REGISTRY_ROOT_NAME, - QueryTable, - NULL, - NULL); - - return(Status); -} - -/* EOF */ +/* $Id$ + * + * initobdir.c - Session Manager object directories + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#include "smss.h" + +#define NDEBUG +#include + +static NTSTATUS STDCALL +SmpObjectDirectoryQueryRoutine(PWSTR ValueName, + ULONG ValueType, + PVOID ValueData, + ULONG ValueLength, + PVOID Context, + PVOID EntryContext) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + UNICODE_STRING UnicodeString; + HANDLE WindowsDirectory; + NTSTATUS Status = STATUS_SUCCESS; + +#ifndef NDEBUG + DbgPrint("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); + DbgPrint("ValueData '%S'\n", (PWSTR)ValueData); +#endif + if (ValueType != REG_SZ) + { + return(STATUS_SUCCESS); + } + + RtlInitUnicodeString(&UnicodeString, + (PWSTR)ValueData); + + InitializeObjectAttributes(&ObjectAttributes, + &UnicodeString, + 0, + NULL, + NULL); + + Status = ZwCreateDirectoryObject(&WindowsDirectory, + 0, + &ObjectAttributes); + + return(Status); +} + + +NTSTATUS +SmCreateObjectDirectories(VOID) +{ + RTL_QUERY_REGISTRY_TABLE QueryTable[2]; + NTSTATUS Status; + + RtlZeroMemory(&QueryTable, + sizeof(QueryTable)); + + QueryTable[0].Name = L"ObjectDirectories"; + QueryTable[0].QueryRoutine = SmpObjectDirectoryQueryRoutine; + + Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, + SM_REGISTRY_ROOT_NAME, + QueryTable, + NULL, + NULL); + + return(Status); +} + +/* EOF */ diff --git a/reactos/subsys/smss/initpage.c b/reactos/subsys/smss/initpage.c index 69d672e21b7..ec0533e48aa 100644 --- a/reactos/subsys/smss/initpage.c +++ b/reactos/subsys/smss/initpage.c @@ -1,127 +1,127 @@ -/* $Id: init.c 13449 2005-02-06 21:55:07Z ea $ - * - * initpage.c - - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ -#include "smss.h" -#include -#include - -#define NDEBUG -#include - -static NTSTATUS STDCALL -SmpPagingFilesQueryRoutine(PWSTR ValueName, - ULONG ValueType, - PVOID ValueData, - ULONG ValueLength, - PVOID Context, - PVOID EntryContext) -{ - UNICODE_STRING FileName; - LARGE_INTEGER InitialSize; - LARGE_INTEGER MaximumSize; - NTSTATUS Status; - LPWSTR p; - - DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); - DPRINT("ValueData '%S'\n", (PWSTR)ValueData); - - if (ValueType != REG_SZ) - { - return(STATUS_SUCCESS); - } - - /* - * Format: "[ [ ]]" - */ - if ((p = wcschr(ValueData, ' ')) != NULL) - { - *p = L'\0'; - InitialSize.QuadPart = wcstoul(p + 1, &p, 0) * 256 * 4096; - if (*p == ' ') - { - MaximumSize.QuadPart = wcstoul(p + 1, NULL, 0) * 256 * 4096; - } - else - MaximumSize = InitialSize; - } - else - { - InitialSize.QuadPart = 50 * 4096; - MaximumSize.QuadPart = 80 * 4096; - } - - if (!RtlDosPathNameToNtPathName_U ((LPWSTR)ValueData, - &FileName, - NULL, - NULL)) - { - return (STATUS_SUCCESS); - } - - DPRINT("SMSS: Created paging file %wZ with size %dKB\n", - &FileName, InitialSize.QuadPart / 1024); - Status = NtCreatePagingFile(&FileName, - &InitialSize, - &MaximumSize, - 0); - - RtlFreeUnicodeString(&FileName); - - return(STATUS_SUCCESS); -} - - -NTSTATUS -SmCreatePagingFiles(VOID) -{ - RTL_QUERY_REGISTRY_TABLE QueryTable[2]; - NTSTATUS Status; - - DPRINT("SM: creating system paging files\n"); - /* - * Disable paging file on MiniNT/Live CD. - */ - if (RtlCheckRegistryKey(RTL_REGISTRY_CONTROL, L"MiniNT") == STATUS_SUCCESS) - { - return STATUS_SUCCESS; - } - - RtlZeroMemory(&QueryTable, - sizeof(QueryTable)); - - QueryTable[0].Name = L"PagingFiles"; - QueryTable[0].QueryRoutine = SmpPagingFilesQueryRoutine; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, - L"\\Session Manager\\Memory Management", - QueryTable, - NULL, - NULL); - - return(Status); -} - - -/* EOF */ +/* $Id$ + * + * initpage.c - + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#include "smss.h" +#include +#include + +#define NDEBUG +#include + +static NTSTATUS STDCALL +SmpPagingFilesQueryRoutine(PWSTR ValueName, + ULONG ValueType, + PVOID ValueData, + ULONG ValueLength, + PVOID Context, + PVOID EntryContext) +{ + UNICODE_STRING FileName; + LARGE_INTEGER InitialSize; + LARGE_INTEGER MaximumSize; + NTSTATUS Status; + LPWSTR p; + + DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); + DPRINT("ValueData '%S'\n", (PWSTR)ValueData); + + if (ValueType != REG_SZ) + { + return(STATUS_SUCCESS); + } + + /* + * Format: "[ [ ]]" + */ + if ((p = wcschr(ValueData, ' ')) != NULL) + { + *p = L'\0'; + InitialSize.QuadPart = wcstoul(p + 1, &p, 0) * 256 * 4096; + if (*p == ' ') + { + MaximumSize.QuadPart = wcstoul(p + 1, NULL, 0) * 256 * 4096; + } + else + MaximumSize = InitialSize; + } + else + { + InitialSize.QuadPart = 50 * 4096; + MaximumSize.QuadPart = 80 * 4096; + } + + if (!RtlDosPathNameToNtPathName_U ((LPWSTR)ValueData, + &FileName, + NULL, + NULL)) + { + return (STATUS_SUCCESS); + } + + DPRINT("SMSS: Created paging file %wZ with size %dKB\n", + &FileName, InitialSize.QuadPart / 1024); + Status = NtCreatePagingFile(&FileName, + &InitialSize, + &MaximumSize, + 0); + + RtlFreeUnicodeString(&FileName); + + return(STATUS_SUCCESS); +} + + +NTSTATUS +SmCreatePagingFiles(VOID) +{ + RTL_QUERY_REGISTRY_TABLE QueryTable[2]; + NTSTATUS Status; + + DPRINT("SM: creating system paging files\n"); + /* + * Disable paging file on MiniNT/Live CD. + */ + if (RtlCheckRegistryKey(RTL_REGISTRY_CONTROL, L"MiniNT") == STATUS_SUCCESS) + { + return STATUS_SUCCESS; + } + + RtlZeroMemory(&QueryTable, + sizeof(QueryTable)); + + QueryTable[0].Name = L"PagingFiles"; + QueryTable[0].QueryRoutine = SmpPagingFilesQueryRoutine; + + Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, + L"\\Session Manager\\Memory Management", + QueryTable, + NULL, + NULL); + + return(Status); +} + + +/* EOF */ diff --git a/reactos/subsys/smss/initreg.c b/reactos/subsys/smss/initreg.c index 76ab72014c7..4d62827fe40 100644 --- a/reactos/subsys/smss/initreg.c +++ b/reactos/subsys/smss/initreg.c @@ -1,41 +1,41 @@ -/* $Id: init.c 13449 2005-02-06 21:55:07Z ea $ - * - * initenv.c - Hive loading - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ - -#include "smss.h" - -#define NDEBUG -#include - -NTSTATUS -SmInitializeRegistry(VOID) -{ - DPRINT("SM: %s: initializing registry\n", __FUNCTION__); - - /* Load remaining registry hives */ - return NtInitializeRegistry(FALSE); -} - -/* EOF */ +/* $Id$ + * + * initenv.c - Hive loading + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ + +#include "smss.h" + +#define NDEBUG +#include + +NTSTATUS +SmInitializeRegistry(VOID) +{ + DPRINT("SM: %s: initializing registry\n", __FUNCTION__); + + /* Load remaining registry hives */ + return NtInitializeRegistry(FALSE); +} + +/* EOF */ diff --git a/reactos/subsys/smss/initrun.c b/reactos/subsys/smss/initrun.c index e19a172b8d7..5b59db9db5a 100644 --- a/reactos/subsys/smss/initrun.c +++ b/reactos/subsys/smss/initrun.c @@ -1,153 +1,153 @@ -/* $Id: init.c 13449 2005-02-06 21:55:07Z ea $ - * - * initrun.c - Run all programs in the boot execution list - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ - -#include "smss.h" - -#define NDEBUG -#include - -//HANDLE Children[2] = {0, 0}; /* csrss, winlogon */ - - -/********************************************************************** - * SmpRunBootAppsQueryRoutine/6 - */ -static NTSTATUS STDCALL -SmpRunBootAppsQueryRoutine(PWSTR ValueName, - ULONG ValueType, - PVOID ValueData, - ULONG ValueLength, - PVOID Context, - PVOID EntryContext) -{ - WCHAR Description [MAX_PATH]; - WCHAR ImageName [MAX_PATH]; - WCHAR ImagePath [MAX_PATH]; - WCHAR CommandLine [MAX_PATH]; - PWSTR p1, p2; - ULONG len; - NTSTATUS Status; - - DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); - DPRINT("ValueData '%S'\n", (PWSTR)ValueData); - - if (ValueType != REG_SZ) - { - return(STATUS_SUCCESS); - } - - /* Extract the description */ - p1 = wcschr((PWSTR)ValueData, L' '); - len = p1 - (PWSTR)ValueData; - memcpy(Description,ValueData, len * sizeof(WCHAR)); - Description[len] = 0; - - /* Extract the image name */ - p1++; - p2 = wcschr(p1, L' '); - if (p2 != NULL) - len = p2 - p1; - else - len = wcslen(p1); - memcpy(ImageName, p1, len * sizeof(WCHAR)); - ImageName[len] = 0; - - /* Extract the command line */ - if (p2 == NULL) - { - CommandLine[0] = 0; - } - else - { - p2++; - wcscpy(CommandLine, p2); - } - - DPRINT("Running %S...\n", Description); - DPRINT("ImageName: '%S'\n", ImageName); - DPRINT("CommandLine: '%S'\n", CommandLine); - - /* initialize executable path */ - wcscpy(ImagePath, L"\\SystemRoot\\system32\\"); - wcscat(ImagePath, ImageName); - wcscat(ImagePath, L".exe"); - - /* Create NT process */ - Status = SmCreateUserProcess (ImagePath, - CommandLine, - TRUE, /* wait */ - NULL, NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT1("SM: %s: running '$S' failed (Status=0x%08lx)\n", - __FUNCTION__, Status); - } - return(STATUS_SUCCESS); -} - - -/********************************************************************** - * SmRunBootApplications/0 - * - * DESCRIPTION - * - * Run native applications listed in the registry. - * - * Key: - * \Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager - * - * Value (format: " ": - * BootExecute = "autocheck autochk *" - */ -NTSTATUS -SmRunBootApplications(VOID) -{ - RTL_QUERY_REGISTRY_TABLE QueryTable[2]; - NTSTATUS Status; - - RtlZeroMemory(&QueryTable, - sizeof(QueryTable)); - - QueryTable[0].Name = L"BootExecute"; - QueryTable[0].QueryRoutine = SmpRunBootAppsQueryRoutine; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, - L"\\Session Manager", - QueryTable, - NULL, - NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT1("%s: RtlQueryRegistryValues() failed! (Status %lx)\n", - __FUNCTION__, - Status); - } - - return(Status); -} - - -/* EOF */ +/* $Id$ + * + * initrun.c - Run all programs in the boot execution list + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ + +#include "smss.h" + +#define NDEBUG +#include + +//HANDLE Children[2] = {0, 0}; /* csrss, winlogon */ + + +/********************************************************************** + * SmpRunBootAppsQueryRoutine/6 + */ +static NTSTATUS STDCALL +SmpRunBootAppsQueryRoutine(PWSTR ValueName, + ULONG ValueType, + PVOID ValueData, + ULONG ValueLength, + PVOID Context, + PVOID EntryContext) +{ + WCHAR Description [MAX_PATH]; + WCHAR ImageName [MAX_PATH]; + WCHAR ImagePath [MAX_PATH]; + WCHAR CommandLine [MAX_PATH]; + PWSTR p1, p2; + ULONG len; + NTSTATUS Status; + + DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); + DPRINT("ValueData '%S'\n", (PWSTR)ValueData); + + if (ValueType != REG_SZ) + { + return(STATUS_SUCCESS); + } + + /* Extract the description */ + p1 = wcschr((PWSTR)ValueData, L' '); + len = p1 - (PWSTR)ValueData; + memcpy(Description,ValueData, len * sizeof(WCHAR)); + Description[len] = 0; + + /* Extract the image name */ + p1++; + p2 = wcschr(p1, L' '); + if (p2 != NULL) + len = p2 - p1; + else + len = wcslen(p1); + memcpy(ImageName, p1, len * sizeof(WCHAR)); + ImageName[len] = 0; + + /* Extract the command line */ + if (p2 == NULL) + { + CommandLine[0] = 0; + } + else + { + p2++; + wcscpy(CommandLine, p2); + } + + DPRINT("Running %S...\n", Description); + DPRINT("ImageName: '%S'\n", ImageName); + DPRINT("CommandLine: '%S'\n", CommandLine); + + /* initialize executable path */ + wcscpy(ImagePath, L"\\SystemRoot\\system32\\"); + wcscat(ImagePath, ImageName); + wcscat(ImagePath, L".exe"); + + /* Create NT process */ + Status = SmCreateUserProcess (ImagePath, + CommandLine, + TRUE, /* wait */ + NULL, NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s: running '$S' failed (Status=0x%08lx)\n", + __FUNCTION__, Status); + } + return(STATUS_SUCCESS); +} + + +/********************************************************************** + * SmRunBootApplications/0 + * + * DESCRIPTION + * + * Run native applications listed in the registry. + * + * Key: + * \Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager + * + * Value (format: " ": + * BootExecute = "autocheck autochk *" + */ +NTSTATUS +SmRunBootApplications(VOID) +{ + RTL_QUERY_REGISTRY_TABLE QueryTable[2]; + NTSTATUS Status; + + RtlZeroMemory(&QueryTable, + sizeof(QueryTable)); + + QueryTable[0].Name = L"BootExecute"; + QueryTable[0].QueryRoutine = SmpRunBootAppsQueryRoutine; + + Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, + L"\\Session Manager", + QueryTable, + NULL, + NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT1("%s: RtlQueryRegistryValues() failed! (Status %lx)\n", + __FUNCTION__, + Status); + } + + return(Status); +} + + +/* EOF */ diff --git a/reactos/subsys/smss/initss.c b/reactos/subsys/smss/initss.c index bc8f7fa412a..0c2f338ffa8 100644 --- a/reactos/subsys/smss/initss.c +++ b/reactos/subsys/smss/initss.c @@ -1,219 +1,219 @@ -/* $Id: init.c 13449 2005-02-06 21:55:07Z ea $ - * - * initss.c - Load the subsystems - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ - - -#include "smss.h" - -#include - -#define NDEBUG -#include - -/* SM handle for its own \SmApiPort */ -HANDLE hSmApiPort = (HANDLE) 0; - - -/* TODO: - * - * a) look if a special option is set for smss.exe in - * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options - */ - -/********************************************************************** - * SmpRegisterSmss/0 - * - * DESCRIPTION - * Make smss register with itself for IMAGE_SUBSYSTEM_NATIVE - * (programmatically). This also opens hSmApiPort to be used - * in loading required subsystems. - */ - -static NTSTATUS -SmpRegisterSmss(VOID) -{ - NTSTATUS Status = STATUS_SUCCESS; - RTL_PROCESS_INFO ProcessInfo; - - - DPRINT("SM: %s called\n",__FUNCTION__); - - RtlZeroMemory (& ProcessInfo, sizeof ProcessInfo); - ProcessInfo.Size = sizeof ProcessInfo; - ProcessInfo.ProcessHandle = (HANDLE) SmSsProcessId; - ProcessInfo.ClientId.UniqueProcess = (HANDLE) SmSsProcessId; - DPRINT("SM: %s: ProcessInfo.ProcessHandle=%lx\n", - __FUNCTION__,ProcessInfo.ProcessHandle); - Status = SmCreateClient (& ProcessInfo, L"Session Manager"); - if (NT_SUCCESS(Status)) - { - UNICODE_STRING SbApiPortName = {0,0,NULL}; - - RtlInitUnicodeString (& SbApiPortName, L""); - Status = SmConnectApiPort(& SbApiPortName, - (HANDLE) -1, /* SM has no SB port */ - IMAGE_SUBSYSTEM_NATIVE, - & hSmApiPort); - if(!NT_SUCCESS(Status)) - { - DPRINT("SM: %s: SMLIB!SmConnectApiPort failed (Status=0x%08lx)\n", - __FUNCTION__,Status); - return Status; - } - DPRINT("SM self registered\n"); - } - else - { - DPRINT1("SM: %s: SmCreateClient failed (Status=0x%08lx)\n", - __FUNCTION__, Status); - } - /* - * Note that you don't need to call complete session - * because connection handling code autocompletes - * the client structure for IMAGE_SUBSYSTEM_NATIVE. - */ - return Status; -} - - -/********************************************************************** - * SmpLoadKernelModeSubsystem/0 - */ -static NTSTATUS -SmpLoadKernelModeSubsystem (VOID) -{ - NTSTATUS Status = STATUS_SUCCESS; - WCHAR Data [MAX_PATH + 1]; - ULONG DataLength = sizeof Data; - ULONG DataType = 0; - - - DPRINT("SM: %s called\n", __FUNCTION__); - - Status = SmLookupSubsystem (L"Kmode", - Data, - & DataLength, - & DataType, - TRUE); - if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0])) - { - WCHAR ImagePath [MAX_PATH + 1] = {0}; - SYSTEM_LOAD_AND_CALL_IMAGE ImageInfo; - - wcscpy (ImagePath, L"\\??\\"); - wcscat (ImagePath, Data); - RtlZeroMemory (& ImageInfo, sizeof ImageInfo); - RtlInitUnicodeString (& ImageInfo.ModuleName, ImagePath); - Status = NtSetSystemInformation(SystemLoadAndCallImage, - & ImageInfo, - sizeof ImageInfo); - if(!NT_SUCCESS(Status)) - { - DPRINT("SM: %s: loading Kmode failed (Status=0x%08lx)\n", - __FUNCTION__, Status); - } - } - return Status; -} - -/********************************************************************** - * SmpLoadRequiredSubsystems/0 - */ -static NTSTATUS -SmpLoadRequiredSubsystems (VOID) -{ - NTSTATUS Status = STATUS_SUCCESS; - WCHAR Data [MAX_PATH + 1]; - ULONG DataLength = sizeof Data; - ULONG DataType = 0; - - - DPRINT("SM: %s called\n", __FUNCTION__); - - RtlZeroMemory (Data, DataLength); - Status = SmLookupSubsystem (L"Required", - Data, - & DataLength, - & DataType, - FALSE); - if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0])) - { - PWCHAR Name = NULL; - ULONG Offset = 0; - - for (Name = Data; (Offset < DataLength); ) - { - if(L'\0' != *Name) - { - UNICODE_STRING Program; - - /* Run the current program */ - RtlInitUnicodeString (& Program, Name); - Status = SmExecuteProgram (hSmApiPort, & Program); - if(!NT_SUCCESS(Status)) - { - DPRINT1("SM: %s failed to run '%S' program (Status=0x%08lx)\n", - __FUNCTION__, Name, Status); - } - /* Look for the next program */ - while ((L'\0' != *Name) && (Offset < DataLength)) - { - ++ Name; - ++ Offset; - } - } - ++ Name; - ++ Offset; - } - } - - return Status; -} - -/********************************************************************** - * SmLoadSubsystems/0 - */ -NTSTATUS -SmLoadSubsystems(VOID) -{ - NTSTATUS Status = STATUS_SUCCESS; - - - DPRINT("SM: loading subsystems\n"); - - /* SM self registers */ - Status = SmpRegisterSmss(); - if(!NT_SUCCESS(Status)) return Status; - /* Load Kmode subsystem (aka win32k.sys) */ - Status = SmpLoadKernelModeSubsystem(); - if(!NT_SUCCESS(Status)) return Status; - /* Load Required subsystems (Debug Windows) */ - Status = SmpLoadRequiredSubsystems(); - if(!NT_SUCCESS(Status)) return Status; - /* done */ - return Status; -} - -/* EOF */ +/* $Id$ + * + * initss.c - Load the subsystems + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ + + +#include "smss.h" + +#include + +#define NDEBUG +#include + +/* SM handle for its own \SmApiPort */ +HANDLE hSmApiPort = (HANDLE) 0; + + +/* TODO: + * + * a) look if a special option is set for smss.exe in + * HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options + */ + +/********************************************************************** + * SmpRegisterSmss/0 + * + * DESCRIPTION + * Make smss register with itself for IMAGE_SUBSYSTEM_NATIVE + * (programmatically). This also opens hSmApiPort to be used + * in loading required subsystems. + */ + +static NTSTATUS +SmpRegisterSmss(VOID) +{ + NTSTATUS Status = STATUS_SUCCESS; + RTL_PROCESS_INFO ProcessInfo; + + + DPRINT("SM: %s called\n",__FUNCTION__); + + RtlZeroMemory (& ProcessInfo, sizeof ProcessInfo); + ProcessInfo.Size = sizeof ProcessInfo; + ProcessInfo.ProcessHandle = (HANDLE) SmSsProcessId; + ProcessInfo.ClientId.UniqueProcess = (HANDLE) SmSsProcessId; + DPRINT("SM: %s: ProcessInfo.ProcessHandle=%lx\n", + __FUNCTION__,ProcessInfo.ProcessHandle); + Status = SmCreateClient (& ProcessInfo, L"Session Manager"); + if (NT_SUCCESS(Status)) + { + UNICODE_STRING SbApiPortName = {0,0,NULL}; + + RtlInitUnicodeString (& SbApiPortName, L""); + Status = SmConnectApiPort(& SbApiPortName, + (HANDLE) -1, /* SM has no SB port */ + IMAGE_SUBSYSTEM_NATIVE, + & hSmApiPort); + if(!NT_SUCCESS(Status)) + { + DPRINT("SM: %s: SMLIB!SmConnectApiPort failed (Status=0x%08lx)\n", + __FUNCTION__,Status); + return Status; + } + DPRINT("SM self registered\n"); + } + else + { + DPRINT1("SM: %s: SmCreateClient failed (Status=0x%08lx)\n", + __FUNCTION__, Status); + } + /* + * Note that you don't need to call complete session + * because connection handling code autocompletes + * the client structure for IMAGE_SUBSYSTEM_NATIVE. + */ + return Status; +} + + +/********************************************************************** + * SmpLoadKernelModeSubsystem/0 + */ +static NTSTATUS +SmpLoadKernelModeSubsystem (VOID) +{ + NTSTATUS Status = STATUS_SUCCESS; + WCHAR Data [MAX_PATH + 1]; + ULONG DataLength = sizeof Data; + ULONG DataType = 0; + + + DPRINT("SM: %s called\n", __FUNCTION__); + + Status = SmLookupSubsystem (L"Kmode", + Data, + & DataLength, + & DataType, + TRUE); + if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0])) + { + WCHAR ImagePath [MAX_PATH + 1] = {0}; + SYSTEM_LOAD_AND_CALL_IMAGE ImageInfo; + + wcscpy (ImagePath, L"\\??\\"); + wcscat (ImagePath, Data); + RtlZeroMemory (& ImageInfo, sizeof ImageInfo); + RtlInitUnicodeString (& ImageInfo.ModuleName, ImagePath); + Status = NtSetSystemInformation(SystemLoadAndCallImage, + & ImageInfo, + sizeof ImageInfo); + if(!NT_SUCCESS(Status)) + { + DPRINT("SM: %s: loading Kmode failed (Status=0x%08lx)\n", + __FUNCTION__, Status); + } + } + return Status; +} + +/********************************************************************** + * SmpLoadRequiredSubsystems/0 + */ +static NTSTATUS +SmpLoadRequiredSubsystems (VOID) +{ + NTSTATUS Status = STATUS_SUCCESS; + WCHAR Data [MAX_PATH + 1]; + ULONG DataLength = sizeof Data; + ULONG DataType = 0; + + + DPRINT("SM: %s called\n", __FUNCTION__); + + RtlZeroMemory (Data, DataLength); + Status = SmLookupSubsystem (L"Required", + Data, + & DataLength, + & DataType, + FALSE); + if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0])) + { + PWCHAR Name = NULL; + ULONG Offset = 0; + + for (Name = Data; (Offset < DataLength); ) + { + if(L'\0' != *Name) + { + UNICODE_STRING Program; + + /* Run the current program */ + RtlInitUnicodeString (& Program, Name); + Status = SmExecuteProgram (hSmApiPort, & Program); + if(!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s failed to run '%S' program (Status=0x%08lx)\n", + __FUNCTION__, Name, Status); + } + /* Look for the next program */ + while ((L'\0' != *Name) && (Offset < DataLength)) + { + ++ Name; + ++ Offset; + } + } + ++ Name; + ++ Offset; + } + } + + return Status; +} + +/********************************************************************** + * SmLoadSubsystems/0 + */ +NTSTATUS +SmLoadSubsystems(VOID) +{ + NTSTATUS Status = STATUS_SUCCESS; + + + DPRINT("SM: loading subsystems\n"); + + /* SM self registers */ + Status = SmpRegisterSmss(); + if(!NT_SUCCESS(Status)) return Status; + /* Load Kmode subsystem (aka win32k.sys) */ + Status = SmpLoadKernelModeSubsystem(); + if(!NT_SUCCESS(Status)) return Status; + /* Load Required subsystems (Debug Windows) */ + Status = SmpLoadRequiredSubsystems(); + if(!NT_SUCCESS(Status)) return Status; + /* done */ + return Status; +} + +/* EOF */ diff --git a/reactos/subsys/smss/initwkdll.c b/reactos/subsys/smss/initwkdll.c index df35724ea27..237c25e7b43 100644 --- a/reactos/subsys/smss/initwkdll.c +++ b/reactos/subsys/smss/initwkdll.c @@ -1,254 +1,254 @@ -/* $Id: init.c 13449 2005-02-06 21:55:07Z ea $ - * - * initwkdll.c - Load the well known DLLs - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ - -#include "smss.h" - -#define NDEBUG -#include - -static NTSTATUS STDCALL -SmpKnownDllsQueryRoutine(PWSTR ValueName, - ULONG ValueType, - PVOID ValueData, - ULONG ValueLength, - PVOID Context, - PVOID EntryContext) -{ - OBJECT_ATTRIBUTES ObjectAttributes; - IO_STATUS_BLOCK IoStatusBlock; - UNICODE_STRING ImageName; - HANDLE FileHandle; - HANDLE SectionHandle; - NTSTATUS Status; - - DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); - DPRINT("ValueData '%S' Context %p EntryContext %p\n", (PWSTR)ValueData, Context, EntryContext); - - /* Ignore the 'DllDirectory' value */ - if (!_wcsicmp(ValueName, L"DllDirectory")) - return STATUS_SUCCESS; - - /* Open the DLL image file */ - RtlInitUnicodeString(&ImageName, - ValueData); - InitializeObjectAttributes(&ObjectAttributes, - &ImageName, - OBJ_CASE_INSENSITIVE, - (HANDLE)Context, - NULL); - Status = NtOpenFile(&FileHandle, - SYNCHRONIZE | FILE_EXECUTE | FILE_READ_DATA, - &ObjectAttributes, - &IoStatusBlock, - FILE_SHARE_READ, - FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtOpenFile() failed (Status %lx)\n", Status); - return STATUS_SUCCESS; - } - - DPRINT("Opened file %wZ successfully\n", &ImageName); - - /* Check for valid image checksum */ - Status = LdrVerifyImageMatchesChecksum (FileHandle, - 0, - 0, - 0); - if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH) - { - /* Raise a hard error (crash the system/BSOD) */ - NtRaiseHardError (Status, - 0, - 0, - 0, - 0, - 0); - } - else if (!NT_SUCCESS(Status)) - { - DPRINT1("Failed to check the image checksum\n"); - - NtClose(SectionHandle); - NtClose(FileHandle); - - return STATUS_SUCCESS; - } - - InitializeObjectAttributes(&ObjectAttributes, - &ImageName, - OBJ_CASE_INSENSITIVE | OBJ_PERMANENT, - (HANDLE)EntryContext, - NULL); - Status = NtCreateSection(&SectionHandle, - SECTION_ALL_ACCESS, - &ObjectAttributes, - NULL, - PAGE_EXECUTE, - SEC_IMAGE, - FileHandle); - if (NT_SUCCESS(Status)) - { - DPRINT("Created section successfully\n"); - NtClose(SectionHandle); - } - - NtClose(FileHandle); - - return STATUS_SUCCESS; -} - - -NTSTATUS -SmLoadKnownDlls(VOID) -{ - RTL_QUERY_REGISTRY_TABLE QueryTable[2]; - OBJECT_ATTRIBUTES ObjectAttributes; - IO_STATUS_BLOCK IoStatusBlock; - UNICODE_STRING DllDosPath; - UNICODE_STRING DllNtPath; - UNICODE_STRING Name; - HANDLE ObjectDirHandle; - HANDLE FileDirHandle; - HANDLE SymlinkHandle; - NTSTATUS Status; - - - DPRINT("SM: loading well-known DLLs\n"); - - DPRINT("SmLoadKnownDlls() called\n"); - - /* Create 'KnownDlls' object directory */ - RtlInitUnicodeString(&Name, - L"\\KnownDlls"); - InitializeObjectAttributes(&ObjectAttributes, - &Name, - OBJ_PERMANENT | OBJ_CASE_INSENSITIVE | OBJ_OPENIF, - NULL, - NULL); - Status = NtCreateDirectoryObject(&ObjectDirHandle, - DIRECTORY_ALL_ACCESS, - &ObjectAttributes); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtCreateDirectoryObject() failed (Status %lx)\n", Status); - return Status; - } - - RtlInitUnicodeString(&DllDosPath, NULL); - - RtlZeroMemory(&QueryTable, - sizeof(QueryTable)); - - QueryTable[0].Name = L"DllDirectory"; - QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; - QueryTable[0].EntryContext = &DllDosPath; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, - L"\\Session Manager\\KnownDlls", - QueryTable, - NULL, - SmSystemEnvironment); - if (!NT_SUCCESS(Status)) - { - DPRINT1("RtlQueryRegistryValues() failed (Status %lx)\n", Status); - return Status; - } - - DPRINT("DllDosPath: '%wZ'\n", &DllDosPath); - - if (!RtlDosPathNameToNtPathName_U(DllDosPath.Buffer, - &DllNtPath, - NULL, - NULL)) - { - DPRINT1("RtlDosPathNameToNtPathName_U() failed\n"); - return STATUS_OBJECT_NAME_INVALID; - } - - DPRINT("DllNtPath: '%wZ'\n", &DllNtPath); - - /* Open the dll path directory */ - InitializeObjectAttributes(&ObjectAttributes, - &DllNtPath, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - Status = NtOpenFile(&FileDirHandle, - SYNCHRONIZE | FILE_READ_DATA, - &ObjectAttributes, - &IoStatusBlock, - FILE_SHARE_READ | FILE_SHARE_WRITE, - FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtOpenFile(%wZ) failed (Status %lx)\n", &DllNtPath, Status); - return Status; - } - - /* Link 'KnownDllPath' the dll path directory */ - RtlInitUnicodeString(&Name, - L"KnownDllPath"); - InitializeObjectAttributes(&ObjectAttributes, - &Name, - OBJ_PERMANENT | OBJ_CASE_INSENSITIVE | OBJ_OPENIF, - ObjectDirHandle, - NULL); - Status = NtCreateSymbolicLinkObject(&SymlinkHandle, - SYMBOLIC_LINK_ALL_ACCESS, - &ObjectAttributes, - &DllDosPath); - if (!NT_SUCCESS(Status)) - { - DPRINT1("NtCreateSymbolicLink() failed (Status %lx)\n", Status); - return Status; - } - - NtClose(SymlinkHandle); - - RtlZeroMemory(&QueryTable, - sizeof(QueryTable)); - - QueryTable[0].QueryRoutine = SmpKnownDllsQueryRoutine; - QueryTable[0].EntryContext = ObjectDirHandle; - - Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, - L"\\Session Manager\\KnownDlls", - QueryTable, - (PVOID)FileDirHandle, - NULL); - if (!NT_SUCCESS(Status)) - { - DPRINT1("RtlQueryRegistryValues() failed (Status %lx)\n", Status); - } - - DPRINT("SmLoadKnownDlls() done\n"); - - return Status; -} - - -/* EOF */ +/* $Id$ + * + * initwkdll.c - Load the well known DLLs + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ + +#include "smss.h" + +#define NDEBUG +#include + +static NTSTATUS STDCALL +SmpKnownDllsQueryRoutine(PWSTR ValueName, + ULONG ValueType, + PVOID ValueData, + ULONG ValueLength, + PVOID Context, + PVOID EntryContext) +{ + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatusBlock; + UNICODE_STRING ImageName; + HANDLE FileHandle; + HANDLE SectionHandle; + NTSTATUS Status; + + DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength); + DPRINT("ValueData '%S' Context %p EntryContext %p\n", (PWSTR)ValueData, Context, EntryContext); + + /* Ignore the 'DllDirectory' value */ + if (!_wcsicmp(ValueName, L"DllDirectory")) + return STATUS_SUCCESS; + + /* Open the DLL image file */ + RtlInitUnicodeString(&ImageName, + ValueData); + InitializeObjectAttributes(&ObjectAttributes, + &ImageName, + OBJ_CASE_INSENSITIVE, + (HANDLE)Context, + NULL); + Status = NtOpenFile(&FileHandle, + SYNCHRONIZE | FILE_EXECUTE | FILE_READ_DATA, + &ObjectAttributes, + &IoStatusBlock, + FILE_SHARE_READ, + FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtOpenFile() failed (Status %lx)\n", Status); + return STATUS_SUCCESS; + } + + DPRINT("Opened file %wZ successfully\n", &ImageName); + + /* Check for valid image checksum */ + Status = LdrVerifyImageMatchesChecksum (FileHandle, + 0, + 0, + 0); + if (Status == STATUS_IMAGE_CHECKSUM_MISMATCH) + { + /* Raise a hard error (crash the system/BSOD) */ + NtRaiseHardError (Status, + 0, + 0, + 0, + 0, + 0); + } + else if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to check the image checksum\n"); + + NtClose(SectionHandle); + NtClose(FileHandle); + + return STATUS_SUCCESS; + } + + InitializeObjectAttributes(&ObjectAttributes, + &ImageName, + OBJ_CASE_INSENSITIVE | OBJ_PERMANENT, + (HANDLE)EntryContext, + NULL); + Status = NtCreateSection(&SectionHandle, + SECTION_ALL_ACCESS, + &ObjectAttributes, + NULL, + PAGE_EXECUTE, + SEC_IMAGE, + FileHandle); + if (NT_SUCCESS(Status)) + { + DPRINT("Created section successfully\n"); + NtClose(SectionHandle); + } + + NtClose(FileHandle); + + return STATUS_SUCCESS; +} + + +NTSTATUS +SmLoadKnownDlls(VOID) +{ + RTL_QUERY_REGISTRY_TABLE QueryTable[2]; + OBJECT_ATTRIBUTES ObjectAttributes; + IO_STATUS_BLOCK IoStatusBlock; + UNICODE_STRING DllDosPath; + UNICODE_STRING DllNtPath; + UNICODE_STRING Name; + HANDLE ObjectDirHandle; + HANDLE FileDirHandle; + HANDLE SymlinkHandle; + NTSTATUS Status; + + + DPRINT("SM: loading well-known DLLs\n"); + + DPRINT("SmLoadKnownDlls() called\n"); + + /* Create 'KnownDlls' object directory */ + RtlInitUnicodeString(&Name, + L"\\KnownDlls"); + InitializeObjectAttributes(&ObjectAttributes, + &Name, + OBJ_PERMANENT | OBJ_CASE_INSENSITIVE | OBJ_OPENIF, + NULL, + NULL); + Status = NtCreateDirectoryObject(&ObjectDirHandle, + DIRECTORY_ALL_ACCESS, + &ObjectAttributes); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtCreateDirectoryObject() failed (Status %lx)\n", Status); + return Status; + } + + RtlInitUnicodeString(&DllDosPath, NULL); + + RtlZeroMemory(&QueryTable, + sizeof(QueryTable)); + + QueryTable[0].Name = L"DllDirectory"; + QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT; + QueryTable[0].EntryContext = &DllDosPath; + + Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, + L"\\Session Manager\\KnownDlls", + QueryTable, + NULL, + SmSystemEnvironment); + if (!NT_SUCCESS(Status)) + { + DPRINT1("RtlQueryRegistryValues() failed (Status %lx)\n", Status); + return Status; + } + + DPRINT("DllDosPath: '%wZ'\n", &DllDosPath); + + if (!RtlDosPathNameToNtPathName_U(DllDosPath.Buffer, + &DllNtPath, + NULL, + NULL)) + { + DPRINT1("RtlDosPathNameToNtPathName_U() failed\n"); + return STATUS_OBJECT_NAME_INVALID; + } + + DPRINT("DllNtPath: '%wZ'\n", &DllNtPath); + + /* Open the dll path directory */ + InitializeObjectAttributes(&ObjectAttributes, + &DllNtPath, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + Status = NtOpenFile(&FileDirHandle, + SYNCHRONIZE | FILE_READ_DATA, + &ObjectAttributes, + &IoStatusBlock, + FILE_SHARE_READ | FILE_SHARE_WRITE, + FILE_SYNCHRONOUS_IO_NONALERT | FILE_DIRECTORY_FILE); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtOpenFile(%wZ) failed (Status %lx)\n", &DllNtPath, Status); + return Status; + } + + /* Link 'KnownDllPath' the dll path directory */ + RtlInitUnicodeString(&Name, + L"KnownDllPath"); + InitializeObjectAttributes(&ObjectAttributes, + &Name, + OBJ_PERMANENT | OBJ_CASE_INSENSITIVE | OBJ_OPENIF, + ObjectDirHandle, + NULL); + Status = NtCreateSymbolicLinkObject(&SymlinkHandle, + SYMBOLIC_LINK_ALL_ACCESS, + &ObjectAttributes, + &DllDosPath); + if (!NT_SUCCESS(Status)) + { + DPRINT1("NtCreateSymbolicLink() failed (Status %lx)\n", Status); + return Status; + } + + NtClose(SymlinkHandle); + + RtlZeroMemory(&QueryTable, + sizeof(QueryTable)); + + QueryTable[0].QueryRoutine = SmpKnownDllsQueryRoutine; + QueryTable[0].EntryContext = ObjectDirHandle; + + Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL, + L"\\Session Manager\\KnownDlls", + QueryTable, + (PVOID)FileDirHandle, + NULL); + if (!NT_SUCCESS(Status)) + { + DPRINT1("RtlQueryRegistryValues() failed (Status %lx)\n", Status); + } + + DPRINT("SmLoadKnownDlls() done\n"); + + return Status; +} + + +/* EOF */ diff --git a/reactos/subsys/smss/print.c b/reactos/subsys/smss/print.c index fccc3ac37d6..d727e5f4ef1 100644 --- a/reactos/subsys/smss/print.c +++ b/reactos/subsys/smss/print.c @@ -1,56 +1,56 @@ -/* $Id: print.c 12852 2005-01-06 13:58:04Z mf $ - * - * print.c - Print on the blue screen - * - * ReactOS Operating System - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ -#define NTOS_MODE_USER -#include - -VOID STDCALL DisplayString(LPCWSTR lpwString) -{ - UNICODE_STRING us; - - RtlInitUnicodeString (&us, lpwString); - ZwDisplayString (&us); -} - -VOID STDCALL PrintString (char* fmt, ...) -{ - char buffer[512]; - va_list ap; - UNICODE_STRING UnicodeString; - ANSI_STRING AnsiString; - - va_start(ap, fmt); - vsprintf(buffer, fmt, ap); - va_end(ap); - - RtlInitAnsiString (&AnsiString, buffer); - RtlAnsiStringToUnicodeString (&UnicodeString, - &AnsiString, - TRUE); - NtDisplayString(&UnicodeString); - RtlFreeUnicodeString (&UnicodeString); -} - -/* EOF */ +/* $Id$ + * + * print.c - Print on the blue screen + * + * ReactOS Operating System + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#define NTOS_MODE_USER +#include + +VOID STDCALL DisplayString(LPCWSTR lpwString) +{ + UNICODE_STRING us; + + RtlInitUnicodeString (&us, lpwString); + ZwDisplayString (&us); +} + +VOID STDCALL PrintString (char* fmt, ...) +{ + char buffer[512]; + va_list ap; + UNICODE_STRING UnicodeString; + ANSI_STRING AnsiString; + + va_start(ap, fmt); + vsprintf(buffer, fmt, ap); + va_end(ap); + + RtlInitAnsiString (&AnsiString, buffer); + RtlAnsiStringToUnicodeString (&UnicodeString, + &AnsiString, + TRUE); + NtDisplayString(&UnicodeString); + RtlFreeUnicodeString (&UnicodeString); +} + +/* EOF */ diff --git a/reactos/subsys/smss/smapicomp.c b/reactos/subsys/smss/smapicomp.c index f4d42220f3e..7b8d9efd59b 100644 --- a/reactos/subsys/smss/smapicomp.c +++ b/reactos/subsys/smss/smapicomp.c @@ -1,54 +1,54 @@ -/* $Id: $ - * - * smapicomp.c - SM_API_COMPLETE_SESSION - * - * Reactos Session Manager - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ -#include "smss.h" - -#define NDEBUG -#include - - -/********************************************************************** - * SmCompSes/1 API - */ -SMAPI(SmCompSes) -{ - NTSTATUS Status = STATUS_SUCCESS; - - DPRINT("SM: %s called\n", __FUNCTION__); - - DPRINT("SM: %s: ClientId.UniqueProcess=%lx\n", - __FUNCTION__, Request->Header.ClientId.UniqueProcess); - Status = SmCompleteClientInitialization ((ULONG) Request->Header.ClientId.UniqueProcess); - if (!NT_SUCCESS(Status)) - { - DPRINT1("SM: %s: NtQueryInformationProcess failed (Status=0x%08lx)\n", - __FUNCTION__, Status); - } - Request->SmHeader.Status = Status; - return STATUS_SUCCESS; -} - - -/* EOF */ +/* $Id$ + * + * smapicomp.c - SM_API_COMPLETE_SESSION + * + * Reactos Session Manager + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#include "smss.h" + +#define NDEBUG +#include + + +/********************************************************************** + * SmCompSes/1 API + */ +SMAPI(SmCompSes) +{ + NTSTATUS Status = STATUS_SUCCESS; + + DPRINT("SM: %s called\n", __FUNCTION__); + + DPRINT("SM: %s: ClientId.UniqueProcess=%lx\n", + __FUNCTION__, Request->Header.ClientId.UniqueProcess); + Status = SmCompleteClientInitialization ((ULONG) Request->Header.ClientId.UniqueProcess); + if (!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s: NtQueryInformationProcess failed (Status=0x%08lx)\n", + __FUNCTION__, Status); + } + Request->SmHeader.Status = Status; + return STATUS_SUCCESS; +} + + +/* EOF */ diff --git a/reactos/subsys/smss/smapiexec.c b/reactos/subsys/smss/smapiexec.c index 445966bac65..3d185b87794 100644 --- a/reactos/subsys/smss/smapiexec.c +++ b/reactos/subsys/smss/smapiexec.c @@ -1,390 +1,390 @@ -/* $Id$ - * - * smapiexec.c - SM_API_EXECUTE_PROGRAM - * - * Reactos Session Manager - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ -#include "smss.h" - -#define NDEBUG -#include - -/********************************************************************** - * SmCreateUserProcess/5 - * - * DESCRIPTION - * - * ARGUMENTS - * ImagePath: bsolute path of the image to run; - * CommandLine: arguments and options for ImagePath; - * WaitForIt: TRUE for boot time processes and FALSE for - * subsystems bootstrapping; - * Timeout: optional: used if WaitForIt==TRUE; - * ProcessHandle: optional: a duplicated handle for - the child process (storage provided by the caller). - * - * RETURN VALUE - * NTSTATUS: - * - */ -NTSTATUS STDCALL -SmCreateUserProcess (LPWSTR ImagePath, - LPWSTR CommandLine, - BOOLEAN WaitForIt, - PLARGE_INTEGER Timeout OPTIONAL, - PRTL_PROCESS_INFO UserProcessInfo OPTIONAL) -{ - UNICODE_STRING ImagePathString = {0}; - UNICODE_STRING CommandLineString = {0}; - PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL; - RTL_PROCESS_INFO ProcessInfo = {0}; - PRTL_PROCESS_INFO pProcessInfo = & ProcessInfo; - NTSTATUS Status = STATUS_SUCCESS; - - DPRINT("SM: %s called\n", __FUNCTION__); - - if (NULL != UserProcessInfo) - { - pProcessInfo = UserProcessInfo; - } - - RtlInitUnicodeString (& ImagePathString, ImagePath); - RtlInitUnicodeString (& CommandLineString, CommandLine); - - RtlCreateProcessParameters(& ProcessParameters, - & ImagePathString, - NULL, - NULL, - & CommandLineString, - SmSystemEnvironment, - NULL, - NULL, - NULL, - NULL); - - Status = RtlCreateUserProcess (& ImagePathString, - OBJ_CASE_INSENSITIVE, - ProcessParameters, - NULL, - NULL, - NULL, - FALSE, - NULL, - NULL, - pProcessInfo); - - RtlDestroyProcessParameters (ProcessParameters); - - if (!NT_SUCCESS(Status)) - { - DPRINT1("SM: %s: Running \"%S\" failed (Status=0x%08lx)\n", - __FUNCTION__, ImagePathString.Buffer, Status); - return Status; - } - /* - * It the caller is *not* interested in the child info, - * resume it immediately. - */ - if (NULL == UserProcessInfo) - { - Status = NtResumeThread (ProcessInfo.ThreadHandle, NULL); - if(!NT_SUCCESS(Status)) - { - DPRINT1("SM: %s: NtResumeThread failed (Status=0x%08lx)\n", - __FUNCTION__, Status); - } - } - else - { - HANDLE DupProcessHandle = (HANDLE) 0; - - Status = NtDuplicateObject (NtCurrentProcess(), - pProcessInfo->ProcessHandle, - NtCurrentProcess(), - & DupProcessHandle, - PROCESS_ALL_ACCESS, - 0, 0); - if(!NT_SUCCESS(Status)) - { - DPRINT1("SM: %s: NtDuplicateObject failed (Status=0x%08lx)\n", - __FUNCTION__, Status); - } - pProcessInfo->ProcessHandle = DupProcessHandle; - - } - - /* Wait for process termination */ - if (WaitForIt) - { - Status = NtWaitForSingleObject (pProcessInfo->ProcessHandle, - FALSE, - Timeout); - if (!NT_SUCCESS(Status)) - { - DPRINT1("SM: %s: NtWaitForSingleObject failed with Status=0x%08lx\n", - __FUNCTION__, Status); - } - - } - return Status; -} - -/********************************************************************** - * NAME - * SmLookupSubsystem/5 - * - * DESCRIPTION - * Read from the registry key - * \Registry\SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems - * the value which name is Name. - * - * ARGUMENTS - * Name: name of the program to run, that is a value's name in - * the SM registry key Subsystems; - * Data: what the registry gave back for Name; - * DataLength: how much Data the registry returns; - * DataType: what is Data? - * Expand: set it TRUE if you want this function to use the env - * to possibly expand Data before giving it back. - */ -NTSTATUS STDCALL -SmLookupSubsystem (IN PWSTR Name, - IN OUT PWSTR Data, - IN OUT PULONG DataLength, - IN OUT PULONG DataType, - IN BOOLEAN Expand) -{ - NTSTATUS Status = STATUS_SUCCESS; - UNICODE_STRING usKeyName = {0}; - OBJECT_ATTRIBUTES Oa = {0}; - HANDLE hKey = (HANDLE) 0; - - DPRINT("SM: %s(Name='%S') called\n", __FUNCTION__, Name); - /* - * Prepare the key name to scan and - * related object attributes. - */ - RtlInitUnicodeString (& usKeyName, - L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\SubSystems"); - - InitializeObjectAttributes (& Oa, - & usKeyName, - OBJ_CASE_INSENSITIVE, - NULL, - NULL); - /* - * Open the key. This MUST NOT fail, if the - * request is for a legitimate subsystem. - */ - Status = NtOpenKey (& hKey, - MAXIMUM_ALLOWED, - & Oa); - if(NT_SUCCESS(Status)) - { - UNICODE_STRING usValueName = {0}; - WCHAR KeyValueInformation [1024] = {L'\0'}; - ULONG ResultLength = 0L; - PKEY_VALUE_PARTIAL_INFORMATION - kvpi = (PKEY_VALUE_PARTIAL_INFORMATION) KeyValueInformation; - - - RtlInitUnicodeString (& usValueName, Name); - Status = NtQueryValueKey (hKey, - & usValueName, - KeyValuePartialInformation, - KeyValueInformation, - sizeof KeyValueInformation, - & ResultLength); - if(NT_SUCCESS(Status)) - { - DPRINT("nkvpi.TitleIndex = %ld\n", kvpi->TitleIndex); - DPRINT("kvpi.Type = %ld\n", kvpi->Type); - DPRINT("kvpi.DataLength = %ld\n", kvpi->DataLength); - - if((NULL != Data) && (NULL != DataLength) && (NULL != DataType)) - { - *DataType = kvpi->Type; - if((Expand) && (REG_EXPAND_SZ == *DataType)) - { - UNICODE_STRING Source; - WCHAR DestinationBuffer [2048] = {0}; - UNICODE_STRING Destination; - ULONG Length = 0; - - DPRINT("SM: %s: value will be expanded\n", __FUNCTION__); - - Source.Length = kvpi->DataLength; - Source.MaximumLength = kvpi->DataLength; - Source.Buffer = (PWCHAR) & kvpi->Data; - - Destination.Length = 0; - Destination.MaximumLength = sizeof DestinationBuffer; - Destination.Buffer = DestinationBuffer; - - Status = RtlExpandEnvironmentStrings_U (SmSystemEnvironment, - & Source, - & Destination, - & Length); - if(NT_SUCCESS(Status)) - { - *DataLength = min(*DataLength, Destination.Length); - RtlCopyMemory (Data, Destination.Buffer, *DataLength); - } - - }else{ - DPRINT("SM: %s: value won't be expanded\n", __FUNCTION__); - *DataLength = min(*DataLength, kvpi->DataLength); - RtlCopyMemory (Data, & kvpi->Data, *DataLength); - } - *DataType = kvpi->Type; - }else{ - DPRINT1("SM: %s: Data or DataLength or DataType is NULL!\n", __FUNCTION__); - Status = STATUS_INVALID_PARAMETER; - } - }else{ - DPRINT1("%s: NtQueryValueKey failed (Status=0x%08lx)\n", __FUNCTION__, Status); - } - NtClose (hKey); - }else{ - DPRINT1("%s: NtOpenKey failed (Status=0x%08lx)\n", __FUNCTION__, Status); - } - return Status; -} - - -/********************************************************************** - * SmExecPgm/1 API - */ -SMAPI(SmExecPgm) -{ - PSM_PORT_MESSAGE_EXECPGM ExecPgm = NULL; - WCHAR Name [SM_EXEXPGM_MAX_LENGTH + 1]; - NTSTATUS Status = STATUS_SUCCESS; - - DPRINT("SM: %s called\n",__FUNCTION__); - - if(NULL == Request) - { - DPRINT1("SM: %s: Request == NULL!\n", __FUNCTION__); - return STATUS_INVALID_PARAMETER; - } - DPRINT("SM: %s called from CID(%lx|%lx)\n", - __FUNCTION__, Request->Header.ClientId.UniqueProcess, - Request->Header.ClientId.UniqueThread); - ExecPgm = & Request->Request.ExecPgm; - /* Check if the name lenght is valid */ - if((ExecPgm->NameLength > 0) && - (ExecPgm->NameLength <= SM_EXEXPGM_MAX_LENGTH) && - TRUE /* TODO: check LPC payload size */) - { - WCHAR Data [MAX_PATH + 1] = {0}; - ULONG DataLength = sizeof Data; - ULONG DataType = REG_EXPAND_SZ; - - - RtlZeroMemory (Name, sizeof Name); - RtlCopyMemory (Name, - ExecPgm->Name, - (sizeof ExecPgm->Name[0] * ExecPgm->NameLength)); - DPRINT("SM: %s: Name='%S'\n", __FUNCTION__, Name); - /* Lookup Name in the registry */ - Status = SmLookupSubsystem (Name, - Data, - & DataLength, - & DataType, - TRUE); /* expand */ - if(NT_SUCCESS(Status)) - { - /* Is the subsystem definition non-empty? */ - if (DataLength > sizeof Data[0]) - { - WCHAR ImagePath [MAX_PATH + 1] = {0}; - PWCHAR CommandLine = ImagePath; - RTL_PROCESS_INFO ProcessInfo = {0}; - - wcscpy (ImagePath, L"\\??\\"); - wcscat (ImagePath, Data); - /* - * Look for the beginning of the command line. - */ - for (; (*CommandLine != L'\0') && (*CommandLine != L' '); - CommandLine ++); - for (; *CommandLine == L' '; CommandLine ++) - { - *CommandLine = L'\0'; - } - /* - * Create a native process (suspended). - */ - ProcessInfo.Size = sizeof ProcessInfo; - Request->SmHeader.Status = - SmCreateUserProcess(ImagePath, - CommandLine, - FALSE, /* wait */ - NULL, /* timeout */ - & ProcessInfo); - if (NT_SUCCESS(Request->SmHeader.Status)) - { - Status = SmCreateClient (& ProcessInfo, Name); - if (NT_SUCCESS(Status)) - { - Status = NtResumeThread (ProcessInfo.ThreadHandle, NULL); - if (!NT_SUCCESS(Status)) - { - //Status = SmDestroyClient TODO - } - } else { - DPRINT1("SM: %s: SmCreateClient failed (Status=0x%08lx)\n", - __FUNCTION__, Status); - } - } - } - else - { - /* - * OK, the definition is empty, but check - * if it is the name of an embedded subsystem. - */ - if(0 == _wcsicmp(L"DEBUG", Name)) - { - /* - * Initialize the embedded DBGSS. - */ - Request->SmHeader.Status = SmInitializeDbgSs(); - } - else - { - /* - * Badly defined subsystem. Check the registry! - */ - Request->SmHeader.Status = STATUS_NOT_FOUND; - } - } - } else { - /* It couldn't lookup the Name! */ - Request->SmHeader.Status = Status; - } - } - return Status; -} - -/* EOF */ +/* $Id$ + * + * smapiexec.c - SM_API_EXECUTE_PROGRAM + * + * Reactos Session Manager + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#include "smss.h" + +#define NDEBUG +#include + +/********************************************************************** + * SmCreateUserProcess/5 + * + * DESCRIPTION + * + * ARGUMENTS + * ImagePath: bsolute path of the image to run; + * CommandLine: arguments and options for ImagePath; + * WaitForIt: TRUE for boot time processes and FALSE for + * subsystems bootstrapping; + * Timeout: optional: used if WaitForIt==TRUE; + * ProcessHandle: optional: a duplicated handle for + the child process (storage provided by the caller). + * + * RETURN VALUE + * NTSTATUS: + * + */ +NTSTATUS STDCALL +SmCreateUserProcess (LPWSTR ImagePath, + LPWSTR CommandLine, + BOOLEAN WaitForIt, + PLARGE_INTEGER Timeout OPTIONAL, + PRTL_PROCESS_INFO UserProcessInfo OPTIONAL) +{ + UNICODE_STRING ImagePathString = {0}; + UNICODE_STRING CommandLineString = {0}; + PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL; + RTL_PROCESS_INFO ProcessInfo = {0}; + PRTL_PROCESS_INFO pProcessInfo = & ProcessInfo; + NTSTATUS Status = STATUS_SUCCESS; + + DPRINT("SM: %s called\n", __FUNCTION__); + + if (NULL != UserProcessInfo) + { + pProcessInfo = UserProcessInfo; + } + + RtlInitUnicodeString (& ImagePathString, ImagePath); + RtlInitUnicodeString (& CommandLineString, CommandLine); + + RtlCreateProcessParameters(& ProcessParameters, + & ImagePathString, + NULL, + NULL, + & CommandLineString, + SmSystemEnvironment, + NULL, + NULL, + NULL, + NULL); + + Status = RtlCreateUserProcess (& ImagePathString, + OBJ_CASE_INSENSITIVE, + ProcessParameters, + NULL, + NULL, + NULL, + FALSE, + NULL, + NULL, + pProcessInfo); + + RtlDestroyProcessParameters (ProcessParameters); + + if (!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s: Running \"%S\" failed (Status=0x%08lx)\n", + __FUNCTION__, ImagePathString.Buffer, Status); + return Status; + } + /* + * It the caller is *not* interested in the child info, + * resume it immediately. + */ + if (NULL == UserProcessInfo) + { + Status = NtResumeThread (ProcessInfo.ThreadHandle, NULL); + if(!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s: NtResumeThread failed (Status=0x%08lx)\n", + __FUNCTION__, Status); + } + } + else + { + HANDLE DupProcessHandle = (HANDLE) 0; + + Status = NtDuplicateObject (NtCurrentProcess(), + pProcessInfo->ProcessHandle, + NtCurrentProcess(), + & DupProcessHandle, + PROCESS_ALL_ACCESS, + 0, 0); + if(!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s: NtDuplicateObject failed (Status=0x%08lx)\n", + __FUNCTION__, Status); + } + pProcessInfo->ProcessHandle = DupProcessHandle; + + } + + /* Wait for process termination */ + if (WaitForIt) + { + Status = NtWaitForSingleObject (pProcessInfo->ProcessHandle, + FALSE, + Timeout); + if (!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s: NtWaitForSingleObject failed with Status=0x%08lx\n", + __FUNCTION__, Status); + } + + } + return Status; +} + +/********************************************************************** + * NAME + * SmLookupSubsystem/5 + * + * DESCRIPTION + * Read from the registry key + * \Registry\SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems + * the value which name is Name. + * + * ARGUMENTS + * Name: name of the program to run, that is a value's name in + * the SM registry key Subsystems; + * Data: what the registry gave back for Name; + * DataLength: how much Data the registry returns; + * DataType: what is Data? + * Expand: set it TRUE if you want this function to use the env + * to possibly expand Data before giving it back. + */ +NTSTATUS STDCALL +SmLookupSubsystem (IN PWSTR Name, + IN OUT PWSTR Data, + IN OUT PULONG DataLength, + IN OUT PULONG DataType, + IN BOOLEAN Expand) +{ + NTSTATUS Status = STATUS_SUCCESS; + UNICODE_STRING usKeyName = {0}; + OBJECT_ATTRIBUTES Oa = {0}; + HANDLE hKey = (HANDLE) 0; + + DPRINT("SM: %s(Name='%S') called\n", __FUNCTION__, Name); + /* + * Prepare the key name to scan and + * related object attributes. + */ + RtlInitUnicodeString (& usKeyName, + L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\SubSystems"); + + InitializeObjectAttributes (& Oa, + & usKeyName, + OBJ_CASE_INSENSITIVE, + NULL, + NULL); + /* + * Open the key. This MUST NOT fail, if the + * request is for a legitimate subsystem. + */ + Status = NtOpenKey (& hKey, + MAXIMUM_ALLOWED, + & Oa); + if(NT_SUCCESS(Status)) + { + UNICODE_STRING usValueName = {0}; + WCHAR KeyValueInformation [1024] = {L'\0'}; + ULONG ResultLength = 0L; + PKEY_VALUE_PARTIAL_INFORMATION + kvpi = (PKEY_VALUE_PARTIAL_INFORMATION) KeyValueInformation; + + + RtlInitUnicodeString (& usValueName, Name); + Status = NtQueryValueKey (hKey, + & usValueName, + KeyValuePartialInformation, + KeyValueInformation, + sizeof KeyValueInformation, + & ResultLength); + if(NT_SUCCESS(Status)) + { + DPRINT("nkvpi.TitleIndex = %ld\n", kvpi->TitleIndex); + DPRINT("kvpi.Type = %ld\n", kvpi->Type); + DPRINT("kvpi.DataLength = %ld\n", kvpi->DataLength); + + if((NULL != Data) && (NULL != DataLength) && (NULL != DataType)) + { + *DataType = kvpi->Type; + if((Expand) && (REG_EXPAND_SZ == *DataType)) + { + UNICODE_STRING Source; + WCHAR DestinationBuffer [2048] = {0}; + UNICODE_STRING Destination; + ULONG Length = 0; + + DPRINT("SM: %s: value will be expanded\n", __FUNCTION__); + + Source.Length = kvpi->DataLength; + Source.MaximumLength = kvpi->DataLength; + Source.Buffer = (PWCHAR) & kvpi->Data; + + Destination.Length = 0; + Destination.MaximumLength = sizeof DestinationBuffer; + Destination.Buffer = DestinationBuffer; + + Status = RtlExpandEnvironmentStrings_U (SmSystemEnvironment, + & Source, + & Destination, + & Length); + if(NT_SUCCESS(Status)) + { + *DataLength = min(*DataLength, Destination.Length); + RtlCopyMemory (Data, Destination.Buffer, *DataLength); + } + + }else{ + DPRINT("SM: %s: value won't be expanded\n", __FUNCTION__); + *DataLength = min(*DataLength, kvpi->DataLength); + RtlCopyMemory (Data, & kvpi->Data, *DataLength); + } + *DataType = kvpi->Type; + }else{ + DPRINT1("SM: %s: Data or DataLength or DataType is NULL!\n", __FUNCTION__); + Status = STATUS_INVALID_PARAMETER; + } + }else{ + DPRINT1("%s: NtQueryValueKey failed (Status=0x%08lx)\n", __FUNCTION__, Status); + } + NtClose (hKey); + }else{ + DPRINT1("%s: NtOpenKey failed (Status=0x%08lx)\n", __FUNCTION__, Status); + } + return Status; +} + + +/********************************************************************** + * SmExecPgm/1 API + */ +SMAPI(SmExecPgm) +{ + PSM_PORT_MESSAGE_EXECPGM ExecPgm = NULL; + WCHAR Name [SM_EXEXPGM_MAX_LENGTH + 1]; + NTSTATUS Status = STATUS_SUCCESS; + + DPRINT("SM: %s called\n",__FUNCTION__); + + if(NULL == Request) + { + DPRINT1("SM: %s: Request == NULL!\n", __FUNCTION__); + return STATUS_INVALID_PARAMETER; + } + DPRINT("SM: %s called from CID(%lx|%lx)\n", + __FUNCTION__, Request->Header.ClientId.UniqueProcess, + Request->Header.ClientId.UniqueThread); + ExecPgm = & Request->Request.ExecPgm; + /* Check if the name lenght is valid */ + if((ExecPgm->NameLength > 0) && + (ExecPgm->NameLength <= SM_EXEXPGM_MAX_LENGTH) && + TRUE /* TODO: check LPC payload size */) + { + WCHAR Data [MAX_PATH + 1] = {0}; + ULONG DataLength = sizeof Data; + ULONG DataType = REG_EXPAND_SZ; + + + RtlZeroMemory (Name, sizeof Name); + RtlCopyMemory (Name, + ExecPgm->Name, + (sizeof ExecPgm->Name[0] * ExecPgm->NameLength)); + DPRINT("SM: %s: Name='%S'\n", __FUNCTION__, Name); + /* Lookup Name in the registry */ + Status = SmLookupSubsystem (Name, + Data, + & DataLength, + & DataType, + TRUE); /* expand */ + if(NT_SUCCESS(Status)) + { + /* Is the subsystem definition non-empty? */ + if (DataLength > sizeof Data[0]) + { + WCHAR ImagePath [MAX_PATH + 1] = {0}; + PWCHAR CommandLine = ImagePath; + RTL_PROCESS_INFO ProcessInfo = {0}; + + wcscpy (ImagePath, L"\\??\\"); + wcscat (ImagePath, Data); + /* + * Look for the beginning of the command line. + */ + for (; (*CommandLine != L'\0') && (*CommandLine != L' '); + CommandLine ++); + for (; *CommandLine == L' '; CommandLine ++) + { + *CommandLine = L'\0'; + } + /* + * Create a native process (suspended). + */ + ProcessInfo.Size = sizeof ProcessInfo; + Request->SmHeader.Status = + SmCreateUserProcess(ImagePath, + CommandLine, + FALSE, /* wait */ + NULL, /* timeout */ + & ProcessInfo); + if (NT_SUCCESS(Request->SmHeader.Status)) + { + Status = SmCreateClient (& ProcessInfo, Name); + if (NT_SUCCESS(Status)) + { + Status = NtResumeThread (ProcessInfo.ThreadHandle, NULL); + if (!NT_SUCCESS(Status)) + { + //Status = SmDestroyClient TODO + } + } else { + DPRINT1("SM: %s: SmCreateClient failed (Status=0x%08lx)\n", + __FUNCTION__, Status); + } + } + } + else + { + /* + * OK, the definition is empty, but check + * if it is the name of an embedded subsystem. + */ + if(0 == _wcsicmp(L"DEBUG", Name)) + { + /* + * Initialize the embedded DBGSS. + */ + Request->SmHeader.Status = SmInitializeDbgSs(); + } + else + { + /* + * Badly defined subsystem. Check the registry! + */ + Request->SmHeader.Status = STATUS_NOT_FOUND; + } + } + } else { + /* It couldn't lookup the Name! */ + Request->SmHeader.Status = Status; + } + } + return Status; +} + +/* EOF */ diff --git a/reactos/subsys/smss/smapiquery.c b/reactos/subsys/smss/smapiquery.c index d1c402de757..5b8af3b7876 100644 --- a/reactos/subsys/smss/smapiquery.c +++ b/reactos/subsys/smss/smapiquery.c @@ -1,71 +1,71 @@ -/* $Id$ - * - * smapiquery.c - SM_API_QUERY_INFORMATION - * - * Reactos Session Manager - * - * -------------------------------------------------------------------- - * - * This software is free software; you can redistribute it and/or - * modify it under the terms of the GNU General Public License as - * published by the Free Software Foundation; either version 2 of the - * License, or (at your option) any later version. - * - * This software is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this software; see the file COPYING.LIB. If not, write - * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, - * MA 02139, USA. - * - * -------------------------------------------------------------------- - */ -#include "smss.h" - -#define NDEBUG -#include - - -/********************************************************************** - * SmQryInfo/1 API - */ -SMAPI(SmQryInfo) -{ - NTSTATUS Status = STATUS_SUCCESS; - - DPRINT("SM: %s called\n", __FUNCTION__); - - switch (Request->Request.QryInfo.SmInformationClass) - { - case SmBasicInformation: - if(Request->Request.QryInfo.DataLength != sizeof (SM_BASIC_INFORMATION)) - { - Request->Reply.QryInfo.DataLength = sizeof (SM_BASIC_INFORMATION); - Request->SmHeader.Status = STATUS_INFO_LENGTH_MISMATCH; - }else{ - Request->SmHeader.Status = - SmGetClientBasicInformation (& Request->Reply.QryInfo.BasicInformation); - } - break; - case SmSubSystemInformation: - if(Request->Request.QryInfo.DataLength != sizeof (SM_SUBSYSTEM_INFORMATION)) - { - Request->Reply.QryInfo.DataLength = sizeof (SM_SUBSYSTEM_INFORMATION); - Request->SmHeader.Status = STATUS_INFO_LENGTH_MISMATCH; - }else{ - Request->SmHeader.Status = - SmGetSubSystemInformation (& Request->Reply.QryInfo.SubSystemInformation); - } - break; - default: - Request->SmHeader.Status = STATUS_NOT_IMPLEMENTED; - break; - } - return Status; -} - - -/* EOF */ +/* $Id$ + * + * smapiquery.c - SM_API_QUERY_INFORMATION + * + * Reactos Session Manager + * + * -------------------------------------------------------------------- + * + * This software is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License as + * published by the Free Software Foundation; either version 2 of the + * License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this software; see the file COPYING.LIB. If not, write + * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, + * MA 02139, USA. + * + * -------------------------------------------------------------------- + */ +#include "smss.h" + +#define NDEBUG +#include + + +/********************************************************************** + * SmQryInfo/1 API + */ +SMAPI(SmQryInfo) +{ + NTSTATUS Status = STATUS_SUCCESS; + + DPRINT("SM: %s called\n", __FUNCTION__); + + switch (Request->Request.QryInfo.SmInformationClass) + { + case SmBasicInformation: + if(Request->Request.QryInfo.DataLength != sizeof (SM_BASIC_INFORMATION)) + { + Request->Reply.QryInfo.DataLength = sizeof (SM_BASIC_INFORMATION); + Request->SmHeader.Status = STATUS_INFO_LENGTH_MISMATCH; + }else{ + Request->SmHeader.Status = + SmGetClientBasicInformation (& Request->Reply.QryInfo.BasicInformation); + } + break; + case SmSubSystemInformation: + if(Request->Request.QryInfo.DataLength != sizeof (SM_SUBSYSTEM_INFORMATION)) + { + Request->Reply.QryInfo.DataLength = sizeof (SM_SUBSYSTEM_INFORMATION); + Request->SmHeader.Status = STATUS_INFO_LENGTH_MISMATCH; + }else{ + Request->SmHeader.Status = + SmGetSubSystemInformation (& Request->Reply.QryInfo.SubSystemInformation); + } + break; + default: + Request->SmHeader.Status = STATUS_NOT_IMPLEMENTED; + break; + } + return Status; +} + + +/* EOF */