ReactOS 0.4.16-dev-297-gc569aee
procsup.c File Reference
#include <srv.h>
#include <winuser.h>
#include <debug.h>
Include dependency graph for procsup.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

VOID NTAPI CsrSetToNormalPriority (VOID)
 
VOID NTAPI CsrSetToShutdownPriority (VOID)
 
VOID NTAPI CsrProcessRefcountZero (IN PCSR_PROCESS CsrProcess)
 
VOID NTAPI CsrLockedDereferenceProcess (PCSR_PROCESS CsrProcess)
 
PCSR_PROCESS NTAPI CsrAllocateProcess (VOID)
 
VOID NTAPI CsrLockedReferenceProcess (IN PCSR_PROCESS CsrProcess)
 
NTSTATUS NTAPI CsrInitializeProcessStructure (VOID)
 
VOID NTAPI CsrDeallocateProcess (IN PCSR_PROCESS CsrProcess)
 
VOID NTAPI CsrRemoveProcess (IN PCSR_PROCESS CsrProcess)
 
VOID NTAPI CsrInsertProcess (IN PCSR_PROCESS ParentProcess OPTIONAL, IN PCSR_PROCESS CsrProcess)
 
NTSTATUS NTAPI CsrCreateProcess (IN HANDLE hProcess, IN HANDLE hThread, IN PCLIENT_ID ClientId, IN PCSR_NT_SESSION NtSession, IN ULONG Flags, IN PCLIENT_ID DebugCid)
 
NTSTATUS NTAPI CsrDebugProcess (IN PCSR_PROCESS CsrProcess)
 
NTSTATUS NTAPI CsrDebugProcessStop (IN PCSR_PROCESS CsrProcess)
 
VOID NTAPI CsrDereferenceProcess (IN PCSR_PROCESS CsrProcess)
 
NTSTATUS NTAPI CsrDestroyProcess (IN PCLIENT_ID Cid, IN NTSTATUS ExitStatus)
 
NTSTATUS NTAPI CsrGetProcessLuid (IN HANDLE hProcess OPTIONAL, OUT PLUID Luid)
 
BOOLEAN NTAPI CsrImpersonateClient (IN PCSR_THREAD CsrThread)
 
NTSTATUS NTAPI CsrLockProcessByClientId (IN HANDLE Pid, OUT PCSR_PROCESS *CsrProcess)
 
BOOLEAN NTAPI CsrRevertToSelf (VOID)
 
VOID NTAPI CsrSetBackgroundPriority (IN PCSR_PROCESS CsrProcess)
 
VOID NTAPI CsrSetForegroundPriority (IN PCSR_PROCESS CsrProcess)
 
PCSR_PROCESS NTAPI FindProcessForShutdown (IN PLUID CallerLuid)
 
NTSTATUS NTAPI CsrShutdownProcesses (IN PLUID CallerLuid, IN ULONG Flags)
 
NTSTATUS NTAPI CsrUnlockProcess (IN PCSR_PROCESS CsrProcess)
 

Variables

RTL_CRITICAL_SECTION CsrProcessLock
 
PCSR_PROCESS CsrRootProcess = NULL
 
SECURITY_QUALITY_OF_SERVICE CsrSecurityQos
 
ULONG CsrProcessSequenceCount = 5
 
ULONG CsrTotalPerProcessDataLength
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 16 of file procsup.c.

Function Documentation

◆ CsrAllocateProcess()

PCSR_PROCESS NTAPI CsrAllocateProcess ( VOID  )

Definition at line 189 of file procsup.c.

190{
192 ULONG TotalSize;
193
194 /* Calculate the amount of memory this should take */
195 TotalSize = sizeof(CSR_PROCESS) +
196 (CSR_SERVER_DLL_MAX * sizeof(PVOID)) +
198
199 /* Allocate a Process */
201 if (!CsrProcess) return NULL;
202
203 /* Handle the Sequence Number and protect against overflow */
204 CsrProcess->SequenceNumber = CsrProcessSequenceCount++;
206
207 /* Increase the reference count */
209
210 /* Initialize the Thread List */
211 InitializeListHead(&CsrProcess->ThreadList);
212
213 /* Return the Process */
214 return CsrProcess;
215}
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:590
struct _CSR_PROCESS CSR_PROCESS
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define InitializeListHead(ListHead)
Definition: env_spec_w32.h:944
#define CSR_SERVER_DLL_MAX
Definition: api.h:34
HANDLE CsrHeap
Definition: init.c:25
ULONG CsrTotalPerProcessDataLength
Definition: init.c:39
VOID NTAPI CsrLockedReferenceProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:233
ULONG CsrProcessSequenceCount
Definition: procsup.c:30
uint32_t ULONG
Definition: typedefs.h:59
PKPROCESS CsrProcess
Definition: videoprt.c:39

Referenced by CsrCreateProcess(), CsrInitializeProcessStructure(), and CsrSbCreateSession().

◆ CsrCreateProcess()

NTSTATUS NTAPI CsrCreateProcess ( IN HANDLE  hProcess,
IN HANDLE  hThread,
IN PCLIENT_ID  ClientId,
IN PCSR_NT_SESSION  NtSession,
IN ULONG  Flags,
IN PCLIENT_ID  DebugCid 
)

Definition at line 422 of file procsup.c.

