ReactOS 0.4.17-dev-769-g1500a35
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#define DEFAULT_INITIAL_COMMAND L"winlogon.exe"
26#define DEFAULT_KMODE_SUBSYSTEM L"\\SystemRoot\\System32\\win32k.sys"
27
28/* FUNCTIONS ******************************************************************/
29
33 IN USHORT MessageLength,
34 IN HANDLE PortHandle)
35{
37
38 /* Initialize the header and send the message to CSRSS */
39 SbApiMsg->h.u2.ZeroInit = 0;
40 SbApiMsg->h.u1.s1.DataLength = MessageLength + 8;
41 SbApiMsg->h.u1.s1.TotalLength = sizeof(SB_API_MSG);
42 SbApiMsg->ApiNumber = SbpCreateProcess;
43 Status = NtRequestWaitReplyPort(PortHandle, &SbApiMsg->h, &SbApiMsg->h);
44 if (NT_SUCCESS(Status)) Status = SbApiMsg->ReturnValue;
45 return Status;
46}
47
48VOID
51{
52 /* Acquire the database lock while we (potentially) destroy this subsystem */
54
55 /* Drop the reference and see if it's terminating */
56 if (!(--SubSystem->ReferenceCount) && (SubSystem->Terminating))
57 {
58 /* Close all handles and free it */
59 if (SubSystem->Event) NtClose(SubSystem->Event);
60 if (SubSystem->ProcessHandle) NtClose(SubSystem->ProcessHandle);
61 if (SubSystem->SbApiPort) NtClose(SubSystem->SbApiPort);
62 RtlFreeHeap(SmpHeap, 0, SubSystem);
63 }
64
65 /* Release the database lock */
67}
68
72{
73 PSMP_SUBSYSTEM Subsystem = NULL;
74 PLIST_ENTRY NextEntry;
75
76 /* Lock the subsystem database */
78
79 /* Loop each subsystem in the database */
80 NextEntry = SmpKnownSubSysHead.Flink;
81 while (NextEntry != &SmpKnownSubSysHead)
82 {
83 /* Check if this one matches the client ID and is still valid */
84 Subsystem = CONTAINING_RECORD(NextEntry, SMP_SUBSYSTEM, Entry);
85 if ((*(PULONGLONG)&Subsystem->ClientId == *(PULONGLONG)ClientId) &&
86 !(Subsystem->Terminating))
87 {
88 /* Add a reference and return it */
89 Subsystem->ReferenceCount++;
90 break;
91 }
92
93 /* Reset the current pointer and keep searching */
94 Subsystem = NULL;
95 NextEntry = NextEntry->Flink;
96 }
97
98 /* Release the lock and return the subsystem we found */
100 return Subsystem;
101}
102
104NTAPI
107{
108 PSMP_SUBSYSTEM Subsystem = NULL;
109 PLIST_ENTRY NextEntry;
110
111 /* Lock the subsystem database */
113
114 /* Loop each subsystem in the database */
115 NextEntry = SmpKnownSubSysHead.Flink;
116 while (NextEntry != &SmpKnownSubSysHead)
117 {
118 /* Check if this one matches the image and uID, and is still valid */
119 Subsystem = CONTAINING_RECORD(NextEntry, SMP_SUBSYSTEM, Entry);
120 if ((Subsystem->ImageType == ImageType) &&
121 !(Subsystem->Terminating) &&
122 (Subsystem->MuSessionId == MuSessionId))
123 {
124 /* Return it referenced for the caller */
125 Subsystem->ReferenceCount++;
126 break;
127 }
128
129 /* Reset the current pointer and keep searching */
130 Subsystem = NULL;
131 NextEntry = NextEntry->Flink;
132 }
133
134 /* Release the lock and return the subsystem we found */
136 return Subsystem;
137}
138
140NTAPI
143 IN PUNICODE_STRING CommandLine,
144 IN ULONG MuSessionId,
146 IN ULONG Flags)
147{
148 PSMP_SUBSYSTEM Subsystem, NewSubsystem, KnownSubsystem = NULL;
149 HANDLE SubSysProcessId;
151 SB_API_MSG SbApiMsg;
152 RTL_USER_PROCESS_INFORMATION ProcessInformation;
154 PVOID State;
157
158 /* Make sure this is a found subsystem */
160 {
161 DPRINT1("SMSS: Unable to find subsystem - %wZ\n", FileName);
163 }
164
165 /* Don't use a session if the flag is set */
166 if (Flags & 0x80) MuSessionId = 0;
167
168 /* Lock the subsystems while we do a look up */
170 while (TRUE)
171 {
172 /* Check if we found a subsystem not yet fully initialized */
173 Subsystem = SmpLocateKnownSubSysByType(MuSessionId, -1);
174 if (!Subsystem) break;
176
177 /* Wait on it to initialize */
179
180 /* Dereference it and try the next one */
182 SmpDereferenceSubsystem(Subsystem);
183 }
184
185 /* Check if this is a POSIX subsystem */
186 if (Flags & SMP_POSIX_FLAG)
187 {
188 /* Do we already have it? */
190 }
191 else if (Flags & SMP_OS2_FLAG)
192 {
193 /* This is an OS/2 subsystem, do we we already have it? */
194 Subsystem = SmpLocateKnownSubSysByType(MuSessionId, IMAGE_SUBSYSTEM_OS2_CUI);
195 }
196
197 /* Check if we already have one of the optional subsystems for the session */
198 if (Subsystem)
199 {
200 /* Dereference and return, no work to do */
201 SmpDereferenceSubsystem(Subsystem);
203 return STATUS_SUCCESS;
204 }
205
206 /* Allocate a new subsystem! */
207 NewSubsystem = RtlAllocateHeap(SmpHeap, SmBaseTag, sizeof(SMP_SUBSYSTEM));
208 if (!NewSubsystem)
209 {
211 return STATUS_NO_MEMORY;
212 }
213
214 /* Initialize its header and reference count */
215 NewSubsystem->ReferenceCount = 1;
216 NewSubsystem->MuSessionId = MuSessionId;
217 NewSubsystem->ImageType = -1;
218
219 /* Clear out all the other data for now */
220 NewSubsystem->Terminating = FALSE;
221 NewSubsystem->ProcessHandle = NULL;
222 NewSubsystem->Event = NULL;
223 NewSubsystem->PortHandle = NULL;
224 NewSubsystem->SbApiPort = NULL;
225
226 /* Create the event we'll be waiting on for initialization */
227 Status = NtCreateEvent(&NewSubsystem->Event,
229 NULL,
231 FALSE);
232 if (!NT_SUCCESS(Status))
233 {
234 /* This failed, bail out */
235 RtlFreeHeap(SmpHeap, 0, NewSubsystem);
237 return STATUS_NO_MEMORY;
238 }
239
240 /* Insert the subsystem and release the lock. It can now be found */
241 InsertTailList(&SmpKnownSubSysHead, &NewSubsystem->Entry);
243
244 /* The OS/2 and POSIX subsystems are actually Windows applications! */
246 {
247 /* Locate the Windows subsystem for this session */
248 KnownSubsystem = SmpLocateKnownSubSysByType(MuSessionId,
250 if (!KnownSubsystem)
251 {
252 DPRINT1("SMSS: SmpLoadSubSystem - SmpLocateKnownSubSysByType Failed\n");
253 goto Quickie2;
254 }
255
256 /* Fill out all the process details and call CSRSS to launch it */
257 CreateProcess->In.ImageName = FileName;
258 CreateProcess->In.CurrentDirectory = Directory;
259 CreateProcess->In.CommandLine = CommandLine;
263 CreateProcess->In.DebugFlags = SmpDebug;
265 sizeof(*CreateProcess),
266 KnownSubsystem->SbApiPort);
267 if (!NT_SUCCESS(Status))
268 {
269 /* Handle failures */
270 DPRINT1("SMSS: SmpLoadSubSystem - SmpCallCsrCreateProcess Failed with Status %lx\n",
271 Status);
272 goto Quickie2;
273 }
274
275 /* Save the process information we'll need for the create session */
276 ProcessInformation.ProcessHandle = CreateProcess->Out.ProcessHandle;
277 ProcessInformation.ThreadHandle = CreateProcess->Out.ThreadHandle;
278 ProcessInformation.ClientId = CreateProcess->Out.ClientId;
279 ProcessInformation.ImageInformation.SubSystemType = CreateProcess->Out.SubsystemType;
280 }
281 else
282 {
283 /* This must be CSRSS itself, so just launch it and that's it */
285 Directory,
286 CommandLine,
287 MuSessionId,
289 &ProcessInformation);
290 if (!NT_SUCCESS(Status))
291 {
292 /* Handle failures */
293 DPRINT1("SMSS: SmpLoadSubSystem - SmpExecuteImage Failed with Status %lx\n",
294 Status);
295 goto Quickie2;
296 }
297 }
298
299 /* Fill out the handle and client ID in the subsystem structure now */
300 NewSubsystem->ProcessHandle = ProcessInformation.ProcessHandle;
301 NewSubsystem->ClientId = ProcessInformation.ClientId;
302
303 /* Check if we launched a native image or a subsystem-backed image */
304 if (ProcessInformation.ImageInformation.SubSystemType == IMAGE_SUBSYSTEM_NATIVE)
305 {
306 /* This must be CSRSS itself, since it's a native subsystem image */
307 SubSysProcessId = ProcessInformation.ClientId.UniqueProcess;
308 if ((ProcessId) && !(*ProcessId)) *ProcessId = SubSysProcessId;
309
310 /* Was this the initial CSRSS on Session 0? */
311 if (!MuSessionId)
312 {
313 /* Then save it in the global variables */
314 SmpWindowsSubSysProcessId = SubSysProcessId;
315 SmpWindowsSubSysProcess = ProcessInformation.ProcessHandle;
316 }
318 }
319 else
320 {
321 /* This is the POSIX or OS/2 subsystem process, copy its information */
322 CreateSession->ProcessInfo = ProcessInformation;
323
324 CreateSession->DbgSessionId = 0;
325 *(PULONGLONG)&CreateSession->DbgUiClientId = 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 CreateSession->SessionId = SmpAllocateSessionId(Subsystem, NULL);
376
377 /* Send the create session message to the subsystem */
378 SbApiMsg.ReturnValue = STATUS_SUCCESS;
379 SbApiMsg.h.u2.ZeroInit = 0;
380 SbApiMsg.h.u1.s1.DataLength = sizeof(SB_CREATE_SESSION_MSG) + 8;
381 SbApiMsg.h.u1.s1.TotalLength = sizeof(SB_API_MSG);
382 SbApiMsg.ApiNumber = SbpCreateSession;
384 &SbApiMsg.h,
385 &SbApiMsg.h);
386 if (NT_SUCCESS(Status)) Status = SbApiMsg.ReturnValue;
387 if (!NT_SUCCESS(Status))
388 {
389 /* Delete the session and handle failure if the LPC call failed */
391 DPRINT1("SMSS: SmpLoadSubSystem - NtRequestWaitReplyPort Failed with Status %lx for sessionid %lu\n",
392 Status,
393 MuSessionId);
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");
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
443Quickie:
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 */
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
492Quickie2:
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, NULL);
503 SmpDereferenceSubsystem(NewSubsystem);
504 }
505
506 /* Finally, we're all done! */
508 return Status;
509}
510
512NTAPI
515 IN PUNICODE_STRING InitialCommand)
516{
517 NTSTATUS Status = STATUS_SUCCESS, Status2;
518 PSMP_REGISTRY_VALUE RegEntry;
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 */
532 RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
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 */
542 RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
543 if (_wcsicmp(RegEntry->Name.Buffer, L"Kmode") == 0)
544 {
545 /* Translate it */
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 */
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 */
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 */
603 RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
604 if (_wcsicmp(RegEntry->Name.Buffer, L"Debug") == 0)
605 {
606 /* Load the internal debug system */
607 Status = SmpExecuteCommand(&RegEntry->Value,
608 *MuSessionId,
609 ProcessId,
611 }
612 else
613 {
614 /* Load the required subsystem */
615 Status = SmpExecuteCommand(&RegEntry->Value,
616 *MuSessionId,
617 ProcessId,
619 }
620 if (!NT_SUCCESS(Status))
621 {
622 DPRINT1("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 */
635 RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
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 initial command (Winlogon) */
647
648 /* Check if there is a debugger for it */
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 /* Set up the debugger string */
660 RtlStringCbCatW(InitialCommandBuffer, sizeof(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 */
670 RegEntry = CONTAINING_RECORD(NextEntry, SMP_REGISTRY_VALUE, Entry);
671 SmpExecuteCommand(&RegEntry->Name, *MuSessionId, NULL, 0);
672 NextEntry = NextEntry->Flink;
673 }
674
675 /* Return status */
676 return Status;
677}
NTSYSAPI NTSTATUS NTAPI NtSetSystemInformation(IN INT SystemInformationClass, IN PVOID SystemInformation, IN ULONG SystemInformationLength)
#define SystemExtendServiceTableInformation
Definition: DriverTester.h:35
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:616
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
_In_ D3DDDI_VIDEO_PRESENT_TARGET_ID _In_ ULONG _In_ ULONG Flags
Definition: dispmprt.h:245
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
_ACRTIMP int __cdecl _wcsicmp(const wchar_t *, const wchar_t *)
Definition: wcs.c:164
#define L(x)
Definition: resources.c:13
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define InsertTailList(ListHead, Entry)
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2712
struct _FileName FileName
Definition: fatprocs.h:897
ImageType
Definition: gdiplusenums.h:192
Status
Definition: gdiplustypes.h:24
#define EVENT_ALL_ACCESS
Definition: isotest.c:82
#define REG_SZ
Definition: layer.c:22
NTSTATUS NTAPI LdrQueryImageFileExecutionOptions(_In_ PUNICODE_STRING SubKey, _In_ PCWSTR ValueName, _In_ ULONG Type, _Out_ PVOID Buffer, _In_ ULONG BufferSize, _Out_opt_ PULONG ReturnedLength)
Definition: ldrinit.c:392
MMRESULT CreateSession(DeviceType device_type, UINT device_id, SessionInfo **session_info)
Definition: session.c:63
#define ASSERT(a)
Definition: mode.c:44
#define SE_LOAD_DRIVER_PRIVILEGE
Definition: security.c:564
@ SystemSessionCreate
Definition: extypes.h:264
@ SystemSessionDetach
Definition: extypes.h:265
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
_Out_ _Inout_ POEM_STRING DestinationString
Definition: rtlfuncs.h:1956
_In_ BOOLEAN _In_ USHORT Directory
Definition: rtlfuncs.h:3962
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 THREAD_ALL_ACCESS
Definition: nt_native.h:1342
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1327
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)
#define NtCurrentProcess()
Definition: nt_native.h:1660
NTSTATUS NTAPI NtDelayExecution(IN BOOLEAN Alertable, IN PLARGE_INTEGER DelayInterval)
Definition: wait.c:876
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3429
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)
__GNU_EXTENSION typedef unsigned __int64 * PULONGLONG
Definition: ntbasedef.h:395
#define UNICODE_NULL
@ NotificationEvent
#define IMAGE_SUBSYSTEM_POSIX_CUI
Definition: ntimage.h:440
#define IMAGE_SUBSYSTEM_OS2_CUI
Definition: ntimage.h:439
#define IMAGE_SUBSYSTEM_WINDOWS_GUI
Definition: ntimage.h:437
#define IMAGE_SUBSYSTEM_NATIVE
Definition: ntimage.h:436
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:463
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:96
NTSTATUS NTAPI NtRequestWaitReplyPort(IN HANDLE PortHandle, IN PPORT_MESSAGE LpcRequest, IN OUT PPORT_MESSAGE LpcReply)
Definition: send.c:696
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
Definition: state.c:290
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define STATUS_WAIT_0
Definition: ntstatus.h:330
#define STATUS_DELETE_PENDING
Definition: ntstatus.h:416
#define STATUS_OBJECT_PATH_SYNTAX_BAD
Definition: ntstatus.h:389
#define STATUS_NO_SUCH_PACKAGE
Definition: ntstatus.h:584
NTSTRSAFEAPI RtlStringCbCatW(_Inout_updates_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cbDest, _In_ NTSTRSAFE_PCWSTR pszSrc)
Definition: ntstrsafe.h:636
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:3437
short WCHAR
Definition: pedump.c:58
unsigned short USHORT
Definition: pedump.c:61
static ULONG Timeout
Definition: ping.c:61
Entry
Definition: section.c:5216
#define STATUS_SUCCESS
Definition: shellext.h:65
PVOID SmpHeap
Definition: sminit.c:25
LIST_ENTRY SmpSubSystemList
Definition: sminit.c:22
LIST_ENTRY SmpSubSystemsToLoad
Definition: sminit.c:22
LIST_ENTRY SmpExecuteList
Definition: sminit.c:23
ULONG SmBaseTag
Definition: sminit.c:26
UNICODE_STRING SmpDefaultLibPath
Definition: sminit.c:29
VOID NTAPI SmpTranslateSystemPartitionInformation(VOID)
Definition: sminit.c:832
LIST_ENTRY SmpSetupExecuteList
Definition: sminit.c:19
struct _SB_CREATE_SESSION_MSG SB_CREATE_SESSION_MSG
@ SbpCreateProcess
Definition: smmsg.h:149
@ SbpCreateSession
Definition: smmsg.h:146
struct _SB_API_MSG SB_API_MSG
BOOLEAN NTAPI SmpCheckDuplicateMuSessionId(IN ULONG MuSessionId)
Definition: smsessn.c:37
ULONG NTAPI SmpAllocateSessionId(IN PSMP_SUBSYSTEM Subsystem, IN PSMP_SUBSYSTEM OtherSubsystem)
Definition: smsessn.c:123
VOID NTAPI SmpDeleteSession(IN ULONG SessionId)
Definition: smsessn.c:98
BOOLEAN SmpDebug
Definition: smss.c:20
ULONG AttachedSessionId
Definition: smss.c:19
NTSTATUS NTAPI SmpExecuteCommand(IN PUNICODE_STRING CommandLine, IN ULONG MuSessionId, OUT PHANDLE ProcessId, IN ULONG Flags)
Definition: smss.c:208
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:31
#define SMP_OS2_FLAG
Definition: smss.h:54
VOID NTAPI SmpReleasePrivilege(IN PVOID State)
Definition: smutil.c:124
#define SMP_DEFERRED_FLAG
Definition: smss.h:52
#define SMP_POSIX_FLAG
Definition: smss.h:53
NTSTATUS NTAPI SmpAcquirePrivilege(IN ULONG Privilege, OUT PVOID *PrivilegeStat)
Definition: smutil.c:35
#define SMP_DEBUG_FLAG
Definition: smss.h:47
#define SMP_INVALID_PATH
Definition: smss.h:51
#define SMP_SUBSYSTEM_FLAG
Definition: smss.h:50
HANDLE SmpWindowsSubSysProcess
Definition: smsubsys.c:20
WCHAR InitialCommandBuffer[256]
Definition: smsubsys.c:23
NTSTATUS NTAPI SmpCallCsrCreateProcess(IN PSB_API_MSG SbApiMsg, IN USHORT MessageLength, IN HANDLE PortHandle)
Definition: smsubsys.c:32
NTSTATUS NTAPI SmpLoadSubSystemsForMuSession(IN PULONG MuSessionId, OUT PHANDLE ProcessId, IN PUNICODE_STRING InitialCommand)
Definition: smsubsys.c:513
RTL_CRITICAL_SECTION SmpKnownSubSysLock
Definition: smsubsys.c:18
#define DEFAULT_KMODE_SUBSYSTEM
Definition: smsubsys.c:26
VOID NTAPI SmpDereferenceSubsystem(IN PSMP_SUBSYSTEM SubSystem)
Definition: smsubsys.c:50
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:141
PSMP_SUBSYSTEM NTAPI SmpLocateKnownSubSysByCid(IN PCLIENT_ID ClientId)
Definition: smsubsys.c:71
#define DEFAULT_INITIAL_COMMAND
Definition: smsubsys.c:25
PSMP_SUBSYSTEM NTAPI SmpLocateKnownSubSysByType(IN ULONG MuSessionId, IN ULONG ImageType)
Definition: smsubsys.c:105
HANDLE SmpWindowsSubSysProcessId
Definition: smsubsys.c:21
BOOLEAN RegPosixSingleInstance
Definition: smsubsys.c:22
LIST_ENTRY SmpKnownSubSysHead
Definition: smsubsys.c:19
HANDLE UniqueProcess
Definition: compat.h:825
Definition: typedefs.h:120
struct _LIST_ENTRY * Blink
Definition: typedefs.h:122
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
SECTION_IMAGE_INFORMATION ImageInformation
Definition: rtltypes.h:1600
union _SB_API_MSG::@3961::@3963::@3965 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_CREATE_SESSION_MSG CreateSession
Definition: smmsg.h:242
PORT_MESSAGE h
Definition: smmsg.h:232
UNICODE_STRING Name
Definition: smss.h:61
UNICODE_STRING Value
Definition: smss.h:62
ULONG MuSessionId
Definition: smss.h:75
HANDLE ProcessHandle
Definition: smss.h:70
HANDLE SbApiPort
Definition: smss.h:73
CLIENT_ID ClientId
Definition: smss.h:74
HANDLE Event
Definition: smss.h:69
ULONG ImageType
Definition: smss.h:71
BOOLEAN Terminating
Definition: smss.h:76
LIST_ENTRY Entry
Definition: smss.h:68
HANDLE PortHandle
Definition: smss.h:72
ULONG ReferenceCount
Definition: smss.h:77
uint32_t * PULONG
Definition: typedefs.h:59
#define NTAPI
Definition: typedefs.h:36
#define IN
Definition: typedefs.h:39
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
#define CreateProcess
Definition: winbase.h:3479
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1151