2 * PROJECT: ReactOS Windows-Compatible Session Manager
3 * LICENSE: BSD 2-Clause License
4 * FILE: include/reactos/subsystems/sm/smmsg.h
5 * PURPOSE: SMSS (SB and SM) Message Format
6 * PROGRAMMERS: Alex Ionescu
13 // There are the APIs that a Client (such as CSRSS) can send to the SMSS Server.
15 // These are called "SM" APIs.
17 // The exact names are not known, but we are basing them on the SmpApiName array
18 // in the checked build of SMSS, which is probably a close approximation. We add
19 // "p" to use the similar nomenclature seen/leaked out in the Base CSRSS APIs.
21 // The enumeration finishes with an enumeratee holding the maximum API number.
22 // Its name is based on BasepMaxApiNumber, UserpMaxApiNumber...
25 typedef enum _SMSRV_API_NUMBER
27 SmpCreateForeignSessionApi
,
28 SmpSessionCompleteApi
,
29 SmpTerminateForeignSessionApi
,
31 SmpLoadDeferedSubsystemApi
,
39 // These are the structures making up the SM_API_MSG packet structure defined
40 // below. Each one corresponds to an equivalent API from the list above.
42 typedef struct _SM_CREATE_FOREIGN_SESSION_MSG
45 } SM_CREATE_FOREIGN_SESSION_MSG
, *PSM_CREATE_FOREIGN_SESSION_MSG
;
47 typedef struct _SM_SESSION_COMPLETE_MSG
50 NTSTATUS SessionStatus
;
51 } SM_SESSION_COMPLETE_MSG
, *PSM_SESSION_COMPLETE_MSG
;
53 typedef struct _SM_TERMINATE_FOREIGN_SESSION_MSG
56 } SM_TERMINATE_FOREIGN_SESSION_MSG
, *PSM_TERMINATE_FOREIGN_SESSION_MSG
;
58 typedef struct _SM_EXEC_PGM_MSG
60 RTL_USER_PROCESS_INFORMATION ProcessInformation
;
62 } SM_EXEC_PGM_MSG
, *PSM_EXEC_PGM_MSG
;
64 C_ASSERT(sizeof(SM_EXEC_PGM_MSG
) == 0x48);
67 typedef struct _SM_LOAD_DEFERED_SUBSYSTEM_MSG
71 } SM_LOAD_DEFERED_SUBSYSTEM_MSG
, *PSM_LOAD_DEFERED_SUBSYSTEM_MSG
;
73 typedef struct _SM_START_CSR_MSG
78 HANDLE WindowsSubSysProcessId
;
79 HANDLE SmpInitialCommandProcessId
;
80 } SM_START_CSR_MSG
, *PSM_START_CSR_MSG
;
82 typedef struct _SM_STOP_CSR_MSG
85 } SM_STOP_CSR_MSG
, *PSM_STOP_CSR_MSG
;
88 // This is the actual packet structure sent over LCP to the \SmApiPort
90 typedef struct _SM_API_MSG
93 SMSRV_API_NUMBER ApiNumber
;
97 SM_CREATE_FOREIGN_SESSION_MSG CreateForeignSession
;
98 SM_SESSION_COMPLETE_MSG SessionComplete
;
99 SM_TERMINATE_FOREIGN_SESSION_MSG TerminateForeignComplete
;
100 SM_EXEC_PGM_MSG ExecPgm
;
101 SM_LOAD_DEFERED_SUBSYSTEM_MSG LoadDefered
;
102 SM_START_CSR_MSG StartCsr
;
103 SM_STOP_CSR_MSG StopCsr
;
105 } SM_API_MSG
, *PSM_API_MSG
;
108 // This is the size that Server 2003 SP1 SMSS expects, so make sure we conform.
111 C_ASSERT(sizeof(SM_API_MSG
) == 0x130);
115 // There are the APIs that the SMSS Server can send to a client (such as CSRSS).
117 // These are called "SB" APIs.
119 // The exact names are unknown but we are basing them on the CsrServerSbApiName
120 // array in the checked build of CSRSRV which is probably a close approximation.
121 // We add "p" to use the similar nomenclature seen/leaked out in the Base CSRSS
124 // The enumeration finishes with an enumeratee holding the maximum API number.
125 // Its name is based on BasepMaxApiNumber, UserpMaxApiNumber...
128 typedef enum _SB_API_NUMBER
132 SbpForeignSessionComplete
,
139 // These are the structures making up the SB_API_MSG packet structure defined
140 // below. Each one corresponds to an equivalent API from the list above.
142 typedef struct _SB_CREATE_SESSION_MSG
145 RTL_USER_PROCESS_INFORMATION ProcessInfo
;
149 } SB_CREATE_SESSION_MSG
, *PSB_CREATE_SESSION_MSG
;
151 typedef struct _SB_TERMINATE_SESSION_MSG
154 } SB_TERMINATE_SESSION_MSG
, *PSB_TERMINATE_SESSION_MSG
;
156 typedef struct _SB_FOREIGN_SESSION_COMPLETE_MSG
159 } SB_FOREIGN_SESSION_COMPLETE_MSG
, *PSB_FOREIGN_SESSION_COMPLETE_MSG
;
161 #define SB_PROCESS_FLAGS_DEBUG 0x1
162 #define SB_PROCESS_FLAGS_WAIT_ON_THREAD 0x2
163 #define SB_PROCESS_FLAGS_RESERVE_1MB 0x8
164 #define SB_PROCESS_FLAGS_SKIP_CHECKS 0x20
165 typedef struct _SB_CREATE_PROCESS_MSG
171 PUNICODE_STRING ImageName
;
172 PUNICODE_STRING CurrentDirectory
;
173 PUNICODE_STRING CommandLine
;
174 PUNICODE_STRING DllPath
;
180 HANDLE ProcessHandle
;
186 } SB_CREATE_PROCESS_MSG
, *PSB_CREATE_PROCESS_MSG
;
189 // When the server connects to a client, this structure is exchanged
191 typedef struct _SB_CONNECTION_INFO
194 WCHAR SbApiPortName
[120];
195 } SB_CONNECTION_INFO
, *PSB_CONNECTION_INFO
;
198 // This is the actual packet structure sent over LCP to the \SbApiPort
200 typedef struct _SB_API_MSG
205 SB_CONNECTION_INFO ConnectionInfo
;
208 SB_API_NUMBER ApiNumber
;
209 NTSTATUS ReturnValue
;
212 SB_CREATE_SESSION_MSG CreateSession
;
213 SB_TERMINATE_SESSION_MSG TerminateSession
;
214 SB_FOREIGN_SESSION_COMPLETE_MSG ForeignSessionComplete
;
215 SB_CREATE_PROCESS_MSG CreateProcess
;
219 } SB_API_MSG
, *PSB_API_MSG
;
222 // This is the size that Server 2003 SP1 SMSS expects, so make sure we conform.
225 C_ASSERT(sizeof(SB_CONNECTION_INFO
) == 0xF4);
226 C_ASSERT(sizeof(SB_API_MSG
) == 0x110);
230 // SB Message Handler
234 (NTAPI
*PSB_API_ROUTINE
)(
235 IN PSB_API_MSG SbApiMsg
239 // The actual server functions that a client linking with smlib can call
244 IN PUNICODE_STRING SbApiPortName
,
254 IN PRTL_USER_PROCESS_INFORMATION ProcessInformation
,
263 IN NTSTATUS SessionStatus