ReactOS 0.4.15-dev-6657-ged9973f
api.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

 CSR_API (BaseSrvCheckApplicationCompatibility)
 
VOID BaseInitDefineDosDevice (VOID)
 
VOID BaseCleanupDefineDosDevice (VOID)
 
 CSR_API (BaseSrvDefineDosDevice)
 
 CSR_API (BaseSrvGetTempFile)
 
 CSR_API (BaseSrvCreateProcess)
 
 CSR_API (BaseSrvCreateThread)
 
 CSR_API (BaseSrvExitProcess)
 
 CSR_API (BaseSrvGetProcessShutdownParam)
 
 CSR_API (BaseSrvSetProcessShutdownParam)
 
 CSR_API (BaseSrvDebugProcess)
 
 CSR_API (BaseSrvRegisterThread)
 
 CSR_API (BaseSrvSxsCreateActivationContext)
 
 CSR_API (BaseSrvSetTermsrvAppInstallMode)
 
 CSR_API (BaseSrvSetTermsrvClientTimeZone)
 
 CSR_API (BaseSrvSoundSentryNotification)
 
 CSR_API (BaseSrvCheckVDM)
 
 CSR_API (BaseSrvUpdateVDMEntry)
 
 CSR_API (BaseSrvGetNextVDMCommand)
 
 CSR_API (BaseSrvExitVDM)
 
 CSR_API (BaseSrvIsFirstVDM)
 
 CSR_API (BaseSrvGetVDMExitCode)
 
 CSR_API (BaseSrvSetReenterCount)
 
 CSR_API (BaseSrvSetVDMCurDirs)
 
 CSR_API (BaseSrvGetVDMCurDirs)
 
 CSR_API (BaseSrvBatNotification)
 
 CSR_API (BaseSrvRegisterWowExec)
 
 CSR_API (BaseSrvRefreshIniFileMapping)
 
VOID NTAPI BaseSrvNLSInit (IN PBASE_STATIC_SERVER_DATA StaticData)
 
NTSTATUS NTAPI BaseSrvNlsConnect (IN PCSR_PROCESS CsrProcess, IN OUT PVOID ConnectionInfo, IN OUT PULONG ConnectionInfoLength)
 
 CSR_API (BaseSrvNlsSetUserInfo)
 
 CSR_API (BaseSrvNlsSetMultipleUserInfo)
 
 CSR_API (BaseSrvNlsCreateSection)
 
 CSR_API (BaseSrvNlsUpdateCacheCount)
 
 CSR_API (BaseSrvNlsGetUserInfo)
 

Function Documentation

◆ BaseCleanupDefineDosDevice()

VOID BaseCleanupDefineDosDevice ( VOID  )

Definition at line 39 of file dosdev.c.

40{
42}
NTSYSAPI NTSTATUS NTAPI RtlDeleteCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
static RTL_CRITICAL_SECTION BaseDefineDosDeviceCritSec
Definition: dosdev.c:26

Referenced by DllMain().

◆ BaseInitDefineDosDevice()

VOID BaseInitDefineDosDevice ( VOID  )

Definition at line 34 of file dosdev.c.

35{
37}
NTSYSAPI NTSTATUS NTAPI RtlInitializeCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)

Referenced by CSR_SERVER_DLL_INIT().

◆ BaseSrvNlsConnect()

NTSTATUS NTAPI BaseSrvNlsConnect ( IN PCSR_PROCESS  CsrProcess,
IN OUT PVOID  ConnectionInfo,
IN OUT PULONG  ConnectionInfoLength 
)

Definition at line 140 of file nls.c.

143{
144 /* Does nothing */
145 return STATUS_SUCCESS;
146}
#define STATUS_SUCCESS
Definition: shellext.h:65

Referenced by BaseClientConnectRoutine().

◆ BaseSrvNLSInit()

VOID NTAPI BaseSrvNLSInit ( IN PBASE_STATIC_SERVER_DATA  StaticData)

Definition at line 117 of file nls.c.

118{
119 /* Initialize the lock */
121
122 /* Initialize the data with all F's */
123 pNlsRegUserInfo = &StaticData->NlsUserInfo;
124 RtlFillMemory(&StaticData->NlsUserInfo, sizeof(StaticData->NlsUserInfo), 0xFF);
125
126 /* Set empty LCID */
128
129 /* Reset the cache update counter */
133
134 /* Get the LCID */
136}
#define RtlFillMemory(Dest, Length, Fill)
Definition: winternl.h:599
NTSYSAPI NTSTATUS NTAPI RtlEnterCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSYSAPI NTSTATUS NTAPI RtlLeaveCriticalSection(_In_ PRTL_CRITICAL_SECTION CriticalSection)
NTSTATUS NTAPI NtQueryDefaultLocale(IN BOOLEAN UserProfile, OUT PLCID DefaultLocaleId)
Definition: locale.c:162
LCID UserLocaleId
Definition: base.h:75
ULONG ulCacheUpdateCount
Definition: base.h:77
RTL_CRITICAL_SECTION NlsCacheCriticalSection
Definition: nls.c:20
PNLS_USER_INFO pNlsRegUserInfo
Definition: nls.c:21

Referenced by BaseInitializeStaticServerData().

◆ CSR_API() [1/31]

CSR_API ( BaseSrvBatNotification  )

Definition at line 1442 of file vdm.c.

1443{
1444 DPRINT1("%s not yet implemented\n", __FUNCTION__);
1446}
#define DPRINT1
Definition: precomp.h:8
#define __FUNCTION__
Definition: types.h:116
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:239

◆ CSR_API() [2/31]

CSR_API ( BaseSrvCheckApplicationCompatibility  )

Definition at line 56 of file appcompat.c.

57{
58 PBASE_APP_COMPAT_DATA AppCompatData = (PBASE_APP_COMPAT_DATA)&ApiMessage->Data;
59 DPRINT1("BASESRV: BaseSrvCheckApplicationCompatibility(%wZ)\n",
60 AppCompatData->FileName);
61
62 AppCompatData->CheckRunAppResult = FALSE;
63
64 return STATUS_SUCCESS;
65}
struct _BASE_APP_COMPAT_DATA * PBASE_APP_COMPAT_DATA
#define FALSE
Definition: types.h:117
UNICODE_STRING FileName
Definition: appcompat.c:39

◆ CSR_API() [3/31]

CSR_API ( BaseSrvCheckVDM  )

Definition at line 600 of file vdm.c.

