ReactOS 0.4.16-dev-88-ga65b6ae
server.c File Reference
#include "srv.h"
#include <ndk/mmfuncs.h>
#include <debug.h>
Include dependency graph for server.c:

Go to the source code of this file.

Macros

#define NDEBUG
 

Functions

 CSR_SERVER_DLL_INIT (CsrServerDllInitialization)
 
NTSTATUS NTAPI CsrLoadServerDll (IN PCHAR DllString, IN PCHAR EntryPoint OPTIONAL, IN ULONG ServerId)
 
 CSR_API (CsrSrvClientConnect)
 
NTSTATUS NTAPI CsrSrvCreateSharedSection (IN PCHAR ParameterValue)
 
NTSTATUS NTAPI CsrSrvAttachSharedSection (IN PCSR_PROCESS CsrProcess OPTIONAL, OUT PCSR_API_CONNECTINFO ConnectInfo)
 
 CSR_API (CsrSrvUnusedFunction)
 
VOID NTAPI CsrSetCallingSpooler (ULONG Reserved)
 
EXCEPTION_DISPOSITION NTAPI CsrUnhandledExceptionFilter (IN PEXCEPTION_POINTERS ExceptionInfo)
 

Variables

PCSR_SERVER_DLL CsrLoadedServerDll [CSR_SERVER_DLL_MAX]
 
PVOID CsrSrvSharedSectionHeap = NULL
 
PVOID CsrSrvSharedSectionBase = NULL
 
PVOIDCsrSrvSharedStaticServerData = NULL
 
ULONG CsrSrvSharedSectionSize = 0
 
HANDLE CsrSrvSharedSection = NULL
 
PCSR_API_ROUTINE CsrServerApiDispatchTable [CsrpMaxApiNumber]
 
BOOLEAN CsrServerApiServerValidTable [CsrpMaxApiNumber]
 

Macro Definition Documentation

◆ NDEBUG

#define NDEBUG

Definition at line 15 of file server.c.

Function Documentation

◆ CSR_API() [1/2]

CSR_API ( CsrSrvClientConnect  )

Definition at line 293 of file server.c.

294{
296 PCSR_CLIENT_CONNECT ClientConnect = &ApiMessage->Data.CsrClientConnect;
297 PCSR_SERVER_DLL ServerDll;
298 PCSR_PROCESS CurrentProcess = CsrGetClientThread()->Process;
299
300 /* Set default reply */
301 *ReplyCode = CsrReplyImmediately;
302
303 /* Validate the ServerID */
304 if (ClientConnect->ServerId >= CSR_SERVER_DLL_MAX)
305 {
307 }
308 else if (!CsrLoadedServerDll[ClientConnect->ServerId])
309 {
311 }
312
313 /* Validate the Message Buffer */
314 if (!(CsrValidateMessageBuffer(ApiMessage,
315 &ClientConnect->ConnectionInfo,
316 ClientConnect->ConnectionInfoSize,
317 sizeof(BYTE))))
318 {
319 /* Fail due to buffer overflow or other invalid buffer */
321 }
322
323 /* Load the Server DLL */
324 ServerDll = CsrLoadedServerDll[ClientConnect->ServerId];
325
326 /* Check if it has a Connect Callback */
327 if (ServerDll->ConnectCallback)
328 {
329 /* Call the callback */
330 Status = ServerDll->ConnectCallback(CurrentProcess,
331 ClientConnect->ConnectionInfo,
332 &ClientConnect->ConnectionInfoSize);
333 }
334 else
335 {
336 /* Assume success */
338 }
339
340 /* Return status */
341 return Status;
342}
LONG NTSTATUS
Definition: precomp.h:26
BOOLEAN NTAPI CsrValidateMessageBuffer(IN PCSR_API_MESSAGE ApiMessage, IN PVOID *Buffer, IN ULONG ElementCount, IN ULONG ElementSize)
Definition: api.c:1430
#define CsrGetClientThread()
Definition: csrsrv.h:77
@ CsrReplyImmediately
Definition: csrsrv.h:131
Status
Definition: gdiplustypes.h:25
#define STATUS_TOO_MANY_NAMES
Definition: ntstatus.h:441
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG ConnectionInfoSize
Definition: csrmsg.h:87
PVOID ConnectionInfo
Definition: csrmsg.h:86
PCSR_CONNECT_CALLBACK ConnectCallback
Definition: csrsrv.h:235
#define CSR_SERVER_DLL_MAX
Definition: api.h:34
PCSR_SERVER_DLL CsrLoadedServerDll[CSR_SERVER_DLL_MAX]
Definition: server.c:20
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
unsigned char BYTE
Definition: xxhash.c:193

