ReactOS  0.4.11-dev-721-g95bc44e
csr.c File Reference
#include <win32k.h>
Include dependency graph for csr.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (UserCsr)
 
VOID InitCsrProcess (VOID)
 
VOID ResetCsrProcess (VOID)
 
NTSTATUS InitCsrApiPort (IN HANDLE CsrPortHandle)
 
VOID ResetCsrApiPort (VOID)
 
NTSTATUS NTAPI CsrClientCallServer (IN OUT PCSR_API_MESSAGE ApiMessage, IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer OPTIONAL, IN CSR_API_NUMBER ApiNumber, IN ULONG DataLength)
 

Variables

PEPROCESS gpepCSRSS = NULL
 
PVOID CsrApiPort = NULL
 

Function Documentation

NTSTATUS NTAPI CsrClientCallServer ( IN OUT PCSR_API_MESSAGE  ApiMessage,
IN OUT PCSR_CAPTURE_BUFFER CaptureBuffer  OPTIONAL,
IN CSR_API_NUMBER  ApiNumber,
IN ULONG  DataLength 
)

Definition at line 73 of file csr.c.

77 {
79 #if 0
80  ULONG PointerCount;
81  PULONG_PTR OffsetPointer;
82 #endif
83 
84  /* Do we have a connection to CSR yet? */
85  if (!CsrApiPort)
87 
88  /* Fill out the Port Message Header */
89  ApiMessage->Header.u2.ZeroInit = 0;
90  ApiMessage->Header.u1.s1.TotalLength = FIELD_OFFSET(CSR_API_MESSAGE, Data) + DataLength;
91  ApiMessage->Header.u1.s1.DataLength = ApiMessage->Header.u1.s1.TotalLength -
92  sizeof(ApiMessage->Header);
93 
94  /* Fill out the CSR Header */
95  ApiMessage->ApiNumber = ApiNumber;
96  ApiMessage->CsrCaptureData = NULL;
97 
98  TRACE("API: %lx, u1.s1.DataLength: %x, u1.s1.TotalLength: %x\n",
99  ApiNumber,
100  ApiMessage->Header.u1.s1.DataLength,
101  ApiMessage->Header.u1.s1.TotalLength);
102 
103 #if 0
104  /* Check if we got a Capture Buffer */
105  if (CaptureBuffer)
106  {
107  /*
108  * We have to convert from our local (client) view
109  * to the remote (server) view.
110  */
111  ApiMessage->CsrCaptureData = (PCSR_CAPTURE_BUFFER)
112  ((ULONG_PTR)CaptureBuffer + CsrPortMemoryDelta);
113 
114  /* Lock the buffer. */
115  CaptureBuffer->BufferEnd = NULL;
116 
117  /*
118  * Each client pointer inside the CSR message is converted into
119  * a server pointer, and each pointer to these message pointers
120  * is converted into an offset.
121  */
122  PointerCount = CaptureBuffer->PointerCount;
123  OffsetPointer = CaptureBuffer->PointerOffsetsArray;
124  while (PointerCount--)
125  {
126  if (*OffsetPointer != 0)
127  {
128  *(PULONG_PTR)*OffsetPointer += CsrPortMemoryDelta;
129  *OffsetPointer -= (ULONG_PTR)ApiMessage;
130  }
131  ++OffsetPointer;
132  }
133  }
134 #endif
135 
136  UserLeaveCo();
137 
138  /* Send the LPC Message */
139 
140  // The wait logic below is subject to change in the future. One can
141  // imagine adding an external parameter to CsrClientCallServer, or write
142  // two versions of CsrClientCallServer, synchronous and asynchronous.
144  {
145  Status = LpcRequestPort(CsrApiPort,
146  &ApiMessage->Header);
147  }
148  else
149  {
151  &ApiMessage->Header,
152  &ApiMessage->Header);
153  }
154 
155  UserEnterCo();
156 
157 #if 0
158  /* Check if we got a Capture Buffer */
159  if (CaptureBuffer)
160  {
161  /*
162  * We have to convert back from the remote (server) view
163  * to our local (client) view.
164  */
165  ApiMessage->CsrCaptureData = (PCSR_CAPTURE_BUFFER)
166  ((ULONG_PTR)ApiMessage->CsrCaptureData - CsrPortMemoryDelta);
167 
168  /*
169  * Convert back the offsets into pointers to CSR message
170  * pointers, and convert back these message server pointers
171  * into client pointers.
172  */
173  PointerCount = CaptureBuffer->PointerCount;
174  OffsetPointer = CaptureBuffer->PointerOffsetsArray;
175  while (PointerCount--)
176  {
177  if (*OffsetPointer != 0)
178  {
179  *OffsetPointer += (ULONG_PTR)ApiMessage;
180  *(PULONG_PTR)*OffsetPointer -= CsrPortMemoryDelta;
181  }
182  ++OffsetPointer;
183  }
184  }
185 #endif
186 
187  /* Check for success */
188  if (!NT_SUCCESS(Status))
189  {
190  /* We failed. Overwrite the return value with the failure. */
191  ERR("LPC Failed: %lx\n", Status);
192  ApiMessage->Status = Status;
193  }
194 
195  /* Return the CSR Result */
196  TRACE("Got back: 0x%lx\n", ApiMessage->Status);
197  return ApiMessage->Status;
198 }
PEPROCESS gpepCSRSS
Definition: csr.c:15
NTSTATUS NTAPI LpcRequestWaitReplyPort(IN PVOID PortObject, IN PPORT_MESSAGE LpcRequest, OUT PPORT_MESSAGE LpcReply)
Definition: send.c:178
#define STATUS_INVALID_PORT_HANDLE
Definition: ntstatus.h:288
uint32_t ULONG_PTR
Definition: typedefs.h:63
PVOID CsrApiPort
Definition: csr.c:16
#define UserLeaveCo
Definition: ntuser.h:10
#define PsGetCurrentProcess
Definition: psfuncs.h:17
smooth NULL
Definition: ftsmooth.c:416
struct _CSR_CAPTURE_BUFFER * PCSR_CAPTURE_BUFFER
NTSTATUS NTAPI LpcRequestPort(IN PVOID PortObject, IN PPORT_MESSAGE LpcMessage)
Definition: send.c:22
#define TRACE(s)
Definition: solgame.cpp:4
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define UserEnterCo
Definition: ntuser.h:9
ULONG_PTR CsrPortMemoryDelta
Definition: connect.c:24
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
unsigned int ULONG
Definition: retypes.h:1
#define ULONG_PTR
Definition: config.h:101
uint32_t * PULONG_PTR
Definition: typedefs.h:63
_Must_inspect_result_ _Out_writes_to_ DataLength PHIDP_DATA _Inout_ PULONG DataLength
Definition: hidpi.h:333
DBG_DEFAULT_CHANNEL ( UserCsr  )
NTSTATUS InitCsrApiPort ( IN HANDLE  CsrPortHandle)