428{
429 PCSR_THREAD CurrentThread = CsrGetClientThread();
430 CLIENT_ID CurrentCid;
431 PCSR_PROCESS CurrentProcess;
432 PCSR_SERVER_DLL ServerDll;
433 PVOID ProcessData;
434 ULONG i;
437 PCSR_THREAD CsrThread;
438 KERNEL_USER_TIMES KernelTimes;
439
440 /* Get the current CID and lock Processes */
441 CurrentCid = CurrentThread->ClientId;
443
444 /* Get the current CSR Thread */
445 CurrentThread = CsrLocateThreadByClientId(&CurrentProcess, &CurrentCid);
446 if (!CurrentThread)
447 {
448 /* We've failed to locate the thread */
451 }
452
453 /* Allocate a new Process Object */
455 if (!CsrProcess)
456 {
457 /* Couldn't allocate Process */
459 return STATUS_NO_MEMORY;
460 }
461
462 /* Inherit the Process Data */
463 CurrentProcess = CurrentThread->Process;
464 ProcessData = &CsrProcess->ServerData[CSR_SERVER_DLL_MAX];
465 for (i = 0; i < CSR_SERVER_DLL_MAX; i++)
466 {
467 /* Get the current Server */
468 ServerDll = CsrLoadedServerDll[i];
469
470 /* Check if the DLL is Loaded and has Per Process Data */
471 if (ServerDll && ServerDll->SizeOfProcessData)
472 {
473 /* Set the pointer */
474 CsrProcess->ServerData[i] = ProcessData;
475
476 /* Copy the Data */
477 RtlMoveMemory(ProcessData,
478 CurrentProcess->ServerData[i],
479 ServerDll->SizeOfProcessData);
480
481 /* Update next data pointer */
482 ProcessData = (PVOID)((ULONG_PTR)ProcessData +
483 ServerDll->SizeOfProcessData);
484 }
485 else
486 {
487 /* No data for this Server */
488 CsrProcess->ServerData[i] = NULL;
489 }
490 }
491
492 /* Set the Exception Port for us */
495 &CsrApiPort,
496 sizeof(CsrApiPort));
497 if (!NT_SUCCESS(Status))
498 {
499 /* Failed */
502 return STATUS_NO_MEMORY;
503 }
504
505 /* Check if CreateProcess got CREATE_NEW_PROCESS_GROUP */
507 {
508 /*
509 * We create the process group leader of a new process group, therefore
510 * its process group ID and sequence number are its own ones.
511 */
513 CsrProcess->ProcessGroupSequence = CsrProcess->SequenceNumber;
514 }
515 else
516 {
517 /* Inherit the process group ID and sequence number from the current process */
518 CsrProcess->ProcessGroupId = CurrentProcess->ProcessGroupId;
519 CsrProcess->ProcessGroupSequence = CurrentProcess->ProcessGroupSequence;
520 }
521
522 /* Check if this is a console process */
524
525 /* Mask out non-debug flags */
527
528 /* Check if every process will be debugged */
529 if (!(Flags) && (CurrentProcess->DebugFlags & CsrDebugProcessChildren))
530 {
531 /* Pass it on to the current process */
533 CsrProcess->DebugCid = CurrentProcess->DebugCid;
534 }
535
536 /* Check if Debugging was used on this process */
537 if ((Flags & (CsrDebugOnlyThisProcess | CsrDebugProcessChildren)) && (DebugCid))
538 {
539 /* Save the debug flag used */
540 CsrProcess->DebugFlags = Flags;
541
542 /* Save the CID */
543 CsrProcess->DebugCid = *DebugCid;
544 }
545
546 /* Check if Debugging is enabled */
547 if (CsrProcess->DebugFlags)
548 {
549 /* Set the Debug Port for us */
552 &CsrApiPort,
553 sizeof(CsrApiPort));
555 if (!NT_SUCCESS(Status))
556 {
557 /* Failed */
560 return STATUS_NO_MEMORY;
561 }
562 }
563
564 /* Get the Thread Create Time */
567 &KernelTimes,
568 sizeof(KernelTimes),
569 NULL);
570 if (!NT_SUCCESS(Status))
571 {
572 /* Failed */
575 return STATUS_NO_MEMORY;
576 }
577
578 /* Allocate a CSR Thread Structure */
579 CsrThread = CsrAllocateThread(CsrProcess);
580 if (!CsrThread)
581 {
582 /* Failed */
585 return STATUS_NO_MEMORY;
586 }
587
588 /* Save the data we have */
589 CsrThread->CreateTime = KernelTimes.CreateTime;
590 CsrThread->ClientId = *ClientId;
591 CsrThread->ThreadHandle = hThread;
593 CsrThread->Flags = 0;
594
595 /* Insert the Thread into the Process */
596 Status = CsrInsertThread(CsrProcess, CsrThread);
597 if (!NT_SUCCESS(Status))
598 {
599 /* Bail out */
601 CsrDeallocateThread(CsrThread);
603 return Status;
604 }
605
606 /* Reference the session */
607 CsrReferenceNtSession(NtSession);
608 CsrProcess->NtSession = NtSession;
609
610 /* Setup Process Data */
611 CsrProcess->ClientId = *ClientId;
612 CsrProcess->ProcessHandle = hProcess;
613 CsrProcess->ShutdownLevel = 0x280;
614
615 /* Set the priority to Background */
617
618 /* Insert the Process */
619 CsrInsertProcess(CurrentProcess, CsrProcess);
620
621 /* Release lock and return */
623 return Status;
624}
LONG NTSTATUS
Definition: precomp.h:26
#define HandleToUlong(h)
Definition: basetsd.h:79
#define CsrGetClientThread()
Definition: csrsrv.h:77
@ CsrProcessCreateNewGroup
Definition: csrsrv.h:91
@ CsrProcessIsConsoleApp
Definition: csrsrv.h:94
@ CsrDebugProcessChildren
Definition: csrsrv.h:126
@ CsrDebugOnlyThisProcess
Definition: csrsrv.h:125
#define CsrProcessPriorityFlags
Definition: csrsrv.h:97
#define STATUS_NO_MEMORY
Definition: d3dkmdt.h:51
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
@ ThreadTimes
Definition: compat.h:936
Status
Definition: gdiplustypes.h:25
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
@ ProcessDebugPort
Definition: winternl.h:395
@ ProcessExceptionPort
Definition: winternl.h:864
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
#define ASSERT(a)
Definition: mode.c:44
HANDLE hThread
Definition: wizard.c:28
NTSTATUS NTAPI NtQueryInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, OUT PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:2624
NTSTATUS NTAPI NtSetInformationProcess(IN HANDLE ProcessHandle, IN PROCESSINFOCLASS ProcessInformationClass, IN PVOID ProcessInformation, IN ULONG ProcessInformationLength)
Definition: query.c:1105
#define STATUS_THREAD_IS_TERMINATING
Definition: ntstatus.h:311
HANDLE UniqueProcess
Definition: compat.h:825
ULONG DebugFlags
Definition: csrsrv.h:49
ULONG ProcessGroupId
Definition: csrsrv.h:52
ULONG ProcessGroupSequence
Definition: csrsrv.h:53
PVOID ServerData[ANYSIZE_ARRAY]
Definition: csrsrv.h:60
CLIENT_ID DebugCid
Definition: csrsrv.h:50
ULONG SizeOfProcessData
Definition: csrsrv.h:234
ULONG Flags
Definition: csrsrv.h:72
LARGE_INTEGER CreateTime
Definition: csrsrv.h:65
HANDLE ThreadHandle
Definition: csrsrv.h:71
CLIENT_ID ClientId
Definition: csrsrv.h:68
PCSR_PROCESS Process
Definition: csrsrv.h:69
LARGE_INTEGER CreateTime
Definition: winternl.h:1060
KEXECUTE_OPTIONS Flags
Definition: ketypes.h:2130
HANDLE CsrApiPort
Definition: connect.c:27
NTSTATUS NTAPI CsrInsertThread(IN PCSR_PROCESS Process, IN PCSR_THREAD Thread)
Definition: thredsup.c:297
BOOLEAN NTAPI ProtectHandle(IN HANDLE ObjectHandle)
Definition: thredsup.c:39
VOID NTAPI CsrReferenceNtSession(IN PCSR_NT_SESSION Session)
Definition: session.c:118
VOID NTAPI CsrDeallocateThread(IN PCSR_THREAD CsrThread)
Definition: thredsup.c:345
PCSR_THREAD NTAPI CsrLocateThreadByClientId(OUT PCSR_PROCESS *Process OPTIONAL, IN PCLIENT_ID ClientId)
Definition: thredsup.c:182
PCSR_THREAD NTAPI CsrAllocateThread(IN PCSR_PROCESS CsrProcess)
Definition: thredsup.c:119
#define CsrAcquireProcessLock()
Definition: api.h:12
PCSR_SERVER_DLL CsrLoadedServerDll[CSR_SERVER_DLL_MAX]
Definition: server.c:20
#define CsrReleaseProcessLock()
Definition: api.h:15
PCSR_PROCESS NTAPI CsrAllocateProcess(VOID)
Definition: procsup.c:189
VOID NTAPI CsrInsertProcess(IN PCSR_PROCESS ParentProcess OPTIONAL, IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:366
VOID NTAPI CsrDeallocateProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:297
VOID NTAPI CsrSetBackgroundPriority(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1107
void * PVOID
Definition: typedefs.h:50
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1151

Referenced by CSR_API().

◆ CsrDeallocateProcess()

VOID NTAPI CsrDeallocateProcess ( IN PCSR_PROCESS  CsrProcess)

Definition at line 297 of file procsup.c.

298{
299 /* Free the process object from the heap */
301}
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608

Referenced by CsrCreateProcess(), CsrProcessRefcountZero(), and CsrSbCreateSession().

◆ CsrDebugProcess()

NTSTATUS NTAPI CsrDebugProcess ( IN PCSR_PROCESS  CsrProcess)

Definition at line 643 of file procsup.c.

644{
645 /* CSR does not handle debugging anymore */
646 DPRINT("CSRSRV: %s(0x%p) called\n", __FUNCTION__, CsrProcess);
647 return STATUS_UNSUCCESSFUL;
648}
#define __FUNCTION__
Definition: types.h:116
#define DPRINT
Definition: sndvol32.h:73
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

◆ CsrDebugProcessStop()

NTSTATUS NTAPI CsrDebugProcessStop ( IN PCSR_PROCESS  CsrProcess)

Definition at line 667 of file procsup.c.

668{
669 /* CSR does not handle debugging anymore */
670 DPRINT("CSRSRV: %s(0x%p) called\n", __FUNCTION__, CsrProcess);
671 return STATUS_UNSUCCESSFUL;
672}

◆ CsrDereferenceProcess()

VOID NTAPI CsrDereferenceProcess ( IN PCSR_PROCESS  CsrProcess)

Definition at line 691 of file procsup.c.

692{
694
695 /* Acquire process lock */
697
698 /* Decrease reference count */
699 LockCount = --CsrProcess->ReferenceCount;
700 ASSERT(LockCount >= 0);
701 if (LockCount == 0)
702 {
703 /* Call the generic cleanup code */
705 }
706 else
707 {
708 /* Just release the lock */
710 }
711}
LONG LockCount
Definition: comsup.c:6
long LONG
Definition: pedump.c:60
VOID NTAPI CsrProcessRefcountZero(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:119

Referenced by ConsoleClientShutdown(), CsrThreadRefcountZero(), NonConsoleProcessShutdown(), and UserClientShutdown().

◆ CsrDestroyProcess()

NTSTATUS NTAPI CsrDestroyProcess ( IN PCLIENT_ID  Cid,
IN NTSTATUS  ExitStatus 
)

Definition at line 735 of file procsup.c.

737{
738 PCSR_THREAD CsrThread;
740 CLIENT_ID ClientId = *Cid;
741 PLIST_ENTRY NextEntry;
742
743 /* Acquire lock */
745
746 /* Find the thread */
748
749 /* Make sure we got one back, and that it's not already gone */
750 if (!(CsrThread) || (CsrProcess->Flags & CsrProcessTerminating))
751 {
752 /* Release the lock and return failure */
755 }
756
757 /* Set the terminated flag */
759
760 /* Get the List Pointers */
761 NextEntry = CsrProcess->ThreadList.Flink;
762 while (NextEntry != &CsrProcess->ThreadList)
763 {
764 /* Get the current thread entry */
765 CsrThread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
766
767 /* Move to the next entry */
768 NextEntry = NextEntry->Flink;
769
770 /* Make sure the thread isn't already dead */
771 if (CsrThread->Flags & CsrThreadTerminated)
772 {
773 /* Go the the next thread */
774 continue;
775 }
776
777 /* Set the Terminated flag */
778 CsrThread->Flags |= CsrThreadTerminated;
779
780 /* Acquire the Wait Lock */
782
783 /* Do we have an active wait block? */
784 if (CsrThread->WaitBlock)
785 {
786 /* Notify waiters of termination */
787 CsrNotifyWaitBlock(CsrThread->WaitBlock,
788 NULL,
789 NULL,
790 NULL,
792 TRUE);
793 }
794
795 /* Release the Wait Lock */
797
798 /* Dereference the thread */
800 }
801
802 /* Release the Process Lock and return success */
804 return STATUS_SUCCESS;
805}
@ CsrProcessTerminating
Definition: csrsrv.h:85
@ CsrThreadTerminated
Definition: csrsrv.h:106
#define TRUE
Definition: types.h:120
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _CSR_WAIT_BLOCK * WaitBlock
Definition: csrsrv.h:70
Definition: typedefs.h:120
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
VOID NTAPI CsrLockedDereferenceThread(IN PCSR_THREAD CsrThread)
Definition: thredsup.c:467
#define CsrAcquireWaitLock()
Definition: api.h:21
BOOLEAN NTAPI CsrNotifyWaitBlock(IN PCSR_WAIT_BLOCK WaitBlock, IN PLIST_ENTRY WaitList, IN PVOID WaitArgument1, IN PVOID WaitArgument2, IN ULONG WaitFlags, IN BOOLEAN DereferenceThread)
Definition: wait.c:120
#define CsrReleaseWaitLock()
Definition: api.h:24
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
static int Link(const char **args)
Definition: vfdcmd.c:2414

Referenced by CSR_API(), and CsrApiRequestThread().

◆ CsrGetProcessLuid()

NTSTATUS NTAPI CsrGetProcessLuid ( IN HANDLE hProcess  OPTIONAL,
OUT PLUID  Luid 
)

Definition at line 828 of file procsup.c.

830{
831 HANDLE hToken = NULL;
834 PTOKEN_STATISTICS TokenStats;
835
836 /* Check if we have a handle to a CSR Process */
837 if (!hProcess)
838 {
839 /* We don't, so try opening the Thread's Token */
842 FALSE,
843 &hToken);
844
845 /* Check for success */
846 if (!NT_SUCCESS(Status))
847 {
848 /* If we got some other failure, then return and quit */
849 if (Status != STATUS_NO_TOKEN) return Status;
850
851 /* We don't have a Thread Token, use a Process Token */
853 hToken = NULL;
854 }
855 }
856
857 /* Check if we have a token by now */
858 if (!hToken)
859 {
860 /* No token yet, so open the Process Token */
863 &hToken);
864 if (!NT_SUCCESS(Status))
865 {
866 /* Still no token, return the error */
867 return Status;
868 }
869 }
870
871 /* Now get the size we'll need for the Token Information */
874 NULL,
875 0,
876 &Length);
878 {
879 /* Close the token and fail */
880 NtClose(hToken);
881 return Status;
882 }
883
884 /* Allocate memory for the Token Info */
885 if (!(TokenStats = RtlAllocateHeap(CsrHeap, 0, Length)))
886 {
887 /* Fail and close the token */
888 NtClose(hToken);
889 return STATUS_NO_MEMORY;
890 }
891
892 /* Now query the information */
895 TokenStats,
896 Length,
897 &Length);
898
899 /* Close the handle */
900 NtClose(hToken);
901
902 /* Check for success */
903 if (NT_SUCCESS(Status))
904 {
905 /* Return the LUID */
906 *Luid = TokenStats->AuthenticationId;
907 }
908
909 /* Free the query information */
910 RtlFreeHeap(CsrHeap, 0, TokenStats);
911
912 /* Return the Status */
913 return Status;
914}
#define FALSE
Definition: types.h:117
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSTATUS NTAPI NtOpenProcessToken(IN HANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, OUT PHANDLE TokenHandle)
Definition: security.c:350
NTSTATUS NTAPI NtOpenThreadToken(_In_ HANDLE ThreadHandle, _In_ ACCESS_MASK DesiredAccess, _In_ BOOLEAN OpenAsSelf, _Out_ PHANDLE TokenHandle)
Opens a token that is tied to a thread handle.
Definition: token.c:2474
#define STATUS_NO_TOKEN
Definition: ntstatus.h:360
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
LUID AuthenticationId
Definition: setypes.h:1087
_Must_inspect_result_ __kernel_entry NTSTATUS NTAPI NtQueryInformationToken(_In_ HANDLE TokenHandle, _In_ TOKEN_INFORMATION_CLASS TokenInformationClass, _Out_writes_bytes_to_opt_(TokenInformationLength, *ReturnLength) PVOID TokenInformation, _In_ ULONG TokenInformationLength, _Out_ PULONG ReturnLength)
Queries a specific type of information in regard of an access token based upon the information class....
Definition: tokencls.c:473
#define TOKEN_QUERY
Definition: setypes.h:928
@ TokenStatistics
Definition: setypes.h:975
#define NtCurrentThread()