◆ CSR_API() [2/2]

CSR_API ( CsrSrvUnusedFunction  )

Definition at line 593 of file server.c.

594{
595 UNREFERENCED_PARAMETER(ApiMessage);
596 UNREFERENCED_PARAMETER(ReplyCode);
597
598 /* Deprecated */
600}
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317

◆ CSR_SERVER_DLL_INIT()

CSR_SERVER_DLL_INIT ( CsrServerDllInitialization  )

Definition at line 87 of file server.c.

88{
89 /* Setup the DLL Object */
90 LoadedServerDll->ApiBase = CSRSRV_FIRST_API_NUMBER;
91 LoadedServerDll->HighestApiSupported = CsrpMaxApiNumber;
92 LoadedServerDll->DispatchTable = CsrServerApiDispatchTable;
93 LoadedServerDll->ValidTable = CsrServerApiServerValidTable;
94#ifdef CSR_DBG
95 LoadedServerDll->NameTable = CsrServerApiNameTable;
96#endif
97 LoadedServerDll->SizeOfProcessData = 0;
98 LoadedServerDll->ConnectCallback = NULL;
99 LoadedServerDll->DisconnectCallback = NULL;
100
101 /* All done */
102 return STATUS_SUCCESS;
103}
#define CSRSRV_FIRST_API_NUMBER
Definition: csrmsg.h:21
@ CsrpMaxApiNumber
Definition: csrmsg.h:31
#define NULL
Definition: types.h:112
BOOLEAN CsrServerApiServerValidTable[CsrpMaxApiNumber]
Definition: server.c:41
PCSR_API_ROUTINE CsrServerApiDispatchTable[CsrpMaxApiNumber]
Definition: server.c:27

◆ CsrLoadServerDll()

NTSTATUS NTAPI CsrLoadServerDll ( IN PCHAR  DllString,
IN PCHAR EntryPoint  OPTIONAL,
IN ULONG  ServerId 
)

Definition at line 126 of file server.c.

