3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS kernel
5 * PURPOSE: Interface to csrss
6 * FILE: subsys/win32k/ntuser/csr.c
7 * PROGRAMER: Ge van Geldorp (ge@gse.nl)
12 static HANDLE WindowsApiPort
= NULL
;
13 PEPROCESS CsrProcess
= NULL
;
19 UNICODE_STRING PortName
;
20 ULONG ConnectInfoLength
;
22 RtlInitUnicodeString(&PortName
, L
"\\Windows\\ApiPort");
23 ConnectInfoLength
= 0;
24 Status
= ZwConnectPort(&WindowsApiPort
,
32 if (! NT_SUCCESS(Status
))
37 CsrProcess
= PsGetCurrentProcess();
39 return STATUS_SUCCESS
;
44 CsrNotify(PCSRSS_API_REQUEST Request
, PCSRSS_API_REPLY Reply
)
49 if (NULL
== CsrProcess
)
51 return STATUS_INVALID_PORT_HANDLE
;
54 Request
->Header
.DataSize
= sizeof(CSRSS_API_REQUEST
) - LPC_MESSAGE_BASE_SIZE
;
55 Request
->Header
.MessageSize
= sizeof(CSRSS_API_REQUEST
);
57 /* Switch to the process in which the WindowsApiPort handle is valid */
58 OldProcess
= PsGetCurrentProcess();
59 if (CsrProcess
!= OldProcess
)
61 KeAttachProcess(CsrProcess
);
63 Status
= ZwRequestWaitReplyPort(WindowsApiPort
,
66 if (CsrProcess
!= OldProcess
)
71 if (NT_SUCCESS(Status
))
73 Status
= Reply
->Status
;
80 CsrInsertObject(PVOID Object
,
81 PACCESS_STATE PassedAccessState
,
82 ACCESS_MASK DesiredAccess
,
83 ULONG AdditionalReferences
,
84 PVOID
* ReferencedObject
,
90 /* Switch to the process in which the handle is valid */
91 OldProcess
= PsGetCurrentProcess();
92 if (CsrProcess
!= OldProcess
)
94 KeAttachProcess(CsrProcess
);
97 Status
= ObInsertObject(Object
,
100 AdditionalReferences
,
104 if (CsrProcess
!= OldProcess
)
113 CsrCloseHandle(HANDLE Handle
)
116 PEPROCESS OldProcess
;
118 /* Switch to the process in which the handle is valid */
119 OldProcess
= PsGetCurrentProcess();
120 if (CsrProcess
!= OldProcess
)
122 KeAttachProcess(CsrProcess
);
125 Status
= ZwClose(Handle
);
127 if (CsrProcess
!= OldProcess
)