mirror of
https://github.com/reactos/reactos.git
synced 2024-06-30 09:50:07 +00:00
SM/CSR: move win32k.sys loading from the SM to the Win32 user mode server.
svn path=/trunk/; revision=15729
This commit is contained in:
parent
114fa63aa5
commit
da87b75712
|
@ -30,5 +30,11 @@ SmQueryInformation (IN HANDLE SmApiPort,
|
||||||
IN OUT PVOID Data,
|
IN OUT PVOID Data,
|
||||||
IN ULONG DataLength,
|
IN ULONG DataLength,
|
||||||
IN OUT PULONG ReturnedDataLength OPTIONAL);
|
IN OUT PULONG ReturnedDataLength OPTIONAL);
|
||||||
|
/* smlib/lookupss.c */
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
SmLookupSubsystem (IN PWSTR Name,
|
||||||
|
IN OUT PWSTR Data,
|
||||||
|
IN OUT PULONG DataLength,
|
||||||
|
IN OUT PULONG DataType,
|
||||||
|
IN PVOID Environment OPTIONAL);
|
||||||
#endif /* ndef INCLUDE_SM_HELPER_H */
|
#endif /* ndef INCLUDE_SM_HELPER_H */
|
||||||
|
|
|
@ -1,13 +1,13 @@
|
||||||
#if !defined(INCLUDE_SM_NS_H)
|
#if !defined(INCLUDE_SM_NS_H)
|
||||||
#define INCLUDE_SM_NS_H
|
#define INCLUDE_SM_NS_H
|
||||||
|
|
||||||
/* $Id: helper.h 13689 2005-02-20 16:46:10Z ea $ */
|
/* $Id$ */
|
||||||
|
|
||||||
#define SM_REGISTRY_ROOT_NAME L"\\Session Manager"
|
#define SM_REGISTRY_ROOT_NAME L"\\Session Manager"
|
||||||
#define SM_REGISTRY_SUBSYSTEMS_NAME L"SubSystems"
|
#define SM_REGISTRY_SUBSYSTEMS_NAME L"SubSystems"
|
||||||
|
|
||||||
#define SM_API_PORT_NAME L"\\SmApiPort"
|
#define SM_API_PORT_NAME L"\\SmApiPort"
|
||||||
#define SM_DBGSS_PORT_NAME L"\\DbgSsApiPort"
|
#define SM_DBGSS_PORT_NAME L"\\DbgSsApiPort"
|
||||||
#define SM_DBGUI_PORT_NAME L"\\DbgUiApiPort"
|
#define SM_DBGUI_PORT_NAME L"\\DbgUiApiPort"
|
||||||
|
|
||||||
#endif /* ndef INCLUDE_SM_NS_H */
|
#endif /* ndef INCLUDE_SM_NS_H */
|
||||||
|
|
|
@ -4,3 +4,4 @@ SmCompleteSession@12
|
||||||
SmConnectApiPort@16
|
SmConnectApiPort@16
|
||||||
SmExecuteProgram@8
|
SmExecuteProgram@8
|
||||||
SmQueryInformation@20
|
SmQueryInformation@20
|
||||||
|
SmLookupSubsystem@20
|
||||||
|
|
|
@ -1,63 +1,63 @@
|
||||||
/* $Id: compses.c 13731 2005-02-23 23:37:06Z ea $
|
/* $Id$
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
* FILE: lib/smlib/compses.c
|
* FILE: lib/smlib/compses.c
|
||||||
* PURPOSE: Call SM API SM_API_COMPLETE_SESSION
|
* PURPOSE: Call SM API SM_API_COMPLETE_SESSION
|
||||||
*/
|
*/
|
||||||
#define NTOS_MODE_USER
|
#define NTOS_MODE_USER
|
||||||
#include <ntos.h>
|
#include <ntos.h>
|
||||||
#include <sm/helper.h>
|
#include <sm/helper.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
* SmCompleteSession/3
|
* SmCompleteSession/3
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* This function is called by an environment subsystem server to
|
* This function is called by an environment subsystem server to
|
||||||
* tell the SM it finished initialization phase and is ready to
|
* tell the SM it finished initialization phase and is ready to
|
||||||
* manage processes it registered for (SmConnectApiPort).
|
* manage processes it registered for (SmConnectApiPort).
|
||||||
*
|
*
|
||||||
* ARGUMENTS
|
* ARGUMENTS
|
||||||
* hSmApiPort: port handle returned by SmConnectApiPort;
|
* hSmApiPort: port handle returned by SmConnectApiPort;
|
||||||
* hSbApiPort: call back API port of the subsystem (handle);
|
* hSbApiPort: call back API port of the subsystem (handle);
|
||||||
* hApiPort : API port of the subsystem (handle).
|
* hApiPort : API port of the subsystem (handle).
|
||||||
*
|
*
|
||||||
* RETURN VALUE
|
* RETURN VALUE
|
||||||
* Success status as handed by the SM reply; otherwise a failure
|
* Success status as handed by the SM reply; otherwise a failure
|
||||||
* status code.
|
* status code.
|
||||||
*/
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
SmCompleteSession (IN HANDLE hSmApiPort,
|
SmCompleteSession (IN HANDLE hSmApiPort,
|
||||||
IN HANDLE hSbApiPort,
|
IN HANDLE hSbApiPort,
|
||||||
IN HANDLE hApiPort)
|
IN HANDLE hApiPort)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
SM_PORT_MESSAGE SmReqMsg;
|
SM_PORT_MESSAGE SmReqMsg;
|
||||||
|
|
||||||
DPRINT("SMLIB: %s called\n", __FUNCTION__);
|
DPRINT("SMLIB: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
/* Marshal Ses in the LPC message */
|
/* Marshal Ses in the LPC message */
|
||||||
SmReqMsg.Request.CompSes.hApiPort = hApiPort;
|
SmReqMsg.Request.CompSes.hApiPort = hApiPort;
|
||||||
SmReqMsg.Request.CompSes.hSbApiPort = hSbApiPort;
|
SmReqMsg.Request.CompSes.hSbApiPort = hSbApiPort;
|
||||||
|
|
||||||
/* SM API to invoke */
|
/* SM API to invoke */
|
||||||
SmReqMsg.SmHeader.ApiIndex = SM_API_COMPLETE_SESSION;
|
SmReqMsg.SmHeader.ApiIndex = SM_API_COMPLETE_SESSION;
|
||||||
|
|
||||||
/* Port message */
|
/* Port message */
|
||||||
SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;
|
SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;
|
||||||
SmReqMsg.Header.DataSize = SM_PORT_DATA_SIZE(SmReqMsg.Request);
|
SmReqMsg.Header.DataSize = SM_PORT_DATA_SIZE(SmReqMsg.Request);
|
||||||
SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;
|
SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;
|
||||||
Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);
|
Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return SmReqMsg.SmHeader.Status;
|
return SmReqMsg.SmHeader.Status;
|
||||||
}
|
}
|
||||||
DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
|
DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,106 +1,106 @@
|
||||||
/* $Id: connect.c 14015 2005-03-13 17:00:19Z ea $
|
/* $Id$
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
* FILE: reactos/lib/smlib/connect.c
|
* FILE: reactos/lib/smlib/connect.c
|
||||||
* PURPOSE: Connect to the API LPC port exposed by the SM
|
* PURPOSE: Connect to the API LPC port exposed by the SM
|
||||||
*/
|
*/
|
||||||
#define NTOS_MODE_USER
|
#define NTOS_MODE_USER
|
||||||
#include <ntos.h>
|
#include <ntos.h>
|
||||||
#include <sm/helper.h>
|
#include <sm/helper.h>
|
||||||
#include <pe.h>
|
#include <pe.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
* SmConnectApiPort/4
|
* SmConnectApiPort/4
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* Connect to SM API port and register a session "begin" port (Sb)
|
* Connect to SM API port and register a session "begin" port (Sb)
|
||||||
* or to issue API requests to SmApiPort.
|
* or to issue API requests to SmApiPort.
|
||||||
*
|
*
|
||||||
* ARGUMENTS
|
* ARGUMENTS
|
||||||
* pSbApiPortName: name of the Sb port the calling subsystem
|
* pSbApiPortName: name of the Sb port the calling subsystem
|
||||||
* server already created in the system name space;
|
* server already created in the system name space;
|
||||||
* hSbApiPort: LPC port handle (checked, but not used: the
|
* hSbApiPort: LPC port handle (checked, but not used: the
|
||||||
* subsystem is required to have already created
|
* subsystem is required to have already created
|
||||||
* the callback port before it connects to the SM);
|
* the callback port before it connects to the SM);
|
||||||
* wSubsystem: a valid IMAGE_SUBSYSTEM_xxx value;
|
* wSubsystem: a valid IMAGE_SUBSYSTEM_xxx value;
|
||||||
* phSmApiPort: a pointer to a HANDLE, which will be
|
* phSmApiPort: a pointer to a HANDLE, which will be
|
||||||
* filled with a valid client-side LPC comm port.
|
* filled with a valid client-side LPC comm port.
|
||||||
*
|
*
|
||||||
* There should be only two ways to call this API:
|
* There should be only two ways to call this API:
|
||||||
* a) subsystems willing to register with SM will use it
|
* a) subsystems willing to register with SM will use it
|
||||||
* with full parameters (the function checks them);
|
* with full parameters (the function checks them);
|
||||||
* b) regular SM clients, will set to 0 the 1st, the 2nd,
|
* b) regular SM clients, will set to 0 the 1st, the 2nd,
|
||||||
* and the 3rd parameter.
|
* and the 3rd parameter.
|
||||||
*
|
*
|
||||||
* RETURN VALUE
|
* RETURN VALUE
|
||||||
* If all three optional values are omitted, an LPC status.
|
* If all three optional values are omitted, an LPC status.
|
||||||
* STATUS_INVALID_PARAMETER_MIX if PortName is defined and
|
* STATUS_INVALID_PARAMETER_MIX if PortName is defined and
|
||||||
* both hSbApiPort and wSubsystem are 0.
|
* both hSbApiPort and wSubsystem are 0.
|
||||||
*/
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
SmConnectApiPort (IN PUNICODE_STRING pSbApiPortName OPTIONAL,
|
SmConnectApiPort (IN PUNICODE_STRING pSbApiPortName OPTIONAL,
|
||||||
IN HANDLE hSbApiPort OPTIONAL,
|
IN HANDLE hSbApiPort OPTIONAL,
|
||||||
IN WORD wSubSystemId OPTIONAL,
|
IN WORD wSubSystemId OPTIONAL,
|
||||||
IN OUT PHANDLE phSmApiPort)
|
IN OUT PHANDLE phSmApiPort)
|
||||||
{
|
{
|
||||||
UNICODE_STRING SmApiPortName;
|
UNICODE_STRING SmApiPortName;
|
||||||
SECURITY_QUALITY_OF_SERVICE SecurityQos;
|
SECURITY_QUALITY_OF_SERVICE SecurityQos;
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
SM_CONNECT_DATA ConnectData = {0,0,{0}};
|
SM_CONNECT_DATA ConnectData = {0,0,{0}};
|
||||||
ULONG ConnectDataLength = 0;
|
ULONG ConnectDataLength = 0;
|
||||||
|
|
||||||
DPRINT("SMLIB: %s called\n", __FUNCTION__);
|
DPRINT("SMLIB: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
if (pSbApiPortName)
|
if (pSbApiPortName)
|
||||||
{
|
{
|
||||||
if (pSbApiPortName->Length > (sizeof pSbApiPortName->Buffer[0] * SM_SB_NAME_MAX_LENGTH))
|
if (pSbApiPortName->Length > (sizeof pSbApiPortName->Buffer[0] * SM_SB_NAME_MAX_LENGTH))
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER_1;
|
return STATUS_INVALID_PARAMETER_1;
|
||||||
}
|
}
|
||||||
if (NULL == hSbApiPort || IMAGE_SUBSYSTEM_UNKNOWN == wSubSystemId)
|
if (NULL == hSbApiPort || IMAGE_SUBSYSTEM_UNKNOWN == wSubSystemId)
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER_MIX;
|
return STATUS_INVALID_PARAMETER_MIX;
|
||||||
}
|
}
|
||||||
RtlZeroMemory (& ConnectData, sizeof ConnectData);
|
RtlZeroMemory (& ConnectData, sizeof ConnectData);
|
||||||
ConnectData.Unused = 0;
|
ConnectData.Unused = 0;
|
||||||
ConnectData.SubSystemId = wSubSystemId;
|
ConnectData.SubSystemId = wSubSystemId;
|
||||||
if (pSbApiPortName->Length > 0)
|
if (pSbApiPortName->Length > 0)
|
||||||
{
|
{
|
||||||
RtlCopyMemory (& ConnectData.SbName,
|
RtlCopyMemory (& ConnectData.SbName,
|
||||||
pSbApiPortName->Buffer,
|
pSbApiPortName->Buffer,
|
||||||
pSbApiPortName->Length);
|
pSbApiPortName->Length);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ConnectDataLength = sizeof ConnectData;
|
ConnectDataLength = sizeof ConnectData;
|
||||||
|
|
||||||
SecurityQos.Length = sizeof (SecurityQos);
|
SecurityQos.Length = sizeof (SecurityQos);
|
||||||
SecurityQos.ImpersonationLevel = SecurityIdentification;
|
SecurityQos.ImpersonationLevel = SecurityIdentification;
|
||||||
SecurityQos.ContextTrackingMode = TRUE;
|
SecurityQos.ContextTrackingMode = TRUE;
|
||||||
SecurityQos.EffectiveOnly = TRUE;
|
SecurityQos.EffectiveOnly = TRUE;
|
||||||
|
|
||||||
RtlInitUnicodeString (& SmApiPortName, SM_API_PORT_NAME);
|
RtlInitUnicodeString (& SmApiPortName, SM_API_PORT_NAME);
|
||||||
|
|
||||||
Status = NtConnectPort (
|
Status = NtConnectPort (
|
||||||
phSmApiPort,
|
phSmApiPort,
|
||||||
& SmApiPortName,
|
& SmApiPortName,
|
||||||
& SecurityQos,
|
& SecurityQos,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
& ConnectData,
|
& ConnectData,
|
||||||
& ConnectDataLength
|
& ConnectDataLength
|
||||||
);
|
);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
|
DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
|
@ -1,87 +1,87 @@
|
||||||
/* $Id: execpgm.c 13731 2005-02-23 23:37:06Z ea $
|
/* $Id$
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
* FILE: lib/smlib/execpgm.c
|
* FILE: lib/smlib/execpgm.c
|
||||||
* PURPOSE: Call SM API SM_API_EXECPGM
|
* PURPOSE: Call SM API SM_API_EXECPGM
|
||||||
*/
|
*/
|
||||||
#define NTOS_MODE_USER
|
#define NTOS_MODE_USER
|
||||||
#include <ntos.h>
|
#include <ntos.h>
|
||||||
#include <sm/helper.h>
|
#include <sm/helper.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME EXPORTED
|
* NAME EXPORTED
|
||||||
* SmExecuteProgram/2
|
* SmExecuteProgram/2
|
||||||
*
|
*
|
||||||
* DESCRIPTION
|
* DESCRIPTION
|
||||||
* This function is used to make the SM start an environment
|
* This function is used to make the SM start an environment
|
||||||
* subsystem server process.
|
* subsystem server process.
|
||||||
*
|
*
|
||||||
* ARGUMENTS
|
* ARGUMENTS
|
||||||
* hSmApiPort: port handle returned by SmConnectApiPort;
|
* hSmApiPort: port handle returned by SmConnectApiPort;
|
||||||
* Pgm : name of the subsystem (to be used by the SM to
|
* Pgm : name of the subsystem (to be used by the SM to
|
||||||
* lookup the image name from the registry).
|
* lookup the image name from the registry).
|
||||||
* Valid names are: DEBUG, WINDOWS, POSIX, OS2,
|
* Valid names are: DEBUG, WINDOWS, POSIX, OS2,
|
||||||
* and VMS.
|
* and VMS.
|
||||||
*
|
*
|
||||||
* RETURN VALUE
|
* RETURN VALUE
|
||||||
* Success status as handed by the SM reply; otherwise a failure
|
* Success status as handed by the SM reply; otherwise a failure
|
||||||
* status code.
|
* status code.
|
||||||
*/
|
*/
|
||||||
NTSTATUS STDCALL
|
NTSTATUS STDCALL
|
||||||
SmExecuteProgram (IN HANDLE hSmApiPort,
|
SmExecuteProgram (IN HANDLE hSmApiPort,
|
||||||
IN PUNICODE_STRING Pgm)
|
IN PUNICODE_STRING Pgm)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
SM_PORT_MESSAGE SmReqMsg;
|
SM_PORT_MESSAGE SmReqMsg;
|
||||||
|
|
||||||
|
|
||||||
DPRINT("SMLIB: %s(%08lx,'%S') called\n",
|
DPRINT("SMLIB: %s(%08lx,'%S') called\n",
|
||||||
__FUNCTION__, hSmApiPort, Pgm->Buffer);
|
__FUNCTION__, hSmApiPort, Pgm->Buffer);
|
||||||
|
|
||||||
/* Check Pgm's length */
|
/* Check Pgm's length */
|
||||||
if (Pgm->Length > (sizeof (Pgm->Buffer[0]) * SM_EXEXPGM_MAX_LENGTH))
|
if (Pgm->Length > (sizeof (Pgm->Buffer[0]) * SM_EXEXPGM_MAX_LENGTH))
|
||||||
{
|
{
|
||||||
return STATUS_INVALID_PARAMETER;
|
return STATUS_INVALID_PARAMETER;
|
||||||
}
|
}
|
||||||
/* Marshal Pgm in the LPC message */
|
/* Marshal Pgm in the LPC message */
|
||||||
RtlZeroMemory (& SmReqMsg, sizeof SmReqMsg);
|
RtlZeroMemory (& SmReqMsg, sizeof SmReqMsg);
|
||||||
SmReqMsg.Request.ExecPgm.NameLength = Pgm->Length;
|
SmReqMsg.Request.ExecPgm.NameLength = Pgm->Length;
|
||||||
RtlCopyMemory (SmReqMsg.Request.ExecPgm.Name,
|
RtlCopyMemory (SmReqMsg.Request.ExecPgm.Name,
|
||||||
Pgm->Buffer,
|
Pgm->Buffer,
|
||||||
Pgm->Length);
|
Pgm->Length);
|
||||||
|
|
||||||
/* SM API to invoke */
|
/* SM API to invoke */
|
||||||
SmReqMsg.SmHeader.ApiIndex = SM_API_EXECUTE_PROGRAMME;
|
SmReqMsg.SmHeader.ApiIndex = SM_API_EXECUTE_PROGRAMME;
|
||||||
|
|
||||||
/* LPC message */
|
/* LPC message */
|
||||||
SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;
|
SmReqMsg.Header.MessageType = LPC_NEW_MESSAGE;
|
||||||
SmReqMsg.Header.DataSize = SM_PORT_DATA_SIZE(SmReqMsg.Request);
|
SmReqMsg.Header.DataSize = SM_PORT_DATA_SIZE(SmReqMsg.Request);
|
||||||
SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;
|
SmReqMsg.Header.MessageSize = SM_PORT_MESSAGE_SIZE;
|
||||||
|
|
||||||
DPRINT("SMLIB: %s:\n"
|
DPRINT("SMLIB: %s:\n"
|
||||||
" MessageType = %d\n"
|
" MessageType = %d\n"
|
||||||
" DataSize = %d\n"
|
" DataSize = %d\n"
|
||||||
" MessageSize = %d\n"
|
" MessageSize = %d\n"
|
||||||
" sizeof(LPC_MESSAGE)==%d\n",
|
" sizeof(LPC_MESSAGE)==%d\n",
|
||||||
__FUNCTION__,
|
__FUNCTION__,
|
||||||
SmReqMsg.Header.MessageType,
|
SmReqMsg.Header.MessageType,
|
||||||
SmReqMsg.Header.DataSize,
|
SmReqMsg.Header.DataSize,
|
||||||
SmReqMsg.Header.MessageSize,
|
SmReqMsg.Header.MessageSize,
|
||||||
sizeof(LPC_MESSAGE));
|
sizeof(LPC_MESSAGE));
|
||||||
|
|
||||||
/* Call SM and wait for a reply */
|
/* Call SM and wait for a reply */
|
||||||
Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);
|
Status = NtRequestWaitReplyPort (hSmApiPort, (PLPC_MESSAGE) & SmReqMsg, (PLPC_MESSAGE) & SmReqMsg);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
return SmReqMsg.SmHeader.Status;
|
return SmReqMsg.SmHeader.Status;
|
||||||
}
|
}
|
||||||
DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
|
DPRINT("SMLIB: %s failed (Status=0x%08lx)\n", __FUNCTION__, Status);
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
155
reactos/lib/smlib/lookupss.c
Normal file
155
reactos/lib/smlib/lookupss.c
Normal file
|
@ -0,0 +1,155 @@
|
||||||
|
/* $Id$
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: lib/smlib/lookupss.c
|
||||||
|
*/
|
||||||
|
#define NTOS_MODE_USER
|
||||||
|
#include <ntos.h>
|
||||||
|
#include <sm/helper.h>
|
||||||
|
|
||||||
|
#define NDEBUG
|
||||||
|
#include <debug.h>
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* NAME EXPORTED
|
||||||
|
* SmLookupSubsystem/6
|
||||||
|
*
|
||||||
|
* DESCRIPTION
|
||||||
|
* Read from the registry key
|
||||||
|
* \Registry\SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems
|
||||||
|
* the value which name is Name.
|
||||||
|
*
|
||||||
|
* ARGUMENTS
|
||||||
|
* Name: name of the program to run, that is a value's name in
|
||||||
|
* the SM registry key Subsystems;
|
||||||
|
* Data: what the registry gave back for Name;
|
||||||
|
* DataLength: how much Data the registry returns;
|
||||||
|
* DataType: what is Data?
|
||||||
|
* Environment: set it if you want this function to use it
|
||||||
|
* to possibly expand Data before giving it back; if set
|
||||||
|
* to NULL, no expansion will be performed.
|
||||||
|
*/
|
||||||
|
NTSTATUS STDCALL
|
||||||
|
SmLookupSubsystem (IN PWSTR Name,
|
||||||
|
IN OUT PWSTR Data,
|
||||||
|
IN OUT PULONG DataLength,
|
||||||
|
IN OUT PULONG DataType,
|
||||||
|
IN PVOID Environment OPTIONAL)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
UNICODE_STRING usKeyName = {0};
|
||||||
|
OBJECT_ATTRIBUTES Oa = {0};
|
||||||
|
HANDLE hKey = (HANDLE) 0;
|
||||||
|
|
||||||
|
DPRINT("SM: %s(Name='%S') called\n", __FUNCTION__, Name);
|
||||||
|
/*
|
||||||
|
* Prepare the key name to scan and
|
||||||
|
* related object attributes.
|
||||||
|
*/
|
||||||
|
RtlInitUnicodeString (& usKeyName,
|
||||||
|
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\SubSystems");
|
||||||
|
|
||||||
|
InitializeObjectAttributes (& Oa,
|
||||||
|
& usKeyName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
NULL);
|
||||||
|
/*
|
||||||
|
* Open the key. This MUST NOT fail, if the
|
||||||
|
* request is for a legitimate subsystem.
|
||||||
|
*/
|
||||||
|
Status = NtOpenKey (& hKey,
|
||||||
|
MAXIMUM_ALLOWED,
|
||||||
|
& Oa);
|
||||||
|
if(NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
UNICODE_STRING usValueName = {0};
|
||||||
|
PWCHAR KeyValueInformation = NULL;
|
||||||
|
ULONG KeyValueInformationLength = 1024;
|
||||||
|
ULONG ResultLength = 0L;
|
||||||
|
PKEY_VALUE_PARTIAL_INFORMATION kvpi = NULL;
|
||||||
|
|
||||||
|
KeyValueInformation = RtlAllocateHeap (RtlGetProcessHeap(),
|
||||||
|
0,
|
||||||
|
KeyValueInformationLength);
|
||||||
|
if (NULL == KeyValueInformation)
|
||||||
|
{
|
||||||
|
return STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
kvpi = (PKEY_VALUE_PARTIAL_INFORMATION) KeyValueInformation;
|
||||||
|
RtlInitUnicodeString (& usValueName, Name);
|
||||||
|
Status = NtQueryValueKey (hKey,
|
||||||
|
& usValueName,
|
||||||
|
KeyValuePartialInformation,
|
||||||
|
KeyValueInformation,
|
||||||
|
KeyValueInformationLength,
|
||||||
|
& ResultLength);
|
||||||
|
if(NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("nkvpi.TitleIndex = %ld\n", kvpi->TitleIndex);
|
||||||
|
DPRINT("kvpi.Type = %ld\n", kvpi->Type);
|
||||||
|
DPRINT("kvpi.DataLength = %ld\n", kvpi->DataLength);
|
||||||
|
|
||||||
|
if((NULL != Data) && (NULL != DataLength) && (NULL != DataType))
|
||||||
|
{
|
||||||
|
*DataType = kvpi->Type;
|
||||||
|
if((NULL != Environment) && (REG_EXPAND_SZ == *DataType))
|
||||||
|
{
|
||||||
|
UNICODE_STRING Source;
|
||||||
|
PWCHAR DestinationBuffer = NULL;
|
||||||
|
UNICODE_STRING Destination;
|
||||||
|
ULONG Length = 0;
|
||||||
|
|
||||||
|
DPRINT("SM: %s: value will be expanded\n", __FUNCTION__);
|
||||||
|
|
||||||
|
DestinationBuffer = RtlAllocateHeap (RtlGetProcessHeap(),
|
||||||
|
0,
|
||||||
|
(2 * KeyValueInformationLength));
|
||||||
|
if (NULL == DestinationBuffer)
|
||||||
|
{
|
||||||
|
Status = STATUS_NO_MEMORY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Source.Length = kvpi->DataLength;
|
||||||
|
Source.MaximumLength = kvpi->DataLength;
|
||||||
|
Source.Buffer = (PWCHAR) & kvpi->Data;
|
||||||
|
|
||||||
|
Destination.Length = 0;
|
||||||
|
Destination.MaximumLength = (2 * KeyValueInformationLength);
|
||||||
|
Destination.Buffer = DestinationBuffer;
|
||||||
|
|
||||||
|
Status = RtlExpandEnvironmentStrings_U (Environment,
|
||||||
|
& Source,
|
||||||
|
& Destination,
|
||||||
|
& Length);
|
||||||
|
if(NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
*DataLength = min(*DataLength, Destination.Length);
|
||||||
|
RtlCopyMemory (Data, Destination.Buffer, *DataLength);
|
||||||
|
}
|
||||||
|
RtlFreeHeap (RtlGetProcessHeap(), 0, DestinationBuffer);
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
DPRINT("SM: %s: value won't be expanded\n", __FUNCTION__);
|
||||||
|
*DataLength = min(*DataLength, kvpi->DataLength);
|
||||||
|
RtlCopyMemory (Data, & kvpi->Data, *DataLength);
|
||||||
|
}
|
||||||
|
*DataType = kvpi->Type;
|
||||||
|
}else{
|
||||||
|
DPRINT1("SM: %s: Data or DataLength or DataType is NULL!\n", __FUNCTION__);
|
||||||
|
Status = STATUS_INVALID_PARAMETER;
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
DPRINT1("%s: NtQueryValueKey failed (Status=0x%08lx)\n", __FUNCTION__, Status);
|
||||||
|
}
|
||||||
|
RtlFreeHeap (RtlGetProcessHeap(), 0, KeyValueInformation);
|
||||||
|
NtClose (hKey);
|
||||||
|
}else{
|
||||||
|
DPRINT1("%s: NtOpenKey failed (Status=0x%08lx)\n", __FUNCTION__, Status);
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
|
@ -4,4 +4,5 @@
|
||||||
<file>connect.c</file>
|
<file>connect.c</file>
|
||||||
<file>execpgm.c</file>
|
<file>execpgm.c</file>
|
||||||
<file>compses.c</file>
|
<file>compses.c</file>
|
||||||
|
<file>lookupss.c</file>
|
||||||
</module>
|
</module>
|
||||||
|
|
|
@ -52,6 +52,8 @@ typedef struct _COMMAND_LINE_ARGUMENT
|
||||||
|
|
||||||
} COMMAND_LINE_ARGUMENT, *PCOMMAND_LINE_ARGUMENT;
|
} COMMAND_LINE_ARGUMENT, *PCOMMAND_LINE_ARGUMENT;
|
||||||
|
|
||||||
|
PRTL_USER_PROCESS_PARAMETERS RtlProcessParameters = NULL;
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* NAME PRIVATE
|
* NAME PRIVATE
|
||||||
* CsrpParseCommandLine/3
|
* CsrpParseCommandLine/3
|
||||||
|
@ -150,7 +152,6 @@ CsrpFreeCommandLine (HANDLE ProcessHeap,
|
||||||
|
|
||||||
VOID STDCALL NtProcessStartup(PPEB Peb)
|
VOID STDCALL NtProcessStartup(PPEB Peb)
|
||||||
{
|
{
|
||||||
PRTL_USER_PROCESS_PARAMETERS RtlProcessParameters = NULL;
|
|
||||||
COMMAND_LINE_ARGUMENT CmdLineArg = {0};
|
COMMAND_LINE_ARGUMENT CmdLineArg = {0};
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
|
|
|
@ -34,6 +34,7 @@ HANDLE CsrObjectDirectory = (HANDLE) 0;
|
||||||
UNICODE_STRING CsrDirectoryName;
|
UNICODE_STRING CsrDirectoryName;
|
||||||
|
|
||||||
extern HANDLE CsrssApiHeap;
|
extern HANDLE CsrssApiHeap;
|
||||||
|
extern PRTL_USER_PROCESS_PARAMETERS RtlProcessParameters;
|
||||||
|
|
||||||
static unsigned InitCompleteProcCount;
|
static unsigned InitCompleteProcCount;
|
||||||
static CSRPLUGIN_INIT_COMPLETE_PROC *InitCompleteProcs = NULL;
|
static CSRPLUGIN_INIT_COMPLETE_PROC *InitCompleteProcs = NULL;
|
||||||
|
@ -306,7 +307,7 @@ CsrpCreateListenPort (IN LPWSTR Name,
|
||||||
/* === INIT ROUTINES === */
|
/* === INIT ROUTINES === */
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* CsrpCreateCallbackPort/0
|
* CsrpCreateHeap/2
|
||||||
*/
|
*/
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
CsrpCreateHeap (ULONG argc, PWSTR* argv)
|
CsrpCreateHeap (ULONG argc, PWSTR* argv)
|
||||||
|
@ -327,7 +328,7 @@ CsrpCreateHeap (ULONG argc, PWSTR* argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* CsrpCreateCallbackPort/0
|
* CsrpCreateCallbackPort/2
|
||||||
*/
|
*/
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
CsrpCreateCallbackPort (ULONG argc, PWSTR* argv)
|
CsrpCreateCallbackPort (ULONG argc, PWSTR* argv)
|
||||||
|
@ -401,7 +402,47 @@ CsrpRegisterSubsystem (ULONG argc, PWSTR* argv)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* CsrpCreateApiPort/0
|
* CsrpLoadKernelModeDriver/2
|
||||||
|
*/
|
||||||
|
static NTSTATUS
|
||||||
|
CsrpLoadKernelModeDriver (ULONG argc, PWSTR* argv)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = STATUS_SUCCESS;
|
||||||
|
WCHAR Data [MAX_PATH + 1];
|
||||||
|
ULONG DataLength = sizeof Data;
|
||||||
|
ULONG DataType = 0;
|
||||||
|
|
||||||
|
|
||||||
|
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||||
|
|
||||||
|
Status = SmLookupSubsystem (L"Kmode",
|
||||||
|
Data,
|
||||||
|
& DataLength,
|
||||||
|
& DataType,
|
||||||
|
RtlProcessParameters->Environment);
|
||||||
|
if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0]))
|
||||||
|
{
|
||||||
|
WCHAR ImagePath [MAX_PATH + 1] = {0};
|
||||||
|
SYSTEM_LOAD_AND_CALL_IMAGE ImageInfo;
|
||||||
|
|
||||||
|
wcscpy (ImagePath, L"\\??\\");
|
||||||
|
wcscat (ImagePath, Data);
|
||||||
|
RtlZeroMemory (& ImageInfo, sizeof ImageInfo);
|
||||||
|
RtlInitUnicodeString (& ImageInfo.ModuleName, ImagePath);
|
||||||
|
Status = NtSetSystemInformation(SystemLoadAndCallImage,
|
||||||
|
& ImageInfo,
|
||||||
|
sizeof ImageInfo);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("WIN: %s: loading Kmode failed (Status=0x%08lx)\n",
|
||||||
|
__FUNCTION__, Status);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**********************************************************************
|
||||||
|
* CsrpCreateApiPort/2
|
||||||
*/
|
*/
|
||||||
static NTSTATUS
|
static NTSTATUS
|
||||||
CsrpCreateApiPort (ULONG argc, PWSTR* argv)
|
CsrpCreateApiPort (ULONG argc, PWSTR* argv)
|
||||||
|
@ -495,16 +536,17 @@ struct {
|
||||||
CSR_INIT_ROUTINE EntryPoint;
|
CSR_INIT_ROUTINE EntryPoint;
|
||||||
PCHAR ErrorMessage;
|
PCHAR ErrorMessage;
|
||||||
} InitRoutine [] = {
|
} InitRoutine [] = {
|
||||||
{TRUE, CsrpCreateCallbackPort, "create the callback port \\Windows\\SbApiPort"},
|
{TRUE, CsrpCreateCallbackPort, "create the callback port \\Windows\\SbApiPort"},
|
||||||
{TRUE, CsrpRegisterSubsystem, "register with SM"},
|
{TRUE, CsrpRegisterSubsystem, "register with SM"},
|
||||||
{TRUE, CsrpCreateHeap, "create the CSR heap"},
|
{TRUE, CsrpCreateHeap, "create the CSR heap"},
|
||||||
{TRUE, CsrpCreateApiPort, "create the api port \\Windows\\ApiPort"},
|
{TRUE, CsrpCreateApiPort, "create the api port \\Windows\\ApiPort"},
|
||||||
{TRUE, CsrpParseCommandLine, "parse the command line"},
|
{TRUE, CsrpParseCommandLine, "parse the command line"},
|
||||||
{TRUE, CsrpInitVideo, "initialize video"},
|
{TRUE, CsrpLoadKernelModeDriver, "load Kmode driver"},
|
||||||
{TRUE, CsrpApiRegisterDef, "initialize api definitions"},
|
{TRUE, CsrpInitVideo, "initialize video"},
|
||||||
{TRUE, CsrpCCTS, "connect client to server"},
|
{TRUE, CsrpApiRegisterDef, "initialize api definitions"},
|
||||||
{TRUE, CsrpInitWin32Csr, "load usermode dll"},
|
{TRUE, CsrpCCTS, "connect client to server"},
|
||||||
{TRUE, CsrpRunWinlogon, "run WinLogon"},
|
{TRUE, CsrpInitWin32Csr, "load usermode dll"},
|
||||||
|
{TRUE, CsrpRunWinlogon, "run WinLogon"},
|
||||||
};
|
};
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
|
|
|
@ -98,46 +98,6 @@ SmpRegisterSmss(VOID)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* SmpLoadKernelModeSubsystem/0
|
|
||||||
*/
|
|
||||||
static NTSTATUS
|
|
||||||
SmpLoadKernelModeSubsystem (VOID)
|
|
||||||
{
|
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
|
||||||
WCHAR Data [MAX_PATH + 1];
|
|
||||||
ULONG DataLength = sizeof Data;
|
|
||||||
ULONG DataType = 0;
|
|
||||||
|
|
||||||
|
|
||||||
DPRINT("SM: %s called\n", __FUNCTION__);
|
|
||||||
|
|
||||||
Status = SmLookupSubsystem (L"Kmode",
|
|
||||||
Data,
|
|
||||||
& DataLength,
|
|
||||||
& DataType,
|
|
||||||
TRUE);
|
|
||||||
if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0]))
|
|
||||||
{
|
|
||||||
WCHAR ImagePath [MAX_PATH + 1] = {0};
|
|
||||||
SYSTEM_LOAD_AND_CALL_IMAGE ImageInfo;
|
|
||||||
|
|
||||||
wcscpy (ImagePath, L"\\??\\");
|
|
||||||
wcscat (ImagePath, Data);
|
|
||||||
RtlZeroMemory (& ImageInfo, sizeof ImageInfo);
|
|
||||||
RtlInitUnicodeString (& ImageInfo.ModuleName, ImagePath);
|
|
||||||
Status = NtSetSystemInformation(SystemLoadAndCallImage,
|
|
||||||
& ImageInfo,
|
|
||||||
sizeof ImageInfo);
|
|
||||||
if(!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("SM: %s: loading Kmode failed (Status=0x%08lx)\n",
|
|
||||||
__FUNCTION__, Status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* SmpLoadRequiredSubsystems/0
|
* SmpLoadRequiredSubsystems/0
|
||||||
*/
|
*/
|
||||||
|
@ -157,7 +117,7 @@ SmpLoadRequiredSubsystems (VOID)
|
||||||
Data,
|
Data,
|
||||||
& DataLength,
|
& DataLength,
|
||||||
& DataType,
|
& DataType,
|
||||||
FALSE);
|
NULL);
|
||||||
if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0]))
|
if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0]))
|
||||||
{
|
{
|
||||||
PWCHAR Name = NULL;
|
PWCHAR Name = NULL;
|
||||||
|
@ -206,9 +166,6 @@ SmLoadSubsystems(VOID)
|
||||||
/* SM self registers */
|
/* SM self registers */
|
||||||
Status = SmpRegisterSmss();
|
Status = SmpRegisterSmss();
|
||||||
if(!NT_SUCCESS(Status)) return Status;
|
if(!NT_SUCCESS(Status)) return Status;
|
||||||
/* Load Kmode subsystem (aka win32k.sys) */
|
|
||||||
Status = SmpLoadKernelModeSubsystem();
|
|
||||||
if(!NT_SUCCESS(Status)) return Status;
|
|
||||||
/* Load Required subsystems (Debug Windows) */
|
/* Load Required subsystems (Debug Windows) */
|
||||||
Status = SmpLoadRequiredSubsystems();
|
Status = SmpLoadRequiredSubsystems();
|
||||||
if(!NT_SUCCESS(Status)) return Status;
|
if(!NT_SUCCESS(Status)) return Status;
|
||||||
|
|
|
@ -135,128 +135,6 @@ SmCreateUserProcess (LPWSTR ImagePath,
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**********************************************************************
|
|
||||||
* NAME
|
|
||||||
* SmLookupSubsystem/5
|
|
||||||
*
|
|
||||||
* DESCRIPTION
|
|
||||||
* Read from the registry key
|
|
||||||
* \Registry\SYSTEM\CurrentControlSet\Control\Session Manager\Subsystems
|
|
||||||
* the value which name is Name.
|
|
||||||
*
|
|
||||||
* ARGUMENTS
|
|
||||||
* Name: name of the program to run, that is a value's name in
|
|
||||||
* the SM registry key Subsystems;
|
|
||||||
* Data: what the registry gave back for Name;
|
|
||||||
* DataLength: how much Data the registry returns;
|
|
||||||
* DataType: what is Data?
|
|
||||||
* Expand: set it TRUE if you want this function to use the env
|
|
||||||
* to possibly expand Data before giving it back.
|
|
||||||
*/
|
|
||||||
NTSTATUS STDCALL
|
|
||||||
SmLookupSubsystem (IN PWSTR Name,
|
|
||||||
IN OUT PWSTR Data,
|
|
||||||
IN OUT PULONG DataLength,
|
|
||||||
IN OUT PULONG DataType,
|
|
||||||
IN BOOLEAN Expand)
|
|
||||||
{
|
|
||||||
NTSTATUS Status = STATUS_SUCCESS;
|
|
||||||
UNICODE_STRING usKeyName = {0};
|
|
||||||
OBJECT_ATTRIBUTES Oa = {0};
|
|
||||||
HANDLE hKey = (HANDLE) 0;
|
|
||||||
|
|
||||||
DPRINT("SM: %s(Name='%S') called\n", __FUNCTION__, Name);
|
|
||||||
/*
|
|
||||||
* Prepare the key name to scan and
|
|
||||||
* related object attributes.
|
|
||||||
*/
|
|
||||||
RtlInitUnicodeString (& usKeyName,
|
|
||||||
L"\\Registry\\Machine\\SYSTEM\\CurrentControlSet\\Control\\Session Manager\\SubSystems");
|
|
||||||
|
|
||||||
InitializeObjectAttributes (& Oa,
|
|
||||||
& usKeyName,
|
|
||||||
OBJ_CASE_INSENSITIVE,
|
|
||||||
NULL,
|
|
||||||
NULL);
|
|
||||||
/*
|
|
||||||
* Open the key. This MUST NOT fail, if the
|
|
||||||
* request is for a legitimate subsystem.
|
|
||||||
*/
|
|
||||||
Status = NtOpenKey (& hKey,
|
|
||||||
MAXIMUM_ALLOWED,
|
|
||||||
& Oa);
|
|
||||||
if(NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
UNICODE_STRING usValueName = {0};
|
|
||||||
WCHAR KeyValueInformation [1024] = {L'\0'};
|
|
||||||
ULONG ResultLength = 0L;
|
|
||||||
PKEY_VALUE_PARTIAL_INFORMATION
|
|
||||||
kvpi = (PKEY_VALUE_PARTIAL_INFORMATION) KeyValueInformation;
|
|
||||||
|
|
||||||
|
|
||||||
RtlInitUnicodeString (& usValueName, Name);
|
|
||||||
Status = NtQueryValueKey (hKey,
|
|
||||||
& usValueName,
|
|
||||||
KeyValuePartialInformation,
|
|
||||||
KeyValueInformation,
|
|
||||||
sizeof KeyValueInformation,
|
|
||||||
& ResultLength);
|
|
||||||
if(NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("nkvpi.TitleIndex = %ld\n", kvpi->TitleIndex);
|
|
||||||
DPRINT("kvpi.Type = %ld\n", kvpi->Type);
|
|
||||||
DPRINT("kvpi.DataLength = %ld\n", kvpi->DataLength);
|
|
||||||
|
|
||||||
if((NULL != Data) && (NULL != DataLength) && (NULL != DataType))
|
|
||||||
{
|
|
||||||
*DataType = kvpi->Type;
|
|
||||||
if((Expand) && (REG_EXPAND_SZ == *DataType))
|
|
||||||
{
|
|
||||||
UNICODE_STRING Source;
|
|
||||||
WCHAR DestinationBuffer [2048] = {0};
|
|
||||||
UNICODE_STRING Destination;
|
|
||||||
ULONG Length = 0;
|
|
||||||
|
|
||||||
DPRINT("SM: %s: value will be expanded\n", __FUNCTION__);
|
|
||||||
|
|
||||||
Source.Length = kvpi->DataLength;
|
|
||||||
Source.MaximumLength = kvpi->DataLength;
|
|
||||||
Source.Buffer = (PWCHAR) & kvpi->Data;
|
|
||||||
|
|
||||||
Destination.Length = 0;
|
|
||||||
Destination.MaximumLength = sizeof DestinationBuffer;
|
|
||||||
Destination.Buffer = DestinationBuffer;
|
|
||||||
|
|
||||||
Status = RtlExpandEnvironmentStrings_U (SmSystemEnvironment,
|
|
||||||
& Source,
|
|
||||||
& Destination,
|
|
||||||
& Length);
|
|
||||||
if(NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
*DataLength = min(*DataLength, Destination.Length);
|
|
||||||
RtlCopyMemory (Data, Destination.Buffer, *DataLength);
|
|
||||||
}
|
|
||||||
|
|
||||||
}else{
|
|
||||||
DPRINT("SM: %s: value won't be expanded\n", __FUNCTION__);
|
|
||||||
*DataLength = min(*DataLength, kvpi->DataLength);
|
|
||||||
RtlCopyMemory (Data, & kvpi->Data, *DataLength);
|
|
||||||
}
|
|
||||||
*DataType = kvpi->Type;
|
|
||||||
}else{
|
|
||||||
DPRINT1("SM: %s: Data or DataLength or DataType is NULL!\n", __FUNCTION__);
|
|
||||||
Status = STATUS_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
DPRINT1("%s: NtQueryValueKey failed (Status=0x%08lx)\n", __FUNCTION__, Status);
|
|
||||||
}
|
|
||||||
NtClose (hKey);
|
|
||||||
}else{
|
|
||||||
DPRINT1("%s: NtOpenKey failed (Status=0x%08lx)\n", __FUNCTION__, Status);
|
|
||||||
}
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**********************************************************************
|
/**********************************************************************
|
||||||
* SmExecPgm/1 API
|
* SmExecPgm/1 API
|
||||||
|
@ -298,7 +176,7 @@ SMAPI(SmExecPgm)
|
||||||
Data,
|
Data,
|
||||||
& DataLength,
|
& DataLength,
|
||||||
& DataType,
|
& DataType,
|
||||||
TRUE); /* expand */
|
SmSystemEnvironment /* expand */);
|
||||||
if(NT_SUCCESS(Status))
|
if(NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Is the subsystem definition non-empty? */
|
/* Is the subsystem definition non-empty? */
|
||||||
|
|
|
@ -61,12 +61,6 @@ NTSTATUS STDCALL SmCreateUserProcess(LPWSTR ImagePath,
|
||||||
BOOLEAN WaitForIt,
|
BOOLEAN WaitForIt,
|
||||||
PLARGE_INTEGER Timeout OPTIONAL,
|
PLARGE_INTEGER Timeout OPTIONAL,
|
||||||
PRTL_PROCESS_INFO UserProcessInfo OPTIONAL);
|
PRTL_PROCESS_INFO UserProcessInfo OPTIONAL);
|
||||||
NTSTATUS STDCALL
|
|
||||||
SmLookupSubsystem (IN PWSTR Name,
|
|
||||||
IN OUT PWSTR Data,
|
|
||||||
IN OUT PULONG DataLength,
|
|
||||||
IN OUT PULONG DataType,
|
|
||||||
IN BOOLEAN Expand);
|
|
||||||
NTSTATUS FASTCALL SmExecPgm(PSM_PORT_MESSAGE);
|
NTSTATUS FASTCALL SmExecPgm(PSM_PORT_MESSAGE);
|
||||||
|
|
||||||
/* smapicomp.c */
|
/* smapicomp.c */
|
||||||
|
|
Loading…
Reference in a new issue