Referenced by FindProcessForShutdown(), and UserExitReactOS().

◆ CsrImpersonateClient()

BOOLEAN NTAPI CsrImpersonateClient ( IN PCSR_THREAD  CsrThread)

Definition at line 932 of file procsup.c.

933{
935 PCSR_THREAD CurrentThread = CsrGetClientThread();
936
937 /* Use the current thread if none given */
938 if (!CsrThread) CsrThread = CurrentThread;
939
940 /* Still no thread, something is wrong */
941 if (!CsrThread)
942 {
943 /* Failure */
944 return FALSE;
945 }
946
947 /* Make the call */
949 CsrThread->ThreadHandle,
951
952 if (!NT_SUCCESS(Status))
953 {
954 /* Failure */
955#ifdef CSR_DBG
956 DPRINT1("CSRSS: Can't impersonate client thread - Status = %lx\n", Status);
957 // if (Status != STATUS_BAD_IMPERSONATION_LEVEL) DbgBreakPoint();
958#endif
959 return FALSE;
960 }
961
962 /* Increase the impersonation count for the current thread */
963 if (CurrentThread) ++CurrentThread->ImpersonationCount;
964
965 /* Return Success */
966 return TRUE;
967}
#define DPRINT1
Definition: precomp.h:8
NTSTATUS NTAPI NtImpersonateThread(IN HANDLE ThreadHandle, IN HANDLE ThreadToImpersonateHandle, IN PSECURITY_QUALITY_OF_SERVICE SecurityQualityOfService)
Definition: security.c:1036
ULONG ImpersonationCount
Definition: csrsrv.h:74
SECURITY_QUALITY_OF_SERVICE CsrSecurityQos
Definition: procsup.c:23

