ReactOS  0.4.14-dev-552-g2fad488
smsubsys.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS Windows-Compatible Session Manager
3  * LICENSE: BSD 2-Clause License
4  * FILE: base/system/smss/smsubsys.c
5  * PURPOSE: Main SMSS Code
6  * PROGRAMMERS: Alex Ionescu
7  */
8 
9 /* INCLUDES *******************************************************************/
10 
11 #include "smss.h"
12 
13 #define NDEBUG
14 #include <debug.h>
15 
16 /* GLOBALS ********************************************************************/
17 
24 
25 /* FUNCTIONS ******************************************************************/
26 
28 NTAPI
30  IN USHORT MessageLength,
31  IN HANDLE PortHandle)
32 {
34 
35  /* Initialize the header and send the message to CSRSS */
36  SbApiMsg->h.u2.ZeroInit = 0;
37  SbApiMsg->h.u1.s1.DataLength = MessageLength + 8;
38  SbApiMsg->h.u1.s1.TotalLength = sizeof(SB_API_MSG);
39  SbApiMsg->ApiNumber = SbpCreateProcess;
40  Status = NtRequestWaitReplyPort(PortHandle, &SbApiMsg->h, &SbApiMsg->h);
41  if (NT_SUCCESS(Status)) Status = SbApiMsg->ReturnValue;
42  return Status;
43 }
44 
45 VOID
46 NTAPI
48 {
49  /* Acquire the database lock while we (potentially) destroy this subsystem */
51 
52  /* Drop the reference and see if it's terminating */
53  if (!(--SubSystem->ReferenceCount) && (SubSystem->Terminating))
54  {
55  /* Close all handles and free it */
56  if (SubSystem->Event) NtClose(SubSystem->Event);
57  if (SubSystem->ProcessHandle) NtClose(SubSystem->ProcessHandle);
58  if (SubSystem->SbApiPort) NtClose(SubSystem->SbApiPort);
59  RtlFreeHeap(SmpHeap, 0, SubSystem);
60  }
61 
62  /* Release the database lock */
64 }
65 
67 NTAPI
69 {
70  PSMP_SUBSYSTEM Subsystem = NULL;
71  PLIST_ENTRY NextEntry;
72 
73  /* Lock the subsystem database */
75 
76  /* Loop each subsystem in the database */
77  NextEntry = SmpKnownSubSysHead.Flink;
78  while (NextEntry != &SmpKnownSubSysHead)
79  {
80  /* Check if this one matches the client ID and is still valid */
81  Subsystem = CONTAINING_RECORD(NextEntry, SMP_SUBSYSTEM, Entry);
82  if ((*(PULONGLONG)&Subsystem->ClientId == *(PULONGLONG)ClientId) &&
83  !(Subsystem->Terminating))
84  {
85  /* Add a reference and return it */
86  Subsystem->ReferenceCount++;
87  break;
88  }
89 
90  /* Reset the current pointer and keep earching */
91  Subsystem = NULL;
92  NextEntry = NextEntry->Flink;
93  }
94 
95  /* Release the lock and return the subsystem we found */
97  return Subsystem;
98 }
99 
101 NTAPI
104 {
105  PSMP_SUBSYSTEM Subsystem = NULL;
106  PLIST_ENTRY NextEntry;
107 
108  /* Lock the subsystem database */
110 
111  /* Loop each subsystem in the database */
112  NextEntry = SmpKnownSubSysHead.Flink;
113  while (NextEntry != &SmpKnownSubSysHead)
114  {
115  /* Check if this one matches the image and uID, and is still valid */
116  Subsystem = CONTAINING_RECORD(NextEntry, SMP_SUBSYSTEM, Entry);
117  if ((Subsystem->ImageType == ImageType) &&
118  !(Subsystem->Terminating) &&
119  (Subsystem->MuSessionId == MuSessionId))
120  {
121  /* Return it referenced for the caller */
122  Subsystem->ReferenceCount++;
123  break;
124  }
125 
126  /* Reset the current pointer and keep earching */
127  Subsystem = NULL;
128  NextEntry = NextEntry->Flink;
129  }
130 
131  /* Release the lock and return the subsystem we found */
133  return Subsystem;
134 }
135 
136 NTSTATUS
137 NTAPI
140  IN PUNICODE_STRING CommandLine,
141  IN ULONG MuSessionId,
143  IN ULONG Flags)
144 {
145  PSMP_SUBSYSTEM Subsystem, NewSubsystem, KnownSubsystem = NULL;
146  HANDLE SubSysProcessId;
148  SB_API_MSG SbApiMsg, SbApiMsg2;
149  RTL_USER_PROCESS_INFORMATION ProcessInformation;
151  PVOID State;
154 
155  /* Make sure this is a found subsystem */
156  if (Flags & SMP_INVALID_PATH)
157  {
158  DPRINT1("SMSS: Unable to find subsystem - %wZ\n", FileName);
160  }
161 
162  /* Don't use a session if the flag is set */
163  if (Flags & 0x80) MuSessionId = 0;
164 
165  /* Lock the subsystems while we do a look up */
167  while (TRUE)
168  {
169  /* Check if we found a subsystem not yet fully initialized */
170  Subsystem = SmpLocateKnownSubSysByType(MuSessionId, -1);
171  if (!Subsystem) break;
173 
174  /* Wait on it to initialize */
175  NtWaitForSingleObject(Subsystem->Event, FALSE, NULL);
176 
177  /* Dereference it and try the next one */
179  SmpDereferenceSubsystem(Subsystem);
180  }
181 
182  /* Check if this is a POSIX subsystem */
183  if (Flags & SMP_POSIX_FLAG)
184  {
185  /* Do we already have it? */
186  Subsystem = SmpLocateKnownSubSysByType(MuSessionId, IMAGE_SUBSYSTEM_POSIX_CUI);
187  }
188  else if (Flags & SMP_OS2_FLAG)
189  {
190  /* This is an OS/2 subsystem, do we we already have it? */
191  Subsystem = SmpLocateKnownSubSysByType(MuSessionId, IMAGE_SUBSYSTEM_OS2_CUI);
192  }
193 
194  /* Check if we already have one of the optional subsystems for the session */
195  if (Subsystem)
196  {
197  /* Dereference and return, no work to do */
198  SmpDereferenceSubsystem(Subsystem);
200  return STATUS_SUCCESS;
201  }
202 
203  /* Allocate a new subsystem! */
204  NewSubsystem = RtlAllocateHeap(SmpHeap, SmBaseTag, sizeof(SMP_SUBSYSTEM));
205  if (!NewSubsystem)
206  {
208  return STATUS_NO_MEMORY;
209  }
210 
211  /* Initialize its header and reference count */
212  NewSubsystem->ReferenceCount = 1;
213  NewSubsystem->MuSessionId = MuSessionId;
214  NewSubsystem->ImageType = -1;
215 
216  /* Clear out all the other data for now */
217  NewSubsystem->Terminating = FALSE;
218  NewSubsystem->ProcessHandle = NULL;
219  NewSubsystem->Event = NULL;
220  NewSubsystem->PortHandle = NULL;
221  NewSubsystem->SbApiPort = NULL;
222 
223  /* Create the event we'll be waiting on for initialization */
224  Status = NtCreateEvent(&NewSubsystem->Event,
226  NULL,
228  FALSE);
229  if (!NT_SUCCESS(Status))
230  {
231  /* This failed, bail out */
232  RtlFreeHeap(SmpHeap, 0, NewSubsystem);
234  return STATUS_NO_MEMORY;
235  }
236 
237  /* Insert the subsystem and release the lock. It can now be found */
238  InsertTailList(&SmpKnownSubSysHead, &NewSubsystem->Entry);
240 
241  /* The OS/2 and POSIX subsystems are actually Windows applications! */
243  {
244  /* Locate the Windows subsystem for this session */
245  KnownSubsystem = SmpLocateKnownSubSysByType(MuSessionId,
247  if (!KnownSubsystem)
248  {
249  DPRINT1("SMSS: SmpLoadSubSystem - SmpLocateKnownSubSysByType Failed\n");
250  goto Quickie2;
251  }
252 
253  /* Fill out all the process details and call CSRSS to launch it */
254  CreateProcess->In.ImageName = FileName;
255  CreateProcess->In.CurrentDirectory = Directory;
256  CreateProcess->In.CommandLine = CommandLine;
257  CreateProcess->In.DllPath = SmpDefaultLibPath.Length ?
259  CreateProcess->In.Flags = Flags | SMP_DEFERRED_FLAG;
260  CreateProcess->In.DebugFlags = SmpDebug;
261  Status = SmpCallCsrCreateProcess(&SbApiMsg,
262  sizeof(*CreateProcess),
263  KnownSubsystem->SbApiPort);
264  if (!NT_SUCCESS(Status))
265  {
266  /* Handle failures */
267  DPRINT1("SMSS: SmpLoadSubSystem - SmpCallCsrCreateProcess Failed with Status %lx\n",
268  Status);
269  goto Quickie2;
270  }
271 
272  /* Save the process information we'll need for the create session */
273  ProcessInformation.ProcessHandle = CreateProcess->Out.ProcessHandle;
274  ProcessInformation.ThreadHandle = CreateProcess->Out.ThreadHandle;
275  ProcessInformation.ClientId = CreateProcess->Out.ClientId;
276  ProcessInformation.ImageInformation.SubSystemType = CreateProcess->Out.SubsystemType;
277  }
278  else
279  {
280  /* This must be CSRSS itself, so just launch it and that's it */
282  Directory,
283  CommandLine,
284  MuSessionId,
286  &ProcessInformation);
287  if (!NT_SUCCESS(Status))
288  {
289  /* Handle failures */
290  DPRINT1("SMSS: SmpLoadSubSystem - SmpExecuteImage Failed with Status %lx\n",
291  Status);
292  goto Quickie2;
293  }
294  }
295 
296  /* Fill out the handle and client ID in the subsystem structure now */
297  NewSubsystem->ProcessHandle = ProcessInformation.ProcessHandle;
298  NewSubsystem->ClientId = ProcessInformation.ClientId;
299 
300  /* Check if we launched a native image or a subsystem-backed image */
301  if (ProcessInformation.ImageInformation.SubSystemType == IMAGE_SUBSYSTEM_NATIVE)
302  {
303  /* This must be CSRSS itself, since it's a native subsystem image */
304  SubSysProcessId = ProcessInformation.ClientId.UniqueProcess;
305  if ((ProcessId) && !(*ProcessId)) *ProcessId = SubSysProcessId;
306 
307  /* Was this the initial CSRSS on Session 0? */
308  if (!MuSessionId)
309  {
310  /* Then save it in the global variables */
311  SmpWindowsSubSysProcessId = SubSysProcessId;
312  SmpWindowsSubSysProcess = ProcessInformation.ProcessHandle;
313  }
315  }
316  else
317  {
318  /* This is the POSIX or OS/2 subsystem process, copy its information */
319  RtlCopyMemory(&CreateSession->ProcessInfo,
320  &ProcessInformation,
321  sizeof(CreateSession->ProcessInfo));
322 
323  /* Not sure these field mean what I think they do -- but clear them */
324  *(PULONGLONG)&CreateSession->ClientId = 0;
325  CreateSession->MuSessionId = 0;
326 
327  /* This should find CSRSS because they are POSIX or OS/2 subsystems */
328  Subsystem = SmpLocateKnownSubSysByType(MuSessionId,
329  ProcessInformation.ImageInformation.SubSystemType);
330  if (!Subsystem)
331  {
332  /* Odd failure -- but handle it anyway */
334  DPRINT1("SMSS: SmpLoadSubSystem - SmpLocateKnownSubSysByType Failed with Status %lx for sessionid %lu\n",
335  Status,
336  MuSessionId);
337  goto Quickie;
338  }
339 
340  /* Duplicate the parent process handle for the subsystem to have */
342  ProcessInformation.ProcessHandle,
343  Subsystem->ProcessHandle,
344  &CreateSession->ProcessInfo.ProcessHandle,
346  0,
347  0);
348  if (!NT_SUCCESS(Status))
349  {
350  /* Fail since this is critical */
351  DPRINT1("SMSS: SmpLoadSubSystem - NtDuplicateObject Failed with Status %lx for sessionid %lu\n",
352  Status,
353  MuSessionId);
354  goto Quickie;
355  }
356 
357  /* Duplicate the initial thread handle for the subsystem to have */
359  ProcessInformation.ThreadHandle,
360  Subsystem->ProcessHandle,
361  &CreateSession->ProcessInfo.ThreadHandle,
363  0,
364  0);
365  if (!NT_SUCCESS(Status))
366  {
367  /* Fail since this is critical */
368  DPRINT1("SMSS: SmpLoadSubSystem - NtDuplicateObject Failed with Status %lx for sessionid %lu\n",
369  Status,
370  MuSessionId);
371  goto Quickie;
372  }
373 
374  /* Allocate an internal Session ID for this subsystem */
375  MuSessionId = SmpAllocateSessionId(Subsystem, 0);
376  CreateSession->SessionId = MuSessionId;
377 
378  /* Send the create session message to the subsystem */
379  SbApiMsg2.ReturnValue = STATUS_SUCCESS;
380  SbApiMsg2.h.u2.ZeroInit = 0;
381  SbApiMsg2.h.u1.s1.DataLength = sizeof(SB_CREATE_SESSION_MSG) + 8;
382  SbApiMsg2.h.u1.s1.TotalLength = sizeof(SB_API_MSG);
384  &SbApiMsg2.h,
385  &SbApiMsg2.h);
386  if (NT_SUCCESS(Status)) Status = SbApiMsg2.ReturnValue;
387  if (!NT_SUCCESS(Status))
388  {
389  /* Delete the session and handle failure if the LPC call failed */
390  SmpDeleteSession(CreateSession->SessionId);
391  DPRINT1("SMSS: SmpLoadSubSystem - NtRequestWaitReplyPort Failed with Status %lx for sessionid %lu\n",
392  Status,
393  CreateSession->SessionId);
394  goto Quickie;
395  }
396  }
397 
398  /* Okay, everything looks good to go, initialize this subsystem now! */
399  Status = NtResumeThread(ProcessInformation.ThreadHandle, NULL);
400  if (!NT_SUCCESS(Status))
401  {
402  /* That didn't work -- back out of everything */
403  DPRINT1("SMSS: SmpLoadSubSystem - NtResumeThread failed Status %lx\n", Status);
404  goto Quickie;
405  }
406 
407  /* Check if this was the subsystem for a different session */
408  if (MuSessionId)
409  {
410  /* Wait up to 60 seconds for it to initialize */
411  Timeout.QuadPart = -600000000;
412  Status = NtWaitForSingleObject(NewSubsystem->Event, FALSE, &Timeout);
413 
414  /* Timeout is done -- does this session still exist? */
415  if (!SmpCheckDuplicateMuSessionId(MuSessionId))
416  {
417  /* Nope, it died. Cleanup should've ocurred in a different path. */
418  DPRINT1("SMSS: SmpLoadSubSystem - session deleted\n");
419  return STATUS_DELETE_PENDING;
420  }
421 
422  /* Check if we timed our or there was another error with the wait */
423  if (Status != STATUS_WAIT_0)
424  {
425  /* Something is wrong with the subsystem, so back out of everything */
426  DPRINT1("SMSS: SmpLoadSubSystem - Timeout waiting for subsystem connect with Status %lx for sessionid %lu\n",
427  Status,
428  MuSessionId);
429  goto Quickie;
430  }
431  }
432  else
433  {
434  /* This a session 0 subsystem, just wait for it to initialize */
435  NtWaitForSingleObject(NewSubsystem->Event, FALSE, NULL);
436  }
437 
438  /* Subsystem is created, resumed, and initialized. Close handles and exit */
439  NtClose(ProcessInformation.ThreadHandle);
441  goto Quickie2;
442 
443 Quickie:
444  /* This is the failure path. First check if we need to detach from session */
445  if ((AttachedSessionId == -1) || (Flags & (SMP_POSIX_FLAG | SMP_OS2_FLAG)))
446  {
447  /* We were not attached, or did not launch subsystems that required it */
448  DPRINT1("SMSS: Did not detach from Session Space: SessionId=%x Flags=%x Status=%x\n",
451  Status);
452  }
453  else
454  {
455  /* Get the privilege we need for detachment */
457  if (!NT_SUCCESS(Status))
458  {
459  /* We can't detach without it */
460  DPRINT1("SMSS: Did not detach from Session Space: SessionId=%x Flags=%x Status=%x\n",
463  Status);
464  }
465  else
466  {
467  /* Now detach from the session */
470  sizeof(AttachedSessionId));
471  if (!NT_SUCCESS(Status))
472  {
473  /* Failed to detach. Note the DPRINT1 has a typo in Windows */
474  DPRINT1("SMSS: SmpStartCsr, Couldn't Detach from Session Space. Status=%x\n", Status);
476  }
477  else
478  {
479  /* Detachment worked, reset our attached session ID */
480  AttachedSessionId = -1;
481  }
482 
483  /* And release the privilege we acquired */
485  }
486  }
487 
488  /* Since this is the failure path, terminate the subsystem process */
489  NtTerminateProcess(ProcessInformation.ProcessHandle, Status);
490  NtClose(ProcessInformation.ThreadHandle);
491 
492 Quickie2:
493  /* This is the cleanup path -- first dereference our subsystems */
495  if (Subsystem) SmpDereferenceSubsystem(Subsystem);
496  if (KnownSubsystem) SmpDereferenceSubsystem(KnownSubsystem);
497 
498  /* In the failure case, destroy the new subsystem we just created */
499  if (!NT_SUCCESS(Status))
500  {
501  RemoveEntryList(&NewSubsystem->Entry);
502  NtSetEvent(NewSubsystem->Event, 0);
503  SmpDereferenceSubsystem(NewSubsystem);
504  }
505 
506  /* Finally, we're all done! */
508  return Status;
509 }
510 
511 NTSTATUS
512 NTAPI
515  IN PUNICODE_STRING InitialCommand)
516 {
517  NTSTATUS Status = STATUS_SUCCESS, Status2;
520  PLIST_ENTRY NextEntry;
522  PVOID State;
523 
524  /* Write a few last registry keys with the boot partition information */
526 
527  /* Process "SetupExecute" values */
528  NextEntry = SmpSetupExecuteList.Flink;
529  while (NextEntry != &SmpSetupExecuteList)
530  {
531  /* Execute each one and move on */
533  SmpExecuteCommand(&RegEntry->Name, 0, NULL, 0);
534  NextEntry = NextEntry->Flink;
535  }
536 
537  /* Now process the subsystems */
538  NextEntry = SmpSubSystemList.Flink;
539  while (NextEntry != &SmpSubSystemList)
540  {
541  /* Get the entry and check if this is the special Win32k entry */
543  if (_wcsicmp(RegEntry->Name.Buffer, L"Kmode") == 0)
544  {
545  /* Translate it */
546  if (!RtlDosPathNameToNtPathName_U(RegEntry->Value.Buffer,
547  &NtPath,
548  NULL,
549  NULL))
550  {
552  DPRINT1("Failed: %lx\n", Status);
553  }
554  else
555  {
556  /* Get the driver privilege */
558  if (NT_SUCCESS(Status))
559  {
560  /* Create the new session */
561  ASSERT(AttachedSessionId == -1);
563  MuSessionId,
564  sizeof(*MuSessionId));
565  if (!NT_SUCCESS(Status))
566  {
567  DPRINT1("SMSS: Session space creation failed\n");
569  RtlFreeHeap(RtlGetProcessHeap(), 0, NtPath.Buffer);
570  return Status;
571  }
572  AttachedSessionId = *MuSessionId;
573 
574  /*
575  * Start Win32k.sys on this session. Use a hardcoded value
576  * instead of the Kmode one...
577  */
579  L"\\SystemRoot\\System32\\win32k.sys");
582  sizeof(DestinationString));
583  RtlFreeHeap(RtlGetProcessHeap(), 0, NtPath.Buffer);
585  if (!NT_SUCCESS(Status))
586  {
587  DPRINT1("SMSS: Load of WIN32K failed.\n");
588  return Status;
589  }
590  }
591  }
592  }
593 
594  /* Next entry */
595  NextEntry = NextEntry->Flink;
596  }
597 
598  /* Now parse the required subsystem list */
599  NextEntry = SmpSubSystemsToLoad.Flink;
600  while (NextEntry != &SmpSubSystemsToLoad)
601  {
602  /* Get each entry and check if it's the internal debug or not */
604  if (_wcsicmp(RegEntry->Name.Buffer, L"Debug") == 0)
605  {
606  /* Load the internal debug system */
608  *MuSessionId,
609  ProcessId,
611  }
612  else
613  {
614  /* Load the required subsystem */
616  *MuSessionId,
617  ProcessId,
619  }
620  if (!NT_SUCCESS(Status))
621  {
622  DbgPrint("SMSS: Subsystem execute failed (%wZ)\n", &RegEntry->Value);
623  return Status;
624  }
625 
626  /* Move to the next entry */
627  NextEntry = NextEntry->Flink;
628  }
629 
630  /* Process the "Execute" list now */
631  NextEntry = SmpExecuteList.Blink;
632  if (NextEntry != &SmpExecuteList)
633  {
634  /* Get the custom initial command */
636 
637  /* Write the initial command and wait for 5 seconds (why??!) */
638  *InitialCommand = RegEntry->Name;
639  Timeout.QuadPart = -50000000;
641  }
642  else
643  {
644  /* Use the default Winlogon initial command */
645  RtlInitUnicodeString(InitialCommand, L"winlogon.exe");
647 
648  /* Check if there's a debugger for Winlogon */
649  Status2 = LdrQueryImageFileExecutionOptions(InitialCommand,
650  L"Debugger",
651  REG_SZ,
653  sizeof(InitialCommandBuffer) -
654  InitialCommand->Length,
655  NULL);
656  if ((NT_SUCCESS(Status2)) && (InitialCommandBuffer[0]))
657  {
658  /* Put the debugger string with the Winlogon string */
660  wcscat(InitialCommandBuffer, InitialCommand->Buffer);
662  }
663  }
664 
665  /* Finally check if there was a custom initial command */
666  NextEntry = SmpExecuteList.Flink;
667  while (NextEntry != &SmpExecuteList)
668  {
669  /* Execute each one */
671  SmpExecuteCommand(&RegEntry->Name, *MuSessionId, NULL, 0);
672  NextEntry = NextEntry->Flink;
673  }
674 
675  /* Return status */
676  return Status;
677 }
#define IN
Definition: typedefs.h:38
#define STATUS_DELETE_PENDING
Definition: ntstatus.h:308
ULONG ReferenceCount
Definition: smss.h:69
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2697
#define THREAD_ALL_ACCESS
Definition: nt_native.h:1339
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define IMAGE_SUBSYSTEM_POSIX_CUI
Definition: ntimage.h:440
HANDLE PortHandle
Definition: smss.h:64
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1324
BOOLEAN NTAPI SmpCheckDuplicateMuSessionId(IN ULONG MuSessionId)
Definition: smsessn.c:37
HANDLE SmpWindowsSubSysProcessId
Definition: smsubsys.c:21
ULONG NTAPI SmpAllocateSessionId(IN PSMP_SUBSYSTEM Subsystem, IN PSMP_SUBSYSTEM OtherSubsystem)
Definition: smsessn.c:123
#define DbgPrint
Definition: loader.c:25
NTSTATUS NTAPI NtRequestWaitReplyPort(IN HANDLE PortHandle, IN PPORT_MESSAGE LpcRequest, IN OUT PPORT_MESSAGE LpcReply)
Definition: send.c:695
PORT_MESSAGE h
Definition: smmsg.h:202
UNICODE_STRING SmpDefaultLibPath
Definition: sminit.c:28
struct _LIST_ENTRY * Blink
Definition: typedefs.h:120
ULONG AttachedSessionId
Definition: smss.c:21
LONG NTSTATUS
Definition: precomp.h:26
#define SE_LOAD_DRIVER_PRIVILEGE
Definition: security.c:664
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
#define STATUS_NO_SUCH_PACKAGE
Definition: ntstatus.h:476
BOOLEAN Terminating
Definition: smss.h:68
VOID NTAPI SmpDeleteSession(IN ULONG SessionId)
Definition: smsessn.c:98
NTSTATUS NTAPI NtCreateEvent(OUT PHANDLE EventHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN EVENT_TYPE EventType, IN BOOLEAN InitialState)
Definition: event.c:100
struct _SB_API_MSG SB_API_MSG
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define SMP_OS2_FLAG
Definition: smss.h:46
SB_CREATE_SESSION_MSG CreateSession
Definition: smmsg.h:212
#define InsertTailList(ListHead, Entry)
ULONG ImageType
Definition: smss.h:63
HANDLE UniqueProcess
Definition: compat.h:482
FORCEINLINE BOOLEAN RemoveEntryList(_In_ PLIST_ENTRY Entry)
Definition: rtlfuncs.h:105
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
NTSTATUS NTAPI SmpLoadSubSystemsForMuSession(IN PULONG MuSessionId, OUT PHANDLE ProcessId, IN PUNICODE_STRING InitialCommand)
Definition: smsubsys.c:513
#define STATUS_WAIT_0
Definition: ntstatus.h:223
#define IMAGE_SUBSYSTEM_OS2_CUI
Definition: ntimage.h:439
NTSTATUS(* NTAPI)(IN PFILE_FULL_EA_INFORMATION EaBuffer, IN ULONG EaLength, OUT PULONG ErrorOffset)
Definition: IoEaTest.cpp:117
HANDLE ProcessHandle
Definition: smss.h:62
SB_CREATE_PROCESS_MSG CreateProcess
Definition: smmsg.h:215
#define UNICODE_NULL
PVOID SmpHeap
Definition: sminit.c:24
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
WCHAR InitialCommandBuffer[256]
Definition: smsubsys.c:23
LIST_ENTRY SmpSubSystemsToLoad
Definition: sminit.c:21
unsigned char BOOLEAN
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1869
smooth NULL
Definition: ftsmooth.c:416
#define IMAGE_SUBSYSTEM_NATIVE
Definition: ntimage.h:436
struct _SB_CREATE_SESSION_MSG SB_CREATE_SESSION_MSG
LIST_ENTRY SmpKnownSubSysHead
Definition: smsubsys.c:19
HANDLE Event
Definition: smss.h:61
#define SMP_POSIX_FLAG
Definition: smss.h:45
NTSYSAPI NTSTATUS NTAPI NtSetSystemInformation(IN INT SystemInformationClass, IN PVOID SystemInformation, IN ULONG SystemInformationLength)
PFLT_MESSAGE_WAITER_QUEUE CONTAINING_RECORD(Csq, DEVICE_EXTENSION, IrpQueue)) -> WaiterQ.mLock) _IRQL_raises_(DISPATCH_LEVEL) VOID NTAPI FltpAcquireMessageWaiterLock(_In_ PIO_CSQ Csq, _Out_ PKIRQL Irql)
Definition: Messaging.c:560
NTSTATUS NTAPI NtDelayExecution(IN BOOLEAN Alertable, IN PLARGE_INTEGER DelayInterval)
Definition: wait.c:879
#define NtCurrentProcess()
Definition: nt_native.h:1657
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
NTSTATUS ReturnValue
Definition: smmsg.h:209
MMRESULT CreateSession(DeviceType device_type, UINT device_id, SessionInfo **session_info)
Definition: session.c:63
LIST_ENTRY SmpSetupExecuteList
Definition: sminit.c:19
struct _LIST_ENTRY * Flink
Definition: typedefs.h:119
SECTION_IMAGE_INFORMATION ImageInformation
Definition: rtltypes.h:1544
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
Definition: state.c:290
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1176
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:458
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
VOID NTAPI SmpTranslateSystemPartitionInformation(VOID)
Definition: sminit.c:786
Registry entry.
Definition: regfs.h:30
ULONG SmBaseTag
Definition: sminit.c:25
HANDLE SbApiPort
Definition: smss.h:65
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3399
VOID NTAPI SmpReleasePrivilege(IN PVOID State)
Definition: smutil.c:129
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
static const WCHAR L[]
Definition: oid.c:1250
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:414
PSMP_SUBSYSTEM NTAPI SmpLocateKnownSubSysByCid(IN PCLIENT_ID ClientId)
Definition: smsubsys.c:68
NTSTATUS NTAPI SmpLoadSubSystem(IN PUNICODE_STRING FileName, IN PUNICODE_STRING Directory, IN PUNICODE_STRING CommandLine, IN ULONG MuSessionId, OUT PHANDLE ProcessId, IN ULONG Flags)
Definition: smsubsys.c:138
BOOLEAN SmpDebug
Definition: smss.c:22
Definition: typedefs.h:117
#define SystemExtendServiceTableInformation
Definition: DriverTester.h:35
#define SMP_INVALID_PATH
Definition: smss.h:43
#define CreateProcess
Definition: winbase.h:3592
NTSTATUS NTAPI SmpAcquirePrivilege(IN ULONG Privilege, OUT PVOID *PrivilegeStat)
Definition: smutil.c:40
NTSTATUS NTAPI LdrQueryImageFileExecutionOptions(IN PUNICODE_STRING SubKey, IN PCWSTR ValueName, IN ULONG Type, OUT PVOID Buffer, IN ULONG BufferSize, OUT PULONG ReturnedLength OPTIONAL)
Definition: ldrinit.c:386
NTSTATUS NTAPI SmpExecuteCommand(IN PUNICODE_STRING CommandLine, IN ULONG MuSessionId, OUT PHANDLE ProcessId, IN ULONG Flags)
Definition: smss.c:221
LIST_ENTRY SmpExecuteList
Definition: sminit.c:22
Status
Definition: gdiplustypes.h:24
ULONG MuSessionId
Definition: smss.h:67
RTL_CRITICAL_SECTION SmpKnownSubSysLock
Definition: smsubsys.c:18
struct _FileName FileName
Definition: fatprocs.h:884
VOID NTAPI SmpDereferenceSubsystem(IN PSMP_SUBSYSTEM SubSystem)
Definition: smsubsys.c:47
enum State_ State
Definition: pofuncs.h:54
static ULONG Timeout
Definition: ping.c:61
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
unsigned short USHORT
Definition: pedump.c:61
LIST_ENTRY Entry
Definition: smss.h:60
#define SMP_DEBUG_FLAG
Definition: smss.h:39
#define STATUS_NO_MEMORY
Definition: ntstatus.h:246
_CRTIMP wchar_t *__cdecl wcscat(_Inout_updates_z_(_String_length_(_Dest)+_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define SMP_SUBSYSTEM_FLAG
Definition: smss.h:42
unsigned int * PULONG
Definition: retypes.h:1
PSMP_SUBSYSTEM NTAPI SmpLocateKnownSubSysByType(IN ULONG MuSessionId, IN ULONG ImageType)
Definition: smsubsys.c:102
HANDLE SmpWindowsSubSysProcess
Definition: smsubsys.c:20
#define DPRINT1
Definition: precomp.h:8
ImageType
Definition: gdiplusenums.h:191
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:3407
#define OUT
Definition: typedefs.h:39
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:390
NTSTATUS NTAPI SmpExecuteImage(IN PUNICODE_STRING FileName, IN PUNICODE_STRING Directory, IN PUNICODE_STRING CommandLine, IN ULONG MuSessionId, IN ULONG Flags, IN PRTL_USER_PROCESS_INFORMATION ProcessInformation)
Definition: smss.c:42
unsigned int ULONG
Definition: retypes.h:1
base for all directory entries
Definition: entries.h:138
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)
LIST_ENTRY SmpSubSystemList
Definition: sminit.c:21
#define SMP_DEFERRED_FLAG
Definition: smss.h:44
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:281
_In_ BOOLEAN _In_ USHORT Directory
Definition: rtlfuncs.h:3734
return STATUS_SUCCESS
Definition: btrfs.c:2938
base of all file and directory entries
Definition: entries.h:82
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
CLIENT_ID ClientId
Definition: smss.h:66
NTSYSAPI BOOLEAN NTAPI RtlDosPathNameToNtPathName_U(_In_opt_z_ PCWSTR DosPathName, _Out_ PUNICODE_STRING NtPathName, _Out_opt_ PCWSTR *NtFileNamePart, _Out_opt_ PRTL_RELATIVE_NAME_U DirectoryInfo)
#define IMAGE_SUBSYSTEM_WINDOWS_GUI
Definition: ntimage.h:437
NTSTATUS NTAPI SmpCallCsrCreateProcess(IN PSB_API_MSG SbApiMsg, IN USHORT MessageLength, IN HANDLE PortHandle)
Definition: smsubsys.c:29
BOOLEAN RegPosixSingleInstance
Definition: smsubsys.c:22
#define REG_SZ
Definition: layer.c:22
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)