ReactOS 0.4.16-dev-91-g764881a
smloop.c File Reference
#include "smss.h"
#include <debug.h>
Include dependency graph for smloop.c:

Go to the source code of this file.

Classes

struct  _SMP_CLIENT_CONTEXT
 

Macros

#define NDEBUG
 

Typedefs

typedef struct _SMP_CLIENT_CONTEXT SMP_CLIENT_CONTEXT
 
typedef struct _SMP_CLIENT_CONTEXTPSMP_CLIENT_CONTEXT
 
typedef NTSTATUS(NTAPIPSM_API_HANDLER) (_In_ PSM_API_MSG SmApiMsg, _In_ PSMP_CLIENT_CONTEXT ClientContext, _In_ HANDLE SmApiPort)
 

Functions

NTSTATUS NTAPI SmpCreateForeignSession (IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
 
NTSTATUS NTAPI SmpSessionComplete (IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
 
NTSTATUS NTAPI SmpTerminateForeignSession (IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
 
NTSTATUS NTAPI SmpExecPgm (IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
 
NTSTATUS NTAPI SmpLoadDeferedSubsystem (_In_ PSM_API_MSG SmApiMsg, _In_ PSMP_CLIENT_CONTEXT ClientContext, _In_ HANDLE SmApiPort)
 
NTSTATUS NTAPI SmpStartCsr (IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
 
NTSTATUS NTAPI SmpStopCsr (IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
 
NTSTATUS NTAPI SmpHandleConnectionRequest (IN HANDLE SmApiPort, IN PSB_API_MSG SbApiMsg)
 
ULONG NTAPI SmpApiLoop (IN PVOID Parameter)
 

Variables

volatile LONG SmTotalApiThreads
 
HANDLE SmUniqueProcessId
 
PSM_API_HANDLER SmpApiDispatch [SmpMaxApiNumber - SmpCreateForeignSessionApi]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 13 of file smloop.c.

Typedef Documentation

◆ PSM_API_HANDLER

Definition at line 27 of file smloop.c.

◆ PSMP_CLIENT_CONTEXT

◆ SMP_CLIENT_CONTEXT

Function Documentation

◆ SmpApiLoop()

ULONG NTAPI SmpApiLoop ( IN PVOID  Parameter)

Definition at line 423 of file smloop.c.

424{
428 PSM_API_MSG ReplyMsg = NULL;
429 SM_API_MSG RequestMsg;
430 PROCESS_BASIC_INFORMATION ProcessInformation;
432
433 /* Increase the number of API threads for throttling code for later */
435
436 /* Mark us critical */
438
439 /* Set the PID of the SM process itself for later checking */
442 &ProcessInformation,
443 sizeof(ProcessInformation),
444 NULL);
445 SmUniqueProcessId = (HANDLE)ProcessInformation.UniqueProcessId;
446
447 /* Now process incoming messages */
448 while (TRUE)
449 {
450 /* Begin waiting on a request */
453 &ReplyMsg->h,
454 &RequestMsg.h);
456 {
457 /* Ran out of memory, so do a little timeout and try again */
458 if (ReplyMsg) DPRINT1("SMSS: Failed to reply to calling thread, retrying.\n");
459 Timeout.QuadPart = -50000000;
461 continue;
462 }
463
464 /* Check what kind of request we received */
465 switch (RequestMsg.h.u2.s2.Type)
466 {
467 /* A new connection */
469 /* Create the right structures for it */
471 ReplyMsg = NULL;
472 break;
473
474 /* A closed connection */
475 case LPC_PORT_CLOSED:
476 /* Destroy any state we had for this client */
477 DPRINT1("Port closed\n");
478 //if (ClientContext) SmpPushDeferredClientContext(ClientContext);
479 ReplyMsg = NULL;
480 break;
481
482 /* An actual API message */
483 default:
484 if (!ClientContext)
485 {
486 ReplyMsg = NULL;
487 break;
488 }
489
490 RequestMsg.ReturnValue = STATUS_PENDING;
491
492 /* Check if the API is valid */
493 if (RequestMsg.ApiNumber >= SmpMaxApiNumber)
494 {
495 /* It isn't, fail */
496 DPRINT1("Invalid API: %lx\n", RequestMsg.ApiNumber);
498 }
499 else if ((RequestMsg.ApiNumber <= SmpTerminateForeignSessionApi) &&
500 !(ClientContext->Subsystem))
501 {
502 /* It's valid, but doesn't have a subsystem with it */
503 DPRINT1("Invalid session API\n");
505 }
506 else
507 {
508 /* It's totally okay, so call the dispatcher for it */
509 Status = SmpApiDispatch[RequestMsg.ApiNumber](&RequestMsg,
511 SmApiPort);
512 }
513
514 /* Write the result value and return the message back */
515 RequestMsg.ReturnValue = Status;
516 ReplyMsg = &RequestMsg;
517 break;
518 }
519 }
520 return STATUS_SUCCESS;
521}
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
while(CdLookupNextInitialFileDirent(IrpContext, Fcb, FileContext))
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
Status
Definition: gdiplustypes.h:25
@ ProcessBasicInformation
Definition: winternl.h:394
long __cdecl _InterlockedExchangeAdd(_Interlocked_operand_ long volatile *_Addend, long _Value)
#define LPC_CONNECTION_REQUEST
Definition: port.c:102
#define LPC_PORT_CLOSED
Definition: port.c:97
NTSYSAPI NTSTATUS __cdecl RtlSetThreadIsCritical(_In_ BOOLEAN NewValue, _Out_opt_ PBOOLEAN OldValue, _In_ BOOLEAN NeedBreaks)
_In_ PVOID ClientContext
Definition: netioddk.h:55
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSTATUS NTAPI NtDelayExecution(IN BOOLEAN Alertable, IN PLARGE_INTEGER DelayInterval)
Definition: wait.c:876
NTSTATUS NTAPI NtReplyWaitReceivePort(IN HANDLE PortHandle, OUT PVOID *PortContext OPTIONAL, IN PPORT_MESSAGE ReplyMessage OPTIONAL, OUT PPORT_MESSAGE ReceiveMessage)
Definition: reply.c:743
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_ PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:59
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239
static ULONG Timeout
Definition: ping.c:61
#define STATUS_SUCCESS
Definition: shellext.h:65
HANDLE SmUniqueProcessId
Definition: smloop.c:34
NTSTATUS NTAPI SmpHandleConnectionRequest(IN HANDLE SmApiPort, IN PSB_API_MSG SbApiMsg)
Definition: smloop.c:273
volatile LONG SmTotalApiThreads
Definition: smloop.c:33
PSM_API_HANDLER SmpApiDispatch[SmpMaxApiNumber - SmpCreateForeignSessionApi]
Definition: smloop.c:258
@ SmpTerminateForeignSessionApi
Definition: smmsg.h:30
@ SmpMaxApiNumber
Definition: smmsg.h:36
HANDLE SmApiPort
Definition: smss.c:23
NTSTATUS ReturnValue
Definition: smmsg.h:106
PORT_MESSAGE h
Definition: smmsg.h:104
SMSRV_API_NUMBER ApiNumber
Definition: smmsg.h:105
PVOID HANDLE
Definition: typedefs.h:73
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
_Inout_opt_ PVOID Parameter
Definition: rtltypes.h:336

Referenced by SmpInit().

◆ SmpCreateForeignSession()

NTSTATUS NTAPI SmpCreateForeignSession ( IN PSM_API_MSG  SmApiMsg,
IN PSMP_CLIENT_CONTEXT  ClientContext,
IN HANDLE  SmApiPort 
)

Definition at line 40 of file smloop.c.

43{
44 DPRINT1("%s is not yet implemented\n", __FUNCTION__);
46}
#define __FUNCTION__
Definition: types.h:116

◆ SmpExecPgm()

NTSTATUS NTAPI SmpExecPgm ( IN PSM_API_MSG  SmApiMsg,
IN PSMP_CLIENT_CONTEXT  ClientContext,
IN HANDLE  SmApiPort 
)

Definition at line 70 of file smloop.c.

73{
77 RTL_USER_PROCESS_INFORMATION ProcessInformation;
79
80 /* Open the client process */
85 &SmApiMsg->h.ClientId);
86 if (!NT_SUCCESS(Status))
87 {
88 /* Fail */
89 DPRINT1("SmExecPgm: NtOpenProcess Failed %lx\n", Status);
90 return Status;
91 }
92
93 /* Copy the process information out of the message */
94 SmExecPgm = &SmApiMsg->u.ExecPgm;
95 ProcessInformation = SmExecPgm->ProcessInformation;
96
97 /* Duplicate the process handle */
99 SmExecPgm->ProcessInformation.ProcessHandle,
101 &ProcessInformation.ProcessHandle,
103 0,
104 0);
105 if (!NT_SUCCESS(Status))
106 {
107 /* Close the handle and fail */
109 DPRINT1("SmExecPgm: NtDuplicateObject (Process) Failed %lx\n", Status);
110 return Status;
111 }
112
113 /* Duplicate the thread handle */
115 SmExecPgm->ProcessInformation.ThreadHandle,
117 &ProcessInformation.ThreadHandle,
119 0,
120 0);
121 if (!NT_SUCCESS(Status))
122 {
123 /* Close both handles and fail */
124 NtClose(ProcessInformation.ProcessHandle);
126 DPRINT1("SmExecPgm: NtDuplicateObject (Thread) Failed %lx\n", Status);
127 return Status;
128 }
129
130 /* Close the process handle and call the internal client API */
133 NULL,
134 &ProcessInformation,
135 0,
136 SmExecPgm->DebugFlag ? &SmApiMsg->h.ClientId : NULL);
137}
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define PROCESS_DUP_HANDLE
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1324
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSTATUS NTAPI NtOpenProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId)
Definition: process.c:1440
NTSTATUS NTAPI NtDuplicateObject(IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle OPTIONAL, OUT PHANDLE TargetHandle OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG HandleAttributes, IN ULONG Options)
Definition: obhandle.c:3410
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
NTSTATUS NTAPI SmpSbCreateSession(IN PVOID Reserved, IN PSMP_SUBSYSTEM OtherSubsystem, IN PRTL_USER_PROCESS_INFORMATION ProcessInformation, IN ULONG DbgSessionId, IN PCLIENT_ID DbgUiClientId)
Definition: smsbapi.c:36