Referenced by BaseSrvIsVdmAllowed(), CheckForGlobalDriveLetter(), ConSrvInitConsole(), CSR_API(), FindProcessForShutdown(), GuiInit(), GuiLoadFrontEnd(), and UserExitReactOS().

◆ CsrInitializeProcessStructure()

NTSTATUS NTAPI CsrInitializeProcessStructure ( VOID  )

Definition at line 255 of file procsup.c.

256{
258 ULONG i;
259
260 /* Initialize the Lock */
262 if (!NT_SUCCESS(Status)) return Status;
263
264 /* Set up the Root Process */
266 if (!CsrRootProcess) return STATUS_NO_MEMORY;
267
268 /* Set up the minimal information for it */
271 CsrRootProcess->ClientId = NtCurrentTeb()->ClientId;
272
273 /* Initialize the Thread Hash List */
275
276 /* Initialize the Wait Lock */
278}
#define NtCurrentTeb
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
CLIENT_ID ClientId
Definition: csrsrv.h:38
LIST_ENTRY ListLink
Definition: csrsrv.h:39
HANDLE ProcessHandle
Definition: csrsrv.h:46
RTL_CRITICAL_SECTION CsrWaitListsLock
Definition: api.h:10
LIST_ENTRY CsrThreadHashTable[NUMBER_THREAD_HASH_BUCKETS]
Definition: thredsup.c:21
#define NUMBER_THREAD_HASH_BUCKETS
Definition: api.h:44
PCSR_PROCESS CsrRootProcess
Definition: procsup.c:22
RTL_CRITICAL_SECTION CsrProcessLock
Definition: procsup.c:21
PVOID HANDLE
Definition: typedefs.h:73

