ReactOS  0.4.14-dev-604-gcfdd483
smmsg.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _SM_CREATE_FOREIGN_SESSION_MSG
 
struct  _SM_SESSION_COMPLETE_MSG
 
struct  _SM_TERMINATE_FOREIGN_SESSION_MSG
 
struct  _SM_EXEC_PGM_MSG
 
struct  _SM_LOAD_DEFERED_SUBSYSTEM_MSG
 
struct  _SM_START_CSR_MSG
 
struct  _SM_STOP_CSR_MSG
 
struct  _SM_API_MSG
 
struct  _SB_CREATE_SESSION_MSG
 
struct  _SB_TERMINATE_SESSION_MSG
 
struct  _SB_FOREIGN_SESSION_COMPLETE_MSG
 
struct  _SB_CREATE_PROCESS_MSG
 
struct  _SB_CONNECTION_INFO
 
struct  _SB_API_MSG
 

Macros

#define _SM_MSG_
 
#define SB_PROCESS_FLAGS_DEBUG   0x1
 
#define SB_PROCESS_FLAGS_WAIT_ON_THREAD   0x2
 
#define SB_PROCESS_FLAGS_RESERVE_1MB   0x8
 
#define SB_PROCESS_FLAGS_SKIP_CHECKS   0x20
 

Typedefs

typedef enum _SMSRV_API_NUMBER SMSRV_API_NUMBER
 
typedef struct _SM_CREATE_FOREIGN_SESSION_MSG SM_CREATE_FOREIGN_SESSION_MSG
 
typedef struct _SM_CREATE_FOREIGN_SESSION_MSGPSM_CREATE_FOREIGN_SESSION_MSG
 
typedef struct _SM_SESSION_COMPLETE_MSG SM_SESSION_COMPLETE_MSG
 
typedef struct _SM_SESSION_COMPLETE_MSGPSM_SESSION_COMPLETE_MSG
 
typedef struct _SM_TERMINATE_FOREIGN_SESSION_MSG SM_TERMINATE_FOREIGN_SESSION_MSG
 
typedef struct _SM_TERMINATE_FOREIGN_SESSION_MSGPSM_TERMINATE_FOREIGN_SESSION_MSG
 
typedef struct _SM_EXEC_PGM_MSG SM_EXEC_PGM_MSG
 
typedef struct _SM_EXEC_PGM_MSGPSM_EXEC_PGM_MSG
 
typedef struct _SM_LOAD_DEFERED_SUBSYSTEM_MSG SM_LOAD_DEFERED_SUBSYSTEM_MSG
 
typedef struct _SM_LOAD_DEFERED_SUBSYSTEM_MSGPSM_LOAD_DEFERED_SUBSYSTEM_MSG
 
typedef struct _SM_START_CSR_MSG SM_START_CSR_MSG
 
typedef struct _SM_START_CSR_MSGPSM_START_CSR_MSG
 
typedef struct _SM_STOP_CSR_MSG SM_STOP_CSR_MSG
 
typedef struct _SM_STOP_CSR_MSGPSM_STOP_CSR_MSG
 
typedef struct _SM_API_MSG SM_API_MSG
 
typedef struct _SM_API_MSGPSM_API_MSG
 
typedef enum _SB_API_NUMBER SB_API_NUMBER
 
typedef struct _SB_CREATE_SESSION_MSG SB_CREATE_SESSION_MSG
 
typedef struct _SB_CREATE_SESSION_MSGPSB_CREATE_SESSION_MSG
 
typedef struct _SB_TERMINATE_SESSION_MSG SB_TERMINATE_SESSION_MSG
 
typedef struct _SB_TERMINATE_SESSION_MSGPSB_TERMINATE_SESSION_MSG
 
typedef struct _SB_FOREIGN_SESSION_COMPLETE_MSG SB_FOREIGN_SESSION_COMPLETE_MSG
 