◆ SmpHandleConnectionRequest()

NTSTATUS NTAPI SmpHandleConnectionRequest ( IN HANDLE  SmApiPort,
IN PSB_API_MSG  SbApiMsg 
)

Definition at line 273 of file smloop.c.

275{
276 BOOLEAN Accept = TRUE;
277 HANDLE PortHandle, ProcessHandle;
279 UNICODE_STRING SubsystemPort;
283 REMOTE_PORT_VIEW PortView;
284 SECURITY_QUALITY_OF_SERVICE SecurityQos;
285 PSMP_SUBSYSTEM CidSubsystem, TypeSubsystem;
286
287 /* Initialize QoS data */
290 SecurityQos.EffectiveOnly = TRUE;
291
292 /* Check if this is SM connecting to itself */
293 if (SbApiMsg->h.ClientId.UniqueProcess == SmUniqueProcessId)
294 {
295 /* No need to get any handle -- assume session 0 */
297 SessionId = 0;
298 }
299 else
300 {
301 /* Reference the foreign process */
306 &SbApiMsg->h.ClientId);
307 if (!NT_SUCCESS(Status)) Accept = FALSE;
308
309 /* Get its session ID */
311 }
312
313 /* See if we already know about the caller's subsystem */
314 CidSubsystem = SmpLocateKnownSubSysByCid(&SbApiMsg->h.ClientId);
315 if ((CidSubsystem) && (Accept))
316 {
317 /* Check if we already have a subsystem for this kind of image */
319 SbApiMsg->ConnectionInfo.SubsystemType);
320 if (TypeSubsystem == CidSubsystem)
321 {
322 /* Someone is trying to take control of an existing subsystem, fail */
323 Accept = FALSE;
324 DPRINT1("SMSS: Connection from SubSystem rejected\n");
325 DPRINT1("SMSS: Image type already being served\n");
326 }
327 else
328 {
329 /* Set this image type as the type for this subsystem */
330 CidSubsystem->ImageType = SbApiMsg->ConnectionInfo.SubsystemType;
331 }
332
333 /* Drop the reference we had acquired */
334 if (TypeSubsystem) SmpDereferenceSubsystem(TypeSubsystem);
335 }
336
337 /* Check if we'll be accepting the connection */
338 if (Accept)
339 {
340 /* We will, so create a client context for it */
342 if (ClientContext)
343 {
344 ClientContext->ProcessHandle = ProcessHandle;
345 ClientContext->Subsystem = CidSubsystem;
346 ClientContext->Reserved = NULL;
347 ClientContext->PortHandle = NULL;
348 }
349 else
350 {
351 /* Failed to allocate a client context, so reject the connection */
352 DPRINT1("Rejecting connection due to lack of memory\n");
353 Accept = FALSE;
354 }
355 }
356 else
357 {
358 /* Use a bogus context since we're going to reject the message */
360 }
361
362 /* Now send the actual accept reply (which could be a rejection) */
363 PortView.Length = sizeof(PortView);
364 Status = NtAcceptConnectPort(&PortHandle,
366 &SbApiMsg->h,
367 Accept,
368 NULL,
369 &PortView);
370 if (!(Accept) || !(NT_SUCCESS(Status)))
371 {
372 /* Close the process handle, reference the subsystem, and exit */
373 DPRINT1("Accept failed or rejected: %lx\n", Status);
374 if (ClientContext != (PVOID)SbApiMsg) RtlFreeHeap(SmpHeap, 0, ClientContext);
376 if (CidSubsystem) SmpDereferenceSubsystem(CidSubsystem);
377 return Status;
378 }
379
380 /* Save the port handle now that we've accepted it */
381 if (ClientContext) ClientContext->PortHandle = PortHandle;
382 if (CidSubsystem) CidSubsystem->PortHandle = PortHandle;
383
384 /* Complete the port connection */
385 Status = NtCompleteConnectPort(PortHandle);
386 if ((NT_SUCCESS(Status)) && (CidSubsystem))
387 {
388 /* This was an actual subsystem, so connect back to it */
389 SbApiMsg->ConnectionInfo.SbApiPortName[119] = UNICODE_NULL;
390 RtlCreateUnicodeString(&SubsystemPort,
391 SbApiMsg->ConnectionInfo.SbApiPortName);
392 Status = NtConnectPort(&CidSubsystem->SbApiPort,
393 &SubsystemPort,
394 &SecurityQos,
395 NULL,
396 NULL,
397 NULL,
398 NULL,
399 NULL);
400 if (!NT_SUCCESS(Status))
401 {
402 DPRINT1("SMSS: Connect back to Sb %wZ failed %lx\n", &SubsystemPort, Status);
403 }
404 RtlFreeUnicodeString(&SubsystemPort);
405
406 /* Now that we're connected, signal the event handle */
407 NtSetEvent(CidSubsystem->Event, NULL);
408 }
409 else if (CidSubsystem)
410 {
411 /* We failed to complete the connection, so clear the port handle */
412 DPRINT1("Completing the connection failed: %lx\n", Status);
413 CidSubsystem->PortHandle = NULL;
414 }
415
416 /* Dereference the subsystem and return the result */
417 if (CidSubsystem) SmpDereferenceSubsystem(CidSubsystem);
418 return Status;
419}
unsigned char BOOLEAN
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
NTSTATUS NTAPI NtAcceptConnectPort(OUT PHANDLE PortHandle, IN PVOID PortContext OPTIONAL, IN PPORT_MESSAGE ReplyMessage, IN BOOLEAN AcceptConnection, IN OUT PPORT_VIEW ServerView OPTIONAL, OUT PREMOTE_PORT_VIEW ClientView OPTIONAL)
Definition: complete.c:40
NTSTATUS NTAPI NtCompleteConnectPort(IN HANDLE PortHandle)
Definition: complete.c:423
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
ULONG SessionId
Definition: dllmain.c:28
#define PROCESS_QUERY_INFORMATION
Definition: pstypes.h:167
@ SecurityIdentification
Definition: lsa.idl:56
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
#define UNICODE_NULL
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:455
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:777
PVOID SmpHeap
Definition: sminit.c:25
struct _SMP_CLIENT_CONTEXT * PSMP_CLIENT_CONTEXT
NTSTATUS NTAPI SmpGetProcessMuSessionId(IN HANDLE ProcessHandle, OUT PULONG SessionId)
Definition: smsessn.c:168
VOID NTAPI SmpDereferenceSubsystem(IN PSMP_SUBSYSTEM SubSystem)
Definition: smsubsys.c:47
PSMP_SUBSYSTEM NTAPI SmpLocateKnownSubSysByCid(IN PCLIENT_ID ClientId)
Definition: smsubsys.c:68
PSMP_SUBSYSTEM NTAPI SmpLocateKnownSubSysByType(IN ULONG MuSessionId, IN ULONG ImageType)
Definition: smsubsys.c:102
SECURITY_CONTEXT_TRACKING_MODE ContextTrackingMode
Definition: lsa.idl:66
SECURITY_IMPERSONATION_LEVEL ImpersonationLevel
Definition: lsa.idl:65
HANDLE SbApiPort
Definition: smss.h:70
HANDLE Event
Definition: smss.h:66
ULONG ImageType
Definition: smss.h:68
HANDLE PortHandle
Definition: smss.h:69
uint32_t ULONG
Definition: typedefs.h:59
#define SECURITY_DYNAMIC_TRACKING
Definition: setypes.h:103

