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(PCSR_API_MESSAGE Request
)
49 if (NULL
== CsrProcess
)
51 return STATUS_INVALID_PORT_HANDLE
;
54 Request
->Header
.DataSize
= sizeof(CSR_API_MESSAGE
) - LPC_MESSAGE_BASE_SIZE
;
55 Request
->Header
.MessageSize
= sizeof(CSR_API_MESSAGE
);
57 /* Switch to the process in which the WindowsApiPort handle is valid */
58 OldProcess
= PsGetCurrentProcess();
59 if (CsrProcess
!= OldProcess
)
61 KeAttachProcess(EPROCESS_TO_KPROCESS(CsrProcess
));
63 Status
= ZwRequestWaitReplyPort(WindowsApiPort
,
66 if (CsrProcess
!= OldProcess
)
71 if (NT_SUCCESS(Status
))
73 Status
= Request
->Status
;
81 CsrInsertObject(HANDLE ObjectHandle
,
82 ACCESS_MASK DesiredAccess
,
86 HANDLE CsrProcessHandle
;
87 OBJECT_ATTRIBUTES ObjectAttributes
;
91 Cid
.UniqueProcess
= CsrProcess
->UniqueProcessId
;
94 /* Empty Attributes */
95 InitializeObjectAttributes(&ObjectAttributes
,
101 /* Get a Handle to Csrss */
102 Status
= ZwOpenProcess(&CsrProcessHandle
,
107 if ((NT_SUCCESS(Status
)))
109 /* Duplicate the Handle */
110 Status
= ZwDuplicateObject(NtCurrentProcess(),
118 /* Close our handle to CSRSS */
119 ZwClose(CsrProcessHandle
);
126 CsrCloseHandle(HANDLE Handle
)
129 PEPROCESS OldProcess
;
131 /* Switch to the process in which the handle is valid */
132 OldProcess
= PsGetCurrentProcess();
133 if (CsrProcess
!= OldProcess
)
135 KeAttachProcess(EPROCESS_TO_KPROCESS(CsrProcess
));
138 Status
= ZwClose(Handle
);
140 if (CsrProcess
!= OldProcess
)