Referenced by CsrServerInitialization().

◆ CsrInsertProcess()

VOID NTAPI CsrInsertProcess ( IN PCSR_PROCESS ParentProcess  OPTIONAL,
IN PCSR_PROCESS  CsrProcess 
)

Definition at line 366 of file procsup.c.

368{
369 PCSR_SERVER_DLL ServerDll;
370 ULONG i;
372
373 /* Insert it into the Root List */
375
376 /* Notify the Server DLLs */
377 for (i = 0; i < CSR_SERVER_DLL_MAX; i++)
378 {
379 /* Get the current Server DLL */
380 ServerDll = CsrLoadedServerDll[i];
381
382 /* Make sure it's valid and that it has callback */
383 if (ServerDll && ServerDll->NewProcessCallback)
384 {
385 ServerDll->NewProcessCallback(ParentProcess, CsrProcess);
386 }
387 }
388}
#define InsertTailList(ListHead, Entry)
PCSR_NEWPROCESS_CALLBACK NewProcessCallback
Definition: csrsrv.h:239
#define ProcessStructureListLocked()
Definition: api.h:18

Referenced by CsrCreateProcess(), and CsrSbCreateSession().

◆ CsrLockedDereferenceProcess()

VOID NTAPI CsrLockedDereferenceProcess ( PCSR_PROCESS  CsrProcess)

Definition at line 159 of file procsup.c.

160{
162
163 /* Decrease reference count */
164 LockCount = --CsrProcess->ReferenceCount;
165 ASSERT(LockCount >= 0);
166 if (LockCount == 0)
167 {
168 /* Call the generic cleanup code */
169 DPRINT1("Should kill process: %p\n", CsrProcess);
171 /* Acquire the lock again, it was released in CsrProcessRefcountZero */
173 }
174}

Referenced by CsrApiHandleConnectionRequest(), CsrRemoveThread(), CsrShutdownProcesses(), and CsrUnlockProcess().

◆ CsrLockedReferenceProcess()

VOID NTAPI CsrLockedReferenceProcess ( IN PCSR_PROCESS  CsrProcess)

Definition at line 233 of file procsup.c.

234{
235 /* Increment the reference count */
236 ++CsrProcess->ReferenceCount;
237}

Referenced by CsrAllocateProcess(), CsrAllocateThread(), CsrApiHandleConnectionRequest(), CsrLockProcessByClientId(), and CsrShutdownProcesses().

