ReactOS 0.4.15-dev-8127-g6338913
smmsg.h
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS NT-Compatible Session Manager
3 * LICENSE: BSD 2-Clause License (https://spdx.org/licenses/BSD-2-Clause)
4 * PURPOSE: SMSS Client (SB and SM) Message Format
5 * COPYRIGHT: Copyright 2012-2013 Alex Ionescu <alex.ionescu@reactos.org>
6 * Copyright 2021 Hervé Poussineau <hpoussin@reactos.org>
7 * Copyright 2022 Hermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
8 */
9
10#ifndef _SM_MSG_
11#define _SM_MSG_
12
13#pragma once
14
15//
16// There are the APIs that a Client (such as CSRSS) can send to the SMSS Server.
17// These are called "SM" APIs.
18//
19// The exact names are not known, but we are basing them on the SmpApiName array
20// in the checked build of SMSS, which is probably a close approximation. We add
21// "p" to use the similar nomenclature seen/leaked out in the Base CSRSS APIs.
22//
23// The enumeration finishes with an enumeratee holding the maximum API number.
24// Its name is based on BasepMaxApiNumber, UserpMaxApiNumber...
25//
27{
35
38
39//
40// These are the structures making up the SM_API_MSG packet structure defined
41// below. Each one corresponds to an equivalent API from the list above.
42//
44{
47
49{
53
55{
58
59typedef struct _SM_EXEC_PGM_MSG
60{
64#ifndef _WIN64
65C_ASSERT(sizeof(SM_EXEC_PGM_MSG) == 0x48);
66#else
67C_ASSERT(sizeof(SM_EXEC_PGM_MSG) == 0x70);
68#endif
69
71{
75
76typedef struct _SM_START_CSR_MSG
77{
84#ifndef _WIN64
85C_ASSERT(sizeof(SM_START_CSR_MSG) == 0x110);
86#else
87C_ASSERT(sizeof(SM_START_CSR_MSG) == 0x118);
88#endif
89
90typedef struct _SM_STOP_CSR_MSG
91{
94
95#if defined(__REACTOS__) && DBG
96#include "smrosdbg.h"
97#endif
98
99//
100// This is the actual packet structure sent over LPC to the \SmApiPort
101//
102typedef struct _SM_API_MSG
103{
107 union
108 {
116
117#if defined(__REACTOS__) && DBG
118 SM_QUERYINFO_MSG QueryInfo;
119#endif
120 } u;
122
123//
124// This is the size that Server 2003 SP1 SMSS expects, so make sure we conform.
125//
126#ifndef _WIN64
127C_ASSERT(sizeof(SM_API_MSG) == 0x130);
128#else
129C_ASSERT(sizeof(SM_API_MSG) == 0x148);
130#endif
131
132//
133// There are the APIs that the SMSS Server can send to a client (such as CSRSS).
134// These are called "SB" APIs.
135//
136// The exact names are unknown but we are basing them on the CsrServerSbApiName
137// array in the checked build of CSRSRV which is probably a close approximation.
138// We add "p" to use the similar nomenclature seen/leaked out in the Base CSRSS
139// APIs.
140//
141// The enumeration finishes with an enumeratee holding the maximum API number.
142// Its name is based on BasepMaxApiNumber, UserpMaxApiNumber...
143//
144typedef enum _SB_API_NUMBER
145{
150
153
154//
155// These are the structures making up the SB_API_MSG packet structure defined
156// below. Each one corresponds to an equivalent API from the list above.
157//
159{
166#ifndef _WIN64
168#else
169C_ASSERT(sizeof(SB_CREATE_SESSION_MSG) == 0x90);
170#endif
171
173{
176
178{
181
182#define SB_PROCESS_FLAGS_DEBUG 0x1
183#define SB_PROCESS_FLAGS_WAIT_ON_THREAD 0x2
184#define SB_PROCESS_FLAGS_RESERVE_1MB 0x8
185#define SB_PROCESS_FLAGS_SKIP_CHECKS 0x20
187{
188 union
189 {
190 struct
191 {
198 } In;
199 struct
200 {
206 };
208#ifndef _WIN64
210#else
211C_ASSERT(sizeof(SB_CREATE_PROCESS_MSG) == 0x28);
212#endif
213
214#ifdef CreateProcess
215#undef CreateProcess
216#endif
217
218//
219// When the server connects to a client, this structure is exchanged
220//
222{
226
227//
228// This is the actual packet structure sent over LPC to the \SbApiPort
229//
230typedef struct _SB_API_MSG
231{
233 union
234 {
236 struct
237 {
240 union
241 {
246 } u;
247 };
248 };
250
251//
252// This is the size that Server 2003 SP1 SMSS expects, so make sure we conform.
253//
254#ifndef _WIN64
255C_ASSERT(sizeof(SB_API_MSG) == 0x110);
256#else
257C_ASSERT(sizeof(SB_API_MSG) == 0x120);
258#endif
259
260//
261// SB Message Handler
262//
263typedef
266 _In_ PSB_API_MSG SbApiMsg
267);
268
269//
270// The actual server functions that a client linking with SMLIB can call.
271//
272/* NTDLL!RtlConnectToSm */
274NTAPI
276 _In_opt_ PUNICODE_STRING SbApiPortName,
277 _In_opt_ HANDLE SbApiPort,
280
281/* NTDLL!RtlSendMsgToSm */
283NTAPI
286 _Inout_ PSM_API_MSG SmApiMsg);
287
289NTAPI
293 _In_ NTSTATUS SessionStatus);
294
296NTAPI
299 _In_ PRTL_USER_PROCESS_INFORMATION ProcessInformation,
301
303NTAPI
306 _In_ PUNICODE_STRING DeferedSubsystem);
307
309NTAPI
312 _Out_ PULONG pMuSessionId,
313 _In_opt_ PUNICODE_STRING CommandLine,
314 _Out_ PHANDLE pWindowsSubSysProcessId,
315 _Out_ PHANDLE pInitialCommandProcessId);
316
318NTAPI
321 _In_ ULONG MuSessionId);
322
323#endif // _SM_MSG_
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
Definition: bufpool.h:45
ULONG DebugFlag
Definition: fxobject.cpp:44
ULONG SessionId
Definition: dllmain.c:28
ImageType
Definition: gdiplusenums.h:193
#define C_ASSERT(e)
Definition: intsafe.h:73
#define _Inout_
Definition: ms_sal.h:378
#define _Out_
Definition: ms_sal.h:345
#define _In_
Definition: ms_sal.h:308
#define _In_opt_
Definition: ms_sal.h:309
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define BOOLEAN
Definition: pedump.c:73
struct _SB_TERMINATE_SESSION_MSG SB_TERMINATE_SESSION_MSG
struct _SM_CREATE_FOREIGN_SESSION_MSG * PSM_CREATE_FOREIGN_SESSION_MSG
struct _SM_TERMINATE_FOREIGN_SESSION_MSG * PSM_TERMINATE_FOREIGN_SESSION_MSG
struct _SB_CREATE_PROCESS_MSG SB_CREATE_PROCESS_MSG
struct _SM_START_CSR_MSG * PSM_START_CSR_MSG
struct _SM_TERMINATE_FOREIGN_SESSION_MSG SM_TERMINATE_FOREIGN_SESSION_MSG
NTSTATUS NTAPI SmLoadDeferedSubsystem(_In_ HANDLE SmApiPort, _In_ PUNICODE_STRING DeferedSubsystem)
This function is used to make the SM start an environment subsystem server process.
Definition: smclient.c:317
NTSTATUS NTAPI SmSessionComplete(_In_ HANDLE SmApiPort, _In_ ULONG SessionId, _In_ NTSTATUS SessionStatus)
This function is called by an environment subsystem server to tell the SM it has terminated the sessi...
Definition: smclient.c:220
BOOLEAN(NTAPI * PSB_API_ROUTINE)(_In_ PSB_API_MSG SbApiMsg)
Definition: smmsg.h:265
NTSTATUS NTAPI SmStartCsr(_In_ HANDLE SmApiPort, _Out_ PULONG pMuSessionId, _In_opt_ PUNICODE_STRING CommandLine, _Out_ PHANDLE pWindowsSubSysProcessId, _Out_ PHANDLE pInitialCommandProcessId)
Requests the SM to create a new Terminal Services session and start an initial command.
Definition: smclient.c:376
struct _SM_STOP_CSR_MSG SM_STOP_CSR_MSG
struct _SM_SESSION_COMPLETE_MSG * PSM_SESSION_COMPLETE_MSG
struct _SM_START_CSR_MSG SM_START_CSR_MSG
struct _SB_TERMINATE_SESSION_MSG * PSB_TERMINATE_SESSION_MSG
struct _SB_FOREIGN_SESSION_COMPLETE_MSG SB_FOREIGN_SESSION_COMPLETE_MSG
struct _SB_CREATE_SESSION_MSG * PSB_CREATE_SESSION_MSG
enum _SMSRV_API_NUMBER SMSRV_API_NUMBER
struct _SM_SESSION_COMPLETE_MSG SM_SESSION_COMPLETE_MSG
enum _SB_API_NUMBER SB_API_NUMBER
struct _SM_API_MSG * PSM_API_MSG
struct _SB_CREATE_SESSION_MSG SB_CREATE_SESSION_MSG
NTSTATUS NTAPI SmConnectToSm(_In_opt_ PUNICODE_STRING SbApiPortName, _In_opt_ HANDLE SbApiPort, _In_opt_ ULONG ImageType, _Out_ PHANDLE SmApiPort)
Connects to the SM API port for registering a session callback port (Sb) associated to a subsystem,...
Definition: smclient.c:57
struct _SB_CONNECTION_INFO SB_CONNECTION_INFO
struct _SB_API_MSG * PSB_API_MSG
struct _SM_EXEC_PGM_MSG SM_EXEC_PGM_MSG
_SB_API_NUMBER
Definition: smmsg.h:145
@ SbpCreateProcess
Definition: smmsg.h:149
@ SbpCreateSession
Definition: smmsg.h:146
@ SbpMaxApiNumber
Definition: smmsg.h:151
@ SbpTerminateSession
Definition: smmsg.h:147
@ SbpForeignSessionComplete
Definition: smmsg.h:148
struct _SB_CREATE_PROCESS_MSG * PSB_CREATE_PROCESS_MSG
NTSTATUS NTAPI SmSendMsgToSm(_In_ HANDLE SmApiPort, _Inout_ PSM_API_MSG SmApiMsg)
Sends a message to the SM via the SM API port.
Definition: smclient.c:149
struct _SM_LOAD_DEFERED_SUBSYSTEM_MSG * PSM_LOAD_DEFERED_SUBSYSTEM_MSG
struct _SB_FOREIGN_SESSION_COMPLETE_MSG * PSB_FOREIGN_SESSION_COMPLETE_MSG
NTSTATUS NTAPI SmStopCsr(_In_ HANDLE SmApiPort, _In_ ULONG MuSessionId)
Requests the SM to terminate a Terminal Services session.
Definition: smclient.c:445
NTSTATUS NTAPI SmExecPgm(_In_ HANDLE SmApiPort, _In_ PRTL_USER_PROCESS_INFORMATION ProcessInformation, _In_ BOOLEAN DebugFlag)
Requests the SM to start a process under a new environment session.
Definition: smclient.c:265
_SMSRV_API_NUMBER
Definition: smmsg.h:27
@ SmpLoadDeferedSubsystemApi
Definition: smmsg.h:32
@ SmpStartCsrApi
Definition: smmsg.h:33
@ SmpStopCsrApi
Definition: smmsg.h:34
@ SmpTerminateForeignSessionApi
Definition: smmsg.h:30
@ SmpSessionCompleteApi
Definition: smmsg.h:29
@ SmpExecPgmApi
Definition: smmsg.h:31
@ SmpMaxApiNumber
Definition: smmsg.h:36
@ SmpCreateForeignSessionApi
Definition: smmsg.h:28
struct _SB_CONNECTION_INFO * PSB_CONNECTION_INFO
struct _SM_CREATE_FOREIGN_SESSION_MSG SM_CREATE_FOREIGN_SESSION_MSG
struct _SM_LOAD_DEFERED_SUBSYSTEM_MSG SM_LOAD_DEFERED_SUBSYSTEM_MSG
struct _SB_API_MSG SB_API_MSG
struct _SM_EXEC_PGM_MSG * PSM_EXEC_PGM_MSG
struct _SM_API_MSG SM_API_MSG
struct _SM_STOP_CSR_MSG * PSM_STOP_CSR_MSG
HANDLE SmApiPort
Definition: smss.c:23
union _SB_API_MSG::@3535::@3537::@3539 u
NTSTATUS ReturnValue
Definition: smmsg.h:239
SB_API_NUMBER ApiNumber
Definition: smmsg.h:238
SB_CREATE_PROCESS_MSG CreateProcess
Definition: smmsg.h:245
SB_FOREIGN_SESSION_COMPLETE_MSG ForeignSessionComplete
Definition: smmsg.h:244
SB_TERMINATE_SESSION_MSG TerminateSession
Definition: smmsg.h:243
SB_CREATE_SESSION_MSG CreateSession
Definition: smmsg.h:242
SB_CONNECTION_INFO ConnectionInfo
Definition: smmsg.h:235
PORT_MESSAGE h
Definition: smmsg.h:232
WCHAR SbApiPortName[120]
Definition: smmsg.h:224
ULONG SubsystemType
Definition: smmsg.h:223
PUNICODE_STRING CommandLine
Definition: smmsg.h:194
HANDLE ProcessHandle
Definition: smmsg.h:201
struct _SB_CREATE_PROCESS_MSG::@3531::@3534 Out
PUNICODE_STRING DllPath
Definition: smmsg.h:195
PUNICODE_STRING ImageName
Definition: smmsg.h:192
struct _SB_CREATE_PROCESS_MSG::@3531::@3533 In
CLIENT_ID ClientId
Definition: smmsg.h:204
PUNICODE_STRING CurrentDirectory
Definition: smmsg.h:193
CLIENT_ID DbgUiClientId
Definition: smmsg.h:164
RTL_USER_PROCESS_INFORMATION ProcessInfo
Definition: smmsg.h:161
SM_SESSION_COMPLETE_MSG SessionComplete
Definition: smmsg.h:110
SM_TERMINATE_FOREIGN_SESSION_MSG TerminateForeignComplete
Definition: smmsg.h:111
SM_STOP_CSR_MSG StopCsr
Definition: smmsg.h:115
SM_START_CSR_MSG StartCsr
Definition: smmsg.h:114
SM_EXEC_PGM_MSG ExecPgm
Definition: smmsg.h:112
NTSTATUS ReturnValue
Definition: smmsg.h:106
SM_CREATE_FOREIGN_SESSION_MSG CreateForeignSession
Definition: smmsg.h:109
PORT_MESSAGE h
Definition: smmsg.h:104
SMSRV_API_NUMBER ApiNumber
Definition: smmsg.h:105
SM_LOAD_DEFERED_SUBSYSTEM_MSG LoadDefered
Definition: smmsg.h:113
union _SM_API_MSG::@3530 u
BOOLEAN DebugFlag
Definition: smmsg.h:62
RTL_USER_PROCESS_INFORMATION ProcessInformation
Definition: smmsg.h:61
NTSTATUS SessionStatus
Definition: smmsg.h:51
HANDLE SmpInitialCommandProcessId
Definition: smmsg.h:82
HANDLE WindowsSubSysProcessId
Definition: smmsg.h:81
ULONG Length
Definition: smmsg.h:79
ULONG MuSessionId
Definition: smmsg.h:78
ULONG MuSessionId
Definition: smmsg.h:92
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
uint32_t ULONG
Definition: typedefs.h:59
__wchar_t WCHAR
Definition: xmlstorage.h:180