601{
603 PBASE_CHECK_VDM CheckVdmRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CheckVDMRequest;
605 PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
606 PVDM_DOS_RECORD DosRecord = NULL;
607 BOOLEAN NewConsoleRecord = FALSE;
608 BOOLEAN NewDosRecord = FALSE;
609
610 /* Don't do anything if the VDM has been disabled in the registry */
612
613 /* Validate the message buffers */
614 if (!CsrValidateMessageBuffer(ApiMessage,
615 (PVOID*)&CheckVdmRequest->CmdLine,
616 CheckVdmRequest->CmdLen,
617 sizeof(*CheckVdmRequest->CmdLine))
618 || !CsrValidateMessageBuffer(ApiMessage,
619 (PVOID*)&CheckVdmRequest->AppName,
620 CheckVdmRequest->AppLen,
621 sizeof(*CheckVdmRequest->AppName))
622 || !CsrValidateMessageBuffer(ApiMessage,
623 (PVOID*)&CheckVdmRequest->PifFile,
624 CheckVdmRequest->PifLen,
625 sizeof(*CheckVdmRequest->PifFile))
626 || !CsrValidateMessageBuffer(ApiMessage,
627 (PVOID*)&CheckVdmRequest->CurDirectory,
628 CheckVdmRequest->CurDirectoryLen,
629 sizeof(*CheckVdmRequest->CurDirectory))
630 || !CsrValidateMessageBuffer(ApiMessage,
631 (PVOID*)&CheckVdmRequest->Desktop,
632 CheckVdmRequest->DesktopLen,
633 sizeof(*CheckVdmRequest->Desktop))
634 || !CsrValidateMessageBuffer(ApiMessage,
635 (PVOID*)&CheckVdmRequest->Title,
636 CheckVdmRequest->TitleLen,
637 sizeof(*CheckVdmRequest->Title))
638 || !CsrValidateMessageBuffer(ApiMessage,
639 (PVOID*)&CheckVdmRequest->Reserved,
640 CheckVdmRequest->ReservedLen,
641 sizeof(*CheckVdmRequest->Reserved)))
642 {
644 }
645
649
650 /* Enter the critical section */
652
653 /* Check if this is a DOS or WOW VDM */
654 if (CheckVdmRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW)
655 {
656 /* Get the console record */
658 &ConsoleRecord);
659 if (!NT_SUCCESS(Status))
660 {
661 /* Allocate a new console record */
662 ConsoleRecord = BaseSrvCreateConsoleRecord();
663 if (ConsoleRecord == NULL)
664 {
666 goto Cleanup;
667 }
668
669 /* Initialize the console record */
670 ConsoleRecord->ConsoleHandle = CheckVdmRequest->ConsoleHandle;
671 if (ConsoleRecord->ConsoleHandle == NULL)
672 {
673 /* The parent doesn't have a console, get a new session ID */
674 ConsoleRecord->SessionId = GetNextDosSesId();
675 }
676 else
677 {
678 /* No session ID is needed */
679 ConsoleRecord->SessionId = 0;
680 }
681
682 /* Remember that the console record was allocated here */
683 NewConsoleRecord = TRUE;
684 }
685
686 if (!NewConsoleRecord)
687 {
688 /* Get the primary DOS record */
689 DosRecord = (PVDM_DOS_RECORD)CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink,
691
692 if (DosRecord->State != VDM_READY) // == VDM_NOT_READY
693 {
694 /* Allocate a new DOS record */
697 sizeof(VDM_DOS_RECORD));
698 if (DosRecord == NULL)
699 {
701 goto Cleanup;
702 }
703
704 /* Remember that the DOS record was allocated here */
705 NewDosRecord = TRUE;
706 }
707 }
708 else
709 {
710 /* Allocate a new DOS record */
713 sizeof(VDM_DOS_RECORD));
714 if (DosRecord == NULL)
715 {
717 goto Cleanup;
718 }
719
720 /* Remember that the DOS record was allocated here */
721 NewDosRecord = TRUE;
722 }
723
724 /* Initialize the DOS record */
725 DosRecord->State = VDM_NOT_READY;
726 DosRecord->ExitCode = 0;
727
728 /* Translate the input structure into a VDM command structure and set it in the DOS record */
729 if (!BaseSrvCopyCommand(CheckVdmRequest, DosRecord))
730 {
731 /* The only possibility is that an allocation failure occurred */
733 goto Cleanup;
734 }
735
736 if (NewDosRecord)
737 {
738 /* Add the DOS record */
739 InsertHeadList(&ConsoleRecord->DosListHead, &DosRecord->Entry);
740 }
741
742 if (!NewConsoleRecord)
743 {
745 if (!NT_SUCCESS(Status)) goto Cleanup;
746
747 /* Return the client event handle */
748 CheckVdmRequest->WaitObjectForParent = DosRecord->ClientEvent;
749 }
750
751 // FIXME: We may notify ONLY if ConsoleRecord->nReEntrancy is > 0
752 // in case NewConsoleRecord == FALSE AND NewDosRecord == TRUE.
753 if (ConsoleRecord->ServerEvent)
754 {
755 /* Signal the session event */
756 NtSetEvent(ConsoleRecord->ServerEvent, NULL);
757 }
758
759 if (NewConsoleRecord)
760 {
761 /* Add the console record */
762 InsertTailList(&VDMConsoleListHead, &ConsoleRecord->Entry);
763 }
764
765 CheckVdmRequest->iTask = ConsoleRecord->SessionId;
766 CheckVdmRequest->VDMState = NewConsoleRecord ? VDM_NOT_LOADED : VDM_READY;
768 }
769 else
770 {
771 // TODO: NOT IMPLEMENTED
774 }
775
776Cleanup:
777 /* Check if it failed */
778 if (!NT_SUCCESS(Status))
779 {
780 /* Free the DOS record if it was allocated here */
781 if (NewDosRecord)
782 {
783 ASSERT(DosRecord != NULL);
784
786 DosRecord->ClientEvent);
787
788 RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
789 DosRecord = NULL;
790 }
791
792 /* Free the console record if it was allocated here */
793 if (NewConsoleRecord)
794 {
795 ASSERT(ConsoleRecord != NULL);
796
797 RtlFreeHeap(BaseSrvHeap, 0, ConsoleRecord);
798 ConsoleRecord = NULL;
799 }
800 }
801
802 /* Leave the critical section */
804
805 return Status;
806}
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
struct _BASE_API_MESSAGE * PBASE_API_MESSAGE
HANDLE BaseSrvHeap
Definition: init.c:29
#define UNIMPLEMENTED
Definition: debug.h:115
PVOID NTAPI RtlAllocateHeap(IN PVOID HeapHandle, IN ULONG Flags, IN SIZE_T Size)
Definition: heap.c:588
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:606
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1430
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
static const WCHAR Cleanup[]
Definition: register.c:80
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
Status
Definition: gdiplustypes.h:25
CRITICAL_SECTION CriticalSection
Definition: iprtprio.c:40
#define ASSERT(a)
Definition: mode.c:44
NTSTATUS NTAPI NtSetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:455
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define STATUS_VDM_DISALLOWED
Definition: ntstatus.h:957
#define VDM_NOT_READY
Definition: vdm.h:47
#define BINARY_TYPE_SEPARATE_WOW
Definition: vdm.h:39
#define VDM_READY
Definition: vdm.h:48
#define VDM_NOT_LOADED
Definition: vdm.h:46
base of all file and directory entries
Definition: entries.h:83
ULONG TitleLen
Definition: basemsg.h:139
PCHAR Desktop
Definition: basemsg.h:136
USHORT CurDirectoryLen
Definition: basemsg.h:145
USHORT VDMState
Definition: basemsg.h:147
HANDLE WaitObjectForParent
Definition: basemsg.h:123
PCHAR PifFile
Definition: basemsg.h:131
ULONG ReservedLen
Definition: basemsg.h:141
HANDLE ConsoleHandle
Definition: basemsg.h:121
PCHAR Reserved
Definition: basemsg.h:140
PCHAR CmdLine
Definition: basemsg.h:129
ULONG DesktopLen
Definition: basemsg.h:137
PCHAR AppName
Definition: basemsg.h:130
USHORT PifLen
Definition: basemsg.h:144
ULONG BinaryType
Definition: basemsg.h:122
PCHAR CurDirectory
Definition: basemsg.h:132
USHORT CmdLen
Definition: basemsg.h:142
USHORT AppLen
Definition: basemsg.h:143
struct _LIST_ENTRY * Flink
Definition: typedefs.h:121
HANDLE ServerEvent
Definition: vdm.h:24
ULONG SessionId
Definition: vdm.h:30
HANDLE ConsoleHandle
Definition: vdm.h:22
LIST_ENTRY Entry
Definition: vdm.h:21
LIST_ENTRY DosListHead
Definition: vdm.h:31
HANDLE ClientEvent
Definition: vdm.h:40
HANDLE ServerEvent
Definition: vdm.h:39
ULONG ExitCode
Definition: vdm.h:38
LIST_ENTRY Entry
Definition: vdm.h:36
USHORT State
Definition: vdm.h:37
LIST_ENTRY VDMConsoleListHead
Definition: vdm.c:21
RTL_CRITICAL_SECTION DosCriticalSection
Definition: vdm.c:22
NTSTATUS BaseSrvGetConsoleRecord(HANDLE ConsoleHandle, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:49
NTSTATUS BaseSrvCreatePairWaitHandles(PHANDLE ServerEvent, PHANDLE ClientEvent)
Definition: vdm.c:240
VOID BaseSrvDestroyPairWaitHandles(HANDLE ServerEvent, HANDLE ClientEvent)
Definition: vdm.c:261
BOOLEAN BaseSrvCopyCommand(PBASE_CHECK_VDM CheckVdmRequest, PVDM_DOS_RECORD DosRecord)
Definition: vdm.c:352
ULONG GetNextDosSesId(VOID)
Definition: vdm.c:114
RTL_CRITICAL_SECTION WowCriticalSection
Definition: vdm.c:23
BOOLEAN BaseSrvIsVdmAllowed(VOID)
Definition: vdm.c:143
PVDM_CONSOLE_RECORD BaseSrvCreateConsoleRecord(VOID)
Definition: vdm.c:27
struct _VDM_DOS_RECORD * PVDM_DOS_RECORD
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135

◆ CSR_API() [4/31]

CSR_API ( BaseSrvCreateProcess  )

Definition at line 67 of file proc.c.

68{
70 PBASE_CREATE_PROCESS CreateProcessRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CreateProcessRequest;
71 HANDLE ProcessHandle, ThreadHandle;
72 PCSR_THREAD CsrThread;
74 ULONG Flags = 0, DebugFlags = 0, VdmPower = 0;
75
76 /* Get the current client thread */
77 CsrThread = CsrGetClientThread();
78 ASSERT(CsrThread != NULL);
79
80 Process = CsrThread->Process;
81
82 /* Extract the flags out of the process handle */
83 Flags = (ULONG_PTR)CreateProcessRequest->ProcessHandle & 3;
84 CreateProcessRequest->ProcessHandle = (HANDLE)((ULONG_PTR)CreateProcessRequest->ProcessHandle & ~3);
85
86 /* Some things should be done if this is a VDM process */
87 if (CreateProcessRequest->VdmBinaryType)
88 {
89 /* We need to set the VDM power later on */
90 VdmPower = 1;
91 }
92
93 /* Duplicate the process handle */
94 Status = NtDuplicateObject(Process->ProcessHandle,
95 CreateProcessRequest->ProcessHandle,
98 0,
99 0,
101 if (!NT_SUCCESS(Status))
102 {
103 DPRINT1("Failed to duplicate process handle: %lx\n", Status);
104 return Status;
105 }
106
107 /* Duplicate the thread handle */
108 Status = NtDuplicateObject(Process->ProcessHandle,
109 CreateProcessRequest->ThreadHandle,
111 &ThreadHandle,
112 0,
113 0,
115 if (!NT_SUCCESS(Status))
116 {
117 DPRINT1("Failed to duplicate thread handle: %lx\n", Status);
119 return Status;
120 }
121
122 /* If this is a VDM process, request VDM power */
123 if (VdmPower)
124 {
127 &VdmPower,
128 sizeof(VdmPower));
129 if (!NT_SUCCESS(Status))
130 {
131 DPRINT1("Failed to get VDM powers\n");
133 NtClose(ThreadHandle);
134 return Status;
135 }
136 }
137
138 /* Flags conversion. FIXME: More need conversion */
139 if (CreateProcessRequest->CreationFlags & CREATE_NEW_PROCESS_GROUP)
140 {
141 DebugFlags |= CsrProcessCreateNewGroup;
142 }
143 if ((Flags & 2) == 0)
144 {
145 /* We are launching a console process */
146 DebugFlags |= CsrProcessIsConsoleApp;
147 }
148
149 /* FIXME: SxS Stuff */
150
151 /* Call CSRSRV to create the CSR_PROCESS structure and the first CSR_THREAD */
153 ThreadHandle,
154 &CreateProcessRequest->ClientId,
155 Process->NtSession,
156 DebugFlags,
157 NULL);
159 {
160 DPRINT1("Thread already dead\n");
161
162 /* Set the special reply value so we don't reply this message back */
163 *ReplyCode = CsrReplyDeadClient;
164
165 return Status;
166 }
167
168 /* Check for other failures */
169 if (!NT_SUCCESS(Status))
170 {
171 DPRINT1("Failed to create process/thread structures: %lx\n", Status);
172 return Status;
173 }
174
175 /* Call the user notification procedure */
177 {
178 UserNotifyProcessCreate(CreateProcessRequest->ClientId.UniqueProcess,
179 Process->ClientId.UniqueThread,
180 0,
181 Flags);
182 }
183
184 /* Check if this is a VDM process */
185 if (CreateProcessRequest->VdmBinaryType)
186 {
187 PVDM_CONSOLE_RECORD ConsoleRecord;
188
189 if (CreateProcessRequest->VdmTask != 0)
190 {
191 /* Get the console record using the task ID */
192 Status = GetConsoleRecordBySessionId(CreateProcessRequest->VdmTask,
193 &ConsoleRecord);
194 }
195 else
196 {
197 /* Get the console record using the console handle */
198 Status = BaseSrvGetConsoleRecord(CreateProcessRequest->hVDM,
199 &ConsoleRecord);
200 }
201
202 /* Check if it failed */
203 if (!NT_SUCCESS(Status)) return Status;
204
205 /* Store the process ID of the VDM in the console record */
206 ConsoleRecord->ProcessId = HandleToUlong(CreateProcessRequest->ClientId.UniqueProcess);
207 }
208
209 /* Return the result of this operation */
210 return Status;
211}
#define HandleToUlong(h)
Definition: basetsd.h:79
#define CsrGetClientThread()
Definition: csrsrv.h:77
@ CsrProcessCreateNewGroup
Definition: csrsrv.h:91
@ CsrProcessIsConsoleApp
Definition: csrsrv.h:94
@ CsrReplyDeadClient
Definition: csrsrv.h:133
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: procsup.c:422
#define ULONG_PTR
Definition: config.h:101
_Must_inspect_result_ _In_ PLARGE_INTEGER _In_ PLARGE_INTEGER _In_ ULONG _In_ PFILE_OBJECT _In_ PVOID Process
Definition: fsrtlfuncs.h:223
@ ProcessWx86Information
Definition: winternl.h:875
_In_ HANDLE ProcessHandle
Definition: mmfuncs.h:403
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
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
NTSTATUS NTAPI NtDuplicateObject(IN HANDLE SourceProcessHandle, IN HANDLE SourceHandle, IN HANDLE TargetProcessHandle OPTIONAL, OUT PHANDLE TargetHandle OPTIONAL, IN ACCESS_MASK DesiredAccess, IN ULONG HandleAttributes, IN ULONG Options)
Definition: obhandle.c:3410
HANDLE ProcessHandle
Definition: basemsg.h:89
CLIENT_ID ClientId
Definition: basemsg.h:91
HANDLE ThreadHandle
Definition: basemsg.h:90
HANDLE UniqueProcess
Definition: compat.h:825
PCSR_PROCESS Process
Definition: csrsrv.h:69
ULONG ProcessId
Definition: vdm.h:26
static BASE_PROCESS_CREATE_NOTIFY_ROUTINE UserNotifyProcessCreate
Definition: proc.c:20
NTSTATUS GetConsoleRecordBySessionId(ULONG TaskId, PVDM_CONSOLE_RECORD *Record)
Definition: vdm.c:95
uint32_t ULONG
Definition: typedefs.h:59
#define CREATE_NEW_PROCESS_GROUP
Definition: winbase.h:185
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define DUPLICATE_SAME_ACCESS

◆ CSR_API() [5/31]

CSR_API ( BaseSrvCreateThread  )

Definition at line 213 of file proc.c.

214{
216 PBASE_CREATE_THREAD CreateThreadRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CreateThreadRequest;
217 PCSR_THREAD CurrentThread;
218 HANDLE ThreadHandle;
220
221 /* Get the current CSR thread */
222 CurrentThread = CsrGetClientThread();
223 if (!CurrentThread)
224 {
225 DPRINT1("Server Thread TID: [%lx.%lx]\n",
226 CreateThreadRequest->ClientId.UniqueProcess,
227 CreateThreadRequest->ClientId.UniqueThread);
228 return STATUS_SUCCESS; // server-to-server
229 }
230
231 /* Get the CSR Process for this request */
232 CsrProcess = CurrentThread->Process;
233 if (CsrProcess->ClientId.UniqueProcess !=
234 CreateThreadRequest->ClientId.UniqueProcess)
235 {
236 /* This is a remote thread request -- is it within the server itself? */
237 if (CreateThreadRequest->ClientId.UniqueProcess == NtCurrentTeb()->ClientId.UniqueProcess)
238 {
239 /* Accept this without any further work */
240 return STATUS_SUCCESS;
241 }
242
243 /* Get the real CSR Process for the remote thread's process */
245 &CsrProcess);
246 if (!NT_SUCCESS(Status)) return Status;
247 }
248
249 /* Duplicate the thread handle so we can own it */
251 CreateThreadRequest->ThreadHandle,
253 &ThreadHandle,
254 0,
255 0,
257 if (NT_SUCCESS(Status))
258 {
259 /* Call CSRSRV to tell it about the new thread */
261 ThreadHandle,
262 &CreateThreadRequest->ClientId,
263 TRUE);
264 }
265
266 /* Unlock the process and return */
267 if (CsrProcess != CurrentThread->Process) CsrUnlockProcess(CsrProcess);
268 return Status;
269}
NTSTATUS NTAPI CsrUnlockProcess(IN PCSR_PROCESS CsrProcess)
Definition: procsup.c:1410
NTSTATUS NTAPI CsrCreateThread(IN PCSR_PROCESS CsrProcess, IN HANDLE hThread, IN PCLIENT_ID ClientId, IN BOOLEAN HaveClient)
Definition: thredsup.c:678
NTSTATUS NTAPI CsrLockProcessByClientId(IN HANDLE Pid, OUT PCSR_PROCESS *CsrProcess OPTIONAL)
#define NtCurrentTeb
HANDLE ThreadHandle
Definition: basemsg.h:104
CLIENT_ID ClientId
Definition: basemsg.h:105
HANDLE UniqueThread
Definition: compat.h:826
HANDLE ProcessHandle
Definition: csrsrv.h:46
PKPROCESS CsrProcess
Definition: videoprt.c:39
_Out_ PCLIENT_ID ClientId
Definition: kefuncs.h:1165