Referenced by SmpApiLoop().

◆ SmpLoadDeferedSubsystem()

NTSTATUS NTAPI SmpLoadDeferedSubsystem ( _In_ PSM_API_MSG  SmApiMsg,
_In_ PSMP_CLIENT_CONTEXT  ClientContext,
_In_ HANDLE  SmApiPort 
)

Definition at line 141 of file smloop.c.

145{
147 PSM_LOAD_DEFERED_SUBSYSTEM_MSG SmLoadDefered = &SmApiMsg->u.LoadDefered;
148 UNICODE_STRING DeferedSubsystem;
149 ULONG MuSessionId;
150 PLIST_ENTRY NextEntry;
152
153 /* Validate DeferedSubsystem's length */
154 if ((SmLoadDefered->Length <= 0) ||
155 (SmLoadDefered->Length > sizeof(SmLoadDefered->Buffer)))
156 {
158 }
159
160 /* Get the name of the subsystem to start */
161 DeferedSubsystem.Length = (USHORT)SmLoadDefered->Length;
162 DeferedSubsystem.MaximumLength = DeferedSubsystem.Length;
163 DeferedSubsystem.Buffer = SmLoadDefered->Buffer;
164
165 /* Find a subsystem responsible for this session */
166 SmpGetProcessMuSessionId(ClientContext->ProcessHandle, &MuSessionId);
167 if (!SmpCheckDuplicateMuSessionId(MuSessionId))
168 {
169 DPRINT1("SMSS: Deferred subsystem load (%wZ) for MuSessionId %u, status=0x%x\n",
170 &DeferedSubsystem, MuSessionId, Status);
171 return Status;
172 }
173
174 /* Now process the deferred subsystems list */
175 for (NextEntry = SmpSubSystemsToDefer.Flink;
176 NextEntry != &SmpSubSystemsToDefer;
177 NextEntry = NextEntry->Flink)
178 {
179 /* Get each entry and check if it's the subsystem we are looking for */
181 if (RtlEqualUnicodeString(&RegEntry->Name, &DeferedSubsystem, TRUE))
182 {
183 // TODO: One may want to extra-flag the command for
184 // specific POSIX or OS2 processing...
185
186 /* Load the deferred subsystem */
188 MuSessionId,
189 NULL,
191 if (!NT_SUCCESS(Status))
192 DPRINT1("SMSS: Subsystem execute failed (%wZ)\n", &RegEntry->Value);
193
194 break;
195 }
196 }
197
198 /* Return status */
199 return Status;
200}
NTSYSAPI BOOLEAN NTAPI RtlEqualUnicodeString(PUNICODE_STRING String1, PUNICODE_STRING String2, BOOLEAN CaseInSensitive)
unsigned short USHORT
Definition: pedump.c:61
LIST_ENTRY SmpSubSystemsToDefer
Definition: sminit.c:22
BOOLEAN NTAPI SmpCheckDuplicateMuSessionId(IN ULONG MuSessionId)
Definition: smsessn.c:37
NTSTATUS NTAPI SmpExecuteCommand(IN PUNICODE_STRING CommandLine, IN ULONG MuSessionId, OUT PHANDLE ProcessId, IN ULONG Flags)
Definition: smss.c:210
#define SMP_SUBSYSTEM_FLAG
Definition: smss.h:47
base of all file and directory entries
Definition: entries.h:83
Registry entry.
Definition: regfs.h:31
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149