◆ CsrLockProcessByClientId()

NTSTATUS NTAPI CsrLockProcessByClientId ( IN HANDLE  Pid,
OUT PCSR_PROCESS CsrProcess 
)

Definition at line 991 of file procsup.c.

993{
994 PLIST_ENTRY NextEntry;
995 PCSR_PROCESS CurrentProcess = NULL;
997
998 /* Acquire the lock */
1000
1001 /* Assume failure */
1003 *CsrProcess = NULL;
1004
1005 /* Setup the List Pointers */
1006 NextEntry = &CsrRootProcess->ListLink;
1007 do
1008 {
1009 /* Get the Process */
1010 CurrentProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink);
1011
1012 /* Check for PID Match */
1013 if (CurrentProcess->ClientId.UniqueProcess == Pid)
1014 {
1016 break;
1017 }
1018
1019 /* Move to the next entry */
1020 NextEntry = NextEntry->Flink;
1021 } while (NextEntry != &CsrRootProcess->ListLink);
1022
1023 /* Check if we didn't find it in the list */
1024 if (!NT_SUCCESS(Status))
1025 {
1026 /* Nothing found, release the lock */
1028 }
1029 else
1030 {
1031 /* Lock the found process and return it */
1032 CsrLockedReferenceProcess(CurrentProcess);
1033 *CsrProcess = CurrentProcess;
1034 }
1035
1036 /* Return the result */
1037 return Status;
1038}

◆ CsrProcessRefcountZero()

VOID NTAPI CsrProcessRefcountZero ( IN PCSR_PROCESS  CsrProcess)

Definition at line 119 of file procsup.c.

120{
122
123 /* Remove the Process from the list */
125
126 /* Check if there's a session */
127 if (CsrProcess->NtSession)
128 {
129 /* Dereference the Session */
131 }
132
133 /* Close the Client Port if there is one */
134 if (CsrProcess->ClientPort) NtClose(CsrProcess->ClientPort);
135
136 /* Close the process handle */
137 NtClose(CsrProcess->ProcessHandle);
138
139 /* Free the Process Object */
141}
VOID NTAPI CsrDereferenceNtSession(IN PCSR_NT_SESSION Session, IN NTSTATUS ExitStatus)
Definition: session.c:156
VOID NTAPI CsrRemoveProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:320

Referenced by CsrDereferenceProcess(), and CsrLockedDereferenceProcess().

◆ CsrRemoveProcess()

VOID NTAPI CsrRemoveProcess ( IN PCSR_PROCESS  CsrProcess)

Definition at line 320 of file procsup.c.

321{
322 PCSR_SERVER_DLL ServerDll;
323 ULONG i;
325
326 /* Remove us from the Process List */
327 RemoveEntryList(&CsrProcess->ListLink);
328
329 /* Release the lock */
331
332 /* Loop every Server DLL */
333 for (i = 0; i < CSR_SERVER_DLL_MAX; i++)
334 {
335 /* Get the Server DLL */
336 ServerDll = CsrLoadedServerDll[i];
337
338 /* Check if it's valid and if it has a Disconnect Callback */
339 if (ServerDll && ServerDll->DisconnectCallback)
340 {
341 /* Call it */
342 ServerDll->DisconnectCallback(CsrProcess);
343 }
344 }
345}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
PCSR_DISCONNECT_CALLBACK DisconnectCallback
Definition: csrsrv.h:236

Referenced by CsrProcessRefcountZero().

◆ CsrRevertToSelf()

BOOLEAN NTAPI CsrRevertToSelf ( VOID  )

Definition at line 1057 of file procsup.c.

1058{
1060 PCSR_THREAD CurrentThread = CsrGetClientThread();
1061 HANDLE ImpersonationToken = NULL;
1062
1063 /* Check if we have a Current Thread */
1064 if (CurrentThread)
1065 {
1066 /* Make sure impersonation is on */
1067 if (!CurrentThread->ImpersonationCount)
1068 {
1069 DPRINT1("CSRSS: CsrRevertToSelf called while not impersonating\n");
1070 // DbgBreakPoint();
1071 return FALSE;
1072 }
1073 else if ((--CurrentThread->ImpersonationCount) > 0)
1074 {
1075 /* Success; impersonation count decreased but still not zero */
1076 return TRUE;
1077 }
1078 }
1079
1080 /* Impersonation has been totally removed, revert to ourselves */
1083 &ImpersonationToken,
1084 sizeof(ImpersonationToken));
1085
1086 /* Return TRUE or FALSE */
1087 return NT_SUCCESS(Status);
1088}
@ ThreadImpersonationToken
Definition: compat.h:940
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:2018

Referenced by BaseSrvIsVdmAllowed(), CheckForGlobalDriveLetter(), ConSrvInitConsole(), CSR_API(), FindProcessForShutdown(), GuiInit(), GuiLoadFrontEnd(), and UserExitReactOS().

◆ CsrSetBackgroundPriority()

VOID NTAPI CsrSetBackgroundPriority ( IN PCSR_PROCESS  CsrProcess)

Definition at line 1107 of file procsup.c.

1108{
1109 PROCESS_FOREGROUND_BACKGROUND ProcessPriority;
1110
1111 /* Set the Foreground bit off */
1112 ProcessPriority.Foreground = FALSE;
1113
1114 /* Set the new priority */
1115 NtSetInformationProcess(CsrProcess->ProcessHandle,
1117 &ProcessPriority,
1118 sizeof(ProcessPriority));
1119}
@ ProcessForegroundInformation
Definition: winternl.h:881

Referenced by ConSrvSetProcessFocus(), CsrCreateProcess(), and CsrSbCreateSession().

◆ CsrSetForegroundPriority()