◆ CSR_API() [6/31]

CSR_API ( BaseSrvDebugProcess  )

Definition at line 24 of file proc.c.

25{
26 /* Deprecated */
28}
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132

◆ CSR_API() [7/31]

CSR_API ( BaseSrvDefineDosDevice  )

Definition at line 474 of file dosdev.c.

475{
477 PBASE_DEFINE_DOS_DEVICE DefineDosDeviceRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.DefineDosDeviceRequest;
479 HANDLE LinkHandle;
485 PSID SystemSid;
489 SHORT AbsLetter;
490 BOOLEAN DriveLetter = FALSE;
491 BOOLEAN RemoveDefinition;
492 BOOLEAN HandleTarget;
493 BOOLEAN Broadcast = FALSE;
494 BOOLEAN IsGlobal = FALSE;
495 ULONG CchLengthLeft;
496 ULONG CchLength;
497 ULONG TargetLength;
498 PWSTR TargetBuffer;
500 /* We store them on the stack, they are known in advance */
501 union {
503 UCHAR Buffer[20];
505 union {
506 ACL Dacl;
507 UCHAR Buffer[256];
508 } Dacl;
510 LUID CallerLuid;
511 WCHAR * CurrentPtr;
512 WCHAR CurrentChar;
513 PWSTR OrigPtr;
514 PWSTR InterPtr;
515 BOOLEAN RemoveFound;
516
517 if (!CsrValidateMessageBuffer(ApiMessage,
518 (PVOID*)&DefineDosDeviceRequest->DeviceName.Buffer,
519 DefineDosDeviceRequest->DeviceName.Length,
520 sizeof(BYTE)) ||
521 (DefineDosDeviceRequest->DeviceName.Length & 1) != 0 ||
522 !CsrValidateMessageBuffer(ApiMessage,
523 (PVOID*)&DefineDosDeviceRequest->TargetPath.Buffer,
524 DefineDosDeviceRequest->TargetPath.Length +
525 (DefineDosDeviceRequest->TargetPath.Length != 0
526 ? sizeof(UNICODE_NULL) : 0),
527 sizeof(BYTE)) ||
528 (DefineDosDeviceRequest->TargetPath.Length & 1) != 0)
529 {
531 }
532
533 DPRINT("BaseSrvDefineDosDevice entered, Flags:%d, DeviceName:%wZ (%d), TargetPath:%wZ (%d)\n",
534 DefineDosDeviceRequest->Flags,
535 &DefineDosDeviceRequest->DeviceName,
536 DefineDosDeviceRequest->DeviceName.Length,
537 &DefineDosDeviceRequest->TargetPath,
538 DefineDosDeviceRequest->TargetPath.Length);
539
540 /*
541 * Allocate a buffer big enough to contain:
542 * - device name
543 * - targets
544 */
546 if (lpBuffer == NULL)
547 {
548 return STATUS_NO_MEMORY;
549 }
550
551 /* Enter our critical section */
553 if (!NT_SUCCESS(Status))
554 {
555 DPRINT1("RtlEnterCriticalSection() failed (Status %lx)\n",
556 Status);
558 return Status;
559 }
560
561 LinkHandle = 0;
562 /* Does the caller wants to remove definition? */
563 RemoveDefinition = !!(DefineDosDeviceRequest->Flags & DDD_REMOVE_DEFINITION);
565 {
566 /* First of all, check if that's a drive letter device amongst LUID mappings */
567 if (BaseStaticServerData->LUIDDeviceMapsEnabled && !(DefineDosDeviceRequest->Flags & DDD_NO_BROADCAST_SYSTEM))
568 {
569 if (DefineDosDeviceRequest->DeviceName.Buffer != NULL &&
570 DefineDosDeviceRequest->DeviceName.Length == 2 * sizeof(WCHAR) &&
571 DefineDosDeviceRequest->DeviceName.Buffer[1] == L':')
572 {
573 Letter = DefineDosDeviceRequest->DeviceName.Buffer[0];
574
575 /* Handle both lower cases and upper cases */
576 AbsLetter = Letter - L'a';
577 if (AbsLetter < 26 && AbsLetter >= 0)
578 {
580 }
581
582 AbsLetter = Letter - L'A';
583 if (AbsLetter < 26)
584 {
585 /* That's a letter! */
586 DriveLetter = TRUE;
587 }
588 }
589 }
590
591 /* We can only broadcast drive letters in case of LUID mappings */
592 if (DefineDosDeviceRequest->Flags & DDD_LUID_BROADCAST_DRIVE &&
593 !DriveLetter)
594 {
597 }
598
599 /* First usage of our buffer: create device name */
600 CchLength = _snwprintf(lpBuffer, 0x1000, L"\\??\\%wZ", &DefineDosDeviceRequest->DeviceName);
601 CchLengthLeft = 0x1000 - 1 - CchLength; /* UNICODE_NULL */
602 CurrentBuffer = lpBuffer + CchLength + 1; /* UNICODE_NULL */
604
605 /* And prepare to open it */
607 &DeviceName,
609 NULL,
610 NULL);
611
612 /* Assume it's OK and has a target to deal with */
613 HandleTarget = TRUE;
614
615 /* Move to the client context if the mapping was local */
617 {
620 }
621
622 /*
623 * While impersonating the caller, also get its LUID.
624 * This is mandatory in case we have a driver letter,
625 * Because we're in the case we've got LUID mapping
626 * enabled and broadcasting enabled. LUID will be required
627 * for the latter
628 */
629 if (DriveLetter)
630 {
631 Status = GetCallerLuid(&CallerLuid);
632 if (NT_SUCCESS(Status))
633 {
634 Broadcast = TRUE;
635 }
636 }
637
638 /* Now, open the device */
639 Status = NtOpenSymbolicLinkObject(&LinkHandle,
642
643 /* And get back to our context */
645
646 /* In case of LUID broadcast, do nothing but return to trigger broadcast */
647 if (DefineDosDeviceRequest->Flags & DDD_LUID_BROADCAST_DRIVE)
648 {
649 /* Zero handle in case of a failure */
650 if (!NT_SUCCESS(Status))
651 {
652 LinkHandle = 0;
653 }
654
655 /* If removal was asked, and no object found: the remval was successful */
656 if (RemoveDefinition && Status == STATUS_OBJECT_NAME_NOT_FOUND)
657 {
659 }
660
661 /* We're done here, nothing more to do */
663 }
664
665 /* If device was not found */
667 {
668 /* No handle */
669 LinkHandle = 0;
670
671 /* If we were asked to remove... */
672 if (RemoveDefinition)
673 {
674 /*
675 * If caller asked to pop first entry, nothing specific,
676 * then, we can consider this as a success
677 */
678 if (DefineDosDeviceRequest->TargetPath.Length == 0)
679 {
681 }
682
683 /* We're done, nothing to change */
685 }
686
687 /* There's no target to handle */
688 HandleTarget = FALSE;
689
690 /*
691 * We'll consider, that's a success
692 * Failing to open the device doesn't prevent
693 * from creating it later on to create
694 * the linking.
695 */
697 }
698 else
699 {
700 /* Unexpected failure, forward to caller */
701 if (!NT_SUCCESS(Status))
702 {
704 }
705
706 /* If LUID mapping enabled */
708 {
709 /* Check if that's global link */
710 Status = IsGlobalSymbolicLink(LinkHandle, &IsGlobal);
711 if (!NT_SUCCESS(Status))
712 {
714 }
715
716 /* If so, change our device name namespace to GLOBAL?? for link creation */
717 if (IsGlobal)
718 {
719 CchLength = _snwprintf(lpBuffer, 0x1000, L"\\GLOBAL??\\%wZ", &DefineDosDeviceRequest->DeviceName);
720 CchLengthLeft = 0x1000 - 1 - CchLength; /* UNICODE_NULL */
721 CurrentBuffer = lpBuffer + CchLength + 1; /* UNICODE_NULL */
722
723 DeviceName.Length = CchLength * sizeof(WCHAR);
724 DeviceName.MaximumLength = CchLength * sizeof(WCHAR) + sizeof(UNICODE_NULL);
725 }
726 }
727 }
728
729 /* If caller provided a target */
730 if (DefineDosDeviceRequest->TargetPath.Length != 0)
731 {
732 /* Make sure it's null terminated */
733 DefineDosDeviceRequest->TargetPath.Buffer[DefineDosDeviceRequest->TargetPath.Length / sizeof(WCHAR)] = UNICODE_NULL;
734
735 /* Compute its size */
736 TargetLength = wcslen(DefineDosDeviceRequest->TargetPath.Buffer);
737
738 /* And make sure it fits our buffer */
739 if (TargetLength + 1 >= CchLengthLeft)
740 {
743 }
744
745 /* Copy it to our internal buffer */
746 RtlMoveMemory(CurrentBuffer, DefineDosDeviceRequest->TargetPath.Buffer, TargetLength * sizeof(WCHAR) + sizeof(UNICODE_NULL));
747 TargetBuffer = CurrentBuffer;
748
749 /* Update our buffer status */
750 CchLengthLeft -= (TargetLength + 1);
751 CurrentBuffer += (TargetLength + 1);
752 }
753 /* Otherwise, zero everything */
754 else
755 {
756 TargetBuffer = NULL;
757 TargetLength = 0;
758 }
759
760 /* If we opened the device, then, handle its current target */
761 if (HandleTarget)
762 {
763 /* Query it with our internal buffer */
764 LinkTarget.Length = 0;
765 LinkTarget.MaximumLength = CchLengthLeft * sizeof(WCHAR);
767
769 &LinkTarget,
770 &Length);
771 /* If we overflow, give up */
773 {
775 }
776 /* In case of a failure, bye bye */
777 if (!NT_SUCCESS(Status))
778 {
780 }
781
782 /*
783 * Properly null it for MULTI_SZ if needed
784 * Always update max length with
785 * the need size
786 * This is needed to hand relatively "small"
787 * strings to Ob and avoid killing ourselves
788 * on the next query
789 */
790 CchLength = Length / sizeof(WCHAR);
791 if (CchLength < 2 ||
792 CurrentBuffer[CchLength - 2] != UNICODE_NULL ||
793 CurrentBuffer[CchLength - 1] != UNICODE_NULL)
794 {
795 CurrentBuffer[CchLength] = UNICODE_NULL;
797 }
798 else
799 {
801 }
802 }
803 /* There's no target, and we're asked to remove, so null target */
804 else if (RemoveDefinition)
805 {
807 }
808 /* There's a target provided - new device, update buffer */
809 else
810 {
811 RtlInitUnicodeString(&LinkTarget, CurrentBuffer - TargetLength - 1);
812 }
813
814 /*
815 * We no longer need old symlink, just drop it, we'll recreate it now
816 * with updated target.
817 * The benefit of it is that if caller asked us to drop last target, then
818 * the device is removed and not dangling
819 */
820 if (LinkHandle != 0)
821 {
822 Status = NtMakeTemporaryObject(LinkHandle);
823 NtClose(LinkHandle);
824 LinkHandle = 0;
825 }
826
827 /* At this point, we must have no failure */
828 if (!NT_SUCCESS(Status))
829 {
831 }
832
833 /*
834 * If we have to remove definition, let's start to browse our
835 * target to actually drop it.
836 */
837 if (RemoveDefinition)
838 {
839 /* We'll browse our multi sz string */
840 RemoveFound = FALSE;
841 CurrentPtr = LinkTarget.Buffer;
842 InterPtr = LinkTarget.Buffer;
843 while (*CurrentPtr != UNICODE_NULL)
844 {
845 CchLength = 0;
846 OrigPtr = CurrentPtr;
847 /* First, find next string */
848 while (TRUE)
849 {
850 CurrentChar = *CurrentPtr;
851 ++CurrentPtr;
852
853 if (CurrentChar == UNICODE_NULL)
854 {
855 break;
856 }
857
858 ++CchLength;
859 }
860
861 /* This check is a bit tricky, but dead useful:
862 * If on the previous loop, we found the caller provided target
863 * in our list, then, we'll move current entry over the found one
864 * So that, it gets deleted.
865 * Also, if we don't find caller entry in our entries, then move
866 * current entry in the string if a previous one got deleted
867 */
868 if (RemoveFound ||
869 ((!(DefineDosDeviceRequest->Flags & DDD_EXACT_MATCH_ON_REMOVE) ||
870 TargetLength != CchLength || _wcsicmp(OrigPtr, TargetBuffer) != 0) &&
871 ((DefineDosDeviceRequest->Flags & DDD_EXACT_MATCH_ON_REMOVE) ||
872 (TargetLength != 0 && _wcsnicmp(OrigPtr, TargetBuffer, TargetLength) != 0))))
873 {
874 if (InterPtr != OrigPtr)
875 {
876 RtlMoveMemory(InterPtr, OrigPtr, sizeof(WCHAR) * CchLength + sizeof(UNICODE_NULL));
877 }
878
879 InterPtr += (CchLength + 1);
880 }
881 else
882 {
883 /* Match case! Remember for next loop turn and to delete it */
884 RemoveFound = TRUE;
885 }
886 }
887
888 /*
889 * Drop last entry, as required (pop)
890 * If there was a match previously, everything
891 * is already moved, so we're just nulling
892 * the end of the string
893 * If there was no match, this is the pop
894 */
895 *InterPtr = UNICODE_NULL;
896 ++InterPtr;
897
898 /* Compute new target length */
899 TargetLength = wcslen(LinkTarget.Buffer) * sizeof(WCHAR);
900 /*
901 * If it's empty, quit
902 * Beware, here, we quit with STATUS_SUCCESS, and that's expected!
903 * In case we dropped last target entry, then, it's empty
904 * and there's no need to recreate the device we deleted previously
905 */
906 if (TargetLength == 0)
907 {
909 }
910
911 /* Update our target string */
912 LinkTarget.Length = TargetLength;
914 }
915 /* If that's not a removal, just update the target to include new target */
916 else if (HandleTarget)
917 {
918 LinkTarget.Buffer = LinkTarget.Buffer - TargetLength - 1;
919 LinkTarget.Length = TargetLength * sizeof(WCHAR);
920 LinkTarget.MaximumLength += (TargetLength * sizeof(WCHAR) + sizeof(UNICODE_NULL));
921 TargetLength *= sizeof(WCHAR);
922 }
923 /* No changes */
924 else
925 {
926 TargetLength = LinkTarget.Length;
927 }
928
929 /* Make sure we don't create empty symlink */
930 if (TargetLength == 0)
931 {
933 }
934
935 /* Initialize our SIDs for symlink ACLs */
937 1,
946 &WorldSid);
947 if (!NT_SUCCESS(Status))
948 {
950 }
951
953 1,
962 &SystemSid);
963 if (!NT_SUCCESS(Status))
964 {
967 }
968
969 /* Initialize our SD (on stack) */
972
973 /* And our ACL (still on stack) */
975
976 /*
977 * For access mask, if we have no session ID, or if
978 * protection mode is disabled, make them wide open
979 */
980 if (SessionId == 0 ||
981 (ProtectionMode & 3) == 0)
982 {
984 }
985 else
986 {
988 }
989
990 /* Setup the ACL */
993
994 /* Drop SIDs */
996 RtlFreeSid(SystemSid);
997
998 /* Link DACL to the SD */
1000
1001 /* And set it in the OA used for creation */
1002 ObjectAttributes.SecurityDescriptor = &SecurityDescriptor;
1003
1004 /*
1005 * If LUID and not global, we need to impersonate the caller
1006 * to make it local.
1007 */
1009 {
1010 if (!IsGlobal)
1011 {
1013 {
1016 }
1017 }
1018 }
1019 /* The object will be permanent */
1020 else
1021 {
1022 ObjectAttributes.Attributes |= OBJ_PERMANENT;
1023 }
1024
1025 /* (Re)Create the symbolic link/device */
1026 Status = NtCreateSymbolicLinkObject(&LinkHandle,
1029 &LinkTarget);
1030
1031 /* Revert to self if required */
1033 {
1035 }
1036
1037 /* In case of a success, make object permanent for LUID links */
1038 if (NT_SUCCESS(Status))
1039 {
1041 {
1042 Status = NtMakePermanentObject(LinkHandle);
1043 }
1044
1045 /* Close the link */
1046 NtClose(LinkHandle);
1047
1048 /*
1049 * Specific failure case here:
1050 * We were asked to remove something
1051 * but we didn't find the something
1052 * (we recreated the symlink hence the fail here!)
1053 * so fail with appropriate status
1054 */
1055 if (RemoveDefinition && !RemoveFound)
1056 {
1058 }
1059 }
1060
1061 /* We closed link, don't double close */
1062 LinkHandle = 0;
1063 }
1065 {
1066 /* If we need to close the link, do it now */
1067 if (LinkHandle != 0)
1068 {
1069 NtClose(LinkHandle);
1070 }
1071
1072 /* Free our internal buffer */
1074
1075 /* Broadcast drive letter creation */
1076 if (DriveLetter && Status == STATUS_SUCCESS && Broadcast)
1077 {
1078 LUID SystemLuid = SYSTEM_LUID;
1079
1080 /* If that's a global drive, broadcast as system */
1081 if (IsGlobal)
1082 {
1083 RtlCopyLuid(&CallerLuid, &SystemLuid);
1084 }
1085
1086 /* Broadcast the event */
1087 AddBSMRequest(AbsLetter, RemoveDefinition, &CallerLuid);
1088
1089 /*
1090 * If we removed drive, and the drive was shadowing a global one
1091 * broadcast the arrival of the global drive (as system - global)
1092 */
1093 if (RemoveDefinition && !RtlEqualLuid(&CallerLuid, &SystemLuid))
1094 {
1095 if (CheckForGlobalDriveLetter(AbsLetter))
1096 {
1097 AddBSMRequest(AbsLetter, FALSE, &CallerLuid);
1098 }
1099 }
1100 }
1101
1102 /* Done! */
1104 }
1105 _SEH2_END;
1106
1107 return Status;
1108}
static ACPI_BUFFER CurrentBuffer
WCHAR Letter
PSID WorldSid
Definition: globals.c:15
ULONG ProtectionMode
Definition: init.c:34
Definition: bufpool.h:45
IN PUNICODE_STRING IN POBJECT_ATTRIBUTES ObjectAttributes
Definition: conport.c:36
BOOLEAN NTAPI CsrImpersonateClient(IN PCSR_THREAD CsrThread)
Definition: procsup.c:932
BOOLEAN NTAPI CsrRevertToSelf(VOID)
Definition: procsup.c:1057
static TAGREF LPCWSTR LPDWORD LPVOID lpBuffer
Definition: db.cpp:175
ULONG SessionId
Definition: dllmain.c:28
PBASE_STATIC_SERVER_DATA BaseStaticServerData
Definition: dllmain.c:19
static SID_IDENTIFIER_AUTHORITY WorldAuthority
Definition: security.c:14
#define _SEH2_FINALLY
Definition: filesup.c:21
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
#define _SEH2_LEAVE
Definition: filesup.c:20
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define OBJ_PERMANENT
Definition: winternl.h:226
NTSYSAPI NTSTATUS WINAPI RtlAddAccessAllowedAce(PACL, DWORD, DWORD, PSID)
NTSYSAPI NTSTATUS WINAPI RtlSetDaclSecurityDescriptor(PSECURITY_DESCRIPTOR, BOOLEAN, PACL, BOOLEAN)
NTSYSAPI void WINAPI RtlCopyLuid(PLUID, const LUID *)
int _snwprintf(wchar_t *buffer, size_t count, const wchar_t *format,...)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
static SID_IDENTIFIER_AUTHORITY SystemAuthority
Definition: msgina.c:38
_In_ ACCESS_MASK AccessMask
Definition: exfuncs.h:186
_Out_writes_bytes_to_opt_ AbsoluteSecurityDescriptorSize PSECURITY_DESCRIPTOR _Inout_ PULONG _Out_writes_bytes_to_opt_ DaclSize PACL Dacl
Definition: rtlfuncs.h:1593
NTSYSAPI NTSTATUS NTAPI RtlCreateAcl(PACL Acl, ULONG AclSize, ULONG AclRevision)
NTSYSAPI NTSTATUS NTAPI RtlCreateSecurityDescriptor(_Out_ PSECURITY_DESCRIPTOR SecurityDescriptor, _In_ ULONG Revision)
NTSYSAPI PVOID NTAPI RtlFreeSid(_In_ _Post_invalid_ PSID Sid)
WCHAR NTAPI RtlUpcaseUnicodeChar(_In_ WCHAR Source)
Definition: nlsboot.c:176
#define SYMBOLIC_LINK_ALL_ACCESS
Definition: nt_native.h:1267
#define SYMBOLIC_LINK_QUERY
Definition: nt_native.h:1265
ULONG ACCESS_MASK
Definition: nt_native.h:40
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define DELETE
Definition: nt_native.h:57
#define UNICODE_NULL
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
NTSYSAPI NTSTATUS NTAPI RtlAllocateAndInitializeSid(IN PSID_IDENTIFIER_AUTHORITY IdentifierAuthority, IN UCHAR SubAuthorityCount, IN ULONG SubAuthority0, IN ULONG SubAuthority1, IN ULONG SubAuthority2, IN ULONG SubAuthority3, IN ULONG SubAuthority4, IN ULONG SubAuthority5, IN ULONG SubAuthority6, IN ULONG SubAuthority7, OUT PSID *Sid)
Definition: sid.c:290
#define STATUS_BAD_IMPERSONATION_LEVEL
Definition: ntstatus.h:401
#define L(x)
Definition: ntvdm.h:50
NTSTATUS NTAPI NtMakePermanentObject(IN HANDLE ObjectHandle)
Definition: oblife.c:1510
NTSTATUS NTAPI NtMakeTemporaryObject(IN HANDLE ObjectHandle)
Definition: oblife.c:1473
short SHORT
Definition: pedump.c:59
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define STATUS_BUFFER_OVERFLOW
Definition: shellext.h:66
#define DPRINT
Definition: sndvol32.h:71
UNICODE_STRING TargetPath
Definition: basemsg.h:257
UNICODE_STRING DeviceName
Definition: basemsg.h:256
BOOLEAN LUIDDeviceMapsEnabled
Definition: base.h:141
USHORT MaximumLength
Definition: env_spec_w32.h:370
NTSTATUS GetCallerLuid(PLUID CallerLuid)
Definition: dosdev.c:45
NTSTATUS AddBSMRequest(LONG DriveLetter, BOOLEAN RemoveDefinition, PLUID BroadcastLuid)
Definition: dosdev.c:391
NTSTATUS IsGlobalSymbolicLink(HANDLE LinkHandle, PBOOLEAN IsGlobal)
Definition: dosdev.c:96
BOOLEAN CheckForGlobalDriveLetter(SHORT DriveLetter)
Definition: dosdev.c:162
uint16_t * PWSTR
Definition: typedefs.h:56
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_OBJECT_NAME_NOT_FOUND
Definition: udferr_usr.h:149
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_opt_ PCUNICODE_STRING DeviceName
Definition: wdfdevice.h:3275
#define DDD_NO_BROADCAST_SYSTEM
Definition: winbase.h:526
#define DDD_EXACT_MATCH_ON_REMOVE
Definition: winbase.h:525
#define DDD_LUID_BROADCAST_DRIVE
Definition: winbase.h:527
#define DDD_REMOVE_DEFINITION
Definition: winbase.h:524
_In_ USHORT _In_ ULONG _In_ PSOCKADDR _In_ PSOCKADDR _Reserved_ ULONG _In_opt_ PVOID _In_opt_ const WSK_CLIENT_CONNECTION_DISPATCH _In_opt_ PEPROCESS _In_opt_ PETHREAD _In_opt_ PSECURITY_DESCRIPTOR SecurityDescriptor
Definition: wsk.h:191
#define RtlEqualLuid(Luid1, Luid2)
Definition: rtlfuncs.h:301
#define SECURITY_WORLD_SID_AUTHORITY
Definition: setypes.h:527
#define ACL_REVISION2
Definition: setypes.h:43
#define SECURITY_NULL_RID
Definition: setypes.h:540
#define SECURITY_RESTRICTED_CODE_RID
Definition: setypes.h:569
#define SECURITY_NT_AUTHORITY
Definition: setypes.h:554
#define SYSTEM_LUID
Definition: setypes.h:700
#define SECURITY_DESCRIPTOR_REVISION
Definition: setypes.h:58
#define ACL_REVISION
Definition: setypes.h:39
unsigned char UCHAR
Definition: xmlstorage.h:181
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193
_Inout_ PUNICODE_STRING LinkTarget
Definition: zwfuncs.h:292