129{
131 ANSI_STRING DllName;
132 UNICODE_STRING TempString, ErrorString;
134 HANDLE hServerDll = NULL;
135 ULONG Size;
136 PCSR_SERVER_DLL ServerDll;
137 STRING EntryPointString;
138 PCSR_SERVER_DLL_INIT_CALLBACK ServerDllInitProcedure;
140
141 /* Check if it's beyond the maximum we support */
142 if (ServerId >= CSR_SERVER_DLL_MAX) return STATUS_TOO_MANY_NAMES;
143
144 /* Check if it's already been loaded */
145 if (CsrLoadedServerDll[ServerId]) return STATUS_INVALID_PARAMETER;
146
147 /* Convert the name to Unicode */
148 ASSERT(DllString != NULL);
149 RtlInitAnsiString(&DllName, DllString);
150 Status = RtlAnsiStringToUnicodeString(&TempString, &DllName, TRUE);
151 if (!NT_SUCCESS(Status)) return Status;
152
153 /* If we are loading ourselves, don't actually load us */
154 if (ServerId != CSRSRV_SERVERDLL_INDEX)
155 {
156 /* Load the DLL */
157 Status = LdrLoadDll(NULL, 0, &TempString, &hServerDll);
158 if (!NT_SUCCESS(Status))
159 {
160 /* Setup error parameters */
161 Parameters[0] = (ULONG_PTR)&TempString;
162 Parameters[1] = (ULONG_PTR)&ErrorString;
163 RtlInitUnicodeString(&ErrorString, L"Default Load Path");
164
165 /* Send a hard error */
167 2,
168 3,
170 OptionOk,
171 &Response);
172 }
173
174 /* Get rid of the string */
175 RtlFreeUnicodeString(&TempString);
176 if (!NT_SUCCESS(Status)) return Status;
177 }
178
179 /* Allocate a CSR DLL Object */
180 Size = sizeof(CSR_SERVER_DLL) + DllName.MaximumLength;
182 if (!ServerDll)
183 {
184 if (hServerDll) LdrUnloadDll(hServerDll);
185 return STATUS_NO_MEMORY;
186 }
187
188 /* Set up the Object */
189 ServerDll->Length = Size;
190 ServerDll->SizeOfProcessData = 0;
191 ServerDll->SharedSection = CsrSrvSharedSectionHeap; // Send to the server dll our shared heap pointer.
192 ServerDll->Name.Length = DllName.Length;
193 ServerDll->Name.MaximumLength = DllName.MaximumLength;
194 ServerDll->Name.Buffer = (PCHAR)(ServerDll + 1);
195 if (DllName.Length)
196 {
197 strncpy(ServerDll->Name.Buffer, DllName.Buffer, DllName.Length);
198 }
199 ServerDll->ServerId = ServerId;
200 ServerDll->ServerHandle = hServerDll;
201
202 /* Now get the entrypoint */
203 if (hServerDll)
204 {
205 /* Initialize a string for the entrypoint, or use the default */
206 RtlInitAnsiString(&EntryPointString,
207 EntryPoint ? EntryPoint : "ServerDllInitialization");
208
209 /* Get a pointer to it */
210 Status = LdrGetProcedureAddress(hServerDll,
211 &EntryPointString,
212 0,
213 (PVOID)&ServerDllInitProcedure);
214 }
215 else
216 {
217 /* No handle, so we are loading ourselves */
218#ifdef CSR_DBG
219 RtlInitAnsiString(&EntryPointString, "CsrServerDllInitialization");
220#endif
221 ServerDllInitProcedure = CsrServerDllInitialization;
223 }
224
225 /* Check if we got the pointer, and call it */
226 if (NT_SUCCESS(Status))
227 {
228 /* Call the Server DLL entrypoint */
230 {
231 Status = ServerDllInitProcedure(ServerDll);
232 }
234 {
236#ifdef CSR_DBG
237 DPRINT1("CSRSS: Exception 0x%lx while calling Server DLL entrypoint %Z!%Z()\n",
238 Status, &DllName, &EntryPointString);
239#endif
240 }
241 _SEH2_END;
242
243 if (NT_SUCCESS(Status))
244 {
245 /*
246 * Add this Server's Per-Process Data Size to the total that each
247 * process will need.
248 */
250
251 /* Save the pointer in our list */
252 CsrLoadedServerDll[ServerDll->ServerId] = ServerDll;
253
254 /* Does it use our generic heap? */
255 if (ServerDll->SharedSection != CsrSrvSharedSectionHeap)
256 {
257 /* No, save the pointer to its shared section in our list */
258 CsrSrvSharedStaticServerData[ServerDll->ServerId] = ServerDll->SharedSection;
259 }
260 }
261 }
262
263 if (!NT_SUCCESS(Status))
264 {
265 /* Server Init failed, unload it */
266 if (hServerDll) LdrUnloadDll(hServerDll);
267
268 /* Delete the Object */
269 RtlFreeHeap(CsrHeap, 0, ServerDll);
270 }
271
272 /* Return to caller */
273 return Status;
274}
char * strncpy(char *DstString, const char *SrcString, ACPI_SIZE Count)
Definition: utclib.c:427
#define DPRINT1
Definition: precomp.h:8
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
#define CSRSRV_SERVERDLL_INDEX
Definition: csrmsg.h:20
struct _CSR_SERVER_DLL CSR_SERVER_DLL
NTSTATUS(NTAPI * PCSR_SERVER_DLL_INIT_CALLBACK)(IN PCSR_SERVER_DLL LoadedServerDll)
Definition: csrsrv.h:253
#define TRUE
Definition: types.h:120
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define ULONG_PTR
Definition: config.h:101
#define _SEH2_END
Definition: filesup.c:22
#define _SEH2_TRY
Definition: filesup.c:19
std::wstring STRING
Definition: fontsub.cpp:33
NTSTATUS NTAPI NtRaiseHardError(IN NTSTATUS ErrorStatus, IN ULONG NumberOfParameters, IN ULONG UnicodeStringParameterMask, IN PULONG_PTR Parameters, IN ULONG ValidResponseOptions, OUT PULONG Response)
Definition: harderr.c:551
NTSTATUS NTAPI LdrUnloadDll(_In_ PVOID BaseAddress)
Definition: ldrapi.c:1291
NTSTATUS NTAPI DECLSPEC_HOTPATCH LdrLoadDll(_In_opt_ PWSTR SearchPath, _In_opt_ PULONG DllCharacteristics, _In_ PUNICODE_STRING DllName, _Out_ PVOID *BaseAddress)
Definition: ldrapi.c:312
NTSTATUS NTAPI LdrGetProcedureAddress(_In_ PVOID BaseAddress, _In_opt_ _When_(Ordinal==0, _Notnull_) PANSI_STRING Name, _In_opt_ _When_(Name==NULL, _In_range_(>, 0)) ULONG Ordinal, _Out_ PVOID *ProcedureAddress)
Definition: ldrapi.c:789
#define PCHAR
Definition: match.c:90
#define ASSERT(a)
Definition: mode.c:44
@ OptionOk
Definition: extypes.h:187
NTSYSAPI NTSTATUS NTAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING DestinationString, PANSI_STRING SourceString, BOOLEAN AllocateDestinationString)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
NTSYSAPI VOID NTAPI RtlInitAnsiString(PANSI_STRING DestinationString, PCSZ SourceString)
#define STATUS_NO_MEMORY
Definition: ntstatus.h:260
#define L(x)
Definition: ntvdm.h:50
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_GetExceptionInformation()
Definition: pseh2_64.h:164
Definition: ncftp.h:89
USHORT MaximumLength
Definition: env_spec_w32.h:377
ANSI_STRING Name
Definition: csrsrv.h:218
PVOID SharedSection
Definition: csrsrv.h:238
ULONG ServerId
Definition: csrsrv.h:220
ULONG Length
Definition: csrsrv.h:217
HANDLE ServerHandle
Definition: csrsrv.h:219
ULONG SizeOfProcessData
Definition: csrsrv.h:234
ULONG CsrTotalPerProcessDataLength
Definition: init.c:39
NTSTATUS NTAPI CsrServerDllInitialization(IN PCSR_SERVER_DLL LoadedServerDll)
HANDLE CsrHeap
Definition: init.c:25
EXCEPTION_DISPOSITION NTAPI CsrUnhandledExceptionFilter(IN PEXCEPTION_POINTERS ExceptionInfo)
Definition: server.c:643
PVOID CsrSrvSharedSectionHeap
Definition: server.c:21
PVOID * CsrSrvSharedStaticServerData
Definition: server.c:23
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFDEVICE _In_ PWDF_DEVICE_PROPERTY_DATA _In_ DEVPROPTYPE _In_ ULONG Size
Definition: wdfdevice.h:4533
_Must_inspect_result_ _In_ WDFQUEUE _In_opt_ WDFREQUEST _In_opt_ WDFFILEOBJECT _Inout_opt_ PWDF_REQUEST_PARAMETERS Parameters
Definition: wdfio.h:869

