ReactOS 0.4.15-dev-7918-g2a2556c
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:396
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 1441 of file vdm.c.

1442{
1443 DPRINT1("%s not yet implemented\n", __FUNCTION__);
1445}
#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 599 of file vdm.c.

600{
602 PBASE_CHECK_VDM CheckVdmRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CheckVDMRequest;
604 PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
605 PVDM_DOS_RECORD DosRecord = NULL;
606 BOOLEAN NewConsoleRecord = FALSE;
607 BOOLEAN NewDosRecord = FALSE;
608
609 /* Don't do anything if the VDM has been disabled in the registry */
611
612 /* Validate the message buffers */
613 if (!CsrValidateMessageBuffer(ApiMessage,
614 (PVOID*)&CheckVdmRequest->CmdLine,
615 CheckVdmRequest->CmdLen,
616 sizeof(*CheckVdmRequest->CmdLine))
617 || !CsrValidateMessageBuffer(ApiMessage,
618 (PVOID*)&CheckVdmRequest->AppName,
619 CheckVdmRequest->AppLen,
620 sizeof(*CheckVdmRequest->AppName))
621 || !CsrValidateMessageBuffer(ApiMessage,
622 (PVOID*)&CheckVdmRequest->PifFile,
623 CheckVdmRequest->PifLen,
624 sizeof(*CheckVdmRequest->PifFile))
625 || !CsrValidateMessageBuffer(ApiMessage,
626 (PVOID*)&CheckVdmRequest->CurDirectory,
627 CheckVdmRequest->CurDirectoryLen,
628 sizeof(*CheckVdmRequest->CurDirectory))
629 || !CsrValidateMessageBuffer(ApiMessage,
630 (PVOID*)&CheckVdmRequest->Desktop,
631 CheckVdmRequest->DesktopLen,
632 sizeof(*CheckVdmRequest->Desktop))
633 || !CsrValidateMessageBuffer(ApiMessage,
634 (PVOID*)&CheckVdmRequest->Title,
635 CheckVdmRequest->TitleLen,
636 sizeof(*CheckVdmRequest->Title))
637 || !CsrValidateMessageBuffer(ApiMessage,
638 (PVOID*)&CheckVdmRequest->Reserved,
639 CheckVdmRequest->ReservedLen,
640 sizeof(*CheckVdmRequest->Reserved)))
641 {
643 }
644
648
649 /* Enter the critical section */
651
652 /* Check if this is a DOS or WOW VDM */
653 if (CheckVdmRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW)
654 {
655 /* Get the console record */
657 &ConsoleRecord);
658 if (!NT_SUCCESS(Status))
659 {
660 /* Allocate a new console record */
661 ConsoleRecord = BaseSrvCreateConsoleRecord();
662 if (ConsoleRecord == NULL)
663 {
665 goto Cleanup;
666 }
667
668 /* Initialize the console record */
669 ConsoleRecord->ConsoleHandle = CheckVdmRequest->ConsoleHandle;
670 if (ConsoleRecord->ConsoleHandle == NULL)
671 {
672 /* The parent doesn't have a console, get a new session ID */
673 ConsoleRecord->SessionId = GetNextDosSesId();
674 }
675 else
676 {
677 /* No session ID is needed */
678 ConsoleRecord->SessionId = 0;
679 }
680
681 /* Remember that the console record was allocated here */
682 NewConsoleRecord = TRUE;
683 }
684
685 if (!NewConsoleRecord)
686 {
687 /* Get the primary DOS record */
688 DosRecord = (PVDM_DOS_RECORD)CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink,
690
691 if (DosRecord->State != VDM_READY) // == VDM_NOT_READY
692 {
693 /* Allocate a new DOS record */
696 sizeof(VDM_DOS_RECORD));
697 if (DosRecord == NULL)
698 {
700 goto Cleanup;
701 }
702
703 /* Remember that the DOS record was allocated here */
704 NewDosRecord = TRUE;
705 }
706 }
707 else
708 {
709 /* Allocate a new DOS record */
712 sizeof(VDM_DOS_RECORD));
713 if (DosRecord == NULL)
714 {
716 goto Cleanup;
717 }
718
719 /* Remember that the DOS record was allocated here */
720 NewDosRecord = TRUE;
721 }
722
723 /* Initialize the DOS record */
724 DosRecord->State = VDM_NOT_READY;
725 DosRecord->ExitCode = 0;
726
727 /* Translate the input structure into a VDM command structure and set it in the DOS record */
728 if (!BaseSrvCopyCommand(CheckVdmRequest, DosRecord))
729 {
730 /* The only possibility is that an allocation failure occurred */
732 goto Cleanup;
733 }
734
735 if (NewDosRecord)
736 {
737 /* Add the DOS record */
738 InsertHeadList(&ConsoleRecord->DosListHead, &DosRecord->Entry);
739 }
740
741 if (!NewConsoleRecord)
742 {
744 if (!NT_SUCCESS(Status)) goto Cleanup;
745
746 /* Return the client event handle */
747 CheckVdmRequest->WaitObjectForParent = DosRecord->ClientEvent;
748 }
749
750 // FIXME: We may notify ONLY if ConsoleRecord->nReEntrancy is > 0
751 // in case NewConsoleRecord == FALSE AND NewDosRecord == TRUE.
752 if (ConsoleRecord->ServerEvent)
753 {
754 /* Signal the session event */
755 NtSetEvent(ConsoleRecord->ServerEvent, NULL);
756 }
757
758 if (NewConsoleRecord)
759 {
760 /* Add the console record */
761 InsertTailList(&VDMConsoleListHead, &ConsoleRecord->Entry);
762 }
763
764 CheckVdmRequest->iTask = ConsoleRecord->SessionId;
765 CheckVdmRequest->VDMState = NewConsoleRecord ? VDM_NOT_LOADED : VDM_READY;
767 }
768 else
769 {
770 // TODO: NOT IMPLEMENTED
773 }
774
775Cleanup:
776 /* Check if it failed */
777 if (!NT_SUCCESS(Status))
778 {
779 /* Free the DOS record if it was allocated here */
780 if (NewDosRecord)
781 {
782 ASSERT(DosRecord != NULL);
783
785 DosRecord->ClientEvent);
786
787 RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
788 DosRecord = NULL;
789 }
790
791 /* Free the console record if it was allocated here */
792 if (NewConsoleRecord)
793 {
794 ASSERT(ConsoleRecord != NULL);
795
796 RtlFreeHeap(BaseSrvHeap, 0, ConsoleRecord);
797 ConsoleRecord = NULL;
798 }
799 }
800
801 /* Leave the critical section */
803
804 return Status;
805}
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:590
BOOLEAN NTAPI RtlFreeHeap(IN PVOID HeapHandle, IN ULONG Flags, IN PVOID HeapBase)
Definition: heap.c:608
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:239
VOID BaseSrvDestroyPairWaitHandles(HANDLE ServerEvent, HANDLE ClientEvent)
Definition: vdm.c:260
BOOLEAN BaseSrvCopyCommand(PBASE_CHECK_VDM CheckVdmRequest, PVDM_DOS_RECORD DosRecord)
Definition: vdm.c:351
ULONG GetNextDosSesId(VOID)
Definition: vdm.c:113
RTL_CRITICAL_SECTION WowCriticalSection
Definition: vdm.c:23
BOOLEAN BaseSrvIsVdmAllowed(VOID)
Definition: vdm.c:142
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:94
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:1151