◆ SmpSessionComplete()

NTSTATUS NTAPI SmpSessionComplete ( IN PSM_API_MSG  SmApiMsg,
IN PSMP_CLIENT_CONTEXT  ClientContext,
IN HANDLE  SmApiPort 
)

Definition at line 50 of file smloop.c.

53{
54 DPRINT1("%s is not yet implemented\n", __FUNCTION__);
56}

◆ SmpStartCsr()

NTSTATUS NTAPI SmpStartCsr ( IN PSM_API_MSG  SmApiMsg,
IN PSMP_CLIENT_CONTEXT  ClientContext,
IN HANDLE  SmApiPort 
)

Definition at line 204 of file smloop.c.

207{
208 PSM_START_CSR_MSG SmStartCsr = &SmApiMsg->u.StartCsr;
209 UNICODE_STRING InitialCommand;
210 HANDLE InitialCommandProcess, InitialCommandProcessId, WindowsSubSysProcessId;
212
214 &WindowsSubSysProcessId,
215 &InitialCommand);
216 if (!NT_SUCCESS(Status))
217 {
218 DPRINT1("SMSS: SmpLoadSubSystemsForMuSession failed with status 0x%08x\n", Status);
219 return Status;
220 }
221
222 if (SmStartCsr->Length)
223 {
224 InitialCommand.Length = InitialCommand.MaximumLength = SmStartCsr->Length;
225 InitialCommand.Buffer = SmStartCsr->Buffer;
226 }
227
229 &InitialCommand,
230 &InitialCommandProcess,
231 &InitialCommandProcessId);
232 if (!NT_SUCCESS(Status))
233 {
234 DPRINT1("SMSS: SmpExecuteInitialCommand failed with status 0x%08x\n", Status);
235 /* FIXME: undo effects of SmpLoadSubSystemsForMuSession */
236 ASSERT(FALSE);
237 return Status;
238 }
239
240 NtClose(InitialCommandProcess);
241
242 SmStartCsr->WindowsSubSysProcessId = WindowsSubSysProcessId;
243 SmStartCsr->SmpInitialCommandProcessId = InitialCommandProcessId;
244
245 return STATUS_SUCCESS;
246}
#define ASSERT(a)
Definition: mode.c:44
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
NTSTATUS NTAPI SmpExecuteInitialCommand(IN ULONG MuSessionId, IN PUNICODE_STRING InitialCommand, IN HANDLE InitialCommandProcess, OUT PHANDLE ReturnPid)
Definition: smss.c:283
NTSTATUS NTAPI SmpLoadSubSystemsForMuSession(IN PULONG MuSessionId, OUT PHANDLE ProcessId, IN PUNICODE_STRING InitialCommand)
Definition: smsubsys.c:510