Referenced by CsrParseServerCommandLine().

◆ CsrSetCallingSpooler()

VOID NTAPI CsrSetCallingSpooler ( ULONG  Reserved)

Definition at line 620 of file server.c.

621{
622 /* Deprecated */
623 return;
624}

◆ CsrSrvAttachSharedSection()

NTSTATUS NTAPI CsrSrvAttachSharedSection ( IN PCSR_PROCESS CsrProcess  OPTIONAL,
OUT PCSR_API_CONNECTINFO  ConnectInfo 
)

Definition at line 482 of file server.c.

484{
486 SIZE_T ViewSize = 0;
487
488 /* Check if we have a process */
489 if (CsrProcess)
490 {
491 /* Map the section into this process */
493 CsrProcess->ProcessHandle,
495 0,
496 0,
497 NULL,
498 &ViewSize,
499 ViewUnmap,
502 if (!NT_SUCCESS(Status)) return Status;
503 }
504
505 /* Write the values in the Connection Info structure */
506 ConnectInfo->SharedSectionBase = CsrSrvSharedSectionBase;
507 ConnectInfo->SharedSectionHeap = CsrSrvSharedSectionHeap;
508 ConnectInfo->SharedStaticServerData = CsrSrvSharedStaticServerData;
509
510 /* Return success */
511 return STATUS_SUCCESS;
512}
NTSTATUS NTAPI NtMapViewOfSection(IN HANDLE SectionHandle, IN HANDLE ProcessHandle, IN OUT PVOID *BaseAddress, IN ULONG_PTR ZeroBits, IN SIZE_T CommitSize, IN OUT PLARGE_INTEGER SectionOffset OPTIONAL, IN OUT PSIZE_T ViewSize, IN SECTION_INHERIT InheritDisposition, IN ULONG AllocationType, IN ULONG Protect)
Definition: section.c:3255
_In_ HANDLE _Outptr_result_bytebuffer_ ViewSize PVOID _In_ ULONG_PTR _In_ SIZE_T _Inout_opt_ PLARGE_INTEGER _Inout_ PSIZE_T ViewSize
Definition: mmfuncs.h:408
#define SEC_NO_CHANGE
Definition: mmtypes.h:95
#define PAGE_EXECUTE_READ
Definition: nt_native.h:1307
@ ViewUnmap
Definition: nt_native.h:1279
HANDLE CsrSrvSharedSection
Definition: server.c:25
PVOID CsrSrvSharedSectionBase
Definition: server.c:22
ULONG_PTR SIZE_T
Definition: typedefs.h:80
PKPROCESS CsrProcess
Definition: videoprt.c:39