VOID NTAPI CsrSetForegroundPriority ( IN PCSR_PROCESS  CsrProcess)

Definition at line 1138 of file procsup.c.

1139{
1140 PROCESS_FOREGROUND_BACKGROUND ProcessPriority;
1141
1142 /* Set the Foreground bit on */
1143 ProcessPriority.Foreground = TRUE;
1144
1145 /* Set the new priority */
1146 NtSetInformationProcess(CsrProcess->ProcessHandle,
1148 &ProcessPriority,
1149 sizeof(ProcessPriority));
1150}

Referenced by ConSrvSetProcessFocus().

◆ CsrSetToNormalPriority()

VOID NTAPI CsrSetToNormalPriority ( VOID  )

Definition at line 52 of file procsup.c.

53{
55
56 /* Set the base priority */
59 &BasePriority,
60 sizeof(BasePriority));
61}
LONG KPRIORITY
Definition: compat.h:803
#define PROCESS_PRIORITY_NORMAL_FOREGROUND
Definition: pstypes.h:120
@ ProcessBasePriority
Definition: winternl.h:861

Referenced by CsrShutdownProcesses().

◆ CsrSetToShutdownPriority()

VOID NTAPI CsrSetToShutdownPriority ( VOID  )

Definition at line 80 of file procsup.c.

81{
83 BOOLEAN Old;
84
85 /* Get the Increase Base Priority privilege */
87 TRUE,
88 FALSE,
89 &Old)))
90 {
91 /* Set the base priority */
94 &BasePriority,
95 sizeof(BasePriority));
96 }
97}
unsigned char BOOLEAN
#define SE_INC_BASE_PRIORITY_PRIVILEGE
Definition: security.c:668
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)

Referenced by CsrShutdownProcesses().

◆ CsrShutdownProcesses()

NTSTATUS NTAPI CsrShutdownProcesses ( IN PLUID  CallerLuid,
IN ULONG  Flags 
)

Definition at line 1277 of file procsup.c.

1279{
1280 PLIST_ENTRY NextEntry;
1284 ULONG i;
1285 PCSR_SERVER_DLL ServerDll;
1286 ULONG Result = 0;
1287
1288 /* Acquire process lock */
1290
1291 /* Add shutdown flag */
1293
1294 /* Get the list pointers */
1295 NextEntry = CsrRootProcess->ListLink.Flink;
1296 while (NextEntry != &CsrRootProcess->ListLink)
1297 {
1298 /* Get the Process */
1299 CsrProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink);
1300
1301 /* Move to the next entry */
1302 NextEntry = NextEntry->Flink;
1303
1304 /* Remove the skip flag, set shutdown flags to 0 */
1305 CsrProcess->Flags &= ~CsrProcessSkipShutdown;
1306 CsrProcess->ShutdownFlags = 0;
1307 }
1308
1309 /* Set shutdown Priority */
1311
1312 /* Start looping */
1313 while (TRUE)
1314 {
1315 /* Find the next process to shutdown */
1316 CsrProcess = FindProcessForShutdown(CallerLuid);
1317 if (!CsrProcess) break;
1318
1319 /* Increase reference to process */
1321
1322 FirstTry = TRUE;
1323 while (TRUE)
1324 {
1325 /* Loop all the servers */
1326 for (i = 0; i < CSR_SERVER_DLL_MAX; i++)
1327 {
1328 /* Get the current server */
1329 ServerDll = CsrLoadedServerDll[i];
1330
1331 /* Check if it's valid and if it has a Shutdown Process Callback */
1332 if (ServerDll && ServerDll->ShutdownProcessCallback)
1333 {
1334 /* Release the lock, make the callback, and acquire it back */
1337 Flags,
1338 FirstTry);
1340
1341 /* Check the result */
1343 {
1344 /* The callback unlocked the process */
1345 break;
1346 }
1347 else if (Result == CsrShutdownCancelled)
1348 {
1349#ifdef CSR_DBG
1350 /* Check if this was a forced shutdown */
1351 if (Flags & EWX_FORCE)
1352 {
1353 DPRINT1("Process %x cancelled forced shutdown (Dll = %d)\n",
1354 CsrProcess->ClientId.UniqueProcess, i);
1355 DbgBreakPoint();
1356 }
1357#endif
1358
1359 /* Shutdown was cancelled, unlock and exit */
1362 goto Quickie;
1363 }
1364 }
1365 }
1366
1367 /* No matches during the first try, so loop again */
1369 {
1370 FirstTry = FALSE;
1371 continue;
1372 }
1373
1374 /* Second try, break out */
1375 break;
1376 }
1377
1378 /* We've reached the final loop here, so dereference */
1379 if (i == CSR_SERVER_DLL_MAX)
1381 }
1382
1383 /* Success path */
1386
1387Quickie:
1388 /* Return to normal priority */
1390
1391 return Status;
1392}
@ CsrShutdownSystem
Definition: csrsrv.h:119
@ CsrShutdownNonCsrProcess
Definition: csrsrv.h:113
@ CsrShutdownCsrProcess
Definition: csrsrv.h:112
@ CsrShutdownCancelled
Definition: csrsrv.h:114
NTSYSAPI void WINAPI DbgBreakPoint(void)
@ FirstTry
Definition: copy.c:25
ULONG ShutdownFlags
Definition: csrsrv.h:59
PCSR_SHUTDOWNPROCESS_CALLBACK ShutdownProcessCallback
Definition: csrsrv.h:240
VOID NTAPI CsrSetToShutdownPriority(VOID)
Definition: procsup.c:80
VOID NTAPI CsrSetToNormalPriority(VOID)
Definition: procsup.c:52
PCSR_PROCESS NTAPI FindProcessForShutdown(IN PLUID CallerLuid)
Definition: procsup.c:1168
VOID NTAPI CsrLockedDereferenceProcess(PCSR_PROCESS CsrProcess)
Definition: procsup.c:159
#define STATUS_CANCELLED
Definition: udferr_usr.h:170
#define EWX_FORCE
Definition: winuser.h:635
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by UserExitReactOS().