◆ 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 1164 of file vdm.c.

1165{
1167 PBASE_EXIT_VDM ExitVdmRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.ExitVDMRequest;
1169 PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
1170 PVDM_DOS_RECORD DosRecord;
1171
1172 CriticalSection = (ExitVdmRequest->iWowTask == 0)
1175
1176 /* Enter the critical section */
1178
1179 if (ExitVdmRequest->iWowTask == 0)
1180 {
1181 /* Get the console record */
1182 Status = BaseSrvGetConsoleRecord(ExitVdmRequest->ConsoleHandle, &ConsoleRecord);
1183 if (!NT_SUCCESS(Status)) goto Cleanup;
1184
1185 if (ConsoleRecord->ServerEvent)
1186 ExitVdmRequest->WaitObjectForVDM = ConsoleRecord->ClientEvent;
1187
1188 // NOTE: The following is the same as in BaseSrvCleanupVDMResources.
1189
1190 if (ConsoleRecord->ServerEvent)
1191 {
1192 NtClose(ConsoleRecord->ServerEvent);
1193 ConsoleRecord->ServerEvent = NULL;
1194 }
1195
1196 /* Cleanup the DOS records */
1197 while (!IsListEmpty(&ConsoleRecord->DosListHead))
1198 {
1199 DosRecord = CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink,
1201
1202 /* Set the event and close it */
1203 if (DosRecord->ServerEvent)
1204 {
1205 NtSetEvent(DosRecord->ServerEvent, NULL);
1206 NtClose(DosRecord->ServerEvent);
1207 DosRecord->ServerEvent = NULL;
1208 }
1209
1210 /* Remove the DOS entry */
1211 if (DosRecord->CommandInfo) BaseSrvFreeVDMInfo(DosRecord->CommandInfo);
1212 RemoveEntryList(&DosRecord->Entry);
1213 RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
1214 }
1215
1216 /* Remove the console record */
1217 RemoveEntryList(&ConsoleRecord->Entry);
1218 BaseSrvDestroyConsoleRecord(ConsoleRecord);
1219 }
1220 else
1221 {
1222 // TODO: NOT IMPLEMENTED
1225 }
1226
1227Cleanup:
1228 /* Leave the critical section */
1230
1231 return Status;
1232}
#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:280

