[CSRSRV]
[reactos.git] / subsystems / win32 / csrsrv / server.c
index 8954c4d..c20ec56 100644 (file)
@@ -1,19 +1,19 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
- * PROJECT:         ReactOS CSR SubSystem
- * FILE:            subsystems/win32/csrss/csrsrv/server.c
+ * PROJECT:         ReactOS Client/Server Runtime SubSystem
+ * FILE:            subsystems/win32/csrsrv/server.c
  * PURPOSE:         CSR Server DLL Server Functions
  * PROGRAMMERS:     Alex Ionescu (alex@relsoft.net)
  */
 
-/* INCLUDES ******************************************************************/
+/* INCLUDES *******************************************************************/
 
 #include "srv.h"
 
 #define NDEBUG
 #include <debug.h>
 
-/* DATA **********************************************************************/
+/* DATA ***********************************************************************/
 
 PCSR_API_ROUTINE CsrServerApiDispatchTable[CsrpMaxApiNumber] =
 {
@@ -49,7 +49,7 @@ PVOID *CsrSrvSharedStaticServerData;
 ULONG CsrSrvSharedSectionSize;
 HANDLE CsrSrvSharedSection;
 
-/* PRIVATE FUNCTIONS**********************************************************/
+/* PRIVATE FUNCTIONS **********************************************************/
 
 /*++
  * @name CsrServerDllInitialization
@@ -119,6 +119,8 @@ CsrLoadServerDll(IN PCHAR DllString,
     PCSR_SERVER_DLL_INIT_CALLBACK ServerDllInitProcedure;
     ULONG Response;
 
+    DPRINT1("CsrLoadServerDll(%s, 0x%p, %lu)\n", DllString, EntryPoint, ServerId);
+
     /* Check if it's beyond the maximum we support */
     if (ServerId >= CSR_SERVER_DLL_MAX) return STATUS_TOO_MANY_NAMES;
 
@@ -222,14 +224,6 @@ CsrLoadServerDll(IN PCHAR DllString,
                 /* No, save the pointer to its shared section in our list */
                 CsrSrvSharedStaticServerData[ServerDll->ServerId] = ServerDll->SharedSection;
             }
-
-#if 0 /* HACK: ReactOS Specific hax. REMOVE IT. */
-            if (ServerDll->HighestApiSupported == 0xDEADBABE)
-            {
-                // CSRSS_API_DEFINITIONS == Old structure.
-                Status = CsrApiRegisterDefinitions((PVOID)ServerDll->DispatchTable);
-            }
-#endif
         }
         else
         {
@@ -259,7 +253,7 @@ LoadFailed:
  * @param ApiMessage
  *        Pointer to the CSR API Message for this request.
  *
- * @param Reply
+ * @param ReplyCode
  *        Optional reply to this request.
  *
  * @return STATUS_SUCCESS in case of success, STATUS_INVALID_PARAMETER
@@ -268,19 +262,15 @@ LoadFailed:
  * @remarks None.
  *
  *--*/
-NTSTATUS
-NTAPI
-CsrSrvClientConnect(IN OUT PCSR_API_MESSAGE ApiMessage,
-                    IN OUT PULONG Reply OPTIONAL)
+CSR_API(CsrSrvClientConnect)
 {
     NTSTATUS Status;
-    PCSR_CLIENT_CONNECT ClientConnect;
+    PCSR_CLIENT_CONNECT ClientConnect = &ApiMessage->Data.CsrClientConnect;
     PCSR_SERVER_DLL ServerDll;
     PCSR_PROCESS CurrentProcess = CsrGetClientThread()->Process;
 
-    /* Load the Message, set default reply */
-    ClientConnect = &ApiMessage->Data.CsrClientConnect;
-    *Reply = 0;
+    /* Set default reply */
+    *ReplyCode = CsrReplyImmediately;
 
     /* Validate the ServerID */
     if (ClientConnect->ServerId >= CSR_SERVER_DLL_MAX)
@@ -294,9 +284,9 @@ CsrSrvClientConnect(IN OUT PCSR_API_MESSAGE ApiMessage,
 
     /* Validate the Message Buffer */
     if (!(CsrValidateMessageBuffer(ApiMessage,
-                                   ClientConnect->ConnectionInfo,
+                                   &ClientConnect->ConnectionInfo,
                                    ClientConnect->ConnectionInfoSize,
-                                   1)))
+                                   sizeof(BYTE))))
     {
         /* Fail due to buffer overflow or other invalid buffer */
         return STATUS_INVALID_PARAMETER;
@@ -428,9 +418,8 @@ CsrSrvCreateSharedSection(IN PCHAR ParameterValue)
 
     /* Now allocate space from the heap for the Shared Data */
     CsrSrvSharedStaticServerData = RtlAllocateHeap(CsrSrvSharedSectionHeap,
-                                                   0,
-                                                   CSR_SERVER_DLL_MAX *
-                                                   sizeof(PVOID));
+                                                   HEAP_ZERO_MEMORY,
+                                                   CSR_SERVER_DLL_MAX * sizeof(PVOID));
     if (!CsrSrvSharedStaticServerData) return STATUS_NO_MEMORY;
 
     /* Write the values to the PEB */