typedef struct _SB_FOREIGN_SESSION_COMPLETE_MSGPSB_FOREIGN_SESSION_COMPLETE_MSG
 
typedef struct _SB_CREATE_PROCESS_MSG SB_CREATE_PROCESS_MSG
 
typedef struct _SB_CREATE_PROCESS_MSGPSB_CREATE_PROCESS_MSG
 
typedef struct _SB_CONNECTION_INFO SB_CONNECTION_INFO
 
typedef struct _SB_CONNECTION_INFOPSB_CONNECTION_INFO
 
typedef struct _SB_API_MSG SB_API_MSG
 
typedef struct _SB_API_MSGPSB_API_MSG
 
typedef BOOLEAN(NTAPIPSB_API_ROUTINE) (IN PSB_API_MSG SbApiMsg)
 

Enumerations

enum  _SMSRV_API_NUMBER {
  SmpCreateForeignSessionApi, SmpSessionCompleteApi, SmpTerminateForeignSessionApi, SmpExecPgmApi,
  SmpLoadDeferedSubsystemApi, SmpStartCsrApi, SmpStopCsrApi, SmpMaxApiNumber
}
 
enum  _SB_API_NUMBER {
  SbpCreateSession, SbpTerminateSession, SbpForeignSessionComplete, SbpCreateProcess,
  SbpMaxApiNumber
}
 

Functions

 C_ASSERT (sizeof(SM_EXEC_PGM_MSG)==0x48)
 
 C_ASSERT (sizeof(SM_API_MSG)==0x130)
 
 C_ASSERT (sizeof(SB_CONNECTION_INFO)==0xF4)
 
 C_ASSERT (sizeof(SB_API_MSG)==0x110)
 
NTSTATUS NTAPI SmConnectToSm (IN PUNICODE_STRING SbApiPortName, IN HANDLE SbApiPort, IN ULONG ImageType, OUT PHANDLE SmApiPort)
 
NTSTATUS NTAPI SmExecPgm (IN HANDLE SmApiPort, IN PRTL_USER_PROCESS_INFORMATION ProcessInformation, IN BOOLEAN DebugFlag)
 
NTSTATUS NTAPI SmSessionComplete (IN HANDLE SmApiPort, IN ULONG SessionId, IN NTSTATUS SessionStatus)
 

Macro Definition Documentation

◆ _SM_MSG_

#define _SM_MSG_

Definition at line 10 of file smmsg.h.

◆ SB_PROCESS_FLAGS_DEBUG

#define SB_PROCESS_FLAGS_DEBUG   0x1

Definition at line 161 of file smmsg.h.

◆ SB_PROCESS_FLAGS_RESERVE_1MB

#define SB_PROCESS_FLAGS_RESERVE_1MB   0x8

Definition at line 163 of file smmsg.h.

◆ SB_PROCESS_FLAGS_SKIP_CHECKS

#define SB_PROCESS_FLAGS_SKIP_CHECKS   0x20

Definition at line 164 of file smmsg.h.

◆ SB_PROCESS_FLAGS_WAIT_ON_THREAD

#define SB_PROCESS_FLAGS_WAIT_ON_THREAD   0x2

Definition at line 162 of file smmsg.h.

Typedef Documentation

◆ PSB_API_MSG

◆ PSB_API_ROUTINE

typedef BOOLEAN(NTAPI * PSB_API_ROUTINE) (IN PSB_API_MSG SbApiMsg)

Definition at line 234 of file smmsg.h.

◆ PSB_CONNECTION_INFO

◆ PSB_CREATE_PROCESS_MSG

◆ PSB_CREATE_SESSION_MSG

◆ PSB_FOREIGN_SESSION_COMPLETE_MSG

◆ PSB_TERMINATE_SESSION_MSG

◆ PSM_API_MSG

◆ PSM_CREATE_FOREIGN_SESSION_MSG

◆ PSM_EXEC_PGM_MSG