Definition at line 37 of file csr.c.

Referenced by NtUserSetInformationThread().

38 {
40 
41  Status = ObReferenceObjectByHandle(CsrPortHandle,
42  0,
43  /* * */LpcPortObjectType, // or NULL,
44  UserMode,
45  &CsrApiPort,
46  NULL);
47  if (!NT_SUCCESS(Status))
48  {
49  CsrApiPort = NULL;
50  ERR("Failed to set CSR API Port.\n");
51  }
52 
53  return Status;
54 }
NTSTATUS NTAPI ObReferenceObjectByHandle(IN HANDLE Handle, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode, OUT PVOID *Object, OUT POBJECT_HANDLE_INFORMATION HandleInformation OPTIONAL)
Definition: obref.c:496
PVOID CsrApiPort
Definition: csr.c:16
smooth NULL
Definition: ftsmooth.c:416
POBJECT_TYPE LpcPortObjectType
Definition: port.c:17
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
Status
Definition: gdiplustypes.h:24
#define ERR(fmt,...)
Definition: debug.h:109
VOID InitCsrProcess ( VOID  )

Definition at line 19 of file csr.c.

Referenced by NtUserInitialize().

20 {
21  /* Save the EPROCESS of CSRSS */
23  // gpepCSRSS = CsrProcess;
25 }
PEPROCESS gpepCSRSS
Definition: csr.c:15
#define PsGetCurrentProcess
Definition: psfuncs.h:17
#define ObReferenceObject
Definition: obfuncs.h:204
VOID ResetCsrApiPort ( VOID  )

Definition at line 57 of file csr.c.

Referenced by _Function_class_().

58 {
59  if (CsrApiPort)
61 
62  CsrApiPort = NULL;
63 }
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
PVOID CsrApiPort
Definition: csr.c:16
smooth NULL
Definition: ftsmooth.c:416
VOID ResetCsrProcess ( VOID  )

Definition at line 28 of file csr.c.

Referenced by _Function_class_().

29 {
30  if (gpepCSRSS)
32 
33  gpepCSRSS = NULL;
34 }
PEPROCESS gpepCSRSS
Definition: csr.c:15
VOID NTAPI ObDereferenceObject(IN PVOID Object)
Definition: obref.c:375
smooth NULL
Definition: ftsmooth.c:416

Variable Documentation

PVOID CsrApiPort = NULL

Definition at line 16 of file csr.c.

Referenced by CsrClientCallServer(), InitCsrApiPort(), and ResetCsrApiPort().