◆ CSR_API() [8/31]

CSR_API ( BaseSrvExitProcess  )

Definition at line 271 of file proc.c.

272{
273 PCSR_THREAD CsrThread = CsrGetClientThread();
274 ASSERT(CsrThread != NULL);
275
276 /* Set the special reply value so we don't reply this message back */
277 *ReplyCode = CsrReplyDeadClient;
278
279 /* Remove the CSR_THREADs and CSR_PROCESS */
280 return CsrDestroyProcess(&CsrThread->ClientId,
281 (NTSTATUS)((PBASE_API_MESSAGE)ApiMessage)->Data.ExitProcessRequest.uExitCode);
282}
NTSTATUS NTAPI CsrDestroyProcess(IN PCLIENT_ID Cid, IN NTSTATUS ExitStatus)
Definition: procsup.c:735
CLIENT_ID ClientId
Definition: csrsrv.h:68

◆ CSR_API() [9/31]

CSR_API ( BaseSrvExitVDM  )

Definition at line 1165 of file vdm.c.

1166{
1168 PBASE_EXIT_VDM ExitVdmRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.ExitVDMRequest;
1170 PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
1171 PVDM_DOS_RECORD DosRecord;
1172
1173 CriticalSection = (ExitVdmRequest->iWowTask == 0)
1176
1177 /* Enter the critical section */
1179
1180 if (ExitVdmRequest->iWowTask == 0)
1181 {
1182 /* Get the console record */
1183 Status = BaseSrvGetConsoleRecord(ExitVdmRequest->ConsoleHandle, &ConsoleRecord);
1184 if (!NT_SUCCESS(Status)) goto Cleanup;
1185
1186 if (ConsoleRecord->ServerEvent)
1187 ExitVdmRequest->WaitObjectForVDM = ConsoleRecord->ClientEvent;
1188
1189 // NOTE: The following is the same as in BaseSrvCleanupVDMResources.
1190
1191 if (ConsoleRecord->ServerEvent)
1192 {
1193 NtClose(ConsoleRecord->ServerEvent);
1194 ConsoleRecord->ServerEvent = NULL;
1195 }
1196
1197 /* Cleanup the DOS records */
1198 while (!IsListEmpty(&ConsoleRecord->DosListHead))
1199 {
1200 DosRecord = CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink,
1202
1203 /* Set the event and close it */
1204 if (DosRecord->ServerEvent)
1205 {
1206 NtSetEvent(DosRecord->ServerEvent, NULL);
1207 NtClose(DosRecord->ServerEvent);
1208 DosRecord->ServerEvent = NULL;
1209 }
1210
1211 /* Remove the DOS entry */
1212 if (DosRecord->CommandInfo) BaseSrvFreeVDMInfo(DosRecord->CommandInfo);
1213 RemoveEntryList(&DosRecord->Entry);
1214 RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
1215 }
1216
1217 /* Remove the console record */
1218 RemoveEntryList(&ConsoleRecord->Entry);
1219 BaseSrvDestroyConsoleRecord(ConsoleRecord);
1220 }
1221 else
1222 {
1223 // TODO: NOT IMPLEMENTED
1226 }
1227
1228Cleanup:
1229 /* Leave the critical section */
1231
1232 return Status;
1233}
#define RemoveEntryList(Entry)
Definition: env_spec_w32.h:986
#define IsListEmpty(ListHead)
Definition: env_spec_w32.h:954
HANDLE WaitObjectForVDM
Definition: basemsg.h:198
ULONG iWowTask
Definition: basemsg.h:197
HANDLE ConsoleHandle
Definition: basemsg.h:196
HANDLE ClientEvent
Definition: vdm.h:25
PVDM_COMMAND_INFO CommandInfo
Definition: vdm.h:41
VOID BaseSrvDestroyConsoleRecord(PVDM_CONSOLE_RECORD ConsoleRecord)
Definition: vdm.c:71
VOID BaseSrvFreeVDMInfo(PVDM_COMMAND_INFO CommandInfo)
Definition: vdm.c:281