Referenced by CsrApiHandleConnectionRequest().

◆ CsrSrvCreateSharedSection()

NTSTATUS NTAPI CsrSrvCreateSharedSection ( IN PCHAR  ParameterValue)

Definition at line 361 of file server.c.

362{
363 PCHAR SizeValue = ParameterValue;
364 ULONG Size;
366 LARGE_INTEGER SectionSize;
367 SIZE_T ViewSize = 0;
369
370 /* If there's no parameter, fail */
372
373 /* Find the first comma, and null terminate */
374 while (*SizeValue)
375 {
376 if (*SizeValue == ',')
377 {
378 *SizeValue++ = ANSI_NULL;
379 break;
380 }
381 else
382 {
383 SizeValue++;
384 }
385 }
386
387 /* Make sure it's valid */
388 if (!*SizeValue) return STATUS_INVALID_PARAMETER;
389
390 /* Convert it to an integer */
391 Status = RtlCharToInteger(SizeValue, 0, &Size);
392 if (!NT_SUCCESS(Status)) return Status;
393
394 /* Multiply by 1024 entries and round to page size */
396
397 /* Create the Secion */
398 SectionSize.LowPart = CsrSrvSharedSectionSize;
399 SectionSize.HighPart = 0;
402 NULL,
403 &SectionSize,
406 NULL);
407 if (!NT_SUCCESS(Status)) return Status;
408
409 /* Map the section */
413 0,
414 0,
415 NULL,
416 &ViewSize,
417 ViewUnmap,
420 if (!NT_SUCCESS(Status))
421 {
422 /* Fail */
424 return Status;
425 }
426
427 /* FIXME: Write the value to registry */
428
429 /* The Heap is the same place as the Base */
431
432 /* Create the heap */
436 PAGE_SIZE,
437 0,
438 0)))
439 {
440 /* Failure, unmap section and return */
443 return STATUS_NO_MEMORY;
444 }
445
446 /* Now allocate space from the heap for the Shared Data */
449 CSR_SERVER_DLL_MAX * sizeof(PVOID));
451
452 /* Write the values to the PEB */
456
457 /* Return */
458 return STATUS_SUCCESS;
459}
NTSTATUS NTAPI NtUnmapViewOfSection(IN HANDLE ProcessHandle, IN PVOID BaseAddress)
Definition: section.c:3481
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:3074
#define NtCurrentPeb()
Definition: FLS.c:22
_In_opt_ PWSTR _In_ PWSTR _Inout_ PULONG ParameterValue
Definition: cdrom.h:963
PPEB Peb
Definition: dllmain.c:27
#define PAGE_SIZE
Definition: env_spec_w32.h:49
#define ROUND_UP(n, align)
Definition: eventvwr.h:34
#define MEM_TOP_DOWN
Definition: nt_native.h:1321
#define HEAP_CLASS_7
Definition: nt_native.h:1717
#define SECTION_ALL_ACCESS
Definition: nt_native.h:1293
#define SEC_RESERVE
Definition: nt_native.h:1323
NTSYSAPI PVOID NTAPI RtlCreateHeap(IN ULONG Flags, IN PVOID HeapBase OPTIONAL, IN ULONG ReserveSize OPTIONAL, IN ULONG CommitSize OPTIONAL, IN PVOID Lock OPTIONAL, IN PRTL_HEAP_PARAMETERS Parameters OPTIONAL)
#define NtCurrentProcess()
Definition: nt_native.h:1657
NTSTATUS NTAPI NtClose(IN HANDLE Handle)
Definition: obhandle.c:3402
NTSYSAPI NTSTATUS NTAPI RtlCharToInteger(PCSZ String, ULONG Base, PULONG Value)
Definition: unicode.c:261
#define PAGE_EXECUTE_READWRITE
Definition: nt_native.h:1308
#define ANSI_NULL
#define SEC_BASED
PVOID ReadOnlySharedMemoryHeap
Definition: ntddk_ex.h:262
PVOID ReadOnlySharedMemoryBase
Definition: ntddk_ex.h:261
PVOID * ReadOnlyStaticServerData
Definition: ntddk_ex.h:263
SYSTEM_BASIC_INFORMATION CsrNtSysInfo
Definition: init.c:44
ULONG CsrSrvSharedSectionSize
Definition: server.c:24
char * PCHAR
Definition: typedefs.h:51
ULONG LowPart
Definition: typedefs.h:106