◆ PSM_LOAD_DEFERED_SUBSYSTEM_MSG

◆ PSM_SESSION_COMPLETE_MSG

◆ PSM_START_CSR_MSG

◆ PSM_STOP_CSR_MSG

◆ PSM_TERMINATE_FOREIGN_SESSION_MSG

◆ SB_API_MSG

◆ SB_API_NUMBER

◆ SB_CONNECTION_INFO

◆ SB_CREATE_PROCESS_MSG

◆ SB_CREATE_SESSION_MSG

◆ SB_FOREIGN_SESSION_COMPLETE_MSG

◆ SB_TERMINATE_SESSION_MSG

◆ SM_API_MSG

◆ SM_CREATE_FOREIGN_SESSION_MSG

◆ SM_EXEC_PGM_MSG

◆ SM_LOAD_DEFERED_SUBSYSTEM_MSG

◆ SM_SESSION_COMPLETE_MSG

◆ SM_START_CSR_MSG

◆ SM_STOP_CSR_MSG

◆ SM_TERMINATE_FOREIGN_SESSION_MSG

◆ SMSRV_API_NUMBER

Enumeration Type Documentation

◆ _SB_API_NUMBER

Enumerator
SbpCreateSession 
SbpTerminateSession 
SbpForeignSessionComplete 
SbpCreateProcess 
SbpMaxApiNumber 

Definition at line 128 of file smmsg.h.

◆ _SMSRV_API_NUMBER

Enumerator
SmpCreateForeignSessionApi 
SmpSessionCompleteApi 
SmpTerminateForeignSessionApi 
SmpExecPgmApi 
SmpLoadDeferedSubsystemApi 
SmpStartCsrApi 
SmpStopCsrApi 
SmpMaxApiNumber 

Definition at line 25 of file smmsg.h.

Function Documentation

◆ C_ASSERT() [1/4]