◆ CSR_API() [10/31]

CSR_API ( BaseSrvGetNextVDMCommand  )

Definition at line 934 of file vdm.c.

935{
937 PBASE_GET_NEXT_VDM_COMMAND GetNextVdmCommandRequest =
938 &((PBASE_API_MESSAGE)ApiMessage)->Data.GetNextVDMCommandRequest;
941 PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
942 PVDM_DOS_RECORD DosRecord = NULL;
943
944 /* Validate the message buffers */
945 if (!CsrValidateMessageBuffer(ApiMessage,
946 (PVOID*)&GetNextVdmCommandRequest->CmdLine,
947 GetNextVdmCommandRequest->CmdLen,
948 sizeof(*GetNextVdmCommandRequest->CmdLine))
949 || !CsrValidateMessageBuffer(ApiMessage,
950 (PVOID*)&GetNextVdmCommandRequest->AppName,
951 GetNextVdmCommandRequest->AppLen,
952 sizeof(*GetNextVdmCommandRequest->AppName))
953 || !CsrValidateMessageBuffer(ApiMessage,
954 (PVOID*)&GetNextVdmCommandRequest->PifFile,
955 GetNextVdmCommandRequest->PifLen,
956 sizeof(*GetNextVdmCommandRequest->PifFile))
957 || !CsrValidateMessageBuffer(ApiMessage,
958 (PVOID*)&GetNextVdmCommandRequest->CurDirectory,
959 GetNextVdmCommandRequest->CurDirectoryLen,
960 sizeof(*GetNextVdmCommandRequest->CurDirectory))
961 || !CsrValidateMessageBuffer(ApiMessage,
962 (PVOID*)&GetNextVdmCommandRequest->Env,
963 GetNextVdmCommandRequest->EnvLen,
964 sizeof(*GetNextVdmCommandRequest->Env))
965 || !CsrValidateMessageBuffer(ApiMessage,
966 (PVOID*)&GetNextVdmCommandRequest->Desktop,
967 GetNextVdmCommandRequest->DesktopLen,
968 sizeof(*GetNextVdmCommandRequest->Desktop))
969 || !CsrValidateMessageBuffer(ApiMessage,
970 (PVOID*)&GetNextVdmCommandRequest->Title,
971 GetNextVdmCommandRequest->TitleLen,
972 sizeof(*GetNextVdmCommandRequest->Title))
973 || !CsrValidateMessageBuffer(ApiMessage,
974 (PVOID*)&GetNextVdmCommandRequest->Reserved,
975 GetNextVdmCommandRequest->ReservedLen,
976 sizeof(*GetNextVdmCommandRequest->Reserved))
977 || !CsrValidateMessageBuffer(ApiMessage,
978 (PVOID*)&GetNextVdmCommandRequest->StartupInfo,
979 1,
980 sizeof(STARTUPINFOA)))
981 {
983 }
984
985 CriticalSection = (GetNextVdmCommandRequest->VDMState & VDM_FLAG_WOW)
988
989 /* Enter the critical section */
991
992 if (GetNextVdmCommandRequest->VDMState & VDM_FLAG_WOW)
993 {
994 // TODO: WOW SUPPORT NOT IMPLEMENTED
997 goto Cleanup;
998 }
999 // else if (!(GetNextVdmCommandRequest->VDMState & VDM_FLAG_WOW))
1000 {
1001 if (GetNextVdmCommandRequest->iTask != 0)
1002 {
1003 /* Get the console record using the task ID */
1004 Status = GetConsoleRecordBySessionId(GetNextVdmCommandRequest->iTask,
1005 &ConsoleRecord);
1006 }
1007 else
1008 {
1009 /* Get the console record using the console handle */
1010 Status = BaseSrvGetConsoleRecord(GetNextVdmCommandRequest->ConsoleHandle,
1011 &ConsoleRecord);
1012 }
1013
1014 /* Make sure we found the console record */
1015 if (!NT_SUCCESS(Status)) goto Cleanup;
1016
1017 /* Return the session ID */
1018 GetNextVdmCommandRequest->iTask = ConsoleRecord->SessionId;
1019 GetNextVdmCommandRequest->WaitObjectForVDM = NULL;
1020
1021 if (GetNextVdmCommandRequest->VDMState & VDM_GET_FIRST_COMMAND)
1022 {
1023 /* Check if the DOS record list is empty */
1024 if (ConsoleRecord->DosListHead.Flink == &ConsoleRecord->DosListHead)
1025 {
1027 goto Cleanup;
1028 }
1029
1030 /* Get the first DOS record */
1031 DosRecord = CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink, VDM_DOS_RECORD, Entry);
1032
1033 /* Make sure its command information is still there */
1034 if (DosRecord->CommandInfo == NULL)
1035 {
1037 goto Cleanup;
1038 }
1039
1040 /* Check if the console handle hasn't been set yet */
1041 if (ConsoleRecord->ConsoleHandle == NULL)
1042 {
1043 /* Set it now */
1044 ConsoleRecord->ConsoleHandle = GetNextVdmCommandRequest->ConsoleHandle;
1045 }
1046
1047 /* Fill the command information */
1048 Status = BaseSrvFillCommandInfo(DosRecord->CommandInfo, GetNextVdmCommandRequest);
1049 goto Cleanup;
1050 }
1051
1052 /* Check if we should set the state of a running DOS record to ready */
1053 if (!(GetNextVdmCommandRequest->VDMState
1055 {
1056 /* Search for a DOS record that is currently running */
1057 for (i = ConsoleRecord->DosListHead.Flink; i != &ConsoleRecord->DosListHead; i = i->Flink)
1058 {
1059 DosRecord = CONTAINING_RECORD(i, VDM_DOS_RECORD, Entry);
1060 if (DosRecord->State == VDM_NOT_READY) break;
1061 }
1062
1063 /* Check if we found any */
1064 if (i == &ConsoleRecord->DosListHead)
1065 {
1067 goto Cleanup;
1068 }
1069
1070 /* Set the exit code */
1071 DosRecord->ExitCode = GetNextVdmCommandRequest->ExitCode;
1072
1073 /* Update the VDM state */
1074 DosRecord->State = VDM_READY;
1075
1076 /* Notify all waiting threads that the task is finished */
1077 NtSetEvent(DosRecord->ServerEvent, NULL);
1078 NtClose(DosRecord->ServerEvent);
1079 DosRecord->ServerEvent = NULL;
1080 }
1081
1082 /* Search for a DOS record that is currently running and has command information */
1083 for (i = ConsoleRecord->DosListHead.Flink; i != &ConsoleRecord->DosListHead; i = i->Flink)
1084 {
1085 DosRecord = CONTAINING_RECORD(i, VDM_DOS_RECORD, Entry);
1086 if ((DosRecord->State == VDM_NOT_READY) && (DosRecord->CommandInfo != NULL)) break;
1087 }
1088
1089 /* Check if we found any */
1090 if (i != &ConsoleRecord->DosListHead)
1091 {
1092 ASSERT(DosRecord->CommandInfo != NULL);
1093
1094 /* Check if the caller only wants environment data */
1095 if (GetNextVdmCommandRequest->VDMState & VDM_GET_ENVIRONMENT)
1096 {
1097 if (GetNextVdmCommandRequest->EnvLen < DosRecord->CommandInfo->EnvLen)
1098 {
1099 /* Not enough space was reserved */
1100 GetNextVdmCommandRequest->EnvLen = DosRecord->CommandInfo->EnvLen;
1102 goto Cleanup;
1103 }
1104
1105 /* Copy the environment data */
1106 RtlMoveMemory(GetNextVdmCommandRequest->Env,
1107 DosRecord->CommandInfo->Env,
1108 DosRecord->CommandInfo->EnvLen);
1109
1110 /* Return the actual size to the caller */
1111 GetNextVdmCommandRequest->EnvLen = DosRecord->CommandInfo->EnvLen;
1112 }
1113 else
1114 {
1115 /* Fill the command information */
1116 Status = BaseSrvFillCommandInfo(DosRecord->CommandInfo, GetNextVdmCommandRequest);
1117 if (!NT_SUCCESS(Status)) goto Cleanup;
1118
1119 /* Free the command information, it's no longer needed */
1120 BaseSrvFreeVDMInfo(DosRecord->CommandInfo);
1121 DosRecord->CommandInfo = NULL;
1122
1123 /* Update the VDM state */
1124 DosRecord->State = VDM_NOT_READY;
1125 }
1126
1128 goto Cleanup;
1129 }
1130 }
1131
1132 GetNextVdmCommandRequest->WaitObjectForVDM = NULL;
1133
1134 /*
1135 * There is no command yet. Prepare for waiting if we asked so,
1136 * and if we were not retrying a request.
1137 */
1138 if (!(GetNextVdmCommandRequest->VDMState & VDM_FLAG_DONT_WAIT) ||
1139 !(GetNextVdmCommandRequest->VDMState & VDM_FLAG_RETRY))
1140 {
1141 if (ConsoleRecord->ServerEvent)
1142 {
1143 /* Reset the event */
1144 NtResetEvent(ConsoleRecord->ServerEvent, NULL);
1145 }
1146 else
1147 {
1148 /* Create a pair of wait handles */
1150 &ConsoleRecord->ClientEvent);
1151 if (!NT_SUCCESS(Status)) goto Cleanup;
1152 }
1153
1154 /* Return the client event handle */
1155 GetNextVdmCommandRequest->WaitObjectForVDM = ConsoleRecord->ClientEvent;
1156 }
1157
1158Cleanup:
1159 /* Leave the critical section */
1161
1162 return Status;
1163}
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
NTSTATUS NTAPI NtResetEvent(IN HANDLE EventHandle, OUT PLONG PreviousState OPTIONAL)
Definition: event.c:386
#define VDM_FLAG_RETRY
Definition: vdm.h:56
#define VDM_FLAG_FIRST_TASK
Definition: vdm.h:53
#define VDM_FLAG_DONT_WAIT
Definition: vdm.h:60
#define VDM_GET_ENVIRONMENT
Definition: vdm.h:62
#define VDM_FLAG_WOW
Definition: vdm.h:54
#define VDM_GET_FIRST_COMMAND
Definition: vdm.h:61
#define VDM_FLAG_NESTED_TASK
Definition: vdm.h:59
LPSTR Env
Definition: vdm.h:81
ULONG EnvLen
Definition: vdm.h:82
LPSTARTUPINFOA StartupInfo
Definition: basemsg.h:178
Definition: typedefs.h:120
NTSTATUS BaseSrvFillCommandInfo(PVDM_COMMAND_INFO CommandInfo, PBASE_GET_NEXT_VDM_COMMAND Message)
Definition: vdm.c:499