Referenced by CsrParseServerCommandLine().

◆ CsrUnhandledExceptionFilter()

EXCEPTION_DISPOSITION NTAPI CsrUnhandledExceptionFilter ( IN PEXCEPTION_POINTERS  ExceptionInfo)

Definition at line 643 of file server.c.

644{
647 BOOLEAN OldValue;
649 UNICODE_STRING ErrorSource;
650 ULONG_PTR ErrorParameters[4];
652
653 DPRINT1("CsrUnhandledExceptionFilter called\n");
654
655 /* Check if a debugger is installed */
657 &DebuggerInfo,
658 sizeof(DebuggerInfo),
659 NULL);
660
661 /* Check if this is Session 0, and the Debugger is Enabled */
662 if ((NtCurrentPeb()->SessionId != 0) && (NT_SUCCESS(Status)) &&
663 (DebuggerInfo.KernelDebuggerEnabled))
664 {
665 /* Call the Unhandled Exception Filter */
666 Result = RtlUnhandledExceptionFilter(ExceptionInfo);
668 {
669 /* We're going to raise an error. Get Shutdown Privilege first */
671 TRUE,
672 TRUE,
673 &OldValue);
674
675 /* Use the Process token if that failed */
676 if (Status == STATUS_NO_TOKEN)
677 {
679 TRUE,
680 FALSE,
681 &OldValue);
682 }
683 if (!NT_SUCCESS(Status))
684 {
685 DPRINT1("CsrUnhandledExceptionFilter(): RtlAdjustPrivilege(SE_SHUTDOWN_PRIVILEGE) failed, Status = 0x%08lx\n", Status);
686 goto NoPrivilege;
687 }
688
689 /* Initialize our Name String */
690 RtlInitUnicodeString(&ErrorSource, L"Windows SubSystem");
691
692 /* Set the parameters */
693 ErrorParameters[0] = (ULONG_PTR)&ErrorSource;
694 ErrorParameters[1] = ExceptionInfo->ExceptionRecord->ExceptionCode;
695 ErrorParameters[2] = (ULONG_PTR)ExceptionInfo->ExceptionRecord->ExceptionAddress;
696 ErrorParameters[3] = (ULONG_PTR)ExceptionInfo->ContextRecord;
697
698 /* Bugcheck */
700 4,
701 1,
702 ErrorParameters,
704 &Response);
705 }
706
707NoPrivilege:
708 /* Just terminate us */
710 ExceptionInfo->ExceptionRecord->ExceptionCode);
711 }
712
713 return Result;
714}
unsigned char BOOLEAN
#define FALSE
Definition: types.h:117
enum _EXCEPTION_DISPOSITION EXCEPTION_DISPOSITION
ULONG SessionId
Definition: dllmain.c:28
@ SystemKernelDebuggerInformation
Definition: ntddk_ex.h:46
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define EXCEPTION_CONTINUE_EXECUTION
Definition: excpt.h:87
#define SE_SHUTDOWN_PRIVILEGE
Definition: security.c:673
@ OptionShutdownSystem
Definition: extypes.h:192
NTSYSAPI NTSTATUS NTAPI RtlAdjustPrivilege(_In_ ULONG Privilege, _In_ BOOLEAN NewValue, _In_ BOOLEAN ForThread, _Out_ PBOOLEAN OldValue)
NTSTATUS NTAPI NtTerminateProcess(HANDLE ProcessHandle, LONG ExitStatus)
#define STATUS_NO_TOKEN
Definition: ntstatus.h:360
#define STATUS_SYSTEM_PROCESS_TERMINATED
Definition: ntstatus.h:670
LONG NTAPI RtlUnhandledExceptionFilter(IN struct _EXCEPTION_POINTERS *ExceptionInfo)
Definition: exception.c:313
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409

