Files forgotten in r19815
authorGé van Geldorp <ge@gse.nl>
Thu, 1 Dec 2005 22:38:03 +0000 (22:38 +0000)
committerGé van Geldorp <ge@gse.nl>
Thu, 1 Dec 2005 22:38:03 +0000 (22:38 +0000)
svn path=/trunk/; revision=19817

reactos/subsys/csrss/api/process.c
reactos/subsys/csrss/api/wapi.c
reactos/subsys/csrss/include/api.h
reactos/subsys/csrss/include/conio.h
reactos/subsys/csrss/include/csrplugin.h
reactos/subsys/csrss/include/win32csr.h
reactos/subsys/csrss/init.c

index dc7d546..64ebc4d 100644 (file)
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
  * reactos/subsys/csrss/api/process.c
  *
  * "\windows\ApiPort" port process management functions
@@ -115,6 +114,14 @@ PCSRSS_PROCESS_DATA STDCALL CsrCreateProcessData(HANDLE ProcessId)
    {
       DPRINT1("CsrCreateProcessData() failed\n");
    }
+   else
+   {
+      pProcessData->Terminated = FALSE;
+
+      /* Set default shutdown parameters */
+      pProcessData->ShutdownLevel = 0x280;
+      pProcessData->ShutdownFlags = 0;
+   }
    return pProcessData;
 }
 
@@ -185,6 +192,34 @@ NTSTATUS STDCALL CsrFreeProcessData(HANDLE Pid)
    return STATUS_INVALID_PARAMETER;
 }
 
+NTSTATUS STDCALL
+CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc, PVOID Context)
+{
+  UINT Hash;
+  PCSRSS_PROCESS_DATA pProcessData;
+  NTSTATUS Status = STATUS_SUCCESS;
+
+  LOCK;
+
+  for (Hash = 0; Hash < (sizeof(ProcessData) / sizeof(*ProcessData)); Hash++)
+    {
+      pProcessData = ProcessData[Hash];
+      while (NULL != pProcessData)
+        {
+          Status = EnumProc(pProcessData, Context);
+          if (STATUS_SUCCESS != Status)
+            {
+              UNLOCK;
+              return Status;
+            }
+          pProcessData = pProcessData->next;
+        }
+    }
+
+  UNLOCK;
+
+  return Status;
+}
 
 /**********************************************************************
  *     CSRSS API
@@ -233,6 +268,7 @@ CSR_API(CsrTerminateProcess)
       return(Request->Status = STATUS_INVALID_PARAMETER);
    }
 
+   ProcessData->Terminated = TRUE;
    Request->Status = STATUS_SUCCESS;
    return STATUS_SUCCESS;
 }
@@ -373,6 +409,13 @@ CSR_API(CsrDuplicateHandle)
   Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
 
   ProcessData = CsrGetProcessData(Request->Data.DuplicateHandleRequest.ProcessId);
+  if (NULL == ProcessData || ProcessData->Terminated)
+    {
+      DPRINT1("Invalid source process %d\n", Request->Data.DuplicateHandleRequest.ProcessId);
+      Request->Status = STATUS_INVALID_PARAMETER;
+      return Request->Status;
+    }
+
   Request->Status = CsrGetObject(ProcessData, Request->Data.DuplicateHandleRequest.Handle, &Object);
   if (! NT_SUCCESS(Request->Status))
     {
index 9a0f83d..bf4e53f 100644 (file)
@@ -12,6 +12,8 @@
 
 #include <csrss.h>
 
+#define NDEBUG
+
 #define NDEBUG
 #include <debug.h>
 
@@ -128,8 +130,8 @@ ClientConnectionThread(HANDLE ServerPort)
                                         &Request->Header);
         if (!NT_SUCCESS(Status))
         {
-            DPRINT1("CSR: NtReplyWaitReceivePort failed\n");
-            break;
+          DPRINT1("NtReplyWaitReceivePort failed\n");
+          break;
         }
         
         /* If the connection was closed, handle that */
@@ -147,11 +149,17 @@ ClientConnectionThread(HANDLE ServerPort)
         ProcessData = CsrGetProcessData(Request->Header.ClientId.UniqueProcess);
         if (ProcessData == NULL)
         {
-            DPRINT1("CSR: Message %d: Unable to find data for process 0x%x\n",
+            DPRINT1("Message %d: Unable to find data for process 0x%x\n",
                     Request->Header.u2.s2.Type,
                     Request->Header.ClientId.UniqueProcess);
             break;
         }
+        if (ProcessData->Terminated)
+        {
+            DPRINT1("Message %d: process %d already terminated\n",
+                   Request->Type, (ULONG)Request->Header.ClientId.UniqueProcess);
+            continue;
+        }
 
         /* Call the Handler */
         CsrApiCallHandler(ProcessData, Request);
index 610c65c..7a2e141 100644 (file)
@@ -50,6 +50,7 @@ typedef struct _CSRSS_PROCESS_DATA
   struct _CSRSS_PROCESS_DATA * next;
   LIST_ENTRY ProcessEntry;
   PCONTROLDISPATCHER CtrlDispatcher;
+  BOOL Terminated;
 } CSRSS_PROCESS_DATA, *PCSRSS_PROCESS_DATA;
 
 typedef VOID (STDCALL *CSR_CLEANUP_OBJECT_PROC)(Object_t *Object);
@@ -110,10 +111,13 @@ extern HANDLE CsrssApiHeap;
 VOID STDCALL CsrInitConsoleSupport(VOID);
 
 /* api/process.c */
+typedef NTSTATUS (STDCALL *CSRSS_ENUM_PROCESS_PROC)(PCSRSS_PROCESS_DATA ProcessData,
+                                                    PVOID Context);
 VOID STDCALL CsrInitProcessData(VOID);
 PCSRSS_PROCESS_DATA STDCALL CsrGetProcessData(HANDLE ProcessId);
 PCSRSS_PROCESS_DATA STDCALL CsrCreateProcessData(HANDLE ProcessId);
 NTSTATUS STDCALL CsrFreeProcessData( HANDLE Pid );
+NTSTATUS STDCALL CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc, PVOID Context);
 
 /* api/handle.c */
 NTSTATUS FASTCALL CsrRegisterObjectDefinitions(PCSRSS_OBJECT_DEFINITION NewDefinitions);
index 17ddad8..f6c1b82 100644 (file)
@@ -100,6 +100,8 @@ void FASTCALL ConioPhysicalToLogical(PCSRSS_SCREEN_BUFFER Buff,
                                      LONG *LogicalY);
 VOID FASTCALL ConioDrawConsole(PCSRSS_CONSOLE Console);
 VOID FASTCALL ConioConsoleCtrlEvent(DWORD Event, PCSRSS_PROCESS_DATA ProcessData);
+VOID FASTCALL ConioConsoleCtrlEventTimeout(DWORD Event, PCSRSS_PROCESS_DATA ProcessData,
+                                           DWORD Timeout);
 
 /* api/conio.c */
 CSR_API(CsrWriteConsole);
index 656d009..9a435cb 100644 (file)
@@ -30,12 +30,15 @@ typedef NTSTATUS (STDCALL *CSRSS_GET_OBJECT_PROC)(PCSRSS_PROCESS_DATA ProcessDat
                                                   Object_t **Object);
 typedef NTSTATUS (STDCALL *CSRSS_RELEASE_OBJECT_PROC)(PCSRSS_PROCESS_DATA ProcessData,
                                                       HANDLE Object );
+typedef NTSTATUS (STDCALL *CSRSS_ENUM_PROCESSES_PROC)(CSRSS_ENUM_PROCESS_PROC EnumProc,
+                                                      PVOID Context);
 
 typedef struct tagCSRSS_EXPORTED_FUNCS
 {
   CSRSS_INSERT_OBJECT_PROC CsrInsertObjectProc;
   CSRSS_GET_OBJECT_PROC CsrGetObjectProc;
   CSRSS_RELEASE_OBJECT_PROC CsrReleaseObjectProc;
+  CSRSS_ENUM_PROCESSES_PROC CsrEnumProcessesProc;
 } CSRSS_EXPORTED_FUNCS, *PCSRSS_EXPORTED_FUNCS;
 
 typedef BOOL (STDCALL *CSRPLUGIN_INIT_COMPLETE_PROC)(void);
index 2260b28..b550b43 100644 (file)
@@ -11,6 +11,7 @@
 #define WIN32CSR_H_INCLUDED
 
 #include <windows.h>
+#include <commctrl.h>
 
 extern HANDLE Win32CsrApiHeap;
 extern HINSTANCE Win32CsrDllHandle;
@@ -24,13 +25,13 @@ NTSTATUS FASTCALL Win32CsrLockObject(PCSRSS_PROCESS_DATA ProcessData,
                                      long Type);
 VOID FASTCALL Win32CsrUnlockObject(Object_t *Object);
 
-#ifndef TODO
 NTSTATUS FASTCALL Win32CsrGetObject(PCSRSS_PROCESS_DATA ProcessData,
                                     HANDLE Handle,
                                     Object_t **Object);
 NTSTATUS FASTCALL Win32CsrReleaseObject(PCSRSS_PROCESS_DATA ProcessData,
                                         HANDLE Object);
-#endif
+NTSTATUS FASTCALL Win32CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
+                                        PVOID Context);
 
 #endif /* WIN32CSR_H_INCLUDED */
 
index cdffec5..a9c8770 100644 (file)
@@ -200,6 +200,7 @@ CsrpInitWin32Csr (int argc, char ** argv, char ** envp)
   Exports.CsrInsertObjectProc = CsrInsertObject;
   Exports.CsrGetObjectProc = CsrGetObject;
   Exports.CsrReleaseObjectProc = CsrReleaseObject;
+  Exports.CsrEnumProcessesProc = CsrEnumProcesses;
   if (! (*InitProc)(&ApiDefinitions, &ObjectDefinitions, &InitCompleteProc,
                     &Exports, CsrssApiHeap))
     {