◆ CSR_API() [10/31]

CSR_API ( BaseSrvGetNextVDMCommand  )

Definition at line 933 of file vdm.c.

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

◆ 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 1397 of file vdm.c.

1398{
1400 PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.VDMCurrentDirsRequest;
1401 PVDM_CONSOLE_RECORD ConsoleRecord;
1402
1403 /* Validate the output buffer */
1404 if (!CsrValidateMessageBuffer(ApiMessage,
1405 (PVOID*)&VDMCurrentDirsRequest->lpszzCurDirs,
1406 VDMCurrentDirsRequest->cchCurDirs,
1407 sizeof(*VDMCurrentDirsRequest->lpszzCurDirs)))
1408 {
1410 }
1411
1412 /* Enter the critical section */
1414
1415 /* Find the console record */
1416 Status = BaseSrvGetConsoleRecord(VDMCurrentDirsRequest->ConsoleHandle, &ConsoleRecord);
1417 if (!NT_SUCCESS(Status)) goto Cleanup;
1418
1419 /* Return the actual size of the current directory information */
1420 VDMCurrentDirsRequest->cchCurDirs = ConsoleRecord->CurDirsLength;
1421
1422 /* Check if the buffer is large enough */
1423 if (VDMCurrentDirsRequest->cchCurDirs < ConsoleRecord->CurDirsLength)
1424 {
1426 goto Cleanup;
1427 }
1428
1429 /* Copy the data */
1430 RtlMoveMemory(VDMCurrentDirsRequest->lpszzCurDirs,
1431 ConsoleRecord->CurrentDirs,
1432 ConsoleRecord->CurDirsLength);
1433
1434Cleanup:
1435 /* Leave the critical section */
1437
1438 return Status;
1439}
#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 1247 of file vdm.c.

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

1235{
1236 PBASE_IS_FIRST_VDM IsFirstVDMRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.IsFirstVDMRequest;
1237
1238 /* Return the result */
1239 IsFirstVDMRequest->FirstVDM = FirstVDM;
1240
1241 /* Clear the first VDM flag */
1242 FirstVDM = FALSE;
1243
1244 return STATUS_SUCCESS;
1245}
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 1453 of file vdm.c.

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

◆ 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 1447 of file vdm.c.

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

◆ 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 1300 of file vdm.c.

1301{
1303 PBASE_SET_REENTER_COUNT SetReenterCountRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.SetReenterCountRequest;
1304 PVDM_CONSOLE_RECORD ConsoleRecord;
1305
1306 /* Enter the critical section */
1308
1309 /* Get the console record */
1310 Status = BaseSrvGetConsoleRecord(SetReenterCountRequest->ConsoleHandle, &ConsoleRecord);
1311 if (!NT_SUCCESS(Status)) goto Cleanup;
1312
1313 if (SetReenterCountRequest->fIncDec == VDM_INC_REENTER_COUNT)
1314 {
1315 ConsoleRecord->ReenterCount++;
1316 }
1317 else if (SetReenterCountRequest->fIncDec == VDM_DEC_REENTER_COUNT)
1318 {
1319 ConsoleRecord->ReenterCount--;
1320 if (ConsoleRecord->ServerEvent)
1321 NtSetEvent(ConsoleRecord->ServerEvent, NULL);
1322 }
1323 else
1324 {
1326 }
1327
1328Cleanup:
1329 /* Leave the critical section */
1331
1332 return Status;
1333}
#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 1335 of file vdm.c.