Referenced by CsrApiRequestThread(), and CsrLoadServerDll().

Variable Documentation

◆ CsrLoadedServerDll

◆ CsrServerApiDispatchTable

PCSR_API_ROUTINE CsrServerApiDispatchTable[CsrpMaxApiNumber]
Initial value:
=
{
CsrSrvClientConnect,
CsrSrvUnusedFunction,
CsrSrvUnusedFunction,
CsrSrvUnusedFunction,
CsrSrvUnusedFunction
}

Definition at line 27 of file server.c.

Referenced by CSR_SERVER_DLL_INIT().

◆ CsrServerApiServerValidTable

BOOLEAN CsrServerApiServerValidTable[CsrpMaxApiNumber]
Initial value:

Definition at line 41 of file server.c.

Referenced by CSR_SERVER_DLL_INIT().

◆ CsrSrvSharedSection

HANDLE CsrSrvSharedSection = NULL

Definition at line 25 of file server.c.

Referenced by CsrSrvAttachSharedSection(), and CsrSrvCreateSharedSection().

◆ CsrSrvSharedSectionBase

PVOID CsrSrvSharedSectionBase = NULL

Definition at line 22 of file server.c.

Referenced by CsrSrvAttachSharedSection(), and CsrSrvCreateSharedSection().

◆ CsrSrvSharedSectionHeap

PVOID CsrSrvSharedSectionHeap = NULL

Definition at line 21 of file server.c.

Referenced by CsrLoadServerDll(), CsrSrvAttachSharedSection(), and CsrSrvCreateSharedSection().

◆ CsrSrvSharedSectionSize

ULONG CsrSrvSharedSectionSize = 0

Definition at line 24 of file server.c.

Referenced by CsrSrvCreateSharedSection().

◆ CsrSrvSharedStaticServerData

PVOID* CsrSrvSharedStaticServerData = NULL

Definition at line 23 of file server.c.

Referenced by CsrLoadServerDll(), CsrSrvAttachSharedSection(), and CsrSrvCreateSharedSection().