◆ CsrUnlockProcess()

NTSTATUS NTAPI CsrUnlockProcess ( IN PCSR_PROCESS  CsrProcess)

Definition at line 1410 of file procsup.c.

1411{
1412 /* Dereference the process */
1414
1415 /* Release the lock and return */
1417 return STATUS_SUCCESS;
1418}

Referenced by CON_API_NOCONSOLE(), CSR_API(), CsrCreateRemoteThread(), CsrCreateThread(), and NotifyUserProcessForShutdown().

◆ FindProcessForShutdown()

PCSR_PROCESS NTAPI FindProcessForShutdown ( IN PLUID  CallerLuid)

Definition at line 1168 of file procsup.c.

1169{
1170 PCSR_PROCESS CsrProcess, ReturnCsrProcess = NULL;
1171 PCSR_THREAD CsrThread;
1173 ULONG Level = 0;
1174 LUID ProcessLuid;
1175 LUID SystemLuid = SYSTEM_LUID;
1176 PLIST_ENTRY NextEntry;
1177
1178 /* Set the List Pointers */
1179 NextEntry = CsrRootProcess->ListLink.Flink;
1180 while (NextEntry != &CsrRootProcess->ListLink)
1181 {
1182 /* Get the process */
1183 CsrProcess = CONTAINING_RECORD(NextEntry, CSR_PROCESS, ListLink);
1184
1185 /* Move to the next entry */
1186 NextEntry = NextEntry->Flink;
1187
1188 /* Skip this process if it's already been processed */
1189 if (CsrProcess->Flags & CsrProcessSkipShutdown) continue;
1190
1191 /* Get the LUID of this process */
1192 Status = CsrGetProcessLuid(CsrProcess->ProcessHandle, &ProcessLuid);
1193
1194 /* Check if we didn't get access to the LUID */
1196 {
1197 /* Check if we have any threads */
1198 if (CsrProcess->ThreadCount)
1199 {
1200 /* Impersonate one of the threads and retry */
1201 CsrThread = CONTAINING_RECORD(CsrProcess->ThreadList.Flink,
1202 CSR_THREAD,
1203 Link);
1204 if (CsrImpersonateClient(CsrThread))
1205 {
1206 Status = CsrGetProcessLuid(NULL, &ProcessLuid);
1208 }
1209 else
1210 {
1212 }
1213 }
1214 }
1215
1216 if (!NT_SUCCESS(Status))
1217 {
1218 /* We didn't have access, so skip it */
1220 continue;
1221 }
1222
1223 /* Check if this is the System LUID */
1224 if (RtlEqualLuid(&ProcessLuid, &SystemLuid))
1225 {
1226 /* Mark this process */
1227 CsrProcess->ShutdownFlags |= CsrShutdownSystem;
1228 }
1229 else if (!RtlEqualLuid(&ProcessLuid, CallerLuid))
1230 {
1231 /* Our LUID doesn't match with the caller's */
1232 CsrProcess->ShutdownFlags |= CsrShutdownOther;
1233 }
1234
1235 /* Check if we're past the previous level */
1236 if ((CsrProcess->ShutdownLevel > Level) || !ReturnCsrProcess)
1237 {
1238 /* Update the level */
1239 Level = CsrProcess->ShutdownLevel;
1240
1241 /* Set the final process */
1242 ReturnCsrProcess = CsrProcess;
1243 }
1244 }
1245
1246 /* Check if we found a process */
1247 if (ReturnCsrProcess)
1248 {
1249 /* Skip this one next time */
1250 ReturnCsrProcess->Flags |= CsrProcessSkipShutdown;
1251 }
1252
1253 return ReturnCsrProcess;
1254}
@ CsrProcessSkipShutdown
Definition: csrsrv.h:86
@ CsrShutdownOther
Definition: csrsrv.h:120
#define STATUS_BAD_IMPERSONATION_LEVEL
Definition: ntstatus.h:401
ULONG Flags
Definition: csrsrv.h:48
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
Definition: procsup.c:932
BOOLEAN NTAPI CsrRevertToSelf(VOID)
Definition: procsup.c:1057
NTSTATUS NTAPI CsrGetProcessLuid(IN HANDLE hProcess OPTIONAL, OUT PLUID Luid)
Definition: procsup.c:828
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145
_IRQL_requires_same_ typedef _In_ ULONG _In_ UCHAR Level
Definition: wmitypes.h:56
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:304
#define SYSTEM_LUID
Definition: setypes.h:700

Referenced by CsrShutdownProcesses().

Variable Documentation

◆ CsrProcessLock

RTL_CRITICAL_SECTION CsrProcessLock

Definition at line 21 of file procsup.c.

Referenced by CsrInitializeProcessStructure().

◆ CsrProcessSequenceCount

ULONG CsrProcessSequenceCount = 5

Definition at line 30 of file procsup.c.

Referenced by CsrAllocateProcess().

◆ CsrRootProcess

◆ CsrSecurityQos

Initial value:
=
{
}
@ SecurityImpersonation
Definition: lsa.idl:57
struct _SECURITY_QUALITY_OF_SERVICE SECURITY_QUALITY_OF_SERVICE
#define SECURITY_STATIC_TRACKING
Definition: setypes.h:104

Definition at line 23 of file procsup.c.

Referenced by CsrImpersonateClient().

◆ CsrTotalPerProcessDataLength

ULONG CsrTotalPerProcessDataLength
extern

Definition at line 39 of file init.c.

Referenced by CsrAllocateProcess(), CsrInitCsrRootProcess(), and CsrParseServerCommandLine().