ReactOS 0.4.17-dev-769-g1500a35
smss.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/smss.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
23
24#define DEFAULT_SUBSYSTEM_DESC L"Windows SubSystem"
25#define DEFAULT_INITIAL_COMMAND_DESC L"Windows Logon Process"
26
27/* FUNCTIONS ******************************************************************/
28
33 IN PUNICODE_STRING CommandLine,
34 IN ULONG MuSessionId,
36 IN PRTL_USER_PROCESS_INFORMATION ProcessInformation)
37{
40 RTL_USER_PROCESS_INFORMATION LocalProcessInfo;
41 PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
42
43 /* Use the input process information if we have it, otherwise use local */
44 ProcessInfo = ProcessInformation;
45 if (!ProcessInfo) ProcessInfo = &LocalProcessInfo;
46
47 /* Create parameters for the target process */
48 Status = RtlCreateProcessParameters(&ProcessParameters,
53 CommandLine,
55 NULL,
56 NULL,
57 NULL,
58 0);
59 if (!NT_SUCCESS(Status))
60 {
61 /* This is a pretty bad failure. ASSERT on checked builds and exit */
62 ASSERTMSG("RtlCreateProcessParameters failed.\n", NT_SUCCESS(Status));
63 DPRINT1("SMSS: RtlCreateProcessParameters failed for %wZ - Status == %lx\n",
65 return Status;
66 }
67
68 /* Set the size field as required */
69 ProcessInfo->Size = sizeof(*ProcessInfo);
70
71 /* Check if the debug flag was requested */
73 {
74 /* Write it in the process parameters */
75 ProcessParameters->DebugFlags = 1;
76 }
77 else
78 {
79 /* Otherwise inherit the flag that was passed to SMSS itself */
80 ProcessParameters->DebugFlags = SmpDebug;
81 }
82
83 /* Subsystems get the first 1MB of memory reserved for DOS/IVT purposes */
85 {
87 }
88
89 /* And always force NX for anything that SMSS launches */
90 ProcessParameters->Flags |= RTL_USER_PROCESS_PARAMETERS_NX;
91
92 /* Now create the process in suspended state */
95 ProcessParameters,
96 NULL,
97 NULL,
98 NULL,
99 FALSE,
100 NULL,
101 NULL,
102 ProcessInfo);
103 RtlDestroyProcessParameters(ProcessParameters);
104 if (!NT_SUCCESS(Status))
105 {
106 /* If we couldn't create it, fail back to the caller */
107 DPRINT1("SMSS: Failed load of %wZ - Status == %lx\n",
109 return Status;
110 }
111
112 /* Associate a session with this process */
113 Status = SmpSetProcessMuSessionId(ProcessInfo->ProcessHandle, MuSessionId);
114
115 /* If the application is deferred (suspended), there's nothing to do */
116 if (Flags & SMP_DEFERRED_FLAG) return Status;
117
118 /* Otherwise, get ready to start it, but make sure it's a native app */
120 {
121 /* Resume it */
122 NtResumeThread(ProcessInfo->ThreadHandle, NULL);
123 if (!(Flags & SMP_ASYNC_FLAG))
124 {
125 /* Block on it unless Async was requested */
127 }
128
129 /* It's up and running now, close our handles */
130 NtClose(ProcessInfo->ThreadHandle);
131 NtClose(ProcessInfo->ProcessHandle);
132 }
133 else
134 {
135 /* This image is invalid, so kill it, close our handles, and fail */
139 NtClose(ProcessInfo->ThreadHandle);
140 NtClose(ProcessInfo->ProcessHandle);
141 DPRINT1("SMSS: Not an NT image - %wZ\n", FileName);
142 }
143
144 /* Return the outcome of the process create */
145 return Status;
146}
147
149NTAPI
152 IN PUNICODE_STRING Arguments,
153 IN ULONG Flags)
154{
155 ANSI_STRING MessageString;
156 CHAR MessageBuffer[256];
158 WCHAR Buffer[1024];
159 BOOLEAN BootState, BootOkay, ShutdownOkay;
160
161 /* Make sure autochk was actually found */
163 {
164 /* It wasn't, so create an error message to print on the screen */
165 RtlStringCbPrintfA(MessageBuffer,
166 sizeof(MessageBuffer),
167 "%wZ program not found - skipping AUTOCHECK\r\n",
168 FileName);
169 RtlInitAnsiString(&MessageString, MessageBuffer);
171 &MessageString,
172 TRUE)))
173 {
174 /* And show it */
177 }
178 }
179 else
180 {
181 /* Autochk is there, so record the BSD state */
182 BootState = SmpSaveAndClearBootStatusData(&BootOkay, &ShutdownOkay);
183
184 /* Build the path to autochk and place its arguments */
185 RtlInitEmptyUnicodeString(&Destination, Buffer, sizeof(Buffer));
189
190 /* Execute it */
192 Directory,
194 0,
196 NULL);
197
198 /* Restore the BSD state */
199 if (BootState) SmpRestoreBootStatusData(BootOkay, ShutdownOkay);
200 }
201
202 /* We're all done! */
203 return STATUS_SUCCESS;
204}
205
207NTAPI
209 IN ULONG MuSessionId,
211 IN ULONG Flags)
212{
215
216 /* There's no longer a debugging subsystem */
217 if (Flags & SMP_DEBUG_FLAG) return STATUS_SUCCESS;
218
219 /* Parse the command line to see what execution flags are requested */
220 Status = SmpParseCommandLine(CommandLine,
221 &Flags,
222 &FileName,
223 &Directory,
224 &Arguments);
225 if (!NT_SUCCESS(Status))
226 {
227 /* Fail if we couldn't do that */
228 DPRINT1("SMSS: SmpParseCommandLine(%wZ) failed - Status == %lx\n",
229 CommandLine, Status);
230 return Status;
231 }
232
233 /* Check if autochk is requested */
235 {
236 /* Run it */
238 }
239 else if (Flags & SMP_SUBSYSTEM_FLAG)
240 {
242 &Directory,
243 CommandLine,
244 MuSessionId,
245 ProcessId,
246 Flags);
247 }
248 else if (Flags & SMP_INVALID_PATH)
249 {
250 /* An invalid image was specified, fail */
251 DPRINT1("SMSS: Image file (%wZ) not found\n", &FileName);
253 }
254 else
255 {
256 /* An actual image name was present, execute it */
258 &Directory,
259 CommandLine,
260 MuSessionId,
261 Flags,
262 NULL);
263 }
264
265 /* Free all the token parameters */
266 if (FileName.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer);
267 if (Directory.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, Directory.Buffer);
268 if (Arguments.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, Arguments.Buffer);
269
270 /* Return to the caller */
271 if (!NT_SUCCESS(Status))
272 {
273 DPRINT1("SMSS: Command '%wZ' failed - Status == %x\n",
274 CommandLine, Status);
275 }
276 return Status;
277}
278
280NTAPI
282 IN PUNICODE_STRING InitialCommand,
283 IN HANDLE InitialCommandProcess,
284 OUT PHANDLE ReturnPid)
285{
289 ULONG Flags = 0;
290
291 /* Check if we haven't yet connected to ourselves */
292 if (!SmApiPort)
293 {
294 /* Connect to ourselves, as a client */
296 if (!NT_SUCCESS(Status))
297 {
298 DPRINT1("SMSS: Unable to connect to SM - Status == %lx\n", Status);
299 return Status;
300 }
301 }
302
303 /* Parse the initial command line */
304 Status = SmpParseCommandLine(InitialCommand,
305 &Flags,
306 &FileName,
307 &Directory,
308 &Arguments);
310 {
311 /* Fail if it doesn't exist */
312 DPRINT1("SMSS: Initial command image (%wZ) not found\n", &FileName);
313 if (FileName.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer);
315 }
316
317 /* And fail if any other reason is also true */
318 if (!NT_SUCCESS(Status))
319 {
320 DPRINT1("SMSS: SmpParseCommandLine(%wZ) failed - Status == %lx\n",
321 InitialCommand, Status);
322 return Status;
323 }
324
325 /* Execute the initial command, but defer its full execution */
327 &Directory,
328 InitialCommand,
329 MuSessionId,
331 &ProcessInfo);
332
333 /* Free all the token parameters */
334 if (FileName.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer);
335 if (Directory.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, Directory.Buffer);
336 if (Arguments.Buffer) RtlFreeHeap(RtlGetProcessHeap(), 0, Arguments.Buffer);
337
338 /* Bail out if we couldn't execute the initial command */
339 if (!NT_SUCCESS(Status)) return Status;
340
341 /* Now duplicate the handle to this process */
343 ProcessInfo.ProcessHandle,
345 InitialCommandProcess,
347 0,
348 0);
349 if (!NT_SUCCESS(Status))
350 {
351 /* Kill it utterly if duplication failed */
352 DPRINT1("SMSS: DupObject Failed. Status == %lx\n", Status);
354 NtResumeThread(ProcessInfo.ThreadHandle, NULL);
355 NtClose(ProcessInfo.ThreadHandle);
356 NtClose(ProcessInfo.ProcessHandle);
357 return Status;
358 }
359
360 /* Return PID to the caller, and set this as the initial command PID */
361 if (ReturnPid) *ReturnPid = ProcessInfo.ClientId.UniqueProcess;
362 if (!MuSessionId) SmpInitialCommandProcessId = ProcessInfo.ClientId.UniqueProcess;
363
364 /* Now call our server execution function to wrap up its initialization */
365 Status = SmExecPgm(SmApiPort, &ProcessInfo, FALSE);
366 if (!NT_SUCCESS(Status)) DPRINT1("SMSS: SmExecPgm Failed. Status == %lx\n", Status);
367 return Status;
368}
369
371NTAPI
373 _In_reads_(ParameterCount) PULONG_PTR Parameters,
374 _In_ ULONG ParameterMask,
375 _In_ ULONG ParameterCount)
376{
379 BOOLEAN Old;
380
381 /* Give the shutdown privilege to the thread */
383 if (Status == STATUS_NO_TOKEN)
384 {
385 /* The thread doesn't have a token, give it to the entire process */
387 }
388
389 /* Take down the process/machine with a hard error */
391 ParameterCount,
392 ParameterMask,
395 &Response);
396
397 /* Terminate the process if the hard error didn't already.
398 * In case the Parameters array has at least 2 elements,
399 * use Parameters[1] that contains the actual failure code,
400 * instead of what NtRaiseHardError() returned. */
401 if (ParameterCount >= 2) Status = Parameters[1];
403}
404
405LONG
406NTAPI
408 _In_ PEXCEPTION_POINTERS ExceptionInfo)
409{
410 PEXCEPTION_RECORD ExceptionRecord = ExceptionInfo->ExceptionRecord;
412 UNICODE_STRING ErrorString;
413
414#if DBG
415 /* Print the message and break into the debugger */
416 DbgPrint("SMSS: Unhandled exception - Status == %x IP == %p\n",
417 ExceptionRecord->ExceptionCode,
418 ExceptionRecord->ExceptionAddress);
419 if ((ExceptionRecord->ExceptionCode == STATUS_IN_PAGE_ERROR) &&
420 (ExceptionRecord->NumberParameters >= 3))
421 {
422 DbgPrint(" Memory Address: %x Read/Write: %x I/O Error: %x\n",
423 ExceptionRecord->ExceptionInformation[1],
424 ExceptionRecord->ExceptionInformation[0],
425 ExceptionRecord->ExceptionInformation[2]);
426 }
427 else
428 if ((ExceptionRecord->ExceptionCode == STATUS_ACCESS_VIOLATION ||
429 ExceptionRecord->ExceptionCode == STATUS_GUARD_PAGE_VIOLATION ||
430 ExceptionRecord->ExceptionCode == STATUS_STACK_OVERFLOW ||
431 ExceptionRecord->ExceptionCode == STATUS_IN_PAGE_ERROR) &&
432 (ExceptionRecord->NumberParameters >= 2))
433 {
434 DbgPrint(" Memory Address: %x Read/Write: %x\n",
435 ExceptionRecord->ExceptionInformation[1],
436 ExceptionRecord->ExceptionInformation[0]);
437 }
438 if (NtCurrentPeb()->BeingDebugged) DbgBreakPoint();
439#endif
440
441 /* Build the hard error and terminate */
442 RtlInitUnicodeString(&ErrorString, L"Unhandled Exception in Session Manager");
443 Parameters[0] = (ULONG_PTR)&ErrorString;
444 Parameters[1] = ExceptionRecord->ExceptionCode;
445 Parameters[2] = (ULONG_PTR)ExceptionRecord->ExceptionAddress;
446 Parameters[3] = (ULONG_PTR)ExceptionInfo->ContextRecord;
448
449 /* We should never get here */
450 ASSERT(FALSE);
452}
453
457 IN PCHAR argv[],
458 IN PCHAR envp[],
460{
462 KPRIORITY SetBasePriority;
464 HANDLE Handles[2];
465 PVOID State;
466 ULONG Flags;
467 PROCESS_BASIC_INFORMATION ProcessInfo;
468 UNICODE_STRING DbgString, InitialCommand;
469
470 /* Make us critical */
473
474 /* Raise our priority */
475 SetBasePriority = 11;
478 (PVOID)&SetBasePriority,
479 sizeof(SetBasePriority));
481
482 /* Save the debug flag if it was passed */
483 if (DebugFlag) SmpDebug = DebugFlag != 0;
484
485 /* Build the hard error parameters */
486 Parameters[0] = (ULONG_PTR)&DbgString;
487 Parameters[1] = Parameters[2] = Parameters[3] = 0;
488
489 /* Enter SEH so we can terminate correctly if anything goes wrong */
491 {
492 /* Initialize SMSS */
493 Status = SmpInit(&InitialCommand, &Handles[0]);
494 if (!NT_SUCCESS(Status))
495 {
496 DPRINT1("SMSS: SmpInit return failure - Status == %x\n", Status);
497 RtlInitUnicodeString(&DbgString, L"Session Manager Initialization");
498 Parameters[1] = Status;
500 }
501
502 /* Get the global flags */
504 &Flags,
505 sizeof(Flags),
506 NULL);
508
509 /* Before executing the initial command check if the debug flag is on */
511 {
512 /* SMSS should launch ntsd with a few parameters at this point */
513 DPRINT1("Global Flags Set to SMSS Debugging: Not yet supported\n");
514 }
515
516 /* Execute the initial command (Winlogon.exe) */
517 Status = SmpExecuteInitialCommand(0, &InitialCommand, &Handles[1], NULL);
518 if (!NT_SUCCESS(Status))
519 {
520 /* Fail and raise a hard error */
521 DPRINT1("SMSS: Execute Initial Command failed\n");
522 RtlInitUnicodeString(&DbgString,
523 L"Session Manager ExecuteInitialCommand");
524 Parameters[1] = Status;
526 }
527
528 /* Check if we're already attached to a session */
530 if (AttachedSessionId != -1)
531 {
532 /* Detach from it, we should be in no session right now */
535 sizeof(AttachedSessionId));
538 }
540
541 /* Wait on either CSRSS or the initial command to die */
543 Handles,
544 WaitAny,
545 FALSE,
546 NULL);
547 if (Status == STATUS_WAIT_0)
548 {
549 /* CSRSS is dead, get its exit code */
553 &ProcessInfo,
554 sizeof(ProcessInfo),
555 NULL);
556 DPRINT1("SMSS: %S terminated when it wasn't supposed to.\n",
558 }
559 else
560 {
561 /* The initial command is dead or we have another failure */
563 if (Status == STATUS_WAIT_1)
564 {
565 /* The initial command got terminated, get its exit code */
568 &ProcessInfo,
569 sizeof(ProcessInfo),
570 NULL);
571 }
572 else
573 {
574 /* Something else satisfied our wait, so set the wait status */
575 ProcessInfo.ExitStatus = Status;
577 }
578 DPRINT1("SMSS: Initial command '%wZ' terminated when it wasn't supposed to.\n",
579 &InitialCommand);
580 }
581
582 /* Check if NtQueryInformationProcess was successful */
583 if (NT_SUCCESS(Status))
584 {
585 /* Then we must have a valid exit status in the structure, use it */
586 Parameters[1] = ProcessInfo.ExitStatus;
587 }
588 else
589 {
590 /* We really don't know what happened, so set a generic error */
592 }
593 }
595 {
596 /* The filter should never return here */
597 ASSERT(FALSE);
598 }
599 _SEH2_END;
600
601 /* Something in the init loop failed, terminate SMSS */
603}
604
605/* EOF */
NTSYSAPI NTSTATUS NTAPI NtSetSystemInformation(IN INT SystemInformationClass, IN PVOID SystemInformation, IN ULONG SystemInformationLength)
#define NtCurrentPeb()
Definition: FLS.c:22
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
unsigned char BOOLEAN
Definition: actypes.h:127
LONG NTSTATUS
Definition: precomp.h:26
#define DPRINT1
Definition: precomp.h:8
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:634
@ ProcessBasicInformation
Definition: cicbase.cpp:63
Definition: bufpool.h:45
ULONG DebugFlag
Definition: fxobject.cpp:44
_In_ HANDLE _In_ CONST PDXGKMDT_OPM_GET_INFO_PARAMETERS Parameters
Definition: dispmprt.h:321
_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
LONG KPRIORITY
Definition: compat.h:803
MonoAssembly int argc
Definition: metahost.c:107
#define __cdecl
Definition: corecrt.h:121
#define L(x)
Definition: resources.c:13
#define ULONG_PTR
Definition: config.h:101
NTSTATUS RtlAppendUnicodeToString(IN PUNICODE_STRING Str1, IN PWSTR Str2)
Definition: string_lib.cpp:62
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ProcessId
Definition: fatprocs.h:2712
struct _FileName FileName
Definition: fatprocs.h:897
@ SystemFlagsInformation
Definition: ntddk_ex.h:20
#define STATUS_ACCESS_VIOLATION
Status
Definition: gdiplustypes.h:24
#define DbgPrint
Definition: hal.h:12
NTSTATUS NTAPI NtRaiseHardError(IN NTSTATUS ErrorStatus, IN ULONG NumberOfParameters, IN ULONG UnicodeStringParameterMask, IN PULONG_PTR Parameters, IN ULONG ValidResponseOptions, OUT PULONG Response)
Definition: harderr.c:551
#define FLG_DEBUG_INITIAL_COMMAND
Definition: pstypes.h:53
#define FLG_DEBUG_INITIAL_COMMAND_EX
Definition: pstypes.h:80
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
#define ASSERT(a)
Definition: mode.c:44
#define SE_SHUTDOWN_PRIVILEGE
Definition: security.c:573
#define SE_LOAD_DRIVER_PRIVILEGE
Definition: security.c:564
#define argv
Definition: mplay32.c:18
@ OptionShutdownSystem
Definition: extypes.h:192
@ SystemSessionDetach
Definition: extypes.h:265
NTSYSAPI NTSTATUS NTAPI RtlDestroyProcessParameters(_In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters)
NTSYSAPI NTSTATUS NTAPI RtlCreateProcessParameters(_Out_ PRTL_USER_PROCESS_PARAMETERS *ProcessParameters, _In_ PUNICODE_STRING ImagePathName, _In_opt_ PUNICODE_STRING DllPath, _In_opt_ PUNICODE_STRING CurrentDirectory, _In_opt_ PUNICODE_STRING CommandLine, _In_opt_ PWSTR Environment, _In_opt_ PUNICODE_STRING WindowTitle, _In_opt_ PUNICODE_STRING DesktopInfo, _In_opt_ PUNICODE_STRING ShellInfo, _In_opt_ PUNICODE_STRING RuntimeInfo)
_In_ PUNICODE_STRING _Inout_ PUNICODE_STRING Destination
Definition: rtlfuncs.h:3051
NTSYSAPI NTSTATUS NTAPI RtlCreateUserProcess(_In_ PUNICODE_STRING ImageFileName, _In_ ULONG Attributes, _In_ PRTL_USER_PROCESS_PARAMETERS ProcessParameters, _In_opt_ PSECURITY_DESCRIPTOR ProcessSecutityDescriptor, _In_opt_ PSECURITY_DESCRIPTOR ThreadSecurityDescriptor, _In_opt_ HANDLE ParentProcess, _In_ BOOLEAN CurrentDirectory, _In_opt_ HANDLE DebugPort, _In_opt_ HANDLE ExceptionPort, _Out_ PRTL_USER_PROCESS_INFORMATION ProcessInfo)
NTSYSAPI NTSTATUS __cdecl RtlSetThreadIsCritical(_In_ BOOLEAN NewValue, _Out_opt_ PBOOLEAN OldValue, _In_ BOOLEAN NeedBreaks)
_In_ BOOLEAN _In_ USHORT Directory
Definition: rtlfuncs.h:3962
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
NTSYSAPI NTSTATUS __cdecl RtlSetProcessIsCritical(_In_ BOOLEAN NewValue, _Out_opt_ PBOOLEAN OldValue, _In_ BOOLEAN NeedBreaks)
#define RTL_USER_PROCESS_PARAMETERS_NX
Definition: rtltypes.h:55
#define RTL_USER_PROCESS_PARAMETERS_RESERVE_1MB
Definition: rtltypes.h:46
#define _In_reads_(s)
Definition: no_sal2.h:168
#define _In_
Definition: no_sal2.h:158
NTSTATUS NTAPI NtDisplayString(PUNICODE_STRING String)
NTSYSAPI NTSTATUS NTAPI RtlAppendUnicodeStringToString(PUNICODE_STRING Destination, PUNICODE_STRING Source)
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
#define PROCESS_ALL_ACCESS
Definition: nt_native.h:1327
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
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 NtClose(IN HANDLE Handle)
Definition: obhandle.c:3429
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI NTSTATUS NTAPI NtWaitForSingleObject(IN HANDLE hObject, IN BOOLEAN bAlertable, IN PLARGE_INTEGER Timeout)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
@ WaitAny
#define IMAGE_SUBSYSTEM_NATIVE
Definition: ntimage.h:436
NTSTATUS NTAPI NtSetInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _In_reads_bytes_(ProcessInformationLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength)
Definition: query.c:1422
NTSTATUS NTAPI NtQueryInformationProcess(_In_ HANDLE ProcessHandle, _In_ PROCESSINFOCLASS ProcessInformationClass, _Out_writes_bytes_to_opt_(ProcessInformationLength, *ReturnLength) PVOID ProcessInformation, _In_ ULONG ProcessInformationLength, _Out_opt_ PULONG ReturnLength)
Definition: query.c:211
NTSTATUS NTAPI NtResumeThread(IN HANDLE ThreadHandle, OUT PULONG SuspendCount OPTIONAL)
Definition: state.c:290
PVOID *typedef PHANDLE
Definition: ntsecpkg.h:455
#define STATUS_NO_TOKEN
Definition: ntstatus.h:454
#define STATUS_WAIT_0
Definition: ntstatus.h:330
#define STATUS_WAIT_1
Definition: ntstatus.h:123
#define STATUS_INVALID_IMAGE_FORMAT
Definition: ntstatus.h:453
#define STATUS_STACK_OVERFLOW
Definition: ntstatus.h:583
#define STATUS_SYSTEM_PROCESS_TERMINATED
Definition: ntstatus.h:792
#define STATUS_IN_PAGE_ERROR
Definition: ntstatus.h:336
#define STATUS_GUARD_PAGE_VIOLATION
Definition: ntstatus.h:262
NTSTRSAFEVAPI RtlStringCbPrintfA(_Out_writes_bytes_(cbDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cbDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1148
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
NTSTATUS NTAPI NtWaitForMultipleObjects(IN ULONG ObjectCount, IN PHANDLE HandleArray, IN WAIT_TYPE WaitType, IN BOOLEAN Alertable, IN PLARGE_INTEGER TimeOut OPTIONAL)
Definition: obwait.c:46
short WCHAR
Definition: pedump.c:58
long LONG
Definition: pedump.c:60
char CHAR
Definition: pedump.c:57
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:104
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:203
#define _SEH2_END
Definition: pseh2_64.h:194
#define _SEH2_TRY
Definition: pseh2_64.h:93
#define _SEH2_LEAVE
Definition: pseh2_64.h:206
#define STATUS_SUCCESS
Definition: shellext.h:65
UNICODE_STRING SmpDefaultLibPath
Definition: sminit.c:29
PWCHAR SmpDefaultEnvironment
Definition: sminit.c:28
NTSTATUS NTAPI SmpInit(IN PUNICODE_STRING InitialCommand, OUT PHANDLE ProcessHandle)
Definition: sminit.c:2473
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
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 SmpSetProcessMuSessionId(IN HANDLE ProcessHandle, IN ULONG SessionId)
Definition: smsessn.c:199
LONG NTAPI SmpUnhandledExceptionFilter(_In_ PEXCEPTION_POINTERS ExceptionInfo)
Definition: smss.c:407
NTSTATUS NTAPI SmpTerminate(_In_reads_(ParameterCount) PULONG_PTR Parameters, _In_ ULONG ParameterMask, _In_ ULONG ParameterCount)
Definition: smss.c:372
BOOLEAN SmpDebug
Definition: smss.c:20
NTSTATUS NTAPI SmpExecuteInitialCommand(IN ULONG MuSessionId, IN PUNICODE_STRING InitialCommand, IN HANDLE InitialCommandProcess, OUT PHANDLE ReturnPid)
Definition: smss.c:281
#define DEFAULT_SUBSYSTEM_DESC
Definition: smss.c:24
HANDLE SmpInitialCommandProcessId
Definition: smss.c:22
ULONG AttachedSessionId
Definition: smss.c:19
NTSTATUS __cdecl _main(IN INT argc, IN PCHAR argv[], IN PCHAR envp[], IN ULONG DebugFlag)
Definition: smss.c:456
#define DEFAULT_INITIAL_COMMAND_DESC
Definition: smss.c:25
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
NTSTATUS NTAPI SmpInvokeAutoChk(IN PUNICODE_STRING FileName, IN PUNICODE_STRING Directory, IN PUNICODE_STRING Arguments, IN ULONG Flags)
Definition: smss.c:150
UNICODE_STRING SmpSystemRoot
Definition: smss.c:18
HANDLE SmApiPort
Definition: smss.c:21
VOID NTAPI SmpReleasePrivilege(IN PVOID State)
Definition: smutil.c:124
#define SMP_AUTOCHK_FLAG
Definition: smss.h:49
NTSTATUS NTAPI SmpParseCommandLine(IN PUNICODE_STRING CommandLine, OUT PULONG Flags, OUT PUNICODE_STRING FileName, OUT PUNICODE_STRING Directory, OUT PUNICODE_STRING Arguments)
Definition: smutil.c:228
#define SMP_DEFERRED_FLAG
Definition: smss.h:52
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
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
BOOLEAN NTAPI SmpSaveAndClearBootStatusData(OUT PBOOLEAN BootOkay, OUT PBOOLEAN ShutdownOkay)
Definition: smutil.c:419
#define SMP_SUBSYSTEM_FLAG
Definition: smss.h:50
#define SMP_ASYNC_FLAG
Definition: smss.h:48
VOID NTAPI SmpRestoreBootStatusData(IN BOOLEAN BootOkay, IN BOOLEAN ShutdownOkay)
Definition: smutil.c:469
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
Definition: ncftp.h:89
HANDLE UniqueProcess
Definition: compat.h:825
struct _EXCEPTION_RECORD * ExceptionRecord
Definition: compat.h:210
DWORD ExceptionCode
Definition: compat.h:208
DWORD NumberParameters
Definition: compat.h:212
ULONG_PTR ExceptionInformation[EXCEPTION_MAXIMUM_PARAMETERS]
Definition: compat.h:213
PVOID ExceptionAddress
Definition: compat.h:211
SECTION_IMAGE_INFORMATION ImageInformation
Definition: rtltypes.h:1600
uint32_t * PULONG_PTR
Definition: typedefs.h:65
#define NTAPI
Definition: typedefs.h:36
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define IN
Definition: typedefs.h:39
uint32_t ULONG
Definition: typedefs.h:59
#define OUT
Definition: typedefs.h:40
char * PCHAR
Definition: typedefs.h:51
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
NTSYSAPI void WINAPI DbgBreakPoint(void)
@ ProcessBasePriority
Definition: winternl.h:1887