◆ CSR_API() [11/31]

CSR_API ( BaseSrvGetProcessShutdownParam  )

Definition at line 284 of file proc.c.

285{
286 PBASE_GETSET_PROCESS_SHUTDOWN_PARAMS ShutdownParametersRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.ShutdownParametersRequest;
287 PCSR_THREAD CsrThread = CsrGetClientThread();
288 ASSERT(CsrThread);
289
290 ShutdownParametersRequest->ShutdownLevel = CsrThread->Process->ShutdownLevel;
291 /* Only SHUTDOWN_NORETRY flag is valid for this API. The other private flags are for CSRSRV/WINSRV only. */
292 ShutdownParametersRequest->ShutdownFlags = CsrThread->Process->ShutdownFlags & SHUTDOWN_NORETRY;
293
294 return STATUS_SUCCESS;
295}
ULONG ShutdownFlags
Definition: csrsrv.h:59
ULONG ShutdownLevel
Definition: csrsrv.h:58
#define SHUTDOWN_NORETRY
Definition: winbase.h:448

◆ CSR_API() [12/31]

CSR_API ( BaseSrvGetTempFile  )

Definition at line 54 of file proc.c.

55{
56 static UINT BaseGetTempFileUnique = 0;
57 PBASE_GET_TEMP_FILE GetTempFile = &((PBASE_API_MESSAGE)ApiMessage)->Data.GetTempFileRequest;
58
59 /* Return 16-bits ID */
60 GetTempFile->UniqueID = (++BaseGetTempFileUnique & 0xFFFF);
61
62 DPRINT("Returning: %u\n", GetTempFile->UniqueID);
63
64 return GetTempFile->UniqueID;
65}
unsigned int UINT
Definition: ndis.h:50

◆ CSR_API() [13/31]

CSR_API ( BaseSrvGetVDMCurDirs  )

Definition at line 1398 of file vdm.c.

1399{
1401 PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.VDMCurrentDirsRequest;
1402 PVDM_CONSOLE_RECORD ConsoleRecord;
1403
1404 /* Validate the output buffer */
1405 if (!CsrValidateMessageBuffer(ApiMessage,
1406 (PVOID*)&VDMCurrentDirsRequest->lpszzCurDirs,
1407 VDMCurrentDirsRequest->cchCurDirs,
1408 sizeof(*VDMCurrentDirsRequest->lpszzCurDirs)))
1409 {
1411 }
1412
1413 /* Enter the critical section */
1415
1416 /* Find the console record */
1417 Status = BaseSrvGetConsoleRecord(VDMCurrentDirsRequest->ConsoleHandle, &ConsoleRecord);
1418 if (!NT_SUCCESS(Status)) goto Cleanup;
1419
1420 /* Return the actual size of the current directory information */
1421 VDMCurrentDirsRequest->cchCurDirs = ConsoleRecord->CurDirsLength;
1422
1423 /* Check if the buffer is large enough */
1424 if (VDMCurrentDirsRequest->cchCurDirs < ConsoleRecord->CurDirsLength)
1425 {
1427 goto Cleanup;
1428 }
1429
1430 /* Copy the data */
1431 RtlMoveMemory(VDMCurrentDirsRequest->lpszzCurDirs,
1432 ConsoleRecord->CurrentDirs,
1433 ConsoleRecord->CurDirsLength);
1434
1435Cleanup:
1436 /* Leave the critical section */
1438
1439 return Status;
1440}
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
PCHAR CurrentDirs
Definition: vdm.h:28
ULONG CurDirsLength
Definition: vdm.h:29