@@ -506,7 +495,7 @@ CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
  * @param ApiMessage
  *        Pointer to the CSR API Message for this request.
  *
- * @param Reply
+ * @param ReplyCode
  *        Pointer to an optional reply to this request.
  *
  * @return STATUS_SUCCESS.
@@ -514,15 +503,12 @@ CsrSrvAttachSharedSection(IN PCSR_PROCESS CsrProcess OPTIONAL,
  * @remarks None.
  *
  *--*/
-NTSTATUS
-NTAPI
-CsrSrvIdentifyAlertableThread(IN OUT PCSR_API_MESSAGE ApiMessage,
-                              IN OUT PULONG Reply)
+CSR_API(CsrSrvIdentifyAlertableThread)
 {
     PCSR_THREAD CsrThread = CsrGetClientThread();
 
     /* Set the alertable flag */
-    CsrThread->Flags |= CsrThreadAltertable;
+    CsrThread->Flags |= CsrThreadAlertable;
 
     /* Return success */
     return STATUS_SUCCESS;
@@ -537,7 +523,7 @@ CsrSrvIdentifyAlertableThread(IN OUT PCSR_API_MESSAGE ApiMessage,
  * @param ApiMessage
  *        Pointer to the CSR API Message for this request.
  *
- * @param Reply
+ * @param ReplyCode
  *        Pointer to an optional reply to this request.
  *
  * @return STATUS_SUCCESS.
@@ -545,10 +531,7 @@ CsrSrvIdentifyAlertableThread(IN OUT PCSR_API_MESSAGE ApiMessage,
  * @remarks None.
  *
  *--*/
-NTSTATUS
-NTAPI
-CsrSrvSetPriorityClass(IN OUT PCSR_API_MESSAGE ApiMessage,
-                       IN OUT PULONG Reply)
+CSR_API(CsrSrvSetPriorityClass)
 {
     /* Deprecated */
     return STATUS_SUCCESS;
@@ -565,7 +548,7 @@ CsrSrvSetPriorityClass(IN OUT PCSR_API_MESSAGE ApiMessage,
  * @param ApiMessage
  *        Pointer to the CSR API Message for this request.
  *
- * @param Reply
+ * @param ReplyCode
  *        Pointer to an optional reply to this request.
  *
  * @return STATUS_INVALID_PARAMETER.
@@ -574,16 +557,13 @@ CsrSrvSetPriorityClass(IN OUT PCSR_API_MESSAGE ApiMessage,
  *          return success.
  *
  *--*/
-NTSTATUS
-NTAPI
-CsrSrvUnusedFunction(IN OUT PCSR_API_MESSAGE ApiMessage,
-                     IN OUT PULONG Reply)
+CSR_API(CsrSrvUnusedFunction)
 {
     /* Deprecated */
     return STATUS_INVALID_PARAMETER;
 }
 
-/* PUBLIC FUNCTIONS***********************************************************/
+/* PUBLIC FUNCTIONS ***********************************************************/
 
 /*++
  * @name CsrSetCallingSpooler