C_ASSERT ( sizeof(SM_EXEC_PGM_MSG = =0x48)

◆ C_ASSERT() [2/4]

C_ASSERT ( sizeof(SM_API_MSG = =0x130)

◆ C_ASSERT() [3/4]

C_ASSERT ( sizeof(SB_CONNECTION_INFO = =0xF4)

◆ C_ASSERT() [4/4]

C_ASSERT ( sizeof(SB_API_MSG = =0x110)

◆ SmConnectToSm()

NTSTATUS NTAPI SmConnectToSm ( IN PUNICODE_STRING  SbApiPortName,
IN HANDLE  SbApiPort,
IN ULONG  ImageType,
OUT PHANDLE  SmApiPort 
)

Definition at line 68 of file smclient.c.

72 {
74  SB_CONNECTION_INFO ConnectInfo;
76  SECURITY_QUALITY_OF_SERVICE SecurityQos;
77  ULONG ConnectInfoLength = sizeof(ConnectInfo);
78 
79  /* Setup the QoS structure */
82  SecurityQos.EffectiveOnly = TRUE;
83 
84  /* Set the SM API port name */
85  RtlInitUnicodeString(&PortName, L"\\SmApiPort");
86 
87  /* Check if this is a client connecting to SMSS, or SMSS to itself */
88  if (SbApiPortName)
89  {
90  /* A client SB port as well as an image type must be present */
91  if (!(SbApiPort) || !(ImageType)) return STATUS_INVALID_PARAMETER_MIX;
92 
93  /* Copy the client port name, and NULL-terminate it */
94  RtlCopyMemory(ConnectInfo.SbApiPortName,
95  SbApiPortName->Buffer,
96  SbApiPortName->Length);
97  ConnectInfo.SbApiPortName[SbApiPortName->Length /
98  sizeof(WCHAR)] = UNICODE_NULL;
99 
100  /* Save the subsystem type */
101  ConnectInfo.SubsystemType = ImageType;
102  }
103  else
104  {
105  /* No client port, and the subsystem type is not set */
106  ConnectInfo.SbApiPortName[0] = UNICODE_NULL;
108  }
109 
110  /* Connect to SMSS and exchange connection information */
112  &PortName,
113  &SecurityQos,
114  NULL,
115  NULL,
116  NULL,
117  &ConnectInfo,
118  &ConnectInfoLength);
119  if (!NT_SUCCESS(Status))
120  {
121  DPRINT1("SmConnectToSm: Connect to Sm failed %lx\n", Status);
122  }
123  else
124  {
125  /* Treat a warning or informational status as success */
127  }
128 
129  /* Return if the connection was successful or not */
130  return Status;
131 }
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG SubsystemType
Definition: smmsg.h:193
HANDLE SmApiPort
Definition: smss.c:23
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_PARAMETER_MIX
Definition: ntstatus.h:271
SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
Definition: lsa.idl:66
#define UNICODE_NULL
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI NtConnectPort(OUT PHANDLE PortHandle, IN PUNICODE_STRING PortName, IN PSECURITY_QUALITY_OF_SERVICE SecurityQos, IN OUT PPORT_VIEW ClientView OPTIONAL, IN OUT PREMOTE_PORT_VIEW ServerView OPTIONAL, OUT PULONG MaxMessageLength OPTIONAL, IN OUT PVOID ConnectionInformation OPTIONAL, IN OUT PULONG ConnectionInformationLength OPTIONAL)
Definition: connect.c:753
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define IMAGE_SUBSYSTEM_UNKNOWN
Definition: ntimage.h:435
WCHAR SbApiPortName[120]
Definition: smmsg.h:194
#define SECURITY_DYNAMIC_TRACKING
Definition: setypes.h:103
static const WCHAR L[]
Definition: oid.c:1250
Status
Definition: gdiplustypes.h:24
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: lsa.idl:65
#define DPRINT1
Definition: precomp.h:8
ImageType
Definition: gdiplusenums.h:191
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
return STATUS_SUCCESS
Definition: btrfs.c:2938
IN PUNICODE_STRING PortName
Definition: conport.c:35

Referenced by CsrServerInitialization(), and SmpExecuteInitialCommand().

◆ SmExecPgm()

NTSTATUS NTAPI SmExecPgm ( IN HANDLE  SmApiPort,
IN PRTL_USER_PROCESS_INFORMATION  ProcessInformation,
IN BOOLEAN  DebugFlag 
)

Definition at line 21 of file smclient.c.

24 {
26  SM_API_MSG SmApiMsg;
27 
28 #if 0 //def _WIN64 // You can take care of this Timo
29  /* 64-bit SMSS needs to talk to 32-bit processes so do the LPC conversion */
30  if (SmpIsWow64Process())
31  {
32  return SmpWow64ExecPgm(SmApiPort, ProcessInformation, DebugFlag);
33  }
34 #endif
35 
36  /* Initialize the generic LPC header */
37  SmApiMsg.h.u2.ZeroInit = 0;
38  SmApiMsg.h.u1.s1.DataLength = sizeof(SM_EXEC_PGM_MSG) + 8;
39  SmApiMsg.h.u1.s1.TotalLength = sizeof(SmApiMsg);
40 
41  /* Initialize this specific API's parameters */
42  SmApiMsg.ApiNumber = SmpExecPgmApi;
44  ProcessInformation,
45  sizeof(SmApiMsg.u.ExecPgm.ProcessInformation));
46  SmApiMsg.u.ExecPgm.DebugFlag = DebugFlag;
47 
48  /* Send the message to SMSS */
49  Status = NtRequestWaitReplyPort(SmApiPort, &SmApiMsg.h, &SmApiMsg.h);
50  if (!NT_SUCCESS(Status))
51  {
52  DPRINT1("SmExecPgm: NtRequestWaitReply Failed %lx\n", Status);
53  }
54  else
55  {
56  /* Upon success, we use the API's return value */
57  Status = SmApiMsg.ReturnValue;
58  }
59 
60  /* Close the handles that the parent passed in and return status */
61  NtClose(ProcessInformation->ProcessHandle);
62  NtClose(ProcessInformation->ThreadHandle);
63  return Status;
64 }
PORT_MESSAGE h
Definition: smmsg.h:92
SM_EXEC_PGM_MSG ExecPgm
Definition: smmsg.h:100
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
RTL_USER_PROCESS_INFORMATION ProcessInformation
Definition: smmsg.h:60
HANDLE SmApiPort
Definition: smss.c:23
NTSTATUS NTAPI NtRequestWaitReplyPort(IN HANDLE PortHandle, IN PPORT_MESSAGE LpcRequest, IN OUT PPORT_MESSAGE LpcReply)
Definition: send.c:695
LONG NTSTATUS
Definition: precomp.h:26
SMSRV_API_NUMBER ApiNumber
Definition: smmsg.h:93
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
union _SM_API_MSG::@3400 u
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
Status
Definition: gdiplustypes.h:24
BOOLEAN DebugFlag
Definition: smmsg.h:61
#define DPRINT1
Definition: precomp.h:8
struct _SM_EXEC_PGM_MSG SM_EXEC_PGM_MSG
NTSTATUS ReturnValue
Definition: smmsg.h:94

Referenced by SmpExecPgm(), and SmpExecuteInitialCommand().

◆ SmSessionComplete()

NTSTATUS NTAPI SmSessionComplete ( IN HANDLE  SmApiPort,
IN ULONG  SessionId,
IN NTSTATUS  SessionStatus 
)

Definition at line 135 of file smclient.c.

138 {
140  SM_API_MSG ApiMessage;
141  PSM_SESSION_COMPLETE_MSG SessionComplete = &ApiMessage.u.SessionComplete;
142 
143  /* Set the message data */
144  SessionComplete->SessionId = SessionId;
145  SessionComplete->SessionStatus = SessionStatus;
146 
147  /* Set the API Message Port Message header */
148  ApiMessage.ApiNumber = SmpSessionCompleteApi;
149  ApiMessage.h.u1.s1.DataLength = sizeof(SM_SESSION_COMPLETE_MSG) + 8;
150  ApiMessage.h.u1.s1.TotalLength = sizeof(SM_API_MSG);
151  ApiMessage.h.u2.ZeroInit = 0;
152 
153  /* Sent the message and wait for a reply */
155  &ApiMessage.h,
156  &ApiMessage.h);
157  if (NT_SUCCESS(Status))
158  {
159  /* Return the real status */
160  Status = ApiMessage.ReturnValue;
161  }
162  else
163  {
164  DPRINT1("SmCompleteSession: NtRequestWaitReply failed\n");
165  }
166 
167  /* Return status */
168  return Status;
169 }
PORT_MESSAGE h
Definition: smmsg.h:92
HANDLE SmApiPort
Definition: smss.c:23
NTSTATUS NTAPI NtRequestWaitReplyPort(IN HANDLE PortHandle, IN PPORT_MESSAGE LpcRequest, IN OUT PPORT_MESSAGE LpcReply)
Definition: send.c:695
ULONG SessionId
Definition: dllmain.c:28
LONG NTSTATUS
Definition: precomp.h:26
SMSRV_API_NUMBER ApiNumber
Definition: smmsg.h:93
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
union _SM_API_MSG::@3400 u
Status
Definition: gdiplustypes.h:24
struct _SM_API_MSG SM_API_MSG
struct _SM_SESSION_COMPLETE_MSG SM_SESSION_COMPLETE_MSG
#define DPRINT1
Definition: precomp.h:8
SM_SESSION_COMPLETE_MSG SessionComplete
Definition: smmsg.h:98
NTSTATUS SessionStatus
Definition: smmsg.h:50
NTSTATUS ReturnValue
Definition: smmsg.h:94

Referenced by CsrDereferenceNtSession().