mirror of
https://github.com/reactos/reactos.git
synced 2025-07-31 10:01:43 +00:00
[SMSS2/SMSS]: Nuke SMSS. SMSS2 is now in full control.
svn path=/trunk/; revision=55589
This commit is contained in:
parent
4780c28aa1
commit
9829c56509
32 changed files with 13 additions and 4315 deletions
|
@ -12,7 +12,6 @@ add_subdirectory(regsvr32)
|
|||
add_subdirectory(rundll32)
|
||||
add_subdirectory(runonce)
|
||||
add_subdirectory(services)
|
||||
add_subdirectory(smss)
|
||||
add_subdirectory(smss2)
|
||||
add_subdirectory(subst)
|
||||
add_subdirectory(userinit)
|
||||
|
|
|
@ -1,34 +0,0 @@
|
|||
|
||||
include_directories(${REACTOS_SOURCE_DIR}/include/reactos/subsys)
|
||||
|
||||
list(APPEND SOURCE
|
||||
client.c
|
||||
debug.c
|
||||
init.c
|
||||
initdosdev.c
|
||||
initenv.c
|
||||
initheap.c
|
||||
initmv.c
|
||||
initobdir.c
|
||||
initpage.c
|
||||
initreg.c
|
||||
initrun.c
|
||||
initss.c
|
||||
initwkdll.c
|
||||
print.c
|
||||
smapi.c
|
||||
smapicomp.c
|
||||
smapiexec.c
|
||||
smapiquery.c
|
||||
smss.c
|
||||
smss.rc)
|
||||
|
||||
add_executable(smss WIN32 ${SOURCE})
|
||||
|
||||
target_link_libraries(smss nt smlib)
|
||||
|
||||
add_pch(smss smss.h)
|
||||
|
||||
set_module_type(smss nativecui)
|
||||
add_importlibs(smss ntdll)
|
||||
add_cd_file(TARGET smss DESTINATION reactos/system32 FOR all)
|
|
@ -1,570 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/client.c
|
||||
* PURPOSE: Client management.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
#include <sm/helper.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* Private ADT */
|
||||
|
||||
#define SM_MAX_CLIENT_COUNT 16
|
||||
#define SM_INVALID_CLIENT_INDEX -1
|
||||
|
||||
struct _SM_CLIENT_DIRECTORY
|
||||
{
|
||||
RTL_CRITICAL_SECTION Lock;
|
||||
ULONG Count;
|
||||
PSM_CLIENT_DATA Client [SM_MAX_CLIENT_COUNT];
|
||||
PSM_CLIENT_DATA CandidateClient;
|
||||
|
||||
} SmpClientDirectory;
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SmInitializeClientManagement/0
|
||||
*/
|
||||
NTSTATUS
|
||||
SmInitializeClientManagement (VOID)
|
||||
{
|
||||
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||
RtlInitializeCriticalSection(& SmpClientDirectory.Lock);
|
||||
SmpClientDirectory.Count = 0;
|
||||
RtlZeroMemory (SmpClientDirectory.Client, sizeof SmpClientDirectory.Client);
|
||||
SmpClientDirectory.CandidateClient = NULL;
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
}
|
||||
/**********************************************************************
|
||||
* SmpSetClientInitialized/1
|
||||
*/
|
||||
VOID FASTCALL
|
||||
SmpSetClientInitialized (PSM_CLIENT_DATA Client)
|
||||
{
|
||||
DPRINT("SM: %s(%p) called\n", __FUNCTION__, Client);
|
||||
Client->Flags |= SM_CLIENT_FLAG_INITIALIZED;
|
||||
}
|
||||
/**********************************************************************
|
||||
* SmpGetFirstFreeClientEntry/0 PRIVATE
|
||||
*
|
||||
* NOTE: call it holding SmpClientDirectory.Lock only
|
||||
*/
|
||||
static INT NTAPI SmpGetFirstFreeClientEntry (VOID)
|
||||
{
|
||||
INT ClientIndex = 0;
|
||||
|
||||
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||
|
||||
if (SmpClientDirectory.Count < SM_MAX_CLIENT_COUNT)
|
||||
{
|
||||
for (ClientIndex = 0;
|
||||
(ClientIndex < SM_MAX_CLIENT_COUNT);
|
||||
ClientIndex ++)
|
||||
{
|
||||
if (NULL == SmpClientDirectory.Client[ClientIndex])
|
||||
{
|
||||
DPRINT("SM: %s => %d\n", __FUNCTION__, ClientIndex);
|
||||
return ClientIndex; // found
|
||||
}
|
||||
}
|
||||
}
|
||||
return SM_INVALID_CLIENT_INDEX; // full!
|
||||
}
|
||||
/**********************************************************************
|
||||
* SmpLookupClient/1 PRIVATE
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Lookup the subsystem server descriptor (client data) given its
|
||||
* base image ID.
|
||||
*
|
||||
* ARGUMENTS
|
||||
* SubsystemId: IMAGE_SUBSYSTEM_xxx
|
||||
*
|
||||
* RETURN VALUES
|
||||
* SM_INVALID_CLIENT_INDEX on error;
|
||||
* otherwise an index in the range (0..SM_MAX_CLIENT_COUNT).
|
||||
*
|
||||
* WARNING
|
||||
* SmpClientDirectory.Lock must be held by the caller.
|
||||
*/
|
||||
static INT FASTCALL
|
||||
SmpLookupClient (USHORT SubsystemId)
|
||||
{
|
||||
INT ClientIndex = 0;
|
||||
|
||||
DPRINT("SM: %s(%d) called\n", __FUNCTION__, SubsystemId);
|
||||
|
||||
if (0 != SmpClientDirectory.Count)
|
||||
{
|
||||
for (ClientIndex = 0; (ClientIndex < SM_MAX_CLIENT_COUNT); ClientIndex ++)
|
||||
{
|
||||
if (NULL != SmpClientDirectory.Client[ClientIndex])
|
||||
{
|
||||
if (SubsystemId == SmpClientDirectory.Client[ClientIndex]->SubsystemId)
|
||||
{
|
||||
return ClientIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return SM_INVALID_CLIENT_INDEX;
|
||||
}
|
||||
/**********************************************************************
|
||||
* SmpDestroyClientObject/2 PRIVATE
|
||||
*
|
||||
* WARNING
|
||||
* SmpClientDirectory.Lock must be held by the caller.
|
||||
*/
|
||||
static NTSTATUS NTAPI
|
||||
SmpDestroyClientObject (PSM_CLIENT_DATA Client, NTSTATUS DestroyReason)
|
||||
{
|
||||
DPRINT("SM:%s(%p,%08lx) called\n", __FUNCTION__, Client, DestroyReason);
|
||||
/* TODO: send shutdown to the SB port */
|
||||
NtTerminateProcess (Client->ServerProcess, DestroyReason);
|
||||
RtlFreeHeap (SmpHeap, 0, Client);
|
||||
-- SmpClientDirectory.Count;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
/**********************************************************************
|
||||
* 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 NTAPI
|
||||
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);
|
||||
INT ClientIndex = SM_INVALID_CLIENT_INDEX;
|
||||
HANDLE Process;
|
||||
|
||||
|
||||
DPRINT("SM: %s(%p,%p) called\n", __FUNCTION__,
|
||||
Request, ClientData);
|
||||
|
||||
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
||||
/*
|
||||
* Is there a subsystem bootstrap in progress?
|
||||
*/
|
||||
if (NULL != SmpClientDirectory.CandidateClient)
|
||||
{
|
||||
PROCESS_BASIC_INFORMATION pbi;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
|
||||
RtlZeroMemory (& pbi, sizeof pbi);
|
||||
InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
|
||||
Status = NtOpenProcess(&Process,
|
||||
PROCESS_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
&Request->Header.ClientId);
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
Status = NtQueryInformationProcess (Process,
|
||||
ProcessBasicInformation,
|
||||
& pbi,
|
||||
sizeof pbi,
|
||||
NULL);
|
||||
ASSERT(NT_SUCCESS(Status));
|
||||
{
|
||||
SmpClientDirectory.CandidateClient->ServerProcessId =
|
||||
(ULONG) pbi.UniqueProcessId;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
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 (SM_INVALID_CLIENT_INDEX != SmpLookupClient(ConnectData->SubSystemId))
|
||||
{
|
||||
DPRINT("SM: %s: attempt to register again subsystem %d.\n",
|
||||
__FUNCTION__,
|
||||
ConnectData->SubSystemId);
|
||||
// TODO something else to do here?
|
||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
/*
|
||||
* Check if a free entry exists in SmpClientDirectory.Client[].
|
||||
*/
|
||||
ClientIndex = SmpGetFirstFreeClientEntry();
|
||||
if (SM_INVALID_CLIENT_INDEX == ClientIndex)
|
||||
{
|
||||
DPRINT("SM: %s: SM_INVALID_CLIENT_INDEX == ClientIndex ", __FUNCTION__);
|
||||
SmpDestroyClientObject (SmpClientDirectory.CandidateClient, STATUS_NO_MEMORY);
|
||||
SmpClientDirectory.CandidateClient = NULL;
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
/* OK! */
|
||||
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) ||
|
||||
((USHORT)-1 == SmpClientDirectory.CandidateClient->SubsystemId))
|
||||
{
|
||||
SmpSetClientInitialized (SmpClientDirectory.CandidateClient);
|
||||
}
|
||||
if (SbApiPortNameSize > 0)
|
||||
{
|
||||
/* Only external servers have an SB port */
|
||||
RtlCopyMemory (SmpClientDirectory.CandidateClient->SbApiPortName,
|
||||
ConnectData->SbName,
|
||||
SbApiPortNameSize);
|
||||
}
|
||||
/*
|
||||
* Insert the new descriptor in the
|
||||
* client directory.
|
||||
*/
|
||||
SmpClientDirectory.Client [ClientIndex] = SmpClientDirectory.CandidateClient;
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/* Done */
|
||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
/**********************************************************************
|
||||
* SmCompleteClientInitialization/1
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Lookup the subsystem server descriptor given the process ID
|
||||
* of the subsystem server process.
|
||||
*/
|
||||
NTSTATUS NTAPI
|
||||
SmCompleteClientInitialization (ULONG ProcessId)
|
||||
{
|
||||
NTSTATUS Status = STATUS_NOT_FOUND;
|
||||
INT ClientIndex = SM_INVALID_CLIENT_INDEX;
|
||||
|
||||
DPRINT("SM: %s(%lu) called\n", __FUNCTION__, ProcessId);
|
||||
|
||||
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
||||
if (SmpClientDirectory.Count > 0)
|
||||
{
|
||||
for (ClientIndex = 0; ClientIndex < SM_MAX_CLIENT_COUNT; ClientIndex ++)
|
||||
{
|
||||
if ((NULL != SmpClientDirectory.Client [ClientIndex]) &&
|
||||
(ProcessId == SmpClientDirectory.Client [ClientIndex]->ServerProcessId))
|
||||
{
|
||||
SmpSetClientInitialized (SmpClientDirectory.Client [ClientIndex]);
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||
return Status;
|
||||
}
|
||||
/**********************************************************************
|
||||
* SmpDestroyClientByClientIndex/1 PRIVATE
|
||||
*/
|
||||
static NTSTATUS NTAPI
|
||||
SmpDestroyClientByClientIndex (INT ClientIndex)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PSM_CLIENT_DATA Client = NULL;
|
||||
|
||||
DPRINT("SM: %s(%d) called\n", __FUNCTION__, ClientIndex);
|
||||
|
||||
if (SM_INVALID_CLIENT_INDEX == ClientIndex)
|
||||
{
|
||||
DPRINT1("SM: %s: SM_INVALID_CLIENT_INDEX == ClientIndex!\n",
|
||||
__FUNCTION__);
|
||||
Status = STATUS_NOT_FOUND;
|
||||
}
|
||||
else
|
||||
{
|
||||
Client = SmpClientDirectory.Client [ClientIndex];
|
||||
SmpClientDirectory.Client [ClientIndex] = NULL;
|
||||
if (NULL != Client)
|
||||
{
|
||||
Status = SmpDestroyClientObject (Client, STATUS_SUCCESS);
|
||||
} else {
|
||||
DPRINT("SM:%s: NULL == Client[%d]!\n", __FUNCTION__,
|
||||
ClientIndex);
|
||||
Status = STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
}
|
||||
return Status;
|
||||
}
|
||||
/**********************************************************************
|
||||
* SmpTimeoutCandidateClient/1
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Give the candidate client time to bootstrap and complete
|
||||
* session initialization. If the client fails in any way,
|
||||
* drop the pending client and kill the process.
|
||||
*
|
||||
* ARGUMENTS
|
||||
* x: HANDLE for the candidate process.
|
||||
*
|
||||
* RETURN VALUE
|
||||
* NONE.
|
||||
*/
|
||||
static VOID NTAPI SmpTimeoutCandidateClient (PVOID x)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
HANDLE CandidateClientProcessHandle = (HANDLE) x;
|
||||
LARGE_INTEGER TimeOut;
|
||||
|
||||
DPRINT("SM: %s(%p) called\n", __FUNCTION__, x);
|
||||
|
||||
TimeOut.QuadPart = (LONGLONG) -300000000L; // 30s
|
||||
Status = NtWaitForSingleObject (CandidateClientProcessHandle,
|
||||
FALSE,
|
||||
& TimeOut);
|
||||
if (STATUS_TIMEOUT == Status)
|
||||
{
|
||||
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
||||
if (NULL != SmpClientDirectory.CandidateClient)
|
||||
{
|
||||
DPRINT("SM:%s: destroy candidate %p\n", __FUNCTION__,
|
||||
SmpClientDirectory.CandidateClient);
|
||||
Status = SmpDestroyClientObject (SmpClientDirectory.CandidateClient,
|
||||
STATUS_TIMEOUT);
|
||||
SmpClientDirectory.CandidateClient = NULL;
|
||||
}
|
||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||
}
|
||||
NtTerminateThread (NtCurrentThread(), 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:
|
||||
* STATUS_SUCCESS if all OK;
|
||||
* STATUS_DEVICE_BUSY if another SS is still booting;
|
||||
* STATUS_NO_MEMORY if client descriptor allocation failed;
|
||||
*
|
||||
*
|
||||
*/
|
||||
NTSTATUS NTAPI
|
||||
SmCreateClient (PRTL_USER_PROCESS_INFORMATION ProcessInfo, PWSTR ProgramName)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
DPRINT("SM: %s(%p, %S) called\n", __FUNCTION__, ProcessInfo->ProcessHandle, ProgramName);
|
||||
|
||||
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
||||
/*
|
||||
* Check if the candidate client slot is empty.
|
||||
*/
|
||||
if (NULL == SmpClientDirectory.CandidateClient)
|
||||
{
|
||||
/*
|
||||
* Check if there exist a free entry in the
|
||||
* SmpClientDirectory.Client array.
|
||||
*/
|
||||
if (SM_INVALID_CLIENT_INDEX == SmpGetFirstFreeClientEntry())
|
||||
{
|
||||
DPRINT("SM: %s(%p): out of memory!\n",
|
||||
__FUNCTION__, ProcessInfo->ProcessHandle);
|
||||
Status = STATUS_NO_MEMORY;
|
||||
}
|
||||
/*
|
||||
* Allocate the storage for client data
|
||||
*/
|
||||
SmpClientDirectory.CandidateClient =
|
||||
RtlAllocateHeap (SmpHeap,
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof (SM_CLIENT_DATA));
|
||||
if (NULL == SmpClientDirectory.CandidateClient)
|
||||
{
|
||||
DPRINT("SM: %s(%p): out of memory!\n",
|
||||
__FUNCTION__, ProcessInfo->ProcessHandle);
|
||||
Status = STATUS_NO_MEMORY;
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT("SM:%s(%p,%S): candidate is %p\n", __FUNCTION__,
|
||||
ProcessInfo, ProgramName, SmpClientDirectory.CandidateClient);
|
||||
/* Initialize the candidate client. */
|
||||
RtlInitializeCriticalSection(& SmpClientDirectory.CandidateClient->Lock);
|
||||
SmpClientDirectory.CandidateClient->ServerProcess =
|
||||
(HANDLE) ProcessInfo->ProcessHandle;
|
||||
SmpClientDirectory.CandidateClient->ServerProcessId =
|
||||
(DWORD_PTR) ProcessInfo->ClientId.UniqueProcess;
|
||||
/*
|
||||
* Copy the program name
|
||||
*/
|
||||
RtlCopyMemory (SmpClientDirectory.CandidateClient->ProgramName,
|
||||
ProgramName,
|
||||
SM_SB_NAME_MAX_LENGTH * sizeof(WCHAR));
|
||||
}
|
||||
} else {
|
||||
DPRINT1("SM: %s: CandidateClient %p pending!\n", __FUNCTION__,
|
||||
SmpClientDirectory.CandidateClient);
|
||||
Status = STATUS_DEVICE_BUSY;
|
||||
}
|
||||
|
||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||
|
||||
/* Create the timeout thread for external subsystems */
|
||||
if (_wcsicmp (ProgramName, L"Session Manager") && _wcsicmp (ProgramName, L"Debug"))
|
||||
{
|
||||
Status = RtlCreateUserThread (NtCurrentProcess(),
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
(PTHREAD_START_ROUTINE) SmpTimeoutCandidateClient,
|
||||
SmpClientDirectory.CandidateClient->ServerProcess,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM:%s: RtlCreateUserThread() failed (Status=%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
}
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
/**********************************************************************
|
||||
* SmpDestroyClient/1
|
||||
*
|
||||
* 1. close any handle
|
||||
* 2. kill client process
|
||||
* 3. release resources
|
||||
*/
|
||||
NTSTATUS NTAPI
|
||||
SmDestroyClient (ULONG SubsystemId)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
INT ClientIndex = SM_INVALID_CLIENT_INDEX;
|
||||
|
||||
DPRINT("SM: %s(%lu) called\n", __FUNCTION__, SubsystemId);
|
||||
|
||||
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
||||
ClientIndex = SmpLookupClient (SubsystemId);
|
||||
if (SM_INVALID_CLIENT_INDEX == ClientIndex)
|
||||
{
|
||||
DPRINT1("SM: %s: del req for non existent subsystem (id=%d)\n",
|
||||
__FUNCTION__, SubsystemId);
|
||||
return STATUS_NOT_FOUND;
|
||||
}
|
||||
Status = SmpDestroyClientByClientIndex (ClientIndex);
|
||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||
return Status;
|
||||
}
|
||||
#if 0
|
||||
/* === Utilities for SmQryInfo === */
|
||||
|
||||
/**********************************************************************
|
||||
* SmGetClientBasicInformation/1
|
||||
*/
|
||||
NTSTATUS FASTCALL
|
||||
SmGetClientBasicInformation (PSM_BASIC_INFORMATION i)
|
||||
{
|
||||
INT ClientIndex = 0;
|
||||
INT Index = 0;
|
||||
|
||||
DPRINT("SM: %s(%p) called\n", __FUNCTION__, i);
|
||||
|
||||
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
||||
|
||||
i->SubSystemCount = SmpClientDirectory.Count;
|
||||
i->Unused = 0;
|
||||
|
||||
if (SmpClientDirectory.Count > 0)
|
||||
{
|
||||
for (ClientIndex = 0; (ClientIndex < SM_MAX_CLIENT_COUNT); ClientIndex ++)
|
||||
{
|
||||
if ((NULL != SmpClientDirectory.Client [ClientIndex]) &&
|
||||
(Index < SM_QRYINFO_MAX_SS_COUNT))
|
||||
{
|
||||
i->SubSystem[Index].Id = SmpClientDirectory.Client [ClientIndex]->SubsystemId;
|
||||
i->SubSystem[Index].Flags = SmpClientDirectory.Client [ClientIndex]->Flags;
|
||||
i->SubSystem[Index].ProcessId = SmpClientDirectory.Client [ClientIndex]->ServerProcessId;
|
||||
++ Index;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* SmGetSubSystemInformation/1
|
||||
*/
|
||||
NTSTATUS FASTCALL
|
||||
SmGetSubSystemInformation (PSM_SUBSYSTEM_INFORMATION i)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
INT ClientIndex = SM_INVALID_CLIENT_INDEX;
|
||||
|
||||
DPRINT("SM: %s(%p) called\n", __FUNCTION__, i);
|
||||
|
||||
RtlEnterCriticalSection (& SmpClientDirectory.Lock);
|
||||
ClientIndex = SmpLookupClient (i->SubSystemId);
|
||||
if (SM_INVALID_CLIENT_INDEX == ClientIndex)
|
||||
{
|
||||
Status = STATUS_NOT_FOUND;
|
||||
}
|
||||
else
|
||||
{
|
||||
i->Flags = SmpClientDirectory.Client [ClientIndex]->Flags;
|
||||
i->ProcessId = SmpClientDirectory.Client [ClientIndex]->ServerProcessId;
|
||||
RtlCopyMemory (i->NameSpaceRootNode,
|
||||
SmpClientDirectory.Client [ClientIndex]->SbApiPortName,
|
||||
(SM_QRYINFO_MAX_ROOT_NODE * sizeof(i->NameSpaceRootNode[0])));
|
||||
}
|
||||
RtlLeaveCriticalSection (& SmpClientDirectory.Lock);
|
||||
return Status;
|
||||
}
|
||||
#endif
|
||||
/* EOF */
|
|
@ -1,171 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/debug.c
|
||||
* PURPOSE: Debug messages switch and router.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if 0
|
||||
|
||||
/* GLOBALS ***********************************************************/
|
||||
|
||||
HANDLE DbgSsApiPort = (HANDLE) 0;
|
||||
HANDLE DbgUiApiPort = (HANDLE) 0;
|
||||
HANDLE hSmDbgApiPort = (HANDLE) 0;
|
||||
|
||||
/* FUNCTIONS *********************************************************/
|
||||
|
||||
static VOID NTAPI
|
||||
DbgSsApiPortThread (PVOID dummy)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PORT_MESSAGE Request ;
|
||||
|
||||
RtlZeroMemory(&Request, sizeof(PORT_MESSAGE));
|
||||
while (TRUE)
|
||||
{
|
||||
Status = NtListenPort (DbgSsApiPort, & Request);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status);
|
||||
break;
|
||||
}
|
||||
/* TODO */
|
||||
}
|
||||
NtTerminateThread(NtCurrentThread(),Status);
|
||||
}
|
||||
|
||||
static VOID NTAPI
|
||||
DbgUiApiPortThread (PVOID dummy)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PORT_MESSAGE Request;
|
||||
|
||||
RtlZeroMemory(&Request, sizeof(PORT_MESSAGE));
|
||||
while (TRUE)
|
||||
{
|
||||
Status = NtListenPort (DbgUiApiPort, & Request);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status);
|
||||
break;
|
||||
}
|
||||
/* TODO */
|
||||
}
|
||||
NtTerminateThread(NtCurrentThread(),Status);
|
||||
}
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
SmpCreatePT (IN OUT PHANDLE hPort,
|
||||
IN LPWSTR wcPortName,
|
||||
IN ULONG ulMaxDataSize,
|
||||
IN ULONG ulMaxMessageSize,
|
||||
IN ULONG ulPoolCharge OPTIONAL,
|
||||
IN VOID (NTAPI * procServingThread)(PVOID) OPTIONAL,
|
||||
IN OUT PHANDLE phServingThread OPTIONAL)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
UNICODE_STRING PortName = { 0, 0, NULL };
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE Thread = (HANDLE) 0;
|
||||
CLIENT_ID Cid = {0, 0};
|
||||
|
||||
RtlInitUnicodeString (& PortName, wcPortName);
|
||||
InitializeObjectAttributes (& ObjectAttributes,
|
||||
& PortName,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = NtCreatePort (hPort,
|
||||
& ObjectAttributes,
|
||||
ulMaxDataSize,
|
||||
ulMaxMessageSize,
|
||||
ulPoolCharge);
|
||||
if(STATUS_SUCCESS != Status)
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
/* Create thread for DbgSsApiPort */
|
||||
RtlCreateUserThread(NtCurrentProcess(),
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
(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__);
|
||||
|
||||
/* Self register */
|
||||
Status = SmRegisterInternalSubsystem (L"Debug",
|
||||
(USHORT)-1,
|
||||
& hSmDbgApiPort);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("DBG:%s: SmRegisterInternalSubsystem failed with Status=%08lx\n",
|
||||
__FUNCTION__, Status);
|
||||
return Status;
|
||||
}
|
||||
/* Create the \DbgSsApiPort object (LPC) */
|
||||
Status = SmpCreatePT(& DbgSsApiPort,
|
||||
SM_DBGSS_PORT_NAME,
|
||||
0, /* MaxDataSize */
|
||||
sizeof(PORT_MESSAGE), /* 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 */
|
||||
sizeof(PORT_MESSAGE), /* 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;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* EOF */
|
||||
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/init.c
|
||||
* PURPOSE: Initialization.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
typedef NTSTATUS (* SM_INIT_ROUTINE)(VOID);
|
||||
|
||||
struct {
|
||||
BOOL Required;
|
||||
SM_INIT_ROUTINE EntryPoint;
|
||||
PCHAR ErrorMessage;
|
||||
} InitRoutine [] = {
|
||||
{TRUE, SmCreateHeap, "create private heap, aborting"},
|
||||
// {TRUE, SmCreateObjectDirectories, "create object directories"},
|
||||
// {TRUE, SmCreateApiPort, "create \\SmApiPort"},
|
||||
// {TRUE, SmCreateEnvironment, "create the system environment"},
|
||||
// {TRUE, SmSetEnvironmentVariables, "set system environment variables"},
|
||||
// {TRUE, SmInitDosDevices, "create dos device links"},
|
||||
// {TRUE, SmRunBootApplications, "run boot applications"},
|
||||
// {TRUE, SmProcessFileRenameList, "process the file rename list"},
|
||||
// {FALSE, SmUpdateEnvironment, "update environment variables"},
|
||||
// {FALSE, SmLoadKnownDlls, "preload system DLLs"},
|
||||
{TRUE, SmCreatePagingFiles, "create paging files"},
|
||||
// {TRUE, SmInitializeRegistry, "initialize the registry"},
|
||||
// {TRUE, SmInitializeClientManagement, "initialize client management"},
|
||||
// {TRUE, SmLoadSubsystems, "load subsystems"}
|
||||
};
|
||||
|
||||
NTSTATUS
|
||||
InitSessionManager(VOID)
|
||||
{
|
||||
UINT i = 0;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
for (i=0; i < (sizeof InitRoutine / sizeof InitRoutine[0]); i++)
|
||||
{
|
||||
Status = InitRoutine[i].EntryPoint();
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: %s: failed to %s (Status=%lx)\n",
|
||||
__FUNCTION__,
|
||||
InitRoutine[i].ErrorMessage,
|
||||
Status);
|
||||
if (InitRoutine[i].Required)
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/initdosdev.c
|
||||
* PURPOSE: Define symbolic links to kernel devices (MS-DOS names).
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if 0
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
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|OBJ_CASE_INSENSITIVE|OBJ_OPENIF,
|
||||
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);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -1,347 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/initenv.c
|
||||
* PURPOSE: Environment initialization.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* GLOBALS */
|
||||
|
||||
PWSTR SmSystemEnvironment = NULL;
|
||||
|
||||
|
||||
/* FUNCTIONS */
|
||||
|
||||
NTSTATUS
|
||||
SmCreateEnvironment(VOID)
|
||||
{
|
||||
return RtlCreateEnvironment(TRUE, &SmSystemEnvironment);
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
|
||||
static NTSTATUS
|
||||
SmpSetEnvironmentVariable(IN PVOID Context,
|
||||
IN PWSTR ValueName,
|
||||
IN PWSTR ValueData)
|
||||
{
|
||||
UNICODE_STRING EnvVariable;
|
||||
UNICODE_STRING EnvValue;
|
||||
|
||||
RtlInitUnicodeString(&EnvVariable,
|
||||
ValueName);
|
||||
RtlInitUnicodeString(&EnvValue,
|
||||
ValueData);
|
||||
return RtlSetEnvironmentVariable(Context,
|
||||
&EnvVariable,
|
||||
&EnvValue);
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
SmpEnvironmentQueryRoutine(IN PWSTR ValueName,
|
||||
IN ULONG ValueType,
|
||||
IN PVOID ValueData,
|
||||
IN ULONG ValueLength,
|
||||
IN PVOID Context,
|
||||
IN PVOID EntryContext)
|
||||
{
|
||||
DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength);
|
||||
|
||||
if (ValueType != REG_SZ && ValueType != REG_EXPAND_SZ)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
DPRINT("ValueData '%S'\n", (PWSTR)ValueData);
|
||||
return SmpSetEnvironmentVariable(Context,ValueName,(PWSTR)ValueData);
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
SmSetEnvironmentVariables(VOID)
|
||||
{
|
||||
SYSTEM_BASIC_INFORMATION BasicInformation;
|
||||
SYSTEM_PROCESSOR_INFORMATION ProcessorInformation;
|
||||
RTL_QUERY_REGISTRY_TABLE QueryTable[3];
|
||||
UNICODE_STRING Identifier;
|
||||
UNICODE_STRING VendorIdentifier;
|
||||
WCHAR Buffer[256];
|
||||
UNICODE_STRING EnvironmentKeyName;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
HANDLE EnvironmentKey;
|
||||
UNICODE_STRING VariableName;
|
||||
PWSTR VariableData;
|
||||
NTSTATUS Status;
|
||||
|
||||
Status = NtQuerySystemInformation(SystemProcessorInformation,
|
||||
&ProcessorInformation,
|
||||
sizeof(SYSTEM_PROCESSOR_INFORMATION),
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: Failed to retrieve system processor information (Status %08lx)", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = NtQuerySystemInformation(SystemBasicInformation,
|
||||
&BasicInformation,
|
||||
sizeof(SYSTEM_BASIC_INFORMATION),
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: Failed to retrieve system basic information (Status %08lx)", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&EnvironmentKeyName,
|
||||
L"\\Registry\\Machine\\System\\CurrentControlSet\\Control\\Session Manager\\Environment");
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&EnvironmentKeyName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* Open the system environment key */
|
||||
Status = NtOpenKey(&EnvironmentKey,
|
||||
GENERIC_WRITE,
|
||||
&ObjectAttributes);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: Failed to open the environment key (Status %08lx)", Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Set the 'NUMBER_OF_PROCESSORS' system environment variable */
|
||||
RtlInitUnicodeString(&VariableName,
|
||||
L"NUMBER_OF_PROCESSORS");
|
||||
|
||||
swprintf(Buffer, L"%lu", BasicInformation.NumberOfProcessors);
|
||||
|
||||
Status = NtSetValueKey(EnvironmentKey,
|
||||
&VariableName,
|
||||
0,
|
||||
REG_SZ,
|
||||
Buffer,
|
||||
(wcslen(Buffer) + 1) * sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: Failed to set the NUMBER_OF_PROCESSORS environment variable (Status %08lx)", Status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Set the 'OS' system environment variable */
|
||||
RtlInitUnicodeString(&VariableName,
|
||||
L"OS");
|
||||
|
||||
VariableData = L"ReactOS";
|
||||
|
||||
Status = NtSetValueKey(EnvironmentKey,
|
||||
&VariableName,
|
||||
0,
|
||||
REG_SZ,
|
||||
VariableData,
|
||||
(wcslen(VariableData) + 1) * sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: Failed to set the OS environment variable (Status %08lx)", Status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Set the 'PROCESSOR_ARCHITECTURE' system environment variable */
|
||||
RtlInitUnicodeString(&VariableName,
|
||||
L"PROCESSOR_ARCHITECTURE");
|
||||
|
||||
switch (ProcessorInformation.ProcessorArchitecture)
|
||||
{
|
||||
case PROCESSOR_ARCHITECTURE_INTEL:
|
||||
VariableData = L"x86";
|
||||
break;
|
||||
|
||||
case PROCESSOR_ARCHITECTURE_PPC:
|
||||
VariableData = L"PPC";
|
||||
break;
|
||||
|
||||
case PROCESSOR_ARCHITECTURE_ARM:
|
||||
VariableData = L"ARM";
|
||||
break;
|
||||
|
||||
case PROCESSOR_ARCHITECTURE_AMD64:
|
||||
VariableData = L"AMD64";
|
||||
break;
|
||||
|
||||
default:
|
||||
VariableData = L"Unknown";
|
||||
break;
|
||||
}
|
||||
|
||||
Status = NtSetValueKey(EnvironmentKey,
|
||||
&VariableName,
|
||||
0,
|
||||
REG_SZ,
|
||||
VariableData,
|
||||
(wcslen(VariableData) + 1) * sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: Failed to set the PROCESSOR_ARCHITECTURE environment variable (Status %08lx)", Status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Set the 'PROCESSOR_LEVEL' system environment variable */
|
||||
RtlInitUnicodeString(&VariableName,
|
||||
L"PROCESSOR_LEVEL");
|
||||
|
||||
swprintf(Buffer, L"%lu", ProcessorInformation.ProcessorLevel);
|
||||
|
||||
Status = NtSetValueKey(EnvironmentKey,
|
||||
&VariableName,
|
||||
0,
|
||||
REG_SZ,
|
||||
Buffer,
|
||||
(wcslen(Buffer) + 1) * sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: Failed to set the PROCESSOR_LEVEL environment variable (Status %08lx)", Status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Set the 'PROCESSOR_REVISION' system environment variable */
|
||||
RtlInitUnicodeString(&VariableName,
|
||||
L"PROCESSOR_REVISION");
|
||||
|
||||
swprintf(Buffer, L"%04x", ProcessorInformation.ProcessorRevision);
|
||||
|
||||
Status = NtSetValueKey(EnvironmentKey,
|
||||
&VariableName,
|
||||
0,
|
||||
REG_SZ,
|
||||
Buffer,
|
||||
(wcslen(Buffer) + 1) * sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: Failed to set the PROCESSOR_REVISION environment variable (Status %08lx)", Status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* Set the 'PROCESSOR_IDENTIFIER' system environment variable */
|
||||
RtlInitUnicodeString(&Identifier, NULL);
|
||||
RtlInitUnicodeString(&VendorIdentifier, NULL);
|
||||
|
||||
RtlZeroMemory(&QueryTable,
|
||||
sizeof(QueryTable));
|
||||
|
||||
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
|
||||
QueryTable[0].Name = L"Identifier";
|
||||
QueryTable[0].EntryContext = &Identifier;
|
||||
|
||||
QueryTable[1].Flags = RTL_QUERY_REGISTRY_DIRECT;
|
||||
QueryTable[1].Name = L"VendorIdentifier";
|
||||
QueryTable[1].EntryContext = &VendorIdentifier;
|
||||
|
||||
Status = RtlQueryRegistryValues(RTL_REGISTRY_ABSOLUTE,
|
||||
L"\\Registry\\Machine\\Hardware\\Description\\System\\CentralProcessor\\0",
|
||||
QueryTable,
|
||||
NULL,
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: Failed to retrieve processor Identifier and/or VendorIdentifier (Status %08lx)", Status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
DPRINT("SM: szIdentifier: %wZ\n" , &Identifier);
|
||||
DPRINT("SM: szVendorIdentifier: %wZ\n", &VendorIdentifier);
|
||||
|
||||
RtlInitUnicodeString(&VariableName, L"PROCESSOR_IDENTIFIER");
|
||||
swprintf(Buffer, L"%wZ, %wZ", &Identifier, &VendorIdentifier);
|
||||
RtlFreeUnicodeString(&VendorIdentifier);
|
||||
RtlFreeUnicodeString(&Identifier);
|
||||
|
||||
Status = NtSetValueKey(EnvironmentKey,
|
||||
&VariableName,
|
||||
0,
|
||||
REG_SZ,
|
||||
Buffer,
|
||||
(wcslen(Buffer) + 1) * sizeof(WCHAR));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: Failed to set the PROCESSOR_IDENTIFIER environment variable (Status %08lx)", Status);
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
/* Close the handle */
|
||||
NtClose(EnvironmentKey);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* Set environment variables from registry
|
||||
*/
|
||||
NTSTATUS
|
||||
SmUpdateEnvironment(VOID)
|
||||
{
|
||||
//RTL_QUERY_REGISTRY_TABLE QueryTable[2];
|
||||
WCHAR ValueBuffer[MAX_PATH];
|
||||
NTSTATUS Status;
|
||||
#ifndef NDEBUG
|
||||
ULONG ii;
|
||||
PWSTR envp;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* 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);
|
||||
|
||||
#ifndef NDEBUG
|
||||
/* Print all environment varaibles */
|
||||
ii = 0;
|
||||
envp = SmSystemEnvironment;
|
||||
DbgPrint("SmUpdateEnvironment:\n");
|
||||
while (*envp)
|
||||
{
|
||||
DbgPrint(" %u: %S\n", ii++, envp);
|
||||
envp += wcslen(envp) + 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
return Status;
|
||||
}
|
||||
#endif
|
||||
/* EOF */
|
|
@ -1,30 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/initheap.c
|
||||
* PURPOSE: Create the SM private heap.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
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 */
|
|
@ -1,452 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/initmv.c
|
||||
* PURPOSE: Process the file rename list.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if 0
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
/*++
|
||||
* @name SmpDeleteFile
|
||||
*
|
||||
* The SmpDeleteFile function deletes a specify file.
|
||||
*
|
||||
* @param lpFileName
|
||||
* the name of a file which should be deleted
|
||||
*
|
||||
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL
|
||||
* othwerwise.
|
||||
*
|
||||
* @remarks
|
||||
* This function is called by SmpMoveFilesQueryRoutine().
|
||||
*
|
||||
*
|
||||
*--*/
|
||||
NTSTATUS
|
||||
SmpDeleteFile( IN LPCWSTR lpFileName )
|
||||
{
|
||||
FILE_DISPOSITION_INFORMATION FileDispInfo;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
UNICODE_STRING FileNameU;
|
||||
HANDLE FileHandle;
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("SmpDeleteFile ( %S )\n", lpFileName);
|
||||
|
||||
if( !lpFileName )
|
||||
return (STATUS_INVALID_PARAMETER);
|
||||
|
||||
RtlInitUnicodeString(&FileNameU, lpFileName);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&FileNameU,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtCreateFile (&FileHandle,
|
||||
DELETE,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
NULL,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
FILE_OPEN,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
if( !NT_SUCCESS(Status) ) {
|
||||
DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
FileDispInfo.DeleteFile = TRUE;
|
||||
|
||||
Status = NtSetInformationFile(
|
||||
FileHandle,
|
||||
&IoStatusBlock,
|
||||
&FileDispInfo,
|
||||
sizeof(FILE_DISPOSITION_INFORMATION),
|
||||
FileDispositionInformation );
|
||||
|
||||
NtClose(FileHandle);
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
/*++
|
||||
* @name SmpMoveFile
|
||||
*
|
||||
* The SmpMoveFile function deletes a specify file.
|
||||
*
|
||||
* @param lpExistingFileName
|
||||
* the name of an existing file which should be removed
|
||||
*
|
||||
* @param lpNewFileName
|
||||
* a new name of an existing file.
|
||||
*
|
||||
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL
|
||||
* othwerwise.
|
||||
*
|
||||
* @remarks
|
||||
* This function called from the SmpMoveFilesQueryRoutine function.
|
||||
*
|
||||
*
|
||||
*--*/
|
||||
NTSTATUS
|
||||
SmpMoveFile( IN LPCWSTR lpExistingFileName,
|
||||
IN LPCWSTR lpNewFileName
|
||||
)
|
||||
{
|
||||
PFILE_RENAME_INFORMATION FileRenameInfo;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
UNICODE_STRING ExistingFileNameU;
|
||||
HANDLE FileHandle;
|
||||
DWORD FileNameSize;
|
||||
BOOLEAN ReplaceIfExists;
|
||||
NTSTATUS Status;
|
||||
|
||||
if( !lpExistingFileName || !lpNewFileName )
|
||||
return (STATUS_INVALID_PARAMETER);
|
||||
|
||||
DPRINT("SmpMoveFile (%S, %S)\n", lpExistingFileName, lpNewFileName);
|
||||
|
||||
RtlInitUnicodeString(&ExistingFileNameU, lpExistingFileName);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&ExistingFileNameU,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtCreateFile (&FileHandle,
|
||||
FILE_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
NULL,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
FILE_OPEN,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
if( !NT_SUCCESS(Status) ) {
|
||||
DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
FileNameSize = wcslen(lpNewFileName)*sizeof(*lpNewFileName);
|
||||
FileRenameInfo = RtlAllocateHeap(
|
||||
RtlGetProcessHeap(),
|
||||
HEAP_ZERO_MEMORY,
|
||||
sizeof(FILE_RENAME_INFORMATION)+FileNameSize);
|
||||
if( !FileRenameInfo ) {
|
||||
DPRINT("RtlAllocateHeap failed\n");
|
||||
NtClose(FileHandle);
|
||||
return (STATUS_NO_MEMORY);
|
||||
}
|
||||
|
||||
if( L'!' == *lpNewFileName ) {
|
||||
lpNewFileName++;
|
||||
FileNameSize -= sizeof(*lpNewFileName);
|
||||
ReplaceIfExists = TRUE;
|
||||
}
|
||||
else {
|
||||
ReplaceIfExists = FALSE;
|
||||
}
|
||||
|
||||
FileRenameInfo->RootDirectory = NULL;
|
||||
FileRenameInfo->ReplaceIfExists = ReplaceIfExists;
|
||||
FileRenameInfo->FileNameLength = FileNameSize;
|
||||
RtlCopyMemory(FileRenameInfo->FileName, lpNewFileName, FileNameSize);
|
||||
|
||||
Status = NtSetInformationFile(
|
||||
FileHandle,
|
||||
&IoStatusBlock,
|
||||
FileRenameInfo,
|
||||
sizeof(FILE_RENAME_INFORMATION)+FileNameSize,
|
||||
FileRenameInformation );
|
||||
|
||||
RtlFreeHeap(RtlGetProcessHeap(), 0, FileRenameInfo);
|
||||
|
||||
/* FIXME: After the FileRenameInformation parameter will be implemented into the fs driver
|
||||
the following code can be removed */
|
||||
if( STATUS_NOT_IMPLEMENTED == Status )
|
||||
{
|
||||
HANDLE FileHandleNew;
|
||||
UNICODE_STRING NewFileNameU;
|
||||
FILE_BASIC_INFORMATION FileBasicInfo;
|
||||
UCHAR *lpBuffer = NULL;
|
||||
SIZE_T RegionSize = 0x10000;
|
||||
LARGE_INTEGER BytesCopied;
|
||||
BOOL EndOfFileFound;
|
||||
|
||||
Status = NtQueryInformationFile(
|
||||
FileHandle,
|
||||
&IoStatusBlock,
|
||||
&FileBasicInfo,
|
||||
sizeof(FILE_BASIC_INFORMATION),
|
||||
FileBasicInformation);
|
||||
if( !NT_SUCCESS(Status) ) {
|
||||
DPRINT("NtQueryInformationFile() failed (Status %lx)\n", Status);
|
||||
NtClose(FileHandle);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&NewFileNameU, lpNewFileName);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&NewFileNameU,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtCreateFile (&FileHandleNew,
|
||||
FILE_ALL_ACCESS,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
NULL,
|
||||
FILE_ATTRIBUTE_NORMAL,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
ReplaceIfExists ? FILE_OVERWRITE_IF : FILE_CREATE,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
if( !NT_SUCCESS(Status) ) {
|
||||
DPRINT("NtCreateFile() failed (Status %lx)\n", Status);
|
||||
NtClose(FileHandle);
|
||||
return (Status);
|
||||
}
|
||||
|
||||
Status = NtAllocateVirtualMemory(
|
||||
NtCurrentProcess(),
|
||||
(PVOID *)&lpBuffer,
|
||||
2,
|
||||
&RegionSize,
|
||||
MEM_RESERVE | MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
if( !NT_SUCCESS(Status) ) {
|
||||
DPRINT("NtAllocateVirtualMemory() failed (Status %lx)\n", Status);
|
||||
NtClose(FileHandle);
|
||||
SmpDeleteFile(lpNewFileName);
|
||||
return (Status);
|
||||
}
|
||||
BytesCopied.QuadPart = 0;
|
||||
EndOfFileFound = FALSE;
|
||||
while( !EndOfFileFound
|
||||
&& NT_SUCCESS(Status) )
|
||||
{
|
||||
Status = NtReadFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
lpBuffer,
|
||||
RegionSize,
|
||||
NULL,
|
||||
NULL);
|
||||
if( NT_SUCCESS(Status) ) {
|
||||
Status = NtWriteFile(FileHandleNew,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&IoStatusBlock,
|
||||
lpBuffer,
|
||||
IoStatusBlock.Information,
|
||||
NULL,
|
||||
NULL);
|
||||
if( NT_SUCCESS(Status) ) {
|
||||
BytesCopied.QuadPart += IoStatusBlock.Information;
|
||||
}
|
||||
else {
|
||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( STATUS_END_OF_FILE == Status ) {
|
||||
EndOfFileFound = TRUE;
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else {
|
||||
DPRINT("NtWriteFile() failed (Status %lx)\n", Status);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
NtFreeVirtualMemory(NtCurrentProcess(),
|
||||
(PVOID *)&lpBuffer,
|
||||
&RegionSize,
|
||||
MEM_RELEASE);
|
||||
|
||||
Status = NtQueryInformationFile(
|
||||
FileHandleNew,
|
||||
&IoStatusBlock,
|
||||
&FileBasicInfo,
|
||||
sizeof(FILE_BASIC_INFORMATION),
|
||||
FileBasicInformation);
|
||||
if( !NT_SUCCESS(Status) ) {
|
||||
DPRINT("NtQueryInformationFile() failed (Status %lx)\n", Status);
|
||||
}
|
||||
|
||||
Status = NtSetInformationFile(FileHandleNew,
|
||||
&IoStatusBlock,
|
||||
&FileBasicInfo,
|
||||
sizeof(FILE_BASIC_INFORMATION),
|
||||
FileBasicInformation);
|
||||
if( !NT_SUCCESS(Status) ) {
|
||||
DPRINT("NtSetInformationFile() failed (Status %lx)\n", Status);
|
||||
}
|
||||
NtClose(FileHandleNew);
|
||||
NtClose(FileHandle);
|
||||
|
||||
SmpDeleteFile(lpExistingFileName);
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
NtClose(FileHandle);
|
||||
|
||||
return (Status);
|
||||
}
|
||||
|
||||
|
||||
/*++
|
||||
* @name SmpMoveFilesQueryRoutine
|
||||
*
|
||||
* The SmpMoveFilesQueryRoutine function processes registry entries.
|
||||
*
|
||||
* @param ValueName
|
||||
* The name of the value.
|
||||
*
|
||||
* @param ValueType
|
||||
* The type of the value.
|
||||
*
|
||||
* @param ValueData
|
||||
* The null-terminated data for the value.
|
||||
*
|
||||
* @param ValueLength
|
||||
* The length of ValueData.
|
||||
*
|
||||
* @param Context
|
||||
* NULL
|
||||
*
|
||||
* @param EntryContext
|
||||
* NULL
|
||||
*
|
||||
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL
|
||||
* othwerwise.
|
||||
*
|
||||
* @remarks
|
||||
*
|
||||
*
|
||||
*
|
||||
*--*/
|
||||
static NTSTATUS NTAPI
|
||||
SmpMoveFilesQueryRoutine(IN PWSTR ValueName,
|
||||
IN ULONG ValueType,
|
||||
IN PVOID ValueData,
|
||||
IN ULONG ValueLength,
|
||||
IN PVOID Context,
|
||||
IN PVOID EntryContext)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
static LPWSTR FistFileName = NULL;
|
||||
|
||||
DPRINT("SmpMoveFilesQueryRoutine() called \n");
|
||||
DPRINT("ValueData = %S \n", (PWSTR) ValueData);
|
||||
|
||||
if( !FistFileName )
|
||||
{
|
||||
/* save a first file name */
|
||||
FistFileName = ValueData;
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
if( 0 == *((LPWSTR)ValueData) ) {
|
||||
/* delete if second file name is absent */
|
||||
Status = SmpDeleteFile( FistFileName );
|
||||
} else {
|
||||
/* remove a file */
|
||||
Status = SmpMoveFile( FistFileName, (LPCWSTR)ValueData );
|
||||
}
|
||||
FistFileName = NULL;
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/*++
|
||||
* @name SmProcessFileRenameList
|
||||
* @implemented
|
||||
*
|
||||
* The SmProcessFileRenameList function moves or deletes files thats have been added to the specify registry key for delayed moving.
|
||||
*
|
||||
* @param VOID
|
||||
*
|
||||
* @return STATUS_SUCCESS in case of success, STATUS_UNSUCCESSFUL
|
||||
* othwerwise.
|
||||
*
|
||||
* @remarks
|
||||
* This function reads the following registry value:
|
||||
* HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Session Manager\PendingFileRenameOperations
|
||||
* This registry value is of type REG_MULTI_SZ. The each operation is specifed as two file names.
|
||||
* A first name is a source file, a second name is a destination file.
|
||||
* In the case of deleting operation a second file name must be the empty string.
|
||||
* For exapmle:
|
||||
* szxSrcFile\0szxDestFile\0\0 <-- the szxSrcFile file will be renamed to the szxDestFile file
|
||||
* szxSomeFile\0\0\0 <-- the szxSomeFile file will be removed
|
||||
* After it will be done, the registry value will be deleted.
|
||||
*
|
||||
*
|
||||
*--*/
|
||||
NTSTATUS
|
||||
SmProcessFileRenameList( VOID )
|
||||
{
|
||||
RTL_QUERY_REGISTRY_TABLE QueryTable[2];
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("SmProcessFileRenameList() called\n");
|
||||
|
||||
RtlZeroMemory( &QueryTable, sizeof(QueryTable) );
|
||||
QueryTable[0].Name = L"PendingFileRenameOperations";
|
||||
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DELETE;
|
||||
QueryTable[0].DefaultType = REG_NONE;
|
||||
QueryTable[0].QueryRoutine = SmpMoveFilesQueryRoutine;
|
||||
|
||||
Status = RtlQueryRegistryValues(
|
||||
RTL_REGISTRY_CONTROL,
|
||||
L"\\Session Manager",
|
||||
QueryTable,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if( !NT_SUCCESS(Status) ) {
|
||||
DPRINT("RtlQueryRegistryValues() failed (Status %lx)\n", Status);
|
||||
}
|
||||
|
||||
/* FIXME: RtlQueryRegistryValues can return an error status if the PendingFileRenameOperations value
|
||||
does not exist, in this case smss hungs, therefore we always return STATUS_SUCCESS */
|
||||
return (STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -1,75 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/initobdir.c
|
||||
* PURPOSE: Object directories.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if 0
|
||||
static NTSTATUS NTAPI
|
||||
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;
|
||||
|
||||
DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength);
|
||||
DPRINT("ValueData '%S'\n", (PWSTR)ValueData);
|
||||
if (ValueType != REG_SZ)
|
||||
{
|
||||
return(STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
RtlInitUnicodeString(&UnicodeString,
|
||||
(PWSTR)ValueData);
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&UnicodeString,
|
||||
OBJ_OPENIF,
|
||||
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);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -1,527 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/initpage.c
|
||||
* PURPOSE: Paging file support.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if 1
|
||||
|
||||
#define GIGABYTE (1024 * 1024 * 1024) /* One Gigabyte */
|
||||
|
||||
static NTSTATUS NTAPI
|
||||
SmpPagingFilesQueryRoutine(PWSTR ValueName,
|
||||
ULONG ValueType,
|
||||
PVOID ValueData,
|
||||
ULONG ValueLength,
|
||||
PVOID Context,
|
||||
PVOID EntryContext)
|
||||
{
|
||||
UNICODE_STRING FileName;
|
||||
LARGE_INTEGER InitialSize = {{0, 0}};
|
||||
LARGE_INTEGER MaximumSize = {{0, 0}};
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PWSTR p, ValueString = (PWSTR)ValueData;
|
||||
WCHAR RootDriveLetter[5] = {0};
|
||||
|
||||
if (ValueLength > 3 * sizeof(WCHAR) &&
|
||||
(ValueLength % sizeof(WCHAR) != 0 ||
|
||||
ValueString[(ValueLength / sizeof(WCHAR)) - 1] != L'\0'))
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
if (ValueType != REG_SZ)
|
||||
{
|
||||
return STATUS_INVALID_PARAMETER_2;
|
||||
}
|
||||
|
||||
/*
|
||||
* Format: "<path>[ <initial_size>[ <maximum_size>]]"
|
||||
*/
|
||||
if ((p = wcschr(ValueString, L' ')) != 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;
|
||||
}
|
||||
}
|
||||
|
||||
if (!RtlDosPathNameToNtPathName_U (ValueString,
|
||||
&FileName,
|
||||
NULL,
|
||||
NULL))
|
||||
{
|
||||
return STATUS_OBJECT_PATH_INVALID;
|
||||
}
|
||||
|
||||
/* If there is only a file name or if initial and max are both 0
|
||||
* the system will pick the sizes. Then it makes intial the size of phyical memory
|
||||
* and makes max the size of 1.5 * initial. If there isnt enough free space then it will
|
||||
* fall back to intial 20% of free space and max 25%. There is a max of 1 gig before
|
||||
* it doesnt make it bigger. */
|
||||
if ((InitialSize.QuadPart == 0 && MaximumSize.QuadPart == 0) || p == NULL)
|
||||
{
|
||||
FILE_FS_SIZE_INFORMATION FileFsSize;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
HANDLE hFile;
|
||||
SYSTEM_BASIC_INFORMATION SysBasicInfo;
|
||||
UNICODE_STRING NtPathU;
|
||||
LARGE_INTEGER FreeBytes = {{0, 0}};
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
|
||||
DPRINT("System managed pagefile...\n");
|
||||
/* Make sure the path that is given for the file actually has the drive in it.
|
||||
At this point if there is not file name, no sizes will be set therefore no page
|
||||
file will be created */
|
||||
if (wcslen(ValueString) <= 3 ||
|
||||
ValueString[1] != L':' ||
|
||||
ValueString[2] != L'\\')
|
||||
{
|
||||
DPRINT1("Invalid path for pagefile.\n");
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
Status = NtQuerySystemInformation(SystemBasicInformation,
|
||||
&SysBasicInfo,
|
||||
sizeof(SysBasicInfo),
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Could not query for physical memory size.\n");
|
||||
goto Cleanup;
|
||||
}
|
||||
DPRINT("PageSize: %d, PhysicalPages: %d, TotalMem: %d\n", SysBasicInfo.PageSize, SysBasicInfo.NumberOfPhysicalPages, (SysBasicInfo.NumberOfPhysicalPages * SysBasicInfo.PageSize) / 1024);
|
||||
|
||||
InitialSize.QuadPart = SysBasicInfo.NumberOfPhysicalPages *
|
||||
SysBasicInfo.PageSize;
|
||||
MaximumSize.QuadPart = InitialSize.QuadPart * 2;
|
||||
|
||||
DPRINT("InitialSize: %I64d PhysicalPages: %lu PageSize: %lu\n",InitialSize.QuadPart,SysBasicInfo.NumberOfPhysicalPages,SysBasicInfo.PageSize);
|
||||
|
||||
/* copy the drive letter, the colon and the slash,
|
||||
tack a null on the end */
|
||||
RootDriveLetter[0] = ValueString[0];
|
||||
RootDriveLetter[1] = L':';
|
||||
RootDriveLetter[2] = L'\\';
|
||||
RootDriveLetter[3] = L'\0';
|
||||
DPRINT("Root drive X:\\...\"%S\"\n",RootDriveLetter);
|
||||
|
||||
if (!RtlDosPathNameToNtPathName_U(RootDriveLetter,
|
||||
&NtPathU,
|
||||
NULL,
|
||||
NULL))
|
||||
{
|
||||
DPRINT1("Invalid path to root of drive\n");
|
||||
Status = STATUS_OBJECT_PATH_INVALID;
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&NtPathU,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* Get a handle to the root to find the free space on the drive */
|
||||
Status = NtCreateFile(&hFile,
|
||||
0,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
NULL,
|
||||
0,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
FILE_OPEN,
|
||||
0,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
RtlFreeHeap(RtlGetProcessHeap(),
|
||||
0,
|
||||
NtPathU.Buffer);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Could not open a handle to the volume.\n");
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
Status = NtQueryVolumeInformationFile(hFile,
|
||||
&IoStatusBlock,
|
||||
&FileFsSize,
|
||||
sizeof(FILE_FS_SIZE_INFORMATION),
|
||||
FileFsSizeInformation);
|
||||
|
||||
NtClose(hFile);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Querying the volume free space failed!\n");
|
||||
goto Cleanup;
|
||||
}
|
||||
|
||||
FreeBytes.QuadPart = FileFsSize.BytesPerSector *
|
||||
FileFsSize.SectorsPerAllocationUnit *
|
||||
FileFsSize.AvailableAllocationUnits.QuadPart;
|
||||
|
||||
DPRINT("Free bytes: %I64d Inital Size based on memory: %I64d \n",FreeBytes.QuadPart,InitialSize.QuadPart);
|
||||
|
||||
|
||||
if (InitialSize.QuadPart > (FreeBytes.QuadPart / 4) || InitialSize.QuadPart == 0)
|
||||
{
|
||||
DPRINT("Inital Size took more then 25%% of free space\n");
|
||||
/* Set by percentage of free space
|
||||
* intial is 20%, and max is 25% */
|
||||
InitialSize.QuadPart = FreeBytes.QuadPart / 5;
|
||||
MaximumSize.QuadPart = FreeBytes.QuadPart / 4;
|
||||
/* The page file is more then a gig, size it down */
|
||||
if (InitialSize.QuadPart > GIGABYTE)
|
||||
{
|
||||
InitialSize.QuadPart = GIGABYTE;
|
||||
MaximumSize.QuadPart = (ULONGLONG)GIGABYTE * 3 / 2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/* FIXME */
|
||||
if (InitialSize.QuadPart > (ULONGLONG)GIGABYTE * 2)
|
||||
InitialSize.QuadPart = (ULONGLONG)GIGABYTE * 2;
|
||||
if (MaximumSize.QuadPart > (ULONGLONG)GIGABYTE * 2)
|
||||
MaximumSize.QuadPart = (ULONGLONG)GIGABYTE * 2;
|
||||
|
||||
/* Make sure that max is not smaller then initial */
|
||||
if (InitialSize.QuadPart > MaximumSize.QuadPart)
|
||||
{
|
||||
DPRINT("Max page file size was bigger then inital.\n");
|
||||
MaximumSize.QuadPart = InitialSize.QuadPart;
|
||||
}
|
||||
|
||||
DPRINT("Creating paging file %wZ with size %I64d KB\n",
|
||||
&FileName, InitialSize.QuadPart / 1024);
|
||||
|
||||
Status = NtCreatePagingFile(&FileName,
|
||||
&InitialSize,
|
||||
&MaximumSize,
|
||||
0);
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Creation of paging file %wZ with size %I64d KB failed (status 0x%x)\n",
|
||||
&FileName, InitialSize.QuadPart / 1024, Status);
|
||||
}
|
||||
|
||||
Cleanup:
|
||||
RtlFreeHeap(RtlGetProcessHeap(),
|
||||
0,
|
||||
FileName.Buffer);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
SmpGetFreeDiskSpace(IN PWSTR PageFileName,
|
||||
OUT PLARGE_INTEGER FreeDiskSpaceInMB)
|
||||
{
|
||||
FILE_FS_SIZE_INFORMATION FileFsSize;
|
||||
IO_STATUS_BLOCK IoStatusBlock;
|
||||
HANDLE hFile;
|
||||
UNICODE_STRING NtPathU;
|
||||
LARGE_INTEGER FreeBytes;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
WCHAR RootPath[5];
|
||||
NTSTATUS Status;
|
||||
|
||||
/*
|
||||
* copy the drive letter, the colon and the slash,
|
||||
* tack a null on the end
|
||||
*/
|
||||
RootPath[0] = PageFileName[0];
|
||||
RootPath[1] = L':';
|
||||
RootPath[2] = L'\\';
|
||||
RootPath[3] = L'\0';
|
||||
|
||||
DPRINT("Root drive X:\\...\"%S\"\n",RootPath);
|
||||
|
||||
if (!RtlDosPathNameToNtPathName_U(RootPath,
|
||||
&NtPathU,
|
||||
NULL,
|
||||
NULL))
|
||||
{
|
||||
DPRINT1("Invalid path to root of drive\n");
|
||||
return STATUS_OBJECT_PATH_INVALID;
|
||||
}
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&NtPathU,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/* Get a handle to the root to find the free space on the drive */
|
||||
Status = NtCreateFile(&hFile,
|
||||
0,
|
||||
&ObjectAttributes,
|
||||
&IoStatusBlock,
|
||||
NULL,
|
||||
0,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
FILE_OPEN,
|
||||
0,
|
||||
NULL,
|
||||
0);
|
||||
|
||||
RtlFreeHeap(RtlGetProcessHeap(),
|
||||
0,
|
||||
NtPathU.Buffer);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Could not open a handle to the volume.\n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = NtQueryVolumeInformationFile(hFile,
|
||||
&IoStatusBlock,
|
||||
&FileFsSize,
|
||||
sizeof(FILE_FS_SIZE_INFORMATION),
|
||||
FileFsSizeInformation);
|
||||
|
||||
NtClose(hFile);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Querying the volume free space failed!\n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
FreeBytes.QuadPart = FileFsSize.BytesPerSector *
|
||||
FileFsSize.SectorsPerAllocationUnit *
|
||||
FileFsSize.AvailableAllocationUnits.QuadPart;
|
||||
|
||||
FreeDiskSpaceInMB->QuadPart = FreeBytes.QuadPart >> 20;
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
SmpSetDefaultPageFileData(IN PWSTR PageFileName,
|
||||
IN PLARGE_INTEGER InitialSizeInMB,
|
||||
IN PLARGE_INTEGER MaximumSizeInMB)
|
||||
{
|
||||
WCHAR ValueString[MAX_PATH * 2];
|
||||
ULONG ValueLength;
|
||||
|
||||
/* Format the value string */
|
||||
swprintf(ValueString,
|
||||
L"%s %I64u %I64u",
|
||||
PageFileName,
|
||||
InitialSizeInMB->QuadPart,
|
||||
MaximumSizeInMB->QuadPart);
|
||||
|
||||
/*
|
||||
* Append another zero character because it is a multi string value
|
||||
* (REG_MULTI_SZ) and calculate the total string length.
|
||||
*/
|
||||
ValueLength = wcslen(ValueString) + 1;
|
||||
ValueString[ValueLength] = 0;
|
||||
ValueLength++;
|
||||
|
||||
/* Write the page file data */
|
||||
return RtlWriteRegistryValue(RTL_REGISTRY_CONTROL,
|
||||
L"\\Session Manager\\Memory Management",
|
||||
L"PagingFiles",
|
||||
REG_MULTI_SZ,
|
||||
ValueString,
|
||||
ValueLength * sizeof(WCHAR));
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
SmpCreatePageFile(IN PWSTR PageFileName,
|
||||
IN PLARGE_INTEGER InitialSizeInMB,
|
||||
IN PLARGE_INTEGER MaximumSizeInMB)
|
||||
{
|
||||
LARGE_INTEGER InitialSize;
|
||||
LARGE_INTEGER MaximumSize;
|
||||
UNICODE_STRING FileName;
|
||||
NTSTATUS Status;
|
||||
|
||||
/* Get the NT path name of the page file */
|
||||
if (!RtlDosPathNameToNtPathName_U(PageFileName,
|
||||
&FileName,
|
||||
NULL,
|
||||
NULL))
|
||||
{
|
||||
return STATUS_OBJECT_PATH_INVALID;
|
||||
}
|
||||
|
||||
/* Convert sizes in megabytes to sizes in bytes */
|
||||
InitialSize.QuadPart = InitialSizeInMB->QuadPart << 20;
|
||||
MaximumSize.QuadPart = MaximumSizeInMB->QuadPart << 20;
|
||||
|
||||
/* Create the pageing file */
|
||||
Status = NtCreatePagingFile(&FileName,
|
||||
&InitialSize,
|
||||
&MaximumSize,
|
||||
0);
|
||||
if (! NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("Creation of paging file %wZ with size %I64d MB failed (status 0x%x)\n",
|
||||
&FileName, InitialSizeInMB->QuadPart, Status);
|
||||
}
|
||||
|
||||
/* Release the file name */
|
||||
RtlFreeHeap(RtlGetProcessHeap(),
|
||||
0,
|
||||
FileName.Buffer);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
static NTSTATUS
|
||||
SmpCreateDefaultPagingFile(VOID)
|
||||
{
|
||||
SYSTEM_BASIC_INFORMATION SysBasicInfo;
|
||||
LARGE_INTEGER MemorySizeInMB;
|
||||
LARGE_INTEGER FreeDiskSpaceInMB;
|
||||
LARGE_INTEGER InitialSizeInMB;
|
||||
LARGE_INTEGER MaximumSizeInMB;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
WCHAR PageFileName[MAX_PATH];
|
||||
|
||||
DPRINT("Creating a default paging file\n");
|
||||
|
||||
Status = NtQuerySystemInformation(SystemBasicInformation,
|
||||
&SysBasicInfo,
|
||||
sizeof(SysBasicInfo),
|
||||
NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("Could not query for physical memory size.\n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("PageSize: %d, PhysicalPages: %d, TotalMem: %d\n",
|
||||
SysBasicInfo.PageSize,
|
||||
SysBasicInfo.NumberOfPhysicalPages,
|
||||
(SysBasicInfo.NumberOfPhysicalPages * SysBasicInfo.PageSize) / 1024);
|
||||
|
||||
MemorySizeInMB.QuadPart = (SysBasicInfo.NumberOfPhysicalPages * SysBasicInfo.PageSize) >> 20;
|
||||
|
||||
DPRINT("MemorySize %I64u MB\n",
|
||||
MemorySizeInMB.QuadPart);
|
||||
|
||||
/* Build the default page file name */
|
||||
PageFileName[0] = SharedUserData->NtSystemRoot[0];
|
||||
PageFileName[1] = 0;
|
||||
wcscat(PageFileName, L":\\pagefile.sys");
|
||||
|
||||
Status = SmpGetFreeDiskSpace(PageFileName,
|
||||
&FreeDiskSpaceInMB);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
DPRINT("FreeDiskSpace %I64u MB\n",
|
||||
FreeDiskSpaceInMB.QuadPart);
|
||||
|
||||
InitialSizeInMB.QuadPart = MemorySizeInMB.QuadPart + (MemorySizeInMB.QuadPart / 2);
|
||||
MaximumSizeInMB.QuadPart = InitialSizeInMB.QuadPart * 2;
|
||||
|
||||
if (InitialSizeInMB.QuadPart > (FreeDiskSpaceInMB.QuadPart / 4))
|
||||
{
|
||||
DPRINT("Inital Size took more then 25%% of free disk space\n");
|
||||
|
||||
/*
|
||||
* Set by percentage of free space
|
||||
* intial is 20%, and max is 25%
|
||||
*/
|
||||
InitialSizeInMB.QuadPart = FreeDiskSpaceInMB.QuadPart / 5;
|
||||
MaximumSizeInMB.QuadPart = FreeDiskSpaceInMB.QuadPart / 4;
|
||||
|
||||
/* The page file is more then a gig, size it down */
|
||||
if (InitialSizeInMB.QuadPart > 1024)
|
||||
{
|
||||
InitialSizeInMB.QuadPart = 1024; /* 1GB */
|
||||
MaximumSizeInMB.QuadPart = 1536; /* 1.5GB */
|
||||
}
|
||||
}
|
||||
|
||||
/* FIXME */
|
||||
if (InitialSizeInMB.QuadPart > 2048)
|
||||
InitialSizeInMB.QuadPart = 2048;
|
||||
if (MaximumSizeInMB.QuadPart > 2048)
|
||||
MaximumSizeInMB.QuadPart = 2048;
|
||||
|
||||
DPRINT("InitialSize %I64u MB MaximumSize %I64u MB\n",
|
||||
InitialSizeInMB.QuadPart,
|
||||
MaximumSizeInMB.QuadPart);
|
||||
|
||||
Status = SmpSetDefaultPageFileData(PageFileName,
|
||||
&InitialSizeInMB,
|
||||
&MaximumSizeInMB);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return Status;
|
||||
}
|
||||
|
||||
return SmpCreatePageFile(PageFileName,
|
||||
&InitialSizeInMB,
|
||||
&MaximumSizeInMB);
|
||||
}
|
||||
|
||||
|
||||
NTSTATUS
|
||||
SmCreatePagingFiles(VOID)
|
||||
{
|
||||
RTL_QUERY_REGISTRY_TABLE QueryTable[2];
|
||||
NTSTATUS Status;
|
||||
|
||||
DPRINT("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;
|
||||
QueryTable[0].Flags = RTL_QUERY_REGISTRY_REQUIRED;
|
||||
|
||||
Status = RtlQueryRegistryValues(RTL_REGISTRY_CONTROL,
|
||||
L"\\Session Manager\\Memory Management",
|
||||
QueryTable,
|
||||
NULL,
|
||||
NULL);
|
||||
if (Status == STATUS_OBJECT_NAME_NOT_FOUND)
|
||||
{
|
||||
Status = SmpCreateDefaultPagingFile();
|
||||
}
|
||||
|
||||
return Status;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/initreg.c
|
||||
* PURPOSE: Hive loading.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if 0
|
||||
NTSTATUS
|
||||
SmInitializeRegistry(VOID)
|
||||
{
|
||||
DPRINT("SM: %s: initializing registry\n", __FUNCTION__);
|
||||
|
||||
/* Load remaining registry hives */
|
||||
return NtInitializeRegistry(CM_BOOT_FLAG_SMSS);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -1,229 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/initrun.c
|
||||
* PURPOSE: Run all programs in the boot execution list.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if 0
|
||||
//HANDLE Children[2] = {0, 0}; /* csrss, winlogon */
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SmpRunBootAppsQueryRoutine/6
|
||||
*/
|
||||
static NTSTATUS NTAPI
|
||||
SmpRunBootAppsQueryRoutine(PWSTR ValueName,
|
||||
ULONG ValueType,
|
||||
PVOID ValueData,
|
||||
ULONG ValueLength,
|
||||
PVOID Context,
|
||||
PVOID EntryContext)
|
||||
{
|
||||
PCWSTR DefaultPath = L"\\SystemRoot\\system32\\";
|
||||
PCWSTR DefaultExtension = L".exe";
|
||||
PWSTR ImageName = NULL;
|
||||
PWSTR ImagePath = NULL;
|
||||
PWSTR CommandLine = NULL;
|
||||
PWSTR p1 = (PWSTR)ValueData;
|
||||
PWSTR p2 = (PWSTR)ValueData;
|
||||
ULONG len = 0;
|
||||
BOOLEAN HasAutocheckToken;
|
||||
BOOLEAN HasNoExtension;
|
||||
BOOLEAN HasDefaultPath;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
DPRINT("ValueName '%S' Type %lu Length %lu\n", ValueName, ValueType, ValueLength);
|
||||
DPRINT("ValueData '%S'\n", (PWSTR)ValueData);
|
||||
|
||||
if (ValueType != REG_SZ)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
/* Skip leading spaces */
|
||||
while (*p1 == L' ')
|
||||
p1++;
|
||||
|
||||
/* Get the next token */
|
||||
p2 = wcschr(p1, L' ');
|
||||
if (p2 == NULL)
|
||||
p2 = p1 + wcslen(p1);
|
||||
len = p2 - p1;
|
||||
|
||||
/* Check whether or not we have the 'autocheck' token */
|
||||
HasAutocheckToken = ((len == 9) && (_wcsnicmp(p1, L"autocheck", 9) == 0));
|
||||
|
||||
if (HasAutocheckToken)
|
||||
{
|
||||
/* Skip the current (autocheck) token */
|
||||
p1 = p2;
|
||||
|
||||
/* Skip spaces */
|
||||
while (*p1 == L' ')
|
||||
p1++;
|
||||
|
||||
/* Get the next token */
|
||||
p2 = wcschr(p1, L' ');
|
||||
if (p2 == NULL)
|
||||
p2 = p1 + wcslen(p1);
|
||||
len = p2 - p1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Now, p1-->p2 is the image name and len is its length.
|
||||
* If the image name is "" (empty string), then we stop
|
||||
* here, we don't execute anything and return STATUS_SUCCESS.
|
||||
*/
|
||||
if (len == 0)
|
||||
return STATUS_SUCCESS;
|
||||
|
||||
/* Allocate the image name buffer */
|
||||
ImageName = RtlAllocateHeap(SmpHeap, HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR));
|
||||
if (ImageName == NULL)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
/* Extract the image name */
|
||||
memmove(ImageName, p1, len * sizeof(WCHAR));
|
||||
|
||||
/* Skip the current token */
|
||||
p1 = p2;
|
||||
|
||||
/* Skip spaces */
|
||||
while (*p1 == L' ')
|
||||
p1++;
|
||||
|
||||
/* Get the length of the command line */
|
||||
len = wcslen(p1);
|
||||
|
||||
/* Allocate the command line buffer */
|
||||
CommandLine = RtlAllocateHeap(SmpHeap, HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR));
|
||||
if (CommandLine == NULL)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
/* Extract the command line. */
|
||||
memmove(CommandLine, p1, len * sizeof(WCHAR));
|
||||
|
||||
/* Determine the image path length */
|
||||
HasDefaultPath = (_wcsnicmp(ImageName, DefaultPath, wcslen(DefaultPath)) == 0);
|
||||
HasNoExtension = (wcsrchr(ImageName, L'.') == NULL);
|
||||
|
||||
len = wcslen(ImageName);
|
||||
|
||||
if (!HasDefaultPath)
|
||||
len += wcslen(DefaultPath);
|
||||
|
||||
if (HasNoExtension)
|
||||
len += wcslen(DefaultExtension);
|
||||
|
||||
/* Allocate the image path buffer */
|
||||
ImagePath = RtlAllocateHeap(SmpHeap, HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR));
|
||||
if (ImagePath == NULL)
|
||||
{
|
||||
Status = STATUS_INSUFFICIENT_RESOURCES;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
/* Build the image path */
|
||||
if (HasDefaultPath)
|
||||
{
|
||||
wcscpy(ImagePath, ImageName);
|
||||
}
|
||||
else
|
||||
{
|
||||
wcscpy(ImagePath, DefaultPath);
|
||||
wcscat(ImagePath, ImageName);
|
||||
}
|
||||
|
||||
if (HasNoExtension)
|
||||
wcscat(ImagePath, DefaultExtension);
|
||||
|
||||
DPRINT("ImageName : '%S'\n", ImageName);
|
||||
DPRINT("ImagePath : '%S'\n", ImagePath);
|
||||
DPRINT("CommandLine: '%S'\n", CommandLine);
|
||||
|
||||
/* Create NT process */
|
||||
Status = SmCreateUserProcess(ImagePath,
|
||||
CommandLine,
|
||||
SM_CREATE_FLAG_WAIT,
|
||||
NULL, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: %s: running '%S' failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, ImageName, Status);
|
||||
|
||||
if (HasAutocheckToken)
|
||||
PrintString("%S program not found - skipping AUTOCHECK\n", ImageName);
|
||||
|
||||
/* No need to return an error */
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
Done:
|
||||
/* Free the buffers */
|
||||
if (ImagePath != NULL)
|
||||
RtlFreeHeap(SmpHeap, 0, ImagePath);
|
||||
|
||||
if (CommandLine != NULL)
|
||||
RtlFreeHeap(SmpHeap, 0, CommandLine);
|
||||
|
||||
if (ImageName != NULL)
|
||||
RtlFreeHeap(SmpHeap, 0, ImageName);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SmRunBootApplications/0
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* Run native applications listed in the registry.
|
||||
*
|
||||
* Key:
|
||||
* \Registry\Machine\SYSTEM\CurrentControlSet\Control\Session Manager
|
||||
*
|
||||
* Value (format: "<description> <executable> <command line>":
|
||||
* 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);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -1,166 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/initss.c
|
||||
* PURPOSE: Load the subsystems.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* 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
|
||||
*/
|
||||
|
||||
/**********************************************************************
|
||||
* SmRegisterInternalSubsystem/3
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Register with itself for ImageSubsystemId
|
||||
* (programmatically).
|
||||
*/
|
||||
NTSTATUS NTAPI SmRegisterInternalSubsystem (LPWSTR PgmName,
|
||||
USHORT ImageSubsystemId,
|
||||
PHANDLE ApiPort)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
RTL_USER_PROCESS_INFORMATION ProcessInfo;
|
||||
|
||||
|
||||
DPRINT("SM: %s(%S,%d) called\n",__FUNCTION__, PgmName, ImageSubsystemId);
|
||||
|
||||
RtlZeroMemory (& ProcessInfo, sizeof ProcessInfo);
|
||||
ProcessInfo.Size = sizeof ProcessInfo;
|
||||
ProcessInfo.ProcessHandle = (HANDLE) UlongToPtr(SmSsProcessId);
|
||||
ProcessInfo.ClientId.UniqueProcess = (HANDLE) UlongToPtr(SmSsProcessId);
|
||||
DPRINT("SM: %s: ProcessInfo.ProcessHandle=%p\n",
|
||||
__FUNCTION__,ProcessInfo.ProcessHandle);
|
||||
Status = SmCreateClient (& ProcessInfo, PgmName);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
UNICODE_STRING SbApiPortName = {0,0,NULL};
|
||||
|
||||
RtlInitUnicodeString (& SbApiPortName, L"");
|
||||
Status = SmConnectApiPort(& SbApiPortName,
|
||||
(HANDLE) -1, /* internal SS have no SB port */
|
||||
ImageSubsystemId,
|
||||
ApiPort);
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("SM: %s: SMLIB!SmConnectApiPort failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__,Status);
|
||||
return Status;
|
||||
}
|
||||
DPRINT("SM:%s: %S self registered\n", __FUNCTION__, PgmName);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("SM: %s: SmCreateClient(%S) failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, PgmName, Status);
|
||||
}
|
||||
/*
|
||||
* Note that you don't need to call complete session
|
||||
* here because connection handling code autocompletes
|
||||
* the client structure for IMAGE_SUBSYSTEM_NATIVE and
|
||||
* -1.
|
||||
*/
|
||||
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,
|
||||
NULL);
|
||||
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: this also opens hSmApiPort to be used
|
||||
* in loading required subsystems.
|
||||
*/
|
||||
Status = SmRegisterInternalSubsystem (L"Session Manager", IMAGE_SUBSYSTEM_NATIVE, & hSmApiPort);
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: %s SmRegisterInternalSubsystem failed Status=%08lx\n", __FUNCTION__, Status);
|
||||
return Status;
|
||||
}
|
||||
/* Load Required subsystems (Debug Windows) */
|
||||
Status = SmpLoadRequiredSubsystems();
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: %s SmpLoadRequiredSubsystems failed Status=%08lx\n", __FUNCTION__, Status);
|
||||
return Status;
|
||||
}
|
||||
/* done */
|
||||
DPRINT("SM: done loading subsystems\n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,242 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/initwkdll.c
|
||||
* PURPOSE: Load the well known DLLs.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if 0
|
||||
static NTSTATUS NTAPI
|
||||
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(FileHandle);
|
||||
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&ImageName,
|
||||
OBJ_CASE_INSENSITIVE | OBJ_PERMANENT | OBJ_OPENIF,
|
||||
(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);
|
||||
|
||||
RtlFreeHeap(RtlGetProcessHeap(),
|
||||
0,
|
||||
DllNtPath.Buffer);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("NtOpenFile failed (Status %lx)\n", 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/print.c
|
||||
* PURPOSE: Print on the blue screen.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if 0
|
||||
VOID NTAPI DisplayString(LPCWSTR lpwString)
|
||||
{
|
||||
UNICODE_STRING us;
|
||||
|
||||
RtlInitUnicodeString (&us, lpwString);
|
||||
NtDisplayString (&us);
|
||||
}
|
||||
|
||||
VOID NTAPI 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);
|
||||
DPRINT1("%s", buffer);
|
||||
|
||||
RtlInitAnsiString (&AnsiString, buffer);
|
||||
RtlAnsiStringToUnicodeString (&UnicodeString,
|
||||
&AnsiString,
|
||||
TRUE);
|
||||
NtDisplayString(&UnicodeString);
|
||||
RtlFreeUnicodeString (&UnicodeString);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -1,352 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/print.c
|
||||
* PURPOSE: \SmApiPort LPC port message management.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* GLOBAL VARIABLES *********************************************************/
|
||||
|
||||
static HANDLE SmApiPort = INVALID_HANDLE_VALUE;
|
||||
|
||||
/* SM API *******************************************************************/
|
||||
|
||||
SMAPI(SmInvalid)
|
||||
{
|
||||
DPRINT("SM: %s called\n",__FUNCTION__);
|
||||
Request->SmHeader.Status = STATUS_NOT_IMPLEMENTED;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* SM API Table */
|
||||
typedef NTSTATUS (FASTCALL * SM_PORT_API)(PSM_PORT_MESSAGE);
|
||||
|
||||
SM_PORT_API SmApi [] =
|
||||
{
|
||||
SmInvalid, /* unused */
|
||||
SmCompSes, /* smapicomp.c */
|
||||
SmInvalid, /* obsolete */
|
||||
SmInvalid, /* unknown */
|
||||
SmExecPgm, /* smapiexec.c */
|
||||
SmInvalid /* smapyqry.c */
|
||||
};
|
||||
|
||||
/* TODO: optimize this address computation (it should be done
|
||||
* with a macro) */
|
||||
PSM_CONNECT_DATA FASTCALL SmpGetConnectData (PSM_PORT_MESSAGE Request)
|
||||
{
|
||||
PPORT_MESSAGE PortMessage = (PPORT_MESSAGE) Request;
|
||||
return (PSM_CONNECT_DATA)(PortMessage + 1);
|
||||
}
|
||||
|
||||
NTSTATUS NTAPI
|
||||
SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request);
|
||||
|
||||
/**********************************************************************
|
||||
* SmpCallbackServer/2
|
||||
*
|
||||
* DESCRIPTION
|
||||
* The SM calls back a previously connected subsystem process to
|
||||
* authorize it to bootstrap (initialize). The SM connects to a
|
||||
* named LPC port which name was sent in the connection data by
|
||||
* the candidate subsystem server process.
|
||||
*/
|
||||
static NTSTATUS
|
||||
SmpCallbackServer (PSM_PORT_MESSAGE Request,
|
||||
PSM_CLIENT_DATA ClientData)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PSM_CONNECT_DATA ConnectData = SmpGetConnectData (Request);
|
||||
UNICODE_STRING CallbackPortName;
|
||||
ULONG CallbackPortNameLength = SM_SB_NAME_MAX_LENGTH; /* TODO: compute length */
|
||||
SB_CONNECT_DATA SbConnectData;
|
||||
ULONG SbConnectDataLength = sizeof SbConnectData;
|
||||
SECURITY_QUALITY_OF_SERVICE SecurityQos;
|
||||
|
||||
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||
|
||||
if ( ((USHORT)-1 == ConnectData->SubSystemId) ||
|
||||
(IMAGE_SUBSYSTEM_NATIVE == ConnectData->SubSystemId))
|
||||
{
|
||||
DPRINT("SM: %s: we do not need calling back SM!\n",
|
||||
__FUNCTION__);
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
RtlCopyMemory (ClientData->SbApiPortName,
|
||||
ConnectData->SbName,
|
||||
CallbackPortNameLength);
|
||||
RtlInitUnicodeString (& CallbackPortName,
|
||||
ClientData->SbApiPortName);
|
||||
|
||||
SecurityQos.Length = sizeof (SecurityQos);
|
||||
SecurityQos.ImpersonationLevel = SecurityIdentification;
|
||||
SecurityQos.ContextTrackingMode = SECURITY_DYNAMIC_TRACKING;
|
||||
SecurityQos.EffectiveOnly = TRUE;
|
||||
|
||||
SbConnectData.SmApiMax = (sizeof SmApi / sizeof SmApi[0]);
|
||||
Status = NtConnectPort (& ClientData->SbApiPort,
|
||||
& CallbackPortName,
|
||||
&SecurityQos,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
& SbConnectData,
|
||||
& SbConnectDataLength);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* NAME
|
||||
* SmpApiConnectedThread/1
|
||||
*
|
||||
* DESCRIPTION
|
||||
* Entry point for the listener thread of LPC port "\SmApiPort".
|
||||
*/
|
||||
VOID NTAPI
|
||||
SmpApiConnectedThread(PVOID pConnectedPort)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PPORT_MESSAGE Reply = NULL;
|
||||
SM_PORT_MESSAGE Request;
|
||||
HANDLE ConnectedPort = * (PHANDLE) pConnectedPort;
|
||||
|
||||
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||
RtlZeroMemory(&Request, sizeof(SM_PORT_MESSAGE));
|
||||
|
||||
while (TRUE)
|
||||
{
|
||||
DPRINT("SM: %s: waiting for message\n",__FUNCTION__);
|
||||
|
||||
Status = NtReplyWaitReceivePort(ConnectedPort,
|
||||
NULL,
|
||||
Reply,
|
||||
(PPORT_MESSAGE) & Request);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("SM: %s: message received (type=%d)\n",
|
||||
__FUNCTION__,
|
||||
Request.Header.u2.s2.Type);
|
||||
|
||||
switch (Request.Header.u2.s2.Type)
|
||||
{
|
||||
case LPC_CONNECTION_REQUEST:
|
||||
SmpHandleConnectionRequest (&Request);
|
||||
Reply = NULL;
|
||||
break;
|
||||
case LPC_DEBUG_EVENT:
|
||||
// DbgSsHandleKmApiMsg (&Request, 0);
|
||||
Reply = NULL;
|
||||
break;
|
||||
case LPC_PORT_CLOSED:
|
||||
Reply = NULL;
|
||||
continue;
|
||||
default:
|
||||
if ((Request.SmHeader.ApiIndex) &&
|
||||
(Request.SmHeader.ApiIndex < (sizeof SmApi / sizeof SmApi[0])))
|
||||
{
|
||||
Status = SmApi[Request.SmHeader.ApiIndex](&Request);
|
||||
Reply = (PPORT_MESSAGE) & Request;
|
||||
} else {
|
||||
Request.SmHeader.Status = STATUS_NOT_IMPLEMENTED;
|
||||
Reply = (PPORT_MESSAGE) & Request;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* LPC failed */
|
||||
DPRINT1("SM: %s: NtReplyWaitReceivePort() failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
break;
|
||||
}
|
||||
}
|
||||
NtClose (ConnectedPort);
|
||||
DPRINT("SM: %s done\n", __FUNCTION__);
|
||||
NtTerminateThread (NtCurrentThread(), Status);
|
||||
}
|
||||
|
||||
/**********************************************************************
|
||||
* NAME
|
||||
* SmpHandleConnectionRequest/1
|
||||
*
|
||||
* ARGUMENTS
|
||||
* Request: LPC connection request message
|
||||
*
|
||||
* REMARKS
|
||||
* Quoted in http://support.microsoft.com/kb/258060/EN-US/
|
||||
*/
|
||||
NTSTATUS NTAPI
|
||||
SmpHandleConnectionRequest (PSM_PORT_MESSAGE Request)
|
||||
{
|
||||
PSM_CONNECT_DATA ConnectData = SmpGetConnectData (Request);
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
BOOL Accept = FALSE;
|
||||
PSM_CLIENT_DATA ClientData = NULL;
|
||||
HANDLE hClientDataApiPort = (HANDLE) 0;
|
||||
PHANDLE ClientDataApiPort = & hClientDataApiPort;
|
||||
PVOID Context = NULL;
|
||||
|
||||
DPRINT("SM: %s called:\n SubSystemID=%d\n SbName=\"%S\"\n",
|
||||
__FUNCTION__, ConnectData->SubSystemId, ConnectData->SbName);
|
||||
|
||||
if(sizeof (SM_CONNECT_DATA) == Request->Header.u1.s1.DataLength)
|
||||
{
|
||||
if(IMAGE_SUBSYSTEM_UNKNOWN == ConnectData->SubSystemId)
|
||||
{
|
||||
/*
|
||||
* This is not a call to register an image set,
|
||||
* but a simple connection request from a process
|
||||
* that will use the SM API.
|
||||
*/
|
||||
DPRINT("SM: %s: simple request\n", __FUNCTION__);
|
||||
ClientDataApiPort = & hClientDataApiPort;
|
||||
Accept = TRUE;
|
||||
} else {
|
||||
DPRINT("SM: %s: request to register an image set\n", __FUNCTION__);
|
||||
/*
|
||||
* Reject GUIs classes: only odd subsystem IDs are
|
||||
* allowed to register here (tty mode images).
|
||||
*/
|
||||
if(1 == (ConnectData->SubSystemId % 2))
|
||||
{
|
||||
DPRINT("SM: %s: id = %d\n", __FUNCTION__, ConnectData->SubSystemId);
|
||||
/*
|
||||
* SmBeginClientInitialization/2 will succeed only if there
|
||||
* is a candidate client ready.
|
||||
*/
|
||||
Status = SmBeginClientInitialization (Request, & ClientData);
|
||||
if(STATUS_SUCCESS == Status)
|
||||
{
|
||||
DPRINT("SM: %s: ClientData = %p\n",
|
||||
__FUNCTION__, ClientData);
|
||||
/*
|
||||
* OK: the client is an environment subsystem
|
||||
* willing to manage a free image type.
|
||||
*/
|
||||
ClientDataApiPort = & ClientData->ApiPort;
|
||||
/*
|
||||
* Call back the candidate environment subsystem
|
||||
* server (use the port name sent in in the
|
||||
* connection request message).
|
||||
*/
|
||||
Status = SmpCallbackServer (Request, ClientData);
|
||||
if(NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("SM: %s: SmpCallbackServer OK\n",
|
||||
__FUNCTION__);
|
||||
Accept = TRUE;
|
||||
} else {
|
||||
DPRINT("SM: %s: SmpCallbackServer failed (Status=%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
Status = SmDestroyClient (ConnectData->SubSystemId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
DPRINT("SM: %s: before NtAcceptConnectPort\n", __FUNCTION__);
|
||||
|
||||
Status = NtAcceptConnectPort (ClientDataApiPort,
|
||||
Context,
|
||||
(PPORT_MESSAGE) Request,
|
||||
Accept,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
if(Accept)
|
||||
{
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: %s: NtAcceptConnectPort() failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
return Status;
|
||||
} else {
|
||||
DPRINT("SM: %s: completing connection request\n", __FUNCTION__);
|
||||
Status = NtCompleteConnectPort (*ClientDataApiPort);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: %s: NtCompleteConnectPort() failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
return Status;
|
||||
}
|
||||
}
|
||||
Status = STATUS_SUCCESS;
|
||||
}
|
||||
DPRINT("SM: %s done\n", __FUNCTION__);
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/* LPC PORT INITIALIZATION **************************************************/
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* NAME
|
||||
* SmCreateApiPort/0
|
||||
*
|
||||
* DECRIPTION
|
||||
*/
|
||||
NTSTATUS
|
||||
SmCreateApiPort(VOID)
|
||||
{
|
||||
OBJECT_ATTRIBUTES ObjectAttributes = {0};
|
||||
UNICODE_STRING UnicodeString = RTL_CONSTANT_STRING(SM_API_PORT_NAME);
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&UnicodeString,
|
||||
0,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
Status = NtCreatePort(&SmApiPort,
|
||||
&ObjectAttributes,
|
||||
sizeof(SM_CONNECT_DATA),
|
||||
sizeof(SM_PORT_MESSAGE),
|
||||
0);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
return(Status);
|
||||
}
|
||||
|
||||
/*
|
||||
* Create one thread for the named LPC
|
||||
* port \SmApiPort
|
||||
*/
|
||||
RtlCreateUserThread(NtCurrentProcess(),
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
(PTHREAD_START_ROUTINE)SmpApiConnectedThread,
|
||||
&SmApiPort,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
/*
|
||||
* On NT LPC, we need a second thread to handle incoming connections
|
||||
* generated by incoming requests, otherwise the thread handling
|
||||
* the request will be busy sending the LPC message, without any other
|
||||
* thread being busy to receive the LPC message.
|
||||
*/
|
||||
Status = RtlCreateUserThread(NtCurrentProcess(),
|
||||
NULL,
|
||||
FALSE,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
(PTHREAD_START_ROUTINE)SmpApiConnectedThread,
|
||||
&SmApiPort,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
return(Status);
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/smapicomp.c
|
||||
* PURPOSE: SM_API_COMPLETE_SESSION.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* SmCompSes/1 API
|
||||
*/
|
||||
SMAPI(SmCompSes)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||
|
||||
DPRINT("SM: %s: ClientId.UniqueProcess=%p\n",
|
||||
__FUNCTION__, Request->Header.ClientId.UniqueProcess);
|
||||
Status = SmCompleteClientInitialization (PtrToUlong(Request->Header.ClientId.UniqueProcess));
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: %s: SmCompleteClientInitialization failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
}
|
||||
Request->SmHeader.Status = Status;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/* EOF */
|
|
@ -1,278 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/smapiexec.c
|
||||
* PURPOSE: SM_API_EXECUTE_PROGRAM.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
static const WCHAR szSystemDirectory[] = L"\\System32";
|
||||
|
||||
/**********************************************************************
|
||||
* SmCreateUserProcess/5
|
||||
*
|
||||
* DESCRIPTION
|
||||
*
|
||||
* ARGUMENTS
|
||||
* ImagePath: absolute path of the image to run;
|
||||
* CommandLine: arguments and options for ImagePath;
|
||||
* Flags: Wait flag: Set for boot time processes and unset for
|
||||
* subsystems bootstrapping;
|
||||
* 1Mb reserve flag: Set for subsystems, unset for everything
|
||||
* else
|
||||
* Timeout: optional: used if WaitForIt==TRUE;
|
||||
* ProcessHandle: optional: a duplicated handle for
|
||||
the child process (storage provided by the caller).
|
||||
*
|
||||
* RETURN VALUE
|
||||
* NTSTATUS:
|
||||
*
|
||||
*/
|
||||
NTSTATUS NTAPI
|
||||
SmCreateUserProcess (LPWSTR ImagePath,
|
||||
LPWSTR CommandLine,
|
||||
ULONG Flags,
|
||||
PLARGE_INTEGER Timeout OPTIONAL,
|
||||
PRTL_USER_PROCESS_INFORMATION UserProcessInfo OPTIONAL)
|
||||
{
|
||||
UNICODE_STRING ImagePathString = { 0, 0, NULL };
|
||||
UNICODE_STRING CommandLineString = { 0, 0, NULL };
|
||||
UNICODE_STRING SystemDirectory = { 0, 0, NULL };
|
||||
PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
|
||||
RTL_USER_PROCESS_INFORMATION ProcessInfo = {0};
|
||||
PRTL_USER_PROCESS_INFORMATION pProcessInfo = & ProcessInfo;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
||||
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||
|
||||
if (NULL != UserProcessInfo)
|
||||
{
|
||||
pProcessInfo = UserProcessInfo;
|
||||
}
|
||||
|
||||
RtlInitUnicodeString (& ImagePathString, ImagePath);
|
||||
RtlInitUnicodeString (& CommandLineString, CommandLine);
|
||||
|
||||
SystemDirectory.MaximumLength = (wcslen(SharedUserData->NtSystemRoot) * sizeof(WCHAR)) + sizeof(szSystemDirectory);
|
||||
SystemDirectory.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
|
||||
0,
|
||||
SystemDirectory.MaximumLength);
|
||||
if (SystemDirectory.Buffer == NULL)
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
DPRINT1("SM: %s: Allocating system directory string failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
Status = RtlAppendUnicodeToString(& SystemDirectory,
|
||||
SharedUserData->NtSystemRoot);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
goto FailProcParams;
|
||||
}
|
||||
|
||||
Status = RtlAppendUnicodeToString(& SystemDirectory,
|
||||
szSystemDirectory);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
goto FailProcParams;
|
||||
}
|
||||
|
||||
|
||||
Status = RtlCreateProcessParameters(& ProcessParameters,
|
||||
& ImagePathString,
|
||||
NULL,
|
||||
& SystemDirectory,
|
||||
& CommandLineString,
|
||||
SmSystemEnvironment,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL);
|
||||
|
||||
RtlFreeHeap(RtlGetProcessHeap(),
|
||||
0,
|
||||
SystemDirectory.Buffer);
|
||||
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
FailProcParams:
|
||||
DPRINT1("SM: %s: Creating process parameters failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Reserve lower 1Mb, if requested */
|
||||
if (Flags & SM_CREATE_FLAG_RESERVE_1MB)
|
||||
ProcessParameters->Flags |= RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB;
|
||||
|
||||
/* Create the user process */
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/* Wait for process termination */
|
||||
if (Flags & SM_CREATE_FLAG_WAIT)
|
||||
{
|
||||
Status = NtWaitForSingleObject (pProcessInfo->ProcessHandle,
|
||||
FALSE,
|
||||
Timeout);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: %s: NtWaitForSingleObject failed with Status=0x%08lx\n",
|
||||
__FUNCTION__, Status);
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == UserProcessInfo)
|
||||
{
|
||||
NtClose(pProcessInfo->ProcessHandle);
|
||||
NtClose(pProcessInfo->ThreadHandle);
|
||||
}
|
||||
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(%p|%p)\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,
|
||||
SmSystemEnvironment /* 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_USER_PROCESS_INFORMATION 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,
|
||||
SM_CREATE_FLAG_RESERVE_1MB,
|
||||
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))
|
||||
{
|
||||
DPRINT1("SM: %s: NtResumeThread failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
//Status = SmDestroyClient TODO
|
||||
}
|
||||
} else {
|
||||
DPRINT1("SM: %s: SmCreateClient failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
}
|
||||
NtClose(ProcessInfo.ThreadHandle);
|
||||
NtClose(ProcessInfo.ProcessHandle);
|
||||
}
|
||||
}
|
||||
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 */
|
|
@ -1,55 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/smapiquery.c
|
||||
* PURPOSE: SM_API_QUERY_INFORMATION.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
#if 0
|
||||
/**********************************************************************
|
||||
* 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;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* EOF */
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* PROJECT: ReactOS Session Manager
|
||||
* LICENSE: GPL v2 or later - See COPYING in the top level directory
|
||||
* FILE: base/system/smss/smss.c
|
||||
* PURPOSE: Initialization routine.
|
||||
* PROGRAMMERS: ReactOS Development Team
|
||||
*/
|
||||
|
||||
/* INCLUDES ******************************************************************/
|
||||
#include "smss.h"
|
||||
#include <reactos/buildno.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
ULONG SmSsProcessId = 0;
|
||||
|
||||
/* Native image's entry point */
|
||||
|
||||
NTSTATUS __cdecl _main(int argc,
|
||||
char *argv[],
|
||||
char *envp[],
|
||||
ULONG DebugFlag)
|
||||
{
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
PROCESS_BASIC_INFORMATION PBI = {0};
|
||||
|
||||
/* Lookup yourself */
|
||||
Status = NtQueryInformationProcess (NtCurrentProcess(),
|
||||
ProcessBasicInformation,
|
||||
& PBI,
|
||||
sizeof PBI,
|
||||
NULL);
|
||||
if(NT_SUCCESS(Status))
|
||||
{
|
||||
SmSsProcessId = (ULONG) PBI.UniqueProcessId;
|
||||
}
|
||||
/* Initialize the system */
|
||||
Status = InitSessionManager();
|
||||
/* Watch required subsystems TODO */
|
||||
#if 0
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
int i;
|
||||
for (i=0; i < (sizeof Children / sizeof Children[0]); i++)
|
||||
{
|
||||
if (Children[i])
|
||||
{
|
||||
NtTerminateProcess(Children[i],0);
|
||||
}
|
||||
}
|
||||
DPRINT1("SM: Initialization failed!\n");
|
||||
goto ByeBye;
|
||||
}
|
||||
|
||||
Status = NtWaitForMultipleObjects(((LONG) sizeof(Children) / sizeof(HANDLE)),
|
||||
Children,
|
||||
WaitAny,
|
||||
TRUE, /* alertable */
|
||||
NULL); /* NULL for infinite */
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SM: NtWaitForMultipleObjects failed! (Status=0x%08lx)\n", Status);
|
||||
}
|
||||
else
|
||||
{
|
||||
DPRINT1("SM: Process terminated!\n");
|
||||
}
|
||||
|
||||
ByeBye:
|
||||
/* Raise a hard error (crash the system/BSOD) */
|
||||
NtRaiseHardError(STATUS_SYSTEM_PROCESS_TERMINATED,
|
||||
0,0,0,0,0);
|
||||
|
||||
// NtTerminateProcess(NtCurrentProcess(), 0);
|
||||
#endif
|
||||
return NtTerminateThread(NtCurrentThread(), Status);
|
||||
}
|
||||
|
||||
/* EOF */
|
|
@ -1,128 +0,0 @@
|
|||
#ifndef _SMSS_H_INCLUDED_
|
||||
#define _SMSS_H_INCLUDED_
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#define NTOS_MODE_USER
|
||||
#include <ndk/cmfuncs.h>
|
||||
#include <ndk/exfuncs.h>
|
||||
#include <ndk/iofuncs.h>
|
||||
#include <ndk/lpcfuncs.h>
|
||||
#include <ndk/mmtypes.h>
|
||||
#include <ndk/mmfuncs.h>
|
||||
#include <ndk/obfuncs.h>
|
||||
#include <ndk/psfuncs.h>
|
||||
#include <ndk/rtlfuncs.h>
|
||||
#include <ndk/umfuncs.h>
|
||||
|
||||
#include <sm/api.h>
|
||||
#include <sm/helper.h>
|
||||
|
||||
/* smss.c */
|
||||
extern ULONG SmSsProcessId;
|
||||
|
||||
/* init.c */
|
||||
NTSTATUS InitSessionManager(VOID);
|
||||
|
||||
/* initheap.c */
|
||||
extern HANDLE SmpHeap;
|
||||
NTSTATUS SmCreateHeap(VOID);
|
||||
|
||||
/* initenv.c */
|
||||
extern PWSTR SmSystemEnvironment;
|
||||
NTSTATUS SmCreateEnvironment(VOID);
|
||||
NTSTATUS SmSetEnvironmentVariables(VOID);
|
||||
NTSTATUS SmUpdateEnvironment(VOID);
|
||||
|
||||
/* initobdir.c */
|
||||
NTSTATUS SmCreateObjectDirectories(VOID);
|
||||
|
||||
/* initdosdev.c */
|
||||
NTSTATUS SmInitDosDevices(VOID);
|
||||
|
||||
/* initrun.c */
|
||||
extern HANDLE Children[2];
|
||||
NTSTATUS SmRunBootApplications(VOID);
|
||||
|
||||
/* initmv.c */
|
||||
NTSTATUS SmProcessFileRenameList(VOID);
|
||||
|
||||
/* initwkdll.c */
|
||||
NTSTATUS SmLoadKnownDlls(VOID);
|
||||
|
||||
/* initpage.c */
|
||||
NTSTATUS SmCreatePagingFiles(VOID);
|
||||
|
||||
/* initreg.c */
|
||||
NTSTATUS SmInitializeRegistry(VOID);
|
||||
|
||||
/* initss.c */
|
||||
NTSTATUS NTAPI SmRegisterInternalSubsystem(LPWSTR,USHORT,PHANDLE);
|
||||
NTSTATUS SmLoadSubsystems(VOID);
|
||||
|
||||
/* smapi.c */
|
||||
#define SMAPI(n) \
|
||||
NTSTATUS FASTCALL n (PSM_PORT_MESSAGE Request)
|
||||
PSM_CONNECT_DATA FASTCALL SmpGetConnectData (PSM_PORT_MESSAGE);
|
||||
NTSTATUS SmCreateApiPort(VOID);
|
||||
VOID NTAPI SmpApiThread(PVOID);
|
||||
|
||||
|
||||
/* smapiexec.c */
|
||||
#define SM_CREATE_FLAG_WAIT 0x01
|
||||
#define SM_CREATE_FLAG_RESERVE_1MB 0x02
|
||||
NTSTATUS NTAPI SmCreateUserProcess(LPWSTR ImagePath,
|
||||
LPWSTR CommandLine,
|
||||
ULONG Flags,
|
||||
PLARGE_INTEGER Timeout OPTIONAL,
|
||||
PRTL_USER_PROCESS_INFORMATION UserProcessInfo OPTIONAL);
|
||||
NTSTATUS FASTCALL SmExecPgm(PSM_PORT_MESSAGE);
|
||||
|
||||
/* smapicomp.c */
|
||||
NTSTATUS FASTCALL SmCompSes(PSM_PORT_MESSAGE);
|
||||
|
||||
/* smapiquery.c */
|
||||
NTSTATUS FASTCALL SmQryInfo(PSM_PORT_MESSAGE);
|
||||
|
||||
/* client.c */
|
||||
#define SM_CLIENT_FLAG_CANDIDATE 0x8000
|
||||
#define SM_CLIENT_FLAG_INITIALIZED 0x0001
|
||||
#define SM_CLIENT_FLAG_REQUIRED 0x0002
|
||||
typedef struct _SM_CLIENT_DATA
|
||||
{
|
||||
RTL_CRITICAL_SECTION Lock;
|
||||
WCHAR ProgramName [SM_SB_NAME_MAX_LENGTH];
|
||||
USHORT SubsystemId;
|
||||
WORD Flags;
|
||||
WORD Unused;
|
||||
ULONG ServerProcessId;
|
||||
HANDLE ServerProcess;
|
||||
HANDLE ApiPort;
|
||||
HANDLE ApiPortThread;
|
||||
HANDLE SbApiPort;
|
||||
WCHAR SbApiPortName [SM_SB_NAME_MAX_LENGTH];
|
||||
|
||||
} SM_CLIENT_DATA, *PSM_CLIENT_DATA;
|
||||
NTSTATUS SmInitializeClientManagement (VOID);
|
||||
NTSTATUS NTAPI SmCreateClient (PRTL_USER_PROCESS_INFORMATION,PWSTR);
|
||||
NTSTATUS NTAPI SmDestroyClient (ULONG);
|
||||
NTSTATUS NTAPI SmBeginClientInitialization (PSM_PORT_MESSAGE,PSM_CLIENT_DATA*);
|
||||
NTSTATUS NTAPI SmCompleteClientInitialization (ULONG);
|
||||
NTSTATUS FASTCALL SmGetClientBasicInformation (PSM_BASIC_INFORMATION);
|
||||
NTSTATUS FASTCALL SmGetSubSystemInformation (PSM_SUBSYSTEM_INFORMATION);
|
||||
|
||||
/* debug.c */
|
||||
extern HANDLE DbgSsApiPort;
|
||||
extern HANDLE DbgUiApiPort;
|
||||
NTSTATUS SmInitializeDbgSs(VOID);
|
||||
|
||||
/* print.c */
|
||||
VOID NTAPI DisplayString(LPCWSTR lpwString);
|
||||
VOID NTAPI PrintString (char* fmt, ...);
|
||||
|
||||
#endif /* _SMSS_H_INCLUDED_ */
|
||||
|
||||
/* EOF */
|
||||
|
|
@ -1,32 +0,0 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<module name="smss" type="nativecui" installbase="system32" installname="smss.exe">
|
||||
<include base="smss">.</include>
|
||||
<include base="ReactOS">include/reactos/subsys</include>
|
||||
<library>nt</library>
|
||||
<library>smlib</library>
|
||||
<library>ntdll</library>
|
||||
<pch>smss.h</pch>
|
||||
<compilationunit name="unit.c">
|
||||
<file>client.c</file>
|
||||
<file>debug.c</file>
|
||||
<file>init.c</file>
|
||||
<file>initdosdev.c</file>
|
||||
<file>initenv.c</file>
|
||||
<file>initheap.c</file>
|
||||
<file>initmv.c</file>
|
||||
<file>initobdir.c</file>
|
||||
<file>initpage.c</file>
|
||||
<file>initreg.c</file>
|
||||
<file>initrun.c</file>
|
||||
<file>initss.c</file>
|
||||
<file>initwkdll.c</file>
|
||||
<file>print.c</file>
|
||||
<file>smapi.c</file>
|
||||
<file>smapicomp.c</file>
|
||||
<file>smapiexec.c</file>
|
||||
<file>smapiquery.c</file>
|
||||
<file>smss.c</file>
|
||||
</compilationunit>
|
||||
<file>smss.rc</file>
|
||||
</module>
|
|
@ -1,6 +0,0 @@
|
|||
/* $Id$ */
|
||||
|
||||
#define REACTOS_STR_FILE_DESCRIPTION "ReactOS Session Manager\0"
|
||||
#define REACTOS_STR_INTERNAL_NAME "smss\0"
|
||||
#define REACTOS_STR_ORIGINAL_FILENAME "smss.exe\0"
|
||||
#include <reactos/version.rc>
|
|
@ -13,12 +13,12 @@ list(APPEND SOURCE
|
|||
smss.c
|
||||
smss.rc)
|
||||
|
||||
add_executable(smss2 WIN32 ${SOURCE})
|
||||
add_executable(smss WIN32 ${SOURCE})
|
||||
|
||||
target_link_libraries(smss2 nt pseh smlib)
|
||||
target_link_libraries(smss nt pseh smlib)
|
||||
|
||||
add_pch(smss2 smss.h)
|
||||
add_pch(smss smss.h)
|
||||
|
||||
set_module_type(smss2 nativecui)
|
||||
add_importlibs(smss2 ntdll)
|
||||
add_cd_file(TARGET smss2 DESTINATION reactos/system32 NO_CAB FOR all)
|
||||
set_module_type(smss nativecui)
|
||||
add_importlibs(smss ntdll)
|
||||
add_cd_file(TARGET smss DESTINATION reactos/system32 FOR all)
|
||||
|
|
|
@ -457,8 +457,7 @@ SmpCreatePagingFile(IN PUNICODE_STRING Name,
|
|||
NTSTATUS Status;
|
||||
|
||||
/* Tell the kernel to create the pagefile */
|
||||
//Status = NtCreatePagingFile(Name, MinSize, MaxSize, Priority);
|
||||
Status = STATUS_SUCCESS;
|
||||
Status = NtCreatePagingFile(Name, MinSize, MaxSize, Priority);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("SMSS:PFILE: NtCreatePagingFile (%wZ, %I64X, %I64X) succeeded. \n",
|
||||
|
|
|
@ -14,18 +14,6 @@
|
|||
|
||||
/* GLOBALS ********************************************************************/
|
||||
|
||||
typedef struct _INIT_BUFFER
|
||||
{
|
||||
WCHAR DebugBuffer[256];
|
||||
RTL_USER_PROCESS_INFORMATION ProcessInfo;
|
||||
} INIT_BUFFER, *PINIT_BUFFER;
|
||||
|
||||
/* NT Initial User Application */
|
||||
WCHAR NtInitialUserProcessBuffer[128] = L"\\SystemRoot\\System32\\smss.exe";
|
||||
ULONG NtInitialUserProcessBufferLength = sizeof(NtInitialUserProcessBuffer) -
|
||||
sizeof(WCHAR);
|
||||
ULONG NtInitialUserProcessBufferType = REG_SZ;
|
||||
|
||||
UNICODE_STRING SmpSystemRoot;
|
||||
ULONG AttachedSessionId = -1;
|
||||
BOOLEAN SmpDebug, SmpEnableDots;
|
||||
|
@ -396,234 +384,6 @@ SmpExecuteInitialCommand(IN ULONG MuSessionId,
|
|||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
ExpLoadInitialProcess(IN PINIT_BUFFER InitBuffer,
|
||||
OUT PRTL_USER_PROCESS_PARAMETERS *ProcessParameters,
|
||||
OUT PCHAR *ProcessEnvironment)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
SIZE_T Size;
|
||||
PWSTR p;
|
||||
UNICODE_STRING NullString = RTL_CONSTANT_STRING(L"");
|
||||
UNICODE_STRING SmssName, DebugString;
|
||||
PVOID EnvironmentPtr = NULL;
|
||||
PRTL_USER_PROCESS_INFORMATION ProcessInformation;
|
||||
PRTL_USER_PROCESS_PARAMETERS ProcessParams = NULL;
|
||||
|
||||
NullString.Length = sizeof(WCHAR);
|
||||
|
||||
/* Use the initial buffer, after the strings */
|
||||
ProcessInformation = &InitBuffer->ProcessInfo;
|
||||
|
||||
/* Allocate memory for the process parameters */
|
||||
Size = sizeof(*ProcessParams) + ((MAX_PATH * 6) * sizeof(WCHAR));
|
||||
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
||||
(PVOID*)&ProcessParams,
|
||||
0,
|
||||
&Size,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Failed, display error */
|
||||
p = InitBuffer->DebugBuffer;
|
||||
_snwprintf(p,
|
||||
256 * sizeof(WCHAR),
|
||||
L"INIT: Unable to allocate Process Parameters. 0x%lx",
|
||||
Status);
|
||||
RtlInitUnicodeString(&DebugString, p);
|
||||
ZwDisplayString(&DebugString);
|
||||
|
||||
/* Bugcheck the system */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Setup the basic header, and give the process the low 1MB to itself */
|
||||
ProcessParams->Length = (ULONG)Size;
|
||||
ProcessParams->MaximumLength = (ULONG)Size;
|
||||
ProcessParams->Flags = RTL_USER_PROCESS_PARAMETERS_NORMALIZED |
|
||||
RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB;
|
||||
|
||||
/* Allocate a page for the environment */
|
||||
Size = PAGE_SIZE;
|
||||
Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
|
||||
&EnvironmentPtr,
|
||||
0,
|
||||
&Size,
|
||||
MEM_COMMIT,
|
||||
PAGE_READWRITE);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Failed, display error */
|
||||
p = InitBuffer->DebugBuffer;
|
||||
_snwprintf(p,
|
||||
256 * sizeof(WCHAR),
|
||||
L"INIT: Unable to allocate Process Environment. 0x%lx",
|
||||
Status);
|
||||
RtlInitUnicodeString(&DebugString, p);
|
||||
ZwDisplayString(&DebugString);
|
||||
|
||||
/* Bugcheck the system */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Write the pointer */
|
||||
ProcessParams->Environment = EnvironmentPtr;
|
||||
|
||||
/* Make a buffer for the DOS path */
|
||||
p = (PWSTR)(ProcessParams + 1);
|
||||
ProcessParams->CurrentDirectory.DosPath.Buffer = p;
|
||||
ProcessParams->CurrentDirectory.DosPath.MaximumLength = MAX_PATH *
|
||||
sizeof(WCHAR);
|
||||
|
||||
/* Copy the DOS path */
|
||||
RtlCopyUnicodeString(&ProcessParams->CurrentDirectory.DosPath,
|
||||
&SmpSystemRoot);
|
||||
|
||||
/* Make a buffer for the DLL Path */
|
||||
p = (PWSTR)((PCHAR)ProcessParams->CurrentDirectory.DosPath.Buffer +
|
||||
ProcessParams->CurrentDirectory.DosPath.MaximumLength);
|
||||
ProcessParams->DllPath.Buffer = p;
|
||||
ProcessParams->DllPath.MaximumLength = MAX_PATH * sizeof(WCHAR);
|
||||
|
||||
/* Copy the DLL path and append the system32 directory */
|
||||
RtlCopyUnicodeString(&ProcessParams->DllPath,
|
||||
&ProcessParams->CurrentDirectory.DosPath);
|
||||
RtlAppendUnicodeToString(&ProcessParams->DllPath, L"\\System32");
|
||||
|
||||
/* Make a buffer for the image name */
|
||||
p = (PWSTR)((PCHAR)ProcessParams->DllPath.Buffer +
|
||||
ProcessParams->DllPath.MaximumLength);
|
||||
ProcessParams->ImagePathName.Buffer = p;
|
||||
ProcessParams->ImagePathName.MaximumLength = MAX_PATH * sizeof(WCHAR);
|
||||
|
||||
/* Make sure the buffer is a valid string which within the given length */
|
||||
if ((NtInitialUserProcessBufferType != REG_SZ) ||
|
||||
((NtInitialUserProcessBufferLength != MAXULONG) &&
|
||||
((NtInitialUserProcessBufferLength < sizeof(WCHAR)) ||
|
||||
(NtInitialUserProcessBufferLength >
|
||||
sizeof(NtInitialUserProcessBuffer) - sizeof(WCHAR)))))
|
||||
{
|
||||
/* Invalid initial process string, bugcheck */
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
/* Cut out anything after a space */
|
||||
p = NtInitialUserProcessBuffer;
|
||||
while ((*p) && (*p != L' ')) p++;
|
||||
|
||||
/* Set the image path length */
|
||||
ProcessParams->ImagePathName.Length =
|
||||
(USHORT)((PCHAR)p - (PCHAR)NtInitialUserProcessBuffer);
|
||||
|
||||
/* Copy the actual buffer */
|
||||
RtlCopyMemory(ProcessParams->ImagePathName.Buffer,
|
||||
NtInitialUserProcessBuffer,
|
||||
ProcessParams->ImagePathName.Length);
|
||||
|
||||
/* Null-terminate it */
|
||||
ProcessParams->ImagePathName.Buffer[ProcessParams->ImagePathName.Length /
|
||||
sizeof(WCHAR)] = UNICODE_NULL;
|
||||
|
||||
/* Make a buffer for the command line */
|
||||
p = (PWSTR)((PCHAR)ProcessParams->ImagePathName.Buffer +
|
||||
ProcessParams->ImagePathName.MaximumLength);
|
||||
ProcessParams->CommandLine.Buffer = p;
|
||||
ProcessParams->CommandLine.MaximumLength = MAX_PATH * sizeof(WCHAR);
|
||||
|
||||
/* Add the image name to the command line */
|
||||
RtlAppendUnicodeToString(&ProcessParams->CommandLine,
|
||||
NtInitialUserProcessBuffer);
|
||||
|
||||
/* Create the environment string */
|
||||
ProcessParams->Environment = SmpDefaultEnvironment;
|
||||
|
||||
/* Create SMSS process */
|
||||
SmssName = ProcessParams->ImagePathName;
|
||||
Status = RtlCreateUserProcess(&SmssName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
RtlDeNormalizeProcessParams(ProcessParams),
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
FALSE,
|
||||
NULL,
|
||||
NULL,
|
||||
ProcessInformation);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Failed, display error */
|
||||
p = InitBuffer->DebugBuffer;
|
||||
_snwprintf(p,
|
||||
256 * sizeof(WCHAR),
|
||||
L"INIT: Unable to create Session Manager. 0x%lx",
|
||||
Status);
|
||||
RtlInitUnicodeString(&DebugString, p);
|
||||
ZwDisplayString(&DebugString);
|
||||
|
||||
/* Bugcheck the system */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Resume the thread */
|
||||
Status = ZwResumeThread(ProcessInformation->ThreadHandle, NULL);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Failed, display error */
|
||||
p = InitBuffer->DebugBuffer;
|
||||
_snwprintf(p,
|
||||
256 * sizeof(WCHAR),
|
||||
L"INIT: Unable to resume Session Manager. 0x%lx",
|
||||
Status);
|
||||
RtlInitUnicodeString(&DebugString, p);
|
||||
ZwDisplayString(&DebugString);
|
||||
|
||||
/* Bugcheck the system */
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Return success */
|
||||
*ProcessParameters = ProcessParams;
|
||||
*ProcessEnvironment = EnvironmentPtr;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
LaunchOldSmss(VOID)
|
||||
{
|
||||
PINIT_BUFFER InitBuffer;
|
||||
PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
|
||||
PRTL_USER_PROCESS_INFORMATION ProcessInfo;
|
||||
NTSTATUS Status;
|
||||
PCHAR Environment;
|
||||
|
||||
/* Initialize the system root */
|
||||
RtlInitUnicodeString(&SmpSystemRoot, SharedUserData->NtSystemRoot);
|
||||
|
||||
/* Allocate the initialization buffer */
|
||||
InitBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, sizeof(INIT_BUFFER));
|
||||
if (!InitBuffer)
|
||||
{
|
||||
/* Bugcheck */
|
||||
return STATUS_NO_MEMORY;
|
||||
}
|
||||
|
||||
/* Launch initial process */
|
||||
ProcessInfo = &InitBuffer->ProcessInfo;
|
||||
Status = ExpLoadInitialProcess(InitBuffer, &ProcessParameters, &Environment);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
/* Failed, display error */
|
||||
DPRINT1("INIT: Session Manager failed to load.\n");
|
||||
return Status;
|
||||
}
|
||||
|
||||
/* Return the handle and status */
|
||||
return Status;
|
||||
}
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
SmpTerminate(IN PULONG_PTR Parameters,
|
||||
|
@ -719,8 +479,6 @@ _main(IN INT argc,
|
|||
/* Enter SEH so we can terminate correctly if anything goes wrong */
|
||||
_SEH2_TRY
|
||||
{
|
||||
LARGE_INTEGER Infinite = {{0x80000000, 0x7FFFFFFF}};
|
||||
|
||||
/* Initialize SMSS */
|
||||
Status = SmpInit(&InitialCommand, Handles);
|
||||
if (!NT_SUCCESS(Status))
|
||||
|
@ -728,11 +486,7 @@ _main(IN INT argc,
|
|||
DPRINT1("SMSS: SmpInit return failure - Status == %x\n", Status);
|
||||
RtlInitUnicodeString(&DbgString, L"Session Manager Initialization");
|
||||
Parameters[1] = Status;
|
||||
DPRINT1("SMSS-2 Loaded... Launching original SMSS\n");
|
||||
//_SEH2_LEAVE; Hack so that setup can work. will go away later
|
||||
Status = LaunchOldSmss();
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
return NtDelayExecution(FALSE, &Infinite);
|
||||
_SEH2_LEAVE;
|
||||
}
|
||||
|
||||
/* Get the global flags */
|
||||
|
@ -758,11 +512,7 @@ _main(IN INT argc,
|
|||
RtlInitUnicodeString(&DbgString,
|
||||
L"Session Manager ExecuteInitialCommand");
|
||||
Parameters[1] = Status;
|
||||
//_SEH2_LEAVE;
|
||||
DPRINT1("SMSS-2 Loaded... Launching original SMSS\n");
|
||||
Status = LaunchOldSmss();
|
||||
if (!NT_SUCCESS(Status)) return Status;
|
||||
return NtDelayExecution(FALSE, &Infinite);
|
||||
_SEH2_LEAVE;
|
||||
}
|
||||
|
||||
/* Check if we're already attached to a session */
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
|
||||
<module name="smss2" type="nativecui" installbase="system32" installname="smss2.exe">
|
||||
<bootstrap installbase="$(CDOUTPUT)/system32" />
|
||||
<include base="smss2">.</include>
|
||||
<module name="smss" type="nativecui" installbase="system32" installname="smss.exe">
|
||||
<include base="smss">.</include>
|
||||
<include base="ReactOS">include/reactos/subsys</include>
|
||||
<library>nt</library>
|
||||
<library>pseh</library>
|
||||
|
|
|
@ -37,9 +37,6 @@
|
|||
<directory name="services">
|
||||
<xi:include href="services/services.rbuild" />
|
||||
</directory>
|
||||
<directory name="smss">
|
||||
<xi:include href="smss/smss.rbuild" />
|
||||
</directory>
|
||||
<directory name="smss2">
|
||||
<xi:include href="smss2/smss2.rbuild" />
|
||||
</directory>
|
||||
|
|
|
@ -127,8 +127,7 @@ base\system\regsvr32\regsvr32.exe 1
|
|||
base\system\rundll32\rundll32.exe 1
|
||||
base\system\runonce\runonce.exe 1
|
||||
base\system\services\services.exe 1
|
||||
base\system\smss\smss.exe 1
|
||||
base\system\smss2\smss2.exe 1
|
||||
base\system\smss2\smss.exe 1
|
||||
base\system\userinit\userinit.exe 1
|
||||
base\system\winlogon\winlogon.exe 1
|
||||
|
||||
|
|
|
@ -58,7 +58,6 @@ pcix.sys=,,,,,,,,,,,,4
|
|||
pcmcia.sys=,,,,,,,,,,,,4
|
||||
swenum.sys=,,,,,,,,,,,,4
|
||||
ntdll.dll=,,,,,,,,,,,,2
|
||||
smss2.exe=,,,,,,,,,,,,2
|
||||
|
||||
[HardwareIdsDatabase]
|
||||
;*PNP0A00 = isapnp
|
||||
|
|
|
@ -66,7 +66,7 @@ BOOLEAN InitIsWinPEMode, InitWinPEModeType;
|
|||
UNICODE_STRING NtSystemRoot;
|
||||
|
||||
/* NT Initial User Application */
|
||||
WCHAR NtInitialUserProcessBuffer[128] = L"\\SystemRoot\\System32\\smss2.exe";
|
||||
WCHAR NtInitialUserProcessBuffer[128] = L"\\SystemRoot\\System32\\smss.exe";
|
||||
ULONG NtInitialUserProcessBufferLength = sizeof(NtInitialUserProcessBuffer) -
|
||||
sizeof(WCHAR);
|
||||
ULONG NtInitialUserProcessBufferType = REG_SZ;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue