Sync to trunk head (r42241)
[reactos.git] / reactos / subsystems / win32 / csrss / api / wapi.c
index 69dd48c..739ac77 100644 (file)
@@ -70,7 +70,6 @@ FASTCALL
 CsrApiCallHandler(PCSRSS_PROCESS_DATA ProcessData,
                   PCSR_API_MESSAGE Request)
 {
-  BOOL Found = FALSE;
   unsigned DefIndex;
   ULONG Type;
 
@@ -79,7 +78,7 @@ CsrApiCallHandler(PCSRSS_PROCESS_DATA ProcessData,
   DPRINT("CSR: API Number: %x ServerID: %x\n",Type, Request->Type >> 16);
 
   /* FIXME: Extract DefIndex instead of looping */
-  for (DefIndex = 0; ! Found && DefIndex < ApiDefinitionsCount; DefIndex++)
+  for (DefIndex = 0; DefIndex < ApiDefinitionsCount; DefIndex++)
     {
       if (ApiDefinitions[DefIndex].Type == Type)
         {
@@ -92,21 +91,20 @@ CsrApiCallHandler(PCSRSS_PROCESS_DATA ProcessData,
             }
           else
             {
-              (ApiDefinitions[DefIndex].Handler)(ProcessData, Request);
-              Found = TRUE;
+              Request->Status = (ApiDefinitions[DefIndex].Handler)(ProcessData, Request);
             }
+          return;
         }
     }
-  if (! Found)
-    {
-      DPRINT1("CSR: Unknown request type 0x%x\n", Request->Type);
-      Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
-      Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
-      Request->Status = STATUS_INVALID_SYSTEM_SERVICE;
-    }
+  DPRINT1("CSR: Unknown request type 0x%x\n", Request->Type);
+  Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+  Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
+  Request->Status = STATUS_INVALID_SYSTEM_SERVICE;
 }
 
-BOOL FASTCALL CallHardError(void);
+BOOL
+CallHardError(IN PCSRSS_PROCESS_DATA ProcessData,
+              IN PHARDERROR_MSG HardErrorMessage);
 
 static
 VOID
@@ -117,10 +115,10 @@ CsrHandleHardError(IN PCSRSS_PROCESS_DATA ProcessData,
     DPRINT1("CSR: received hard error %lx\n", Message->Status);
 
     /* Call the hard error handler in win32csr */
-    CallHardError();
+    (VOID)CallHardError(ProcessData, Message);
 }
 
-NTSTATUS STDCALL
+NTSTATUS WINAPI
 CsrpHandleConnectionRequest (PPORT_MESSAGE Request,
                              IN HANDLE hApiListenPort)
 {
@@ -194,7 +192,7 @@ CsrpHandleConnectionRequest (PPORT_MESSAGE Request,
 }
 
 VOID
-STDCALL
+WINAPI
 ClientConnectionThread(HANDLE ServerPort)
 {
     NTSTATUS Status;
@@ -274,8 +272,8 @@ ClientConnectionThread(HANDLE ServerPort)
         }
         if (ProcessData->Terminated)
         {
-            DPRINT1("Message %d: process %d already terminated\n",
-                    Request->Type, (ULONG)Request->Header.ClientId.UniqueProcess);
+            DPRINT1("Message %d: process %p already terminated\n",
+                    Request->Type, Request->Header.ClientId.UniqueProcess);
             continue;
         }
 
@@ -302,51 +300,6 @@ ClientConnectionThread(HANDLE ServerPort)
     RtlExitUserThread(STATUS_SUCCESS);
 }
 
-/**********************************************************************
- * NAME
- *     ServerApiPortThread/1
- *
- * DESCRIPTION
- *     Handle connection requests from clients to the port
- *     "\Windows\ApiPort".
- */
-#if 0
-DWORD STDCALL
-ServerApiPortThread (HANDLE hApiListenPort)
-{
-    NTSTATUS Status = STATUS_SUCCESS;
-    BYTE RawRequest[sizeof(PORT_MESSAGE) + sizeof(CSR_CONNECTION_INFO)];
-    PPORT_MESSAGE Request = (PPORT_MESSAGE)RawRequest;
-
-    DPRINT("CSR: %s called", __FUNCTION__);
-
-    for (;;)
-    {
-         REMOTE_PORT_VIEW LpcRead;
-         LpcRead.Length = sizeof(LpcRead);
-
-         Status = NtListenPort (hApiListenPort, Request);
-         if (!NT_SUCCESS(Status))
-         {
-             DPRINT1("CSR: NtListenPort() failed, status=%x\n", Status);
-             break;
-         }
-
-         Status = CsrpHandleConnectionRequest(Request, hApiListenPort);
-         if(!NT_SUCCESS(Status))
-         {
-             DPRINT1("CSR: %s: SmpHandleConnectionRequest failed (Status=0x%08lx)\n",
-                     __FUNCTION__, Status);
-             break;
-         }
-    }
-
-    NtClose(hApiListenPort);
-    NtTerminateThread(NtCurrentThread(), Status);
-    return 0;
-}
-#endif
-
 /**********************************************************************
  * NAME
  *     ServerSbApiPortThread/1
@@ -356,7 +309,7 @@ ServerApiPortThread (HANDLE hApiListenPort)
  *     "\Windows\SbApiPort". We will accept only one
  *     connection request (from the SM).
  */
-DWORD STDCALL
+DWORD WINAPI
 ServerSbApiPortThread (HANDLE hSbApiPortListen)
 {
     HANDLE          hConnectedPort = (HANDLE) 0;