◆ CSR_API() [14/31]

CSR_API ( BaseSrvGetVDMExitCode  )

Definition at line 1248 of file vdm.c.

1249{
1251 PBASE_GET_VDM_EXIT_CODE GetVDMExitCodeRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.GetVDMExitCodeRequest;
1252 PLIST_ENTRY i = NULL;
1253 PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
1254 PVDM_DOS_RECORD DosRecord = NULL;
1255
1256 /* Enter the critical section */
1258
1259 /* Get the console record */
1260 Status = BaseSrvGetConsoleRecord(GetVDMExitCodeRequest->ConsoleHandle, &ConsoleRecord);
1261 if (!NT_SUCCESS(Status)) goto Cleanup;
1262
1263 /* Search for a DOS record that has the same parent process handle */
1264 for (i = ConsoleRecord->DosListHead.Flink; i != &ConsoleRecord->DosListHead; i = i->Flink)
1265 {
1266 DosRecord = CONTAINING_RECORD(i, VDM_DOS_RECORD, Entry);
1267 if (DosRecord->ClientEvent == GetVDMExitCodeRequest->hParent) break;
1268 }
1269
1270 /* Check if no DOS record was found */
1271 if (i == &ConsoleRecord->DosListHead)
1272 {
1274 goto Cleanup;
1275 }
1276
1277 /* Check if this task is still running */
1278 if (DosRecord->State != VDM_READY)
1279 {
1280 GetVDMExitCodeRequest->ExitCode = STATUS_PENDING;
1281 goto Cleanup;
1282 }
1283
1284 /* Return the exit code */
1285 GetVDMExitCodeRequest->ExitCode = DosRecord->ExitCode;
1286
1287 // FIXME: We may just change DosRecord->State to VDM_READY in some cases...
1288
1289 /* Since this is a zombie task record, remove it */
1290 if (DosRecord->CommandInfo) BaseSrvFreeVDMInfo(DosRecord->CommandInfo);
1291 RemoveEntryList(&DosRecord->Entry);
1292 RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
1293
1294Cleanup:
1295 /* Leave the critical section */
1297
1298 return Status;
1299}
#define STATUS_PENDING
Definition: ntstatus.h:82
#define STATUS_NOT_FOUND
Definition: shellext.h:72

◆ CSR_API() [15/31]

CSR_API ( BaseSrvIsFirstVDM  )

Definition at line 1235 of file vdm.c.

1236{
1237 PBASE_IS_FIRST_VDM IsFirstVDMRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.IsFirstVDMRequest;
1238
1239 /* Return the result */
1240 IsFirstVDMRequest->FirstVDM = FirstVDM;
1241
1242 /* Clear the first VDM flag */
1243 FirstVDM = FALSE;
1244
1245 return STATUS_SUCCESS;
1246}
BOOLEAN FirstVDM
Definition: vdm.c:20

◆ CSR_API() [16/31]

CSR_API ( BaseSrvNlsCreateSection  )

Definition at line 162 of file nls.c.

163{
165 HANDLE SectionHandle, ProcessHandle, FileHandle;
167 UNICODE_STRING NlsSectionName;
168 PWCHAR NlsFileName;
172 WCHAR NlsSectionNameBuffer[32];
173 PBASE_NLS_CREATE_SECTION NlsMsg = &((PBASE_API_MESSAGE)ApiMessage)->Data.NlsCreateSection;
174
175 /* Load kernel32 first and import the NLS routines */
177 if (!NT_SUCCESS(Status)) return Status;
178
179 /* Assume failure */
180 NlsMsg->SectionHandle = NULL;
181
182 /* Check and validate the locale ID, if one is present */
183 LocaleId = NlsMsg->LocaleId;
184 DPRINT1("NLS: Create Section with LCID: %lx for Type: %d\n", LocaleId, NlsMsg->Type);
185 if (LocaleId)
186 {
188 }
189
190 /* Check which NLS section is being created */
191 switch (NlsMsg->Type)
192 {
193 /* For each one, set the correct filename and object name */
194 case 1:
195 RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionUnicode");
196 NlsFileName = L"unicode.nls";
197 break;
198 case 2:
199 RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionLocale");
200 NlsFileName = L"locale.nls";
201 break;
202 case 3:
203 RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionCType");
204 NlsFileName = L"ctype.nls";
205 break;
206 case 4:
207 RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionSortkey");
208 NlsFileName = L"sortkey.nls";
209 break;
210 case 5:
211 RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionSortTbls");
212 NlsFileName = L"sorttbls.nls";
213 break;
214 case 6:
215 RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionCP437");
216 NlsFileName = L"c_437.nls";
217 break;
218 case 7:
219 RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionCP1252");
220 NlsFileName = L"c_1252.nls";
221 break;
222 case 8:
223 RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionLANG_EXCEPT");
224 NlsFileName = L"l_except.nls";
225 break;
226 case 9:
227 DPRINT1("This type not yet supported\n");
229 case 10:
230 DPRINT1("This type not yet supported\n");
232 case 11:
233 /* Get the filename for this locale */
237 {
238 DPRINT1("File name query failed\n");
240 }
241
242 /* Get the name of the section for this locale */
243 DPRINT1("File name: %S\n", FileNameBuffer);
245 10,
246 0,
247 L"\\NLS\\NlsSectionCP",
248 NlsSectionNameBuffer,
249 RTL_NUMBER_OF(NlsSectionNameBuffer));
250 if (!NT_SUCCESS(Status))
251 {
252 DPRINT1("Section name query failed: %lx\n", Status);
253 return Status;
254 }
255
256 /* Setup the name and go open it */
257 NlsFileName = FileNameBuffer;
258 DPRINT1("Section name: %S\n", NlsSectionNameBuffer);
259 RtlInitUnicodeString(&NlsSectionName, NlsSectionNameBuffer);
260 break;
261 case 12:
262 RtlInitUnicodeString(&NlsSectionName, L"\\NLS\\NlsSectionGeo");
263 NlsFileName = L"geo.nls";
264 break;
265 default:
266 DPRINT1("NLS: Invalid NLS type!\n");
268 }
269
270 /* Open the specified NLS file */
271 Status = pOpenDataFile(&FileHandle, NlsFileName);
272 if (Status != STATUS_SUCCESS)
273 {
274 DPRINT1("NLS: Failed to open file: %lx\n", Status);
275 return Status;
276 }
277
278 /* Create an SD for the section object */
279 Status = pCreateNlsSecurityDescriptor(&SecurityDescriptor,
280 sizeof(SecurityDescriptor),
282 if (!NT_SUCCESS(Status))
283 {
284 DPRINT1("NLS: CreateNlsSecurityDescriptor FAILED!: %lx\n", Status);
286 return Status;
287 }
288
289 /* Create the section object proper */
291 &NlsSectionName,
293 NULL,
295 Status = NtCreateSection(&SectionHandle,
298 0,
301 FileHandle);
303 if (!NT_SUCCESS(Status))
304 {
305 DPRINT1("NLS: Failed to create section! %lx\n", Status);
306 return Status;
307 }
308
309 /* Open a handle to the calling process */
314 &ApiMessage->Header.ClientId);
315 if (!NT_SUCCESS(Status))
316 {
317 DPRINT1("NLS: Failed to open process! %lx\n", Status);
318 NtClose(SectionHandle);
319 return Status;
320 }
321
322 /* Duplicate the handle to the section object into it */
324 SectionHandle,
326 &NlsMsg->SectionHandle,
327 0,
328 0,
329 3);
331 return Status;
332}
NTSTATUS NTAPI NtCreateSection(OUT PHANDLE SectionHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, IN PLARGE_INTEGER MaximumSize OPTIONAL, IN ULONG SectionPageProtection OPTIONAL, IN ULONG AllocationAttributes, IN HANDLE FileHandle OPTIONAL)
Definition: section.c:3441
#define RTL_NUMBER_OF(x)
Definition: RtlRegistry.c:12
WCHAR FileNameBuffer[MAX_PATH]
Definition: framewnd.c:233
#define NLS_SECTION_SECURITY_DESCRIPTOR_SIZE
Definition: base.h:31
#define PAGE_READONLY
Definition: compat.h:138
#define SECTION_MAP_READ
Definition: compat.h:139
_Must_inspect_result_ _In_opt_ PFLT_INSTANCE _Out_ PHANDLE FileHandle
Definition: fltkernel.h:1231
#define OBJ_OPENIF
Definition: winternl.h:229
#define PROCESS_DUP_HANDLE
#define SEC_COMMIT
Definition: mmtypes.h:100
NTSTATUS NTAPI NtOpenProcess(OUT PHANDLE ProcessHandle, IN ACCESS_MASK DesiredAccess, IN POBJECT_ATTRIBUTES ObjectAttributes, IN PCLIENT_ID ClientId)
Definition: process.c:1440
PGET_NLS_SECTION_NAME pGetNlsSectionName
Definition: nls.c:33
POPEN_DATA_FILE pOpenDataFile
Definition: nls.c:27
PVALIDATE_LOCALE pValidateLocale
Definition: nls.c:32
NTSTATUS NTAPI BaseSrvDelayLoadKernel32(VOID)
Definition: nls.c:61
PGET_CP_FILE_NAME_FROM_REGISTRY pGetCPFileNameFromRegistry
Definition: nls.c:35
uint16_t * PWCHAR
Definition: typedefs.h:56
_Must_inspect_result_ _In_ PWDFDEVICE_INIT _In_ PCUNICODE_STRING _In_ PCUNICODE_STRING _In_ LCID LocaleId
Definition: wdfpdo.h:437

◆ CSR_API() [17/31]

CSR_API ( BaseSrvNlsGetUserInfo  )

Definition at line 340 of file nls.c.

341{
343 PBASE_NLS_GET_USER_INFO NlsMsg = &((PBASE_API_MESSAGE)ApiMessage)->Data.NlsGetUserInfo;
344
345 /* Make sure the buffer is valid and of the right size */
346 if ((CsrValidateMessageBuffer(ApiMessage, &NlsMsg->NlsUserInfo, NlsMsg->Size, sizeof(BYTE))) &&
347 (NlsMsg->Size == sizeof(NLS_USER_INFO)))
348 {
349 /* Acquire the lock to prevent updates while we copy */
351 if (NT_SUCCESS(Status))
352 {
353 /* Do the copy now, then drop the lock */
355 DPRINT1("NLS Data copy complete\n");
357 }
358 }
359 else
360 {
361 /* The data was invalid, bail out */
362 DPRINT1("NLS: Size of info is invalid: %lx vs %lx\n", NlsMsg->Size, sizeof(NLS_USER_INFO));
364 }
365
366 /* All done */
367 return Status;
368}
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263

◆ CSR_API() [18/31]

CSR_API ( BaseSrvNlsSetMultipleUserInfo  )

Definition at line 156 of file nls.c.

157{
158 DPRINT1("%s not yet implemented\n", __FUNCTION__);
160}

◆ CSR_API() [19/31]