◆ SmpStopCsr()

NTSTATUS NTAPI SmpStopCsr ( IN PSM_API_MSG  SmApiMsg,
IN PSMP_CLIENT_CONTEXT  ClientContext,
IN HANDLE  SmApiPort 
)

Definition at line 250 of file smloop.c.

253{
254 DPRINT1("%s is not yet implemented\n", __FUNCTION__);
256}

◆ SmpTerminateForeignSession()

NTSTATUS NTAPI SmpTerminateForeignSession ( IN PSM_API_MSG  SmApiMsg,
IN PSMP_CLIENT_CONTEXT  ClientContext,
IN HANDLE  SmApiPort 
)

Definition at line 60 of file smloop.c.

63{
64 DPRINT1("%s is not yet implemented\n", __FUNCTION__);
66}

Variable Documentation

◆ SmpApiDispatch

Initial value:
=
{
}
NTSTATUS NTAPI SmpLoadDeferedSubsystem(_In_ PSM_API_MSG SmApiMsg, _In_ PSMP_CLIENT_CONTEXT ClientContext, _In_ HANDLE SmApiPort)
Definition: smloop.c:141
NTSTATUS NTAPI SmpExecPgm(IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
Definition: smloop.c:70
NTSTATUS NTAPI SmpCreateForeignSession(IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
Definition: smloop.c:40
NTSTATUS NTAPI SmpSessionComplete(IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
Definition: smloop.c:50
NTSTATUS NTAPI SmpTerminateForeignSession(IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
Definition: smloop.c:60
NTSTATUS NTAPI SmpStartCsr(IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
Definition: smloop.c:204
NTSTATUS NTAPI SmpStopCsr(IN PSM_API_MSG SmApiMsg, IN PSMP_CLIENT_CONTEXT ClientContext, IN HANDLE SmApiPort)
Definition: smloop.c:250

Definition at line 258 of file smloop.c.

Referenced by SmpApiLoop().

◆ SmTotalApiThreads

volatile LONG SmTotalApiThreads

Definition at line 33 of file smloop.c.

Referenced by SmpApiLoop().

◆ SmUniqueProcessId

HANDLE SmUniqueProcessId

Definition at line 34 of file smloop.c.

Referenced by SmpApiLoop(), and SmpHandleConnectionRequest().