1336{
1338 PBASE_GETSET_VDM_CURDIRS VDMCurrentDirsRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.VDMCurrentDirsRequest;
1339 PVDM_CONSOLE_RECORD ConsoleRecord;
1340 PCHAR Buffer = NULL;
1341
1342 /* Validate the input buffer */
1343 if (!CsrValidateMessageBuffer(ApiMessage,
1344 (PVOID*)&VDMCurrentDirsRequest->lpszzCurDirs,
1345 VDMCurrentDirsRequest->cchCurDirs,
1346 sizeof(*VDMCurrentDirsRequest->lpszzCurDirs)))
1347 {
1349 }
1350
1351 /* Enter the critical section */
1353
1354 /* Find the console record */
1355 Status = BaseSrvGetConsoleRecord(VDMCurrentDirsRequest->ConsoleHandle, &ConsoleRecord);
1356 if (!NT_SUCCESS(Status)) goto Cleanup;
1357
1358 if (ConsoleRecord->CurrentDirs == NULL)
1359 {
1360 /* Allocate memory for the current directory information */
1363 VDMCurrentDirsRequest->cchCurDirs);
1364 }
1365 else
1366 {
1367 /* Resize the amount of allocated memory */
1370 ConsoleRecord->CurrentDirs,
1371 VDMCurrentDirsRequest->cchCurDirs);
1372 }
1373
1374 if (Buffer == NULL)
1375 {
1376 /* Allocation failed */
1378 goto Cleanup;
1379 }
1380
1381 /* Update the console record */
1382 ConsoleRecord->CurrentDirs = Buffer;
1383 ConsoleRecord->CurDirsLength = VDMCurrentDirsRequest->cchCurDirs;
1384
1385 /* Copy the data */
1386 RtlMoveMemory(ConsoleRecord->CurrentDirs,
1387 VDMCurrentDirsRequest->lpszzCurDirs,
1388 VDMCurrentDirsRequest->cchCurDirs);
1389
1390Cleanup:
1391 /* Leave the critical section */
1393
1394 return Status;
1395}
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 807 of file vdm.c.

808{
810 PBASE_UPDATE_VDM_ENTRY UpdateVdmEntryRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.UpdateVDMEntryRequest;
812 PVDM_CONSOLE_RECORD ConsoleRecord = NULL;
813 PVDM_DOS_RECORD DosRecord = NULL;
814
815 CriticalSection = (UpdateVdmEntryRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW)
818
819 /* Enter the critical section */
821
822 /* Check if this is a DOS or WOW VDM */
823 if (UpdateVdmEntryRequest->BinaryType != BINARY_TYPE_SEPARATE_WOW)
824 {
825 if (UpdateVdmEntryRequest->iTask != 0)
826 {
827 /* Get the console record using the task ID */
828 Status = GetConsoleRecordBySessionId(UpdateVdmEntryRequest->iTask,
829 &ConsoleRecord);
830 }
831 else
832 {
833 /* Get the console record using the console handle */
834 Status = BaseSrvGetConsoleRecord(UpdateVdmEntryRequest->ConsoleHandle,
835 &ConsoleRecord);
836 }
837
838 if (!NT_SUCCESS(Status)) goto Cleanup;
839
840 /* Get the primary DOS record */
841 DosRecord = (PVDM_DOS_RECORD)CONTAINING_RECORD(ConsoleRecord->DosListHead.Flink,
843
844 switch (UpdateVdmEntryRequest->EntryIndex)
845 {
846 case VdmEntryUndo:
847 {
848 /* Close the server event handle, the client will close the client handle */
849 NtClose(DosRecord->ServerEvent);
850 DosRecord->ServerEvent = DosRecord->ClientEvent = NULL;
851
852 if (UpdateVdmEntryRequest->VDMCreationState & (VDM_UNDO_PARTIAL | VDM_UNDO_FULL))
853 {
854 /* Remove the DOS record */
855 if (DosRecord->CommandInfo) BaseSrvFreeVDMInfo(DosRecord->CommandInfo);
856 RemoveEntryList(&DosRecord->Entry);
857 RtlFreeHeap(BaseSrvHeap, 0, DosRecord);
858
859 /*
860 * Since this is an undo, if that was the only DOS record the VDM
861 * won't even start, so the console record should be removed too.
862 */
863 if (ConsoleRecord->DosListHead.Flink == &ConsoleRecord->DosListHead)
864 {
865 RemoveEntryList(&ConsoleRecord->Entry);
866 BaseSrvDestroyConsoleRecord(ConsoleRecord);
867 }
868 }
869
870 /* It was successful */
872
873 break;
874 }
875
877 {
878 /* Duplicate the VDM process handle */
880 UpdateVdmEntryRequest->VDMProcessHandle,
882 &ConsoleRecord->ProcessHandle,
883 0,
884 0,
886 if (!NT_SUCCESS(Status)) goto Cleanup;
887
888 //
889 // FIXME! Should we always do the following??
890 //
891
892 /* Create a pair of handles to one event object */
894 &DosRecord->ClientEvent);
895 if (!NT_SUCCESS(Status)) goto Cleanup;
896
897 /* Return the client event handle */
898 UpdateVdmEntryRequest->WaitObjectForParent = DosRecord->ClientEvent;
899
900 break;
901 }
902
904 {
905 // TODO: NOT IMPLEMENTED
906 DPRINT1("BaseSrvUpdateVDMEntry: VdmEntryUpdateControlCHandler not implemented\n");
908
909 break;
910 }
911
912 default:
913 {
914 /* Invalid */
916 }
917 }
918 }
919 else
920 {
921 // TODO: NOT IMPLEMENTED
924 }
925
926Cleanup:
927 /* Leave the critical section */
929
930 return Status;
931}
#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