CSR_API ( BaseSrvNlsSetUserInfo  )

Definition at line 150 of file nls.c.

151{
152 DPRINT1("%s not yet implemented\n", __FUNCTION__);
154}

◆ CSR_API() [20/31]

CSR_API ( BaseSrvNlsUpdateCacheCount  )

Definition at line 334 of file nls.c.

335{
336 DPRINT1("%s not yet implemented\n", __FUNCTION__);
338}

◆ CSR_API() [21/31]

CSR_API ( BaseSrvRefreshIniFileMapping  )

Definition at line 1454 of file vdm.c.

1455{
1456 DPRINT1("%s not yet implemented\n", __FUNCTION__);
1458}

◆ CSR_API() [22/31]

CSR_API ( BaseSrvRegisterThread  )

Definition at line 30 of file proc.c.

31{
32 DPRINT1("%s not yet implemented\n", __FUNCTION__);
34}

◆ CSR_API() [23/31]

CSR_API ( BaseSrvRegisterWowExec  )

Definition at line 1448 of file vdm.c.

1449{
1450 DPRINT1("%s not yet implemented\n", __FUNCTION__);
1452}

◆ CSR_API() [24/31]

CSR_API ( BaseSrvSetProcessShutdownParam  )

Definition at line 297 of file proc.c.

298{
299 PBASE_GETSET_PROCESS_SHUTDOWN_PARAMS ShutdownParametersRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.ShutdownParametersRequest;
300 PCSR_THREAD CsrThread = CsrGetClientThread();
301 ASSERT(CsrThread);
302
303 /* Only SHUTDOWN_NORETRY flag is valid for this API. The other private flags are for CSRSRV/WINSRV only. */
304 if (ShutdownParametersRequest->ShutdownFlags & ~SHUTDOWN_NORETRY)
305 {
306 /* If there were other flags specified, fail the call */
308 }
309
310 CsrThread->Process->ShutdownLevel = ShutdownParametersRequest->ShutdownLevel;
311 /* Notice that all the possible other private flags are reinitialized here */
312 CsrThread->Process->ShutdownFlags = ShutdownParametersRequest->ShutdownFlags;
313
314 return STATUS_SUCCESS;
315}

◆ CSR_API() [25/31]

CSR_API ( BaseSrvSetReenterCount  )

Definition at line 1301 of file vdm.c.

1302{
1304 PBASE_SET_REENTER_COUNT SetReenterCountRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.SetReenterCountRequest;
1305 PVDM_CONSOLE_RECORD ConsoleRecord;
1306
1307 /* Enter the critical section */
1309
1310 /* Get the console record */
1311 Status = BaseSrvGetConsoleRecord(SetReenterCountRequest->ConsoleHandle, &ConsoleRecord);
1312 if (!NT_SUCCESS(Status)) goto Cleanup;
1313
1314 if (SetReenterCountRequest->fIncDec == VDM_INC_REENTER_COUNT)
1315 {
1316 ConsoleRecord->ReenterCount++;
1317 }
1318 else if (SetReenterCountRequest->fIncDec == VDM_DEC_REENTER_COUNT)
1319 {
1320 ConsoleRecord->ReenterCount--;
1321 if (ConsoleRecord->ServerEvent)
1322 NtSetEvent(ConsoleRecord->ServerEvent, NULL);
1323 }
1324 else
1325 {
1327 }
1328
1329Cleanup:
1330 /* Leave the critical section */
1332
1333 return Status;
1334}
#define VDM_INC_REENTER_COUNT
Definition: vdm.h:57
#define VDM_DEC_REENTER_COUNT
Definition: vdm.h:58
ULONG ReenterCount
Definition: vdm.h:27

◆ CSR_API() [26/31]

CSR_API ( BaseSrvSetTermsrvAppInstallMode  )

Definition at line 42 of file proc.c.

43{
44 DPRINT1("%s not yet implemented\n", __FUNCTION__);
46}

◆ CSR_API() [27/31]

CSR_API ( BaseSrvSetTermsrvClientTimeZone  )

Definition at line 48 of file proc.c.

49{
50 DPRINT1("%s not yet implemented\n", __FUNCTION__);
52}

◆ CSR_API() [28/31]

CSR_API ( BaseSrvSetVDMCurDirs  )

Definition at line 1336 of file vdm.c.

1337{
1339 PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.VDMCurrentDirsRequest;
1340 PVDM_CONSOLE_RECORD ConsoleRecord;
1341 PCHAR Buffer = NULL;
1342
1343 /* Validate the input buffer */
1344 if (!CsrValidateMessageBuffer(ApiMessage,
1345 (PVOID*)&VDMCurrentDirsRequest->lpszzCurDirs,
1346 VDMCurrentDirsRequest->cchCurDirs,
1347 sizeof(*VDMCurrentDirsRequest->lpszzCurDirs)))
1348 {
1350 }
1351
1352 /* Enter the critical section */
1354
1355 /* Find the console record */
1356 Status = BaseSrvGetConsoleRecord(VDMCurrentDirsRequest->ConsoleHandle, &ConsoleRecord);
1357 if (!NT_SUCCESS(Status)) goto Cleanup;
1358
1359 if (ConsoleRecord->CurrentDirs == NULL)
1360 {
1361 /* Allocate memory for the current directory information */
1364 VDMCurrentDirsRequest->cchCurDirs);
1365 }
1366 else
1367 {
1368 /* Resize the amount of allocated memory */
1371 ConsoleRecord->CurrentDirs,
1372 VDMCurrentDirsRequest->cchCurDirs);
1373 }
1374
1375 if (Buffer == NULL)
1376 {
1377 /* Allocation failed */
1379 goto Cleanup;
1380 }
1381
1382 /* Update the console record */
1383 ConsoleRecord->CurrentDirs = Buffer;
1384 ConsoleRecord->CurDirsLength = VDMCurrentDirsRequest->cchCurDirs;
1385
1386 /* Copy the data */
1387 RtlMoveMemory(ConsoleRecord->CurrentDirs,
1388 VDMCurrentDirsRequest->lpszzCurDirs,
1389 VDMCurrentDirsRequest->cchCurDirs);
1390
1391Cleanup:
1392 /* Leave the critical section */
1394
1395 return Status;
1396}
NTSYSAPI PVOID WINAPI RtlReAllocateHeap(HANDLE, ULONG, PVOID, SIZE_T)
Definition: heap.c:2667
char * PCHAR
Definition: typedefs.h:51

◆ CSR_API() [29/31]

CSR_API ( BaseSrvSoundSentryNotification  )

Definition at line 61 of file sndsntry.c.

62{
63 /* Call the API and see if it succeeds */
65}
static PUSER_SOUND_SENTRY _UserSoundSentry
Definition: sndsntry.c:21
#define STATUS_ACCESS_DENIED
Definition: udferr_usr.h:145

◆ CSR_API() [30/31]

CSR_API ( BaseSrvSxsCreateActivationContext  )

Definition at line 36 of file proc.c.

37{
38 DPRINT1("%s not yet implemented\n", __FUNCTION__);
40}

◆ CSR_API() [31/31]

CSR_API ( BaseSrvUpdateVDMEntry  )

Definition at line 808 of file vdm.c.

809{
811 PBASE_UPDATE_VDM_ENTRY UpdateVdmEntryRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.UpdateVDMEntryRequest;
813 PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
814 PVDM_DOS_RECORD DosRecord = NULL;
815
816 CriticalSection = (UpdateVdmEntryRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW)
819
820 /* Enter the critical section */
822
823 /* Check if this is a DOS or WOW VDM */
824 if (UpdateVdmEntryRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW)
825 {
826 if (UpdateVdmEntryRequest->iTask != 0)
827 {
828 /* Get the console record using the task ID */
829 Status = GetConsoleRecordBySessionId(UpdateVdmEntryRequest->iTask,
830 &ConsoleRecord);
831 }
832 else
833 {
834 /* Get the console record using the console handle */
835 Status = BaseSrvGetConsoleRecord(UpdateVdmEntryRequest->ConsoleHandle,
836 &ConsoleRecord);
837 }
838
839 if (!NT_SUCCESS(Status)) goto Cleanup;
840
841 /* Get the primary DOS record */
842 DosRecord = (PVDM_DOS_RECORD)CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink,
844
845 switch (UpdateVdmEntryRequest->EntryIndex)
846 {
847 case VdmEntryUndo:
848 {
849 /* Close the server event handle, the client will close the client handle */
850 NtClose(DosRecord->ServerEvent);
851 DosRecord->ServerEvent = DosRecord->ClientEvent = NULL;
852
853 if (UpdateVdmEntryRequest->VDMCreationState & (VDM_UNDO_PARTIAL | VDM_UNDO_FULL))
854 {
855 /* Remove the DOS record */
856 if (DosRecord->CommandInfo) BaseSrvFreeVDMInfo(DosRecord->CommandInfo);
857 RemoveEntryList(&DosRecord->Entry);
858 RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
859
860 /*
861 * Since this is an undo, if that was the only DOS record the VDM
862 * won't even start, so the console record should be removed too.
863 */
864 if (ConsoleRecord->DosListHead.Flink == &ConsoleRecord->DosListHead)
865 {
866 RemoveEntryList(&ConsoleRecord->Entry);
867 BaseSrvDestroyConsoleRecord(ConsoleRecord);
868 }
869 }
870
871 /* It was successful */
873
874 break;
875 }
876
878 {
879 /* Duplicate the VDM process handle */
881 UpdateVdmEntryRequest->VDMProcessHandle,
883 &ConsoleRecord->ProcessHandle,
884 0,
885 0,
887 if (!NT_SUCCESS(Status)) goto Cleanup;
888
889 //
890 // FIXME! Should we always do the following??
891 //
892
893 /* Create a pair of handles to one event object */
895 &DosRecord->ClientEvent);
896 if (!NT_SUCCESS(Status)) goto Cleanup;
897
898 /* Return the client event handle */
899 UpdateVdmEntryRequest->WaitObjectForParent = DosRecord->ClientEvent;
900
901 break;
902 }
903
905 {
906 // TODO: NOT IMPLEMENTED
907 DPRINT1("BaseSrvUpdateVDMEntry: VdmEntryUpdateControlCHandler not implemented!");
909
910 break;
911 }
912
913 default:
914 {
915 /* Invalid */
917 }
918 }
919 }
920 else
921 {
922 // TODO: NOT IMPLEMENTED
925 }
926
927Cleanup:
928 /* Leave the critical section */
930
931 return Status;
932}
#define DUPLICATE_SAME_ATTRIBUTES
Definition: obtypes.h:153
#define VDM_UNDO_PARTIAL
Definition: vdm.h:27
@ VdmEntryUndo
Definition: vdm.h:19
@ VdmEntryUpdateControlCHandler
Definition: vdm.h:21
@ VdmEntryUpdateProcess
Definition: vdm.h:20
#define VDM_UNDO_FULL
Definition: vdm.h:28
Definition: basemsg.h:151
ULONG BinaryType
Definition: basemsg.h:153
HANDLE WaitObjectForParent
Definition: basemsg.h:156
HANDLE VDMProcessHandle
Definition: basemsg.h:155
USHORT VDMCreationState
Definition: basemsg.h:158
USHORT EntryIndex
Definition: basemsg.h:157
ULONG iTask
Definition: basemsg.h:152
HANDLE ConsoleHandle
Definition: basemsg.h:154
HANDLE ProcessHandle
Definition: vdm.h:23