Corrected the handle generation algorithm in the kernel and csrss
authorDavid Welch <welch@cwcom.net>
Sun, 26 Mar 2000 22:00:10 +0000 (22:00 +0000)
committerDavid Welch <welch@cwcom.net>
Sun, 26 Mar 2000 22:00:10 +0000 (22:00 +0000)
Did some work on services.exe
Did some work on the service functions in advapi32
Made some progress in implementing npfs
Implemented a basic grammar for midl

svn path=/trunk/; revision=1091

35 files changed:
reactos/apps/utils/objdir/makefile [new file with mode: 0644]
reactos/apps/utils/objdir/objdir.c [new file with mode: 0644]
reactos/drivers/fs/np/create.c
reactos/drivers/fs/np/mount.c
reactos/drivers/fs/np/npfs.h
reactos/drivers/fs/np/rw.c [new file with mode: 0644]
reactos/drivers/services/makefile [new file with mode: 0644]
reactos/drivers/services/services.c [new file with mode: 0644]
reactos/drivers/services/services.rc [new file with mode: 0644]
reactos/include/ddk/iotypes.h
reactos/include/ddk/zw.h
reactos/include/security.h
reactos/include/services/services.h [new file with mode: 0644]
reactos/include/structs.h
reactos/lib/advapi32/makefile
reactos/lib/advapi32/service/scm.c
reactos/lib/advapi32/service/sctrl.c [new file with mode: 0644]
reactos/lib/advapi32/service/undoc.c [new file with mode: 0644]
reactos/lib/kernel32/file/rw.c
reactos/lib/kernel32/misc/console.c
reactos/lib/rpcrt4/midl/Makefile [new file with mode: 0644]
reactos/lib/rpcrt4/midl/hello.idl [new file with mode: 0644]
reactos/lib/rpcrt4/midl/idl.l [new file with mode: 0644]
reactos/lib/rpcrt4/midl/idl.y [new file with mode: 0644]
reactos/lib/rpcrt4/midl/interface.c [new file with mode: 0644]
reactos/lib/rpcrt4/midl/midl.c [new file with mode: 0644]
reactos/lib/rpcrt4/midl/midl.h [new file with mode: 0644]
reactos/lib/rpcrt4/midl/option.c [new file with mode: 0644]
reactos/lib/rpcrt4/midl/types.c [new file with mode: 0644]
reactos/lib/rpcrt4/midl/types.h [new file with mode: 0644]
reactos/ntoskrnl/io/npipe.c
reactos/ntoskrnl/io/symlink.c
reactos/ntoskrnl/ob/dirobj.c
reactos/ntoskrnl/ob/handle.c
reactos/subsys/csrss/api/handle.c

diff --git a/reactos/apps/utils/objdir/makefile b/reactos/apps/utils/objdir/makefile
new file mode 100644 (file)
index 0000000..4e8ebf6
--- /dev/null
@@ -0,0 +1,46 @@
+#
+#
+#
+OBJECTS= objdir.o
+
+
+PROGS= objdir.exe 
+
+BASE_CFLAGS = -I../../include
+LIBS = ../../lib/ntdll/ntdll.a
+
+all: $(PROGS)
+
+.phony: all
+
+clean:
+       - $(RM) objdir.o
+       - $(RM) objdir.exe
+       - $(RM) objdir.sym
+
+.phony: clean
+
+floppy: $(PROGS:%=$(FLOPPY_DIR)/apps/%)
+
+$(PROGS:%=$(FLOPPY_DIR)/apps/%): $(FLOPPY_DIR)/apps/%: %
+ifeq ($(DOSCLI),yes)
+       $(CP) $* $(FLOPPY_DIR)\apps\$*
+else
+       $(CP) $* $(FLOPPY_DIR)/apps/$*
+endif
+
+dist: $(PROGS:%=../../$(DIST_DIR)/apps/%)
+
+$(PROGS:%=../../$(DIST_DIR)/apps/%): ../../$(DIST_DIR)/apps/%: %
+ifeq ($(DOSCLI),yes)
+       $(CP) $* ..\..\$(DIST_DIR)\apps\$*
+else
+       $(CP) $* ../../$(DIST_DIR)/apps/$*
+endif
+
+objdir.exe: $(OBJECTS) $(LIBS)
+       $(LD) $(OBJECTS) $(LIBS) -o objdir.exe
+       $(NM) --numeric-sort objdir.exe > objdir.sym
+
+
+include ../../rules.mak
diff --git a/reactos/apps/utils/objdir/objdir.c b/reactos/apps/utils/objdir/objdir.c
new file mode 100644 (file)
index 0000000..e3e74f4
--- /dev/null
@@ -0,0 +1,45 @@
+/* $Id: objdir.c,v 1.1 2000/03/26 22:00:06 dwelch Exp $
+ *
+ * DESCRIPTION: Simple LPC Server
+ * PROGRAMMER:  David Welch
+ */
+
+#include <ddk/ntddk.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+int main(int argc, char* argv[])
+{
+   UNICODE_STRING DirectoryNameW;
+   UNICODE_STRING DirectoryNameA:
+   OBJECT_ATTRIBUTES ObjectAttributes;
+   NTSTATUS Status;
+   HANDLE DirectoryHandle;
+   
+   RtlInitAnsiString(&DirectoryNameA, argv[1]);
+   RtlAnsiStringToUnicodeString(&DirectoryNameW,
+                               &DirectoryNameA,
+                               TRUE);
+   InitializeObjectAttributes(&ObjectAttributes,
+                             &DirectoryNameW,
+                             0,
+                             NULL,
+                             NULL);
+   Status = NtOpenDirectoryObject(&DirectoryHandle,
+                                 0,
+                                 &ObjectAttributes);
+   if (!NT_SUCCESS(Status))
+     {
+       printf("Failed to open directory object (Status%x)\n", Status);
+       return(EXIT_FAILURE);
+     }
+   
+   NtClose(DirectoryHandle);
+
+   return EXIT_SUCCESS;
+}
+
+
+/* EOF */
index def56ba..fd7fac1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: create.c,v 1.2 1999/12/04 20:58:42 ea Exp $
+/* $Id: create.c,v 1.3 2000/03/26 22:00:09 dwelch Exp $
  *
  * COPYRIGHT:  See COPYING in the top level directory
  * PROJECT:    ReactOS kernel
 
 /* FUNCTIONS *****************************************************************/
 
-NTSTATUS NpfsCreatePipe(PNPFS_DEVICE_EXTENSION DeviceExt,
-                       PFILE_OBJECT FileObject)
+NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject,
+                   PIRP Irp)               
 {
+   return(Status);
+}
+
+NTSTATUS NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   PIO_STACK_LOCATION IoStack;
+   PFILE_OBJECT FileObject;
+   NTSTATUS Status;
+   PNPFS_DEVICE_EXTENSION DeviceExt;
    PWSTR PipeName;
    PNPFS_FSCONTEXT PipeDescr;
    NTSTATUS Status;
+   KIRQL oldIrql;
+   PLIST_ENTRY current_entry;
+   PNPFS_CONTEXT current;
    
-   PipeName = wcsrchr(FileObject->FileName.Buffer, L'\\');
-   if (PipeName == NULL)
-     {
-       PipeName = FileObject->FileName.Buffer;
-     }
+   DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+   IoStack = IoGetCurrentIrpStackLocation(Irp);
+   FileObject = IoStack->FileObject;
+   
+   PipeName = FileObject->FileName.Buffer;
    
    PipeDescr = ExAllocatePool(NonPagedPool, sizeof(NPFS_FSCONTEXT));
    if (PipeDescr == NULL)
      {
+       Irp->IoStatus.Status = STATUS_NO_MEMORY;
+       Irp->IoStatus.Information = 0;
+       
+       IoCompleteRequest(Irp, IO_NO_INCREMENT);
+       
        return(STATUS_NO_MEMORY);
      }
-   
-   Status = NpfsCreateEntry(PipeName, PipeDescr);
-   if (!NT_SUCCESS(Status))
+   PipeDescr->Name = ExAllocatePool(NonPagedPool,
+                                   (wcslen(PipeName) + 1) * sizeof(WCHAR));
+   if (PipeDescr->Name == NULL)
      {
        ExFreePool(PipeDescr);
-       return(Status);
+       
+       Irp->IoStatus.Status = STATUS_NO_MEMORY;
+       Irp->IoStatus.Information = 0;
+       
+       IoCompleteRequest(Irp, IO_NO_INCREMENT);
      }
    
-   FileObject->FsContext = PipeDescr;
+   wcscpy(PipeDescr->Name, PipeName);
+   PipeDescr->FileAttributes = 
+     IoStack->Parameters.CreateNamedPipe.FileAttributes;
+   PipeDescr->OpenMode = 
+     IoStack->Parameters.CreateNamedPipe.OpenMode;
+   PipeDescr->PipeType =
+     IoStack->Parameters.CreateNamedPipe.PipeType;
+   PipeDescr->PipeRead =
+     IoStack->Parameters.CreateNamedPipe.PipeRead;
+   PipeDescr->PipeWait =
+     IoStack->Parameters.CreateNamedPipe.PipeWait;
+   PipeDescr->MaxInstances =
+     IoStack->Parameters.CreateNamedPipe.MaxInstances;
+   PipeDescr->InBufferSize =
+     IoStack->Parameters.CreateNamedPipe.InBufferSize;
+   PipeDescr->OutBufferSize =
+     IoStack->Parameters.CreateNamedPipe.OutBufferSize;
+   PipeDescr->Timeout =
+     IoStack->Parameters.CreateNamedPipe.Timeout;
+   KeInitializeSpinLock(&PipeDescr->MsgListLock);
+   InitializeListHead(&PipeDescr->MsgListHead);
+   
+   /*
+    * Check for duplicate names
+    */
+   KeAcquireSpinLock(&PipeListLock, &oldIrql);
+   current_entry = PipeListHead.Flink;
+   while (current_entry != &PipeListHead)
+     {
+       current = CONTAINING_RECORD(current_entry,
+                                   NPFS_FSCONTEXT,
+                                   ListEntry);
+       
+       if (wcscmp(current->Name, PipeDescr->Name) == 0)
+         {
+            KeReleaseSpinLock(&PipeListLock, oldIrql);
+            ExFreePool(PipeDescr->Name);
+            ExFreePool(PipeDescr);
+            
+            Irp->IoStatus.Status = STATUS_OBJECT_NAME_COLLISION;
+            Irp->IoStatus.Information = 0;
+            
+            IoCompleteRequest(Irp, IO_NO_INCREMENT);
+         }
+       
+       current_entry = current_entry->Flink;
+     }
+   InsertTailList(&PipeListHead,
+                 &PipeDescr->ListEntry);
+   KeReleaseSpinLock(&PipeListLock, oldIrql);
    
-   return(Status);
-}
-
-NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
-{
-   PIO_STACK_LOCATION IoStack;
-   PFILE_OBJECT FileObject;
-   NTSTATUS Status;
-   PNPFS_DEVICE_EXTENSION DeviceExt;
    
-   DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-   IoStack = IoGetCurrentIrpStackLocation(Irp);
-   FileObject = IoStack->FileObject;
    
-   Status = NpfsCreatePipe(DeviceExt, FileObject);
+   FileObject->FsContext = PipeDescr;
    
    Irp->IoStatus.Status = Status;
    Irp->IoStatus.Information = 0;
index e2040b7..1c110a6 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: mount.c,v 1.2 1999/12/04 20:58:42 ea Exp $
+/* $Id: mount.c,v 1.3 2000/03/26 22:00:09 dwelch Exp $
  *
  * COPYRIGHT:  See COPYING in the top level directory
  * PROJECT:    ReactOS kernel
 
 static PDRIVER_OBJECT DriverObject;
 
-/* FUNCTIONS *****************************************************************/
+LIST_ENTRY PipeListHead;
+KSPIN_LOCK PipeListLock;
 
-NTSTATUS NpfsMount(PDEVICE_OBJECT DeviceToMount)
-{
-   NTSTATUS Status;
-   PDEVICE_OBJECT DeviceObject;
-   PNPFS_DEVICE_EXTENSION DeviceExt;
-   
-   Status = IoCreateDevice(DriverObject,
-                          sizeof(NPFS_DEVICE_EXTENSION),
-                          NULL,
-                          FILE_DEVICE_FILE_SYSTEM,
-                          0,
-                          FALSE,
-                          &DeviceObject);
-   if (!NT_SUCCESS(Status))
-     {
-       return(Status);
-     }
-   
-   DeviceObject->Flags = DeviceObject->Flags | DO_DIRECT_IO;
-   DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
-   
-   DeviceExt->StorageDevice = IoAttachDeviceToDeviceStack(DeviceObject,
-                                                         DeviceToMount);
-   
-   return(STATUS_SUCCESS);
-}
-
-NTSTATUS NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
-                              PIRP Irp)
-{
-   PIO_STACK_LOCATION IoStack = IoGetCurrentIrpStackLocation(Irp);
-   PVPB Vpb = IoStack->Parameters.Mount.Vpb;
-   PDEVICE_OBJECT DeviceToMount = IoStack->Parameters.Mount.DeviceObject;
-   NTSTATUS Status;
-   
-   Status = NpfsMount(DeviceToMount);
-   
-   Irp->IoStatus.Status = Status;
-   Irp->IoStatus.Information = 0;
-   
-   IoCompleteRequest(Irp, IO_NO_INCREMENT);
-   
-   return(Status);
-   
-}
+/* FUNCTIONS *****************************************************************/
 
 NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
                     PUNICODE_STRING RegistryPath)
@@ -74,6 +31,7 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
    PDEVICE_OBJECT DeviceObject;
    NTSTATUS Status;
    UNICODE_STRING DeviceName;
+   UNICODE_STRING LinkName;
    
    DbgPrint("Named Pipe Filesystem\n");
    
@@ -92,13 +50,17 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
        return(Status);
      }
    
+   RtlInitUnicodeString(&LinkName, L"\\??\\pipe");
+   Status = IoCreateSymbolicLink(&LinkName,
+                                &DeviceName);
+   
    DeviceObject->Flags = 0;
    DeviceObject->MajorFunction[IRP_MJ_CLOSE] = NpfsClose;
+   DeviceObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] =
+     NpfsCreateNamedPipe;
    DeviceObject->MajorFunction[IRP_MJ_CREATE] = NpfsCreate;
    DeviceObject->MajorFunction[IRP_MJ_READ] = NpfsRead;
    DeviceObject->MajorFunction[IRP_MJ_WRITE] = NpfsWrite;
-   DeviceObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
-     NpfsFileSystemControl;
    DeviceObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
      NpfsDirectoryControl;
    DeviceObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
@@ -112,15 +74,9 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
      NpfsQuerySecurity;
    DeviceObject->MajorFunction[IRP_MJ_SET_SECURITY] =
      NpfsSetSecurity;
-   DeviceObject->MajorFunction[IRP_MJ_QUERY_QUOTA] =
-     NpfsQueryQuota;
-   DeviceObject->MajorFunction[IRP_MJ_SET_QUOTA] =
-     NpfsSetQuota;
    
    DriverObject->DriverUnload = NULL;
    
-   IoRegisterFileSystem(DeviceObject);
-   
    return(STATUS_SUCCESS);
 }
 
index 3c26ffd..42b04d9 100644 (file)
@@ -8,18 +8,29 @@ typedef struct
 
 typedef struct
 {
-   LIST_ENTRY ListEntry;
    PVOID Buffer;
-   ULONG Length;
+   ULONG Size;
+   LIST_ENTRY ListEntry;
 } NPFS_MSG, *PNPFS_MSG;
 
 typedef struct
 {
-   LIST_ENTRY DirectoryListEntry;
-   LIST_ENTRY GlobalListEntry;
-   ULONG Flags;
-   LIST_ENTRY MsgListHead;
+   LIST_ENTRY ListEntry;
+   PWSTR Name;
+   ULONG FileAttributes;
+   ULONG OpenMode;
+   ULONG PipeType;
+   ULONG PipeRead;
+   ULONG PipeWait;
+   ULONG MaxInstances;
+   ULONG InBufferSize;
+   ULONG OutBufferSize;
+   LARGE_INTEGER Timeout;
    KSPIN_LOCK MsgListLock;
+   LIST_ENTRY MsgListHead;
 } NPFS_FSCONTEXT, *PNPFS_FSCONTEXT;
 
+extern LIST_ENTRY PipeListHead;
+extern KSPIN_LOCK PipeListLock;
+
 #endif /* __SERVICES_FS_NP_NPFS_H */
diff --git a/reactos/drivers/fs/np/rw.c b/reactos/drivers/fs/np/rw.c
new file mode 100644 (file)
index 0000000..9bac22a
--- /dev/null
@@ -0,0 +1,81 @@
+/* $Id: rw.c,v 1.1 2000/03/26 22:00:09 dwelch Exp $
+ *
+ * COPYRIGHT:  See COPYING in the top level directory
+ * PROJECT:    ReactOS kernel
+ * FILE:       services/fs/np/rw.c
+ * PURPOSE:    Named pipe filesystem
+ * PROGRAMMER: David Welch <welch@cwcom.net>
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <ddk/ntddk.h>
+
+//#define NDEBUG
+#include <internal/debug.h>
+
+#include "npfs.h"
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS NpfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
+{
+   PIO_STACK_LOCATION IoStack;
+   PFILE_OBJECT FileObject;
+   NTSTATUS Status;
+   PNPFS_DEVICE_EXTENSION DeviceExt;
+   PWSTR PipeName;
+   PNPFS_FSCONTEXT PipeDescr;
+   NTSTATUS Status;
+   KIRQL oldIrql;
+   PLIST_ENTRY current_entry;
+   PNPFS_CONTEXT current;
+   ULONG Information;
+   
+   DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
+   IoStack = IoGetCurrentIrpStackLocation(Irp);
+   FileObject = IoStack->FileObject;
+   PipeDescr = FileObject->FsContext;
+   
+   if (PipeType & NPFS_READMODE_BYTE)
+     {
+       PLIST_ENTRY current_entry;
+       PNPFS_MSG current;
+       KIRQL oldIrql;
+       ULONG Length;
+       PVOID Buffer;
+       
+       KeAcquireSpinLock(&PipeDescr->MsgListLock, &oldIrql);
+       current_entry = PipeDescr->MsgListHead.Flink;
+       Information = 0;
+       Length = IoStack->Parameters.Read.Length;
+       Buffer = MmGetSystemAddressForMdl(Irp->MdlAddress);
+       while (Length > 0 &&
+              current_entry != &PipeDescr->MsgListHead)
+         {
+            current = CONTAINING_RECORD(current_entry,
+                                        NPFS_MSG,
+                                        ListEntry);
+            
+            memcpy(Buffer, current->Buffer, current->Length);
+            Buffer = Buffer + current->Length;
+            Length = Length - current->Length;
+            Information = Information + current->Length;
+            
+            current_entry = current_entry->Flink;
+         }
+     }
+   else
+     {
+     }
+   
+   Irp->IoStatus.Status = Status;
+   Irp->IoStatus.Information = Information;
+   
+   IoCompleteRequest(Irp, IO_NO_INCREMENT);
+   
+   return(Status);
+}
+
+
+/* EOF */
diff --git a/reactos/drivers/services/makefile b/reactos/drivers/services/makefile
new file mode 100644 (file)
index 0000000..713ef1c
--- /dev/null
@@ -0,0 +1,63 @@
+# $Id: makefile,v 1.1 2000/03/26 22:00:09 dwelch Exp $
+#
+# CSRSS: Client/server runtime subsystem
+#
+# ReactOS Operating System
+#
+TARGET = services
+
+BASE_CFLAGS = -I../../include -I.
+
+OBJECTS = 
+
+LIBS = ../../lib/ntdll/ntdll.a
+
+all: $(TARGET).exe
+
+.phony: all
+
+clean:
+       - $(RM) api/*.o
+       - $(RM) sbapi/*.o
+       - $(RM) *.o
+       - $(RM) $(TARGET).exe
+       - $(RM) $(TARGET).sym
+       - $(RM) $(TARGET).coff
+
+.phony: clean
+
+$(TARGET).coff: $(TARGET).rc
+       $(RC) $(TARGET).rc $(TARGET).coff
+
+$(TARGET).exe: $(OBJECTS) $(LIBS)
+       $(LD) \
+               $(OBJECTS) \
+               $(LIBS) \
+               -o $(TARGET).exe \
+               --subsystem native
+       $(NM) --numeric-sort $(TARGET).exe > $(TARGET).sym
+
+
+floppy: $(FLOPPY_DIR)/subsys/$(TARGET).exe
+
+$(FLOPPY_DIR)/subsys/$(TARGET).exe: $(TARGET).exe
+ifeq ($(DOSCLI),yes)
+       $(CP) $(TARGET).exe $(FLOPPY_DIR)\subsys\$(TARGET).exe
+else
+       $(CP) $(TARGET).exe $(FLOPPY_DIR)/subsys/$(TARGET).exe
+endif
+
+
+dist: $(DIST_DIR)/subsys/$(TARGET).exe
+
+$(DIST_DIR)/subsys/$(TARGET).exe: $(TARGET).exe
+ifeq ($(DOSCLI),yes)
+       $(CP) $(TARGET).exe ..\..\$(DIST_DIR)\subsys\$(TARGET).exe
+else
+       $(CP) $(TARGET).exe ../../$(DIST_DIR)/subsys/$(TARGET).exe
+endif
+
+
+include ../../rules.mak
+
+# EOF
diff --git a/reactos/drivers/services/services.c b/reactos/drivers/services/services.c
new file mode 100644 (file)
index 0000000..61527cc
--- /dev/null
@@ -0,0 +1,77 @@
+/* $Id: services.c,v 1.1 2000/03/26 22:00:09 dwelch Exp $
+ *
+ * service control manager
+ * 
+ * ReactOS Operating System
+ * 
+ * --------------------------------------------------------------------
+ *
+ * This software is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this software; see the file COPYING.LIB. If not, write
+ * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
+ * MA 02139, USA.  
+ *
+ */
+
+#include <ddk/ntddk.h>
+#include <ntdll/rtl.h>
+#include <services/services.h>
+
+VOID ServicesInitialization(VOID)
+{
+   
+}
+
+/* Native process' entry point */
+
+VOID NtProcessStartup(PPEB Peb)
+{
+   OBJECT_ATTRIBUTES ObjectAttributes;
+   HANDLE ServicesInitEvent;
+   UNICODE_STRING UnicodeString;
+   NTSTATUS Status;
+   
+   DisplayString(L"Service Control Manager\n");
+   
+   RtlInitUnicodeString(&UnicodeString,
+                       L"\\ServicesInitDone");
+   InitializeObjectAttributes(&ObjectAttributes,
+                             &UnicodeString,
+                             EVENT_ALL_ACCESS,
+                             0,
+                             NULL);
+   Status = NtOpenEvent(&ServicesInitEvent,
+                       EVENT_ALL_ACCESS,
+                       &ObjectAttributes);
+   if (!NT_SUCCESS(Status))
+     {
+       DbgPrint("SERVICES: Failed to open notification event\n");
+     }
+   
+   Status = ServicesInitialization ();
+   
+   if (!NT_SUCCESS(Status))
+     {
+       DisplayString( L"SERVICES: Subsystem failed to initialize.\n" );
+       
+       NtTerminateProcess(NtCurrentProcess(), Status);
+     }
+
+   
+   DisplayString( L"CSR: Subsystem initialized.\n" );
+
+   NtSetEvent(ServicesInitEvent, NULL);
+   NtTerminateThread(NtCurrentThread(), STATUS_SUCCESS);
+}
+
+/* EOF */
diff --git a/reactos/drivers/services/services.rc b/reactos/drivers/services/services.rc
new file mode 100644 (file)
index 0000000..c2ecd4d
--- /dev/null
@@ -0,0 +1,38 @@
+#include "../../include/defines.h"
+#include "../../include/reactos/resource.h"
+
+LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
+
+VS_VERSION_INFO VERSIONINFO
+       FILEVERSION     RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
+       PRODUCTVERSION  RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD      
+       FILEFLAGSMASK   0x3fL
+#ifdef _DEBUG
+       FILEFLAGS       0x1L
+#else
+       FILEFLAGS       0x0L
+#endif
+       FILEOS          0x40004L
+       FILETYPE        0x2L
+       FILESUBTYPE     0x0L
+BEGIN
+    BLOCK "StringFileInfo"
+    BEGIN
+        BLOCK "040904b0"
+        BEGIN
+            VALUE "CompanyName",       RES_STR_COMPANY_NAME
+            VALUE "FileDescription",   "Client/Server Runtime Process\0"
+            VALUE "FileVersion",       RES_STR_FILE_VERSION
+            VALUE "InternalName",      "CSRSs and CSRSrv\0"
+            VALUE "LegalCopyright",    RES_STR_LEGAL_COPYRIGHT
+            VALUE "OriginalFilename",  "CSRSs.exe and CSRSrv.dll\0"
+            VALUE "ProductName",       RES_STR_PRODUCT_NAME
+            VALUE "ProductVersion",    RES_STR_PRODUCT_VERSION
+        END
+    END
+    BLOCK "VarFileInfo"
+    BEGIN
+        VALUE "Translation", 0x409, 1200
+    END
+END
+
index c8f9f7e..fa5e4be 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: iotypes.h,v 1.14 2000/03/26 19:38:13 ea Exp $
+/* $Id: iotypes.h,v 1.15 2000/03/26 22:00:06 dwelch Exp $
  * 
  */
 
@@ -165,6 +165,18 @@ typedef struct _IO_STACK_LOCATION
             FILE_INFORMATION_CLASS FileInformationClass;
             ULONG FileIndex;
          } QueryDirectory;
+       struct
+         {
+            ULONG FileAttributes;
+            ULONG OpenMode;
+            ULONG PipeType;
+            ULONG PipeRead;
+            ULONG PipeWait;
+            ULONG MaxInstances;
+            ULONG InBufferSize;
+            ULONG OutBufferSize;
+            LARGE_INTEGER Timeout;
+         } CreateNamedPipe;
      } Parameters;
    
    PIO_COMPLETION_ROUTINE CompletionRoutine;
index 3214a59..e08ad31 100644 (file)
@@ -1,5 +1,5 @@
 
-/* $Id: zw.h,v 1.26 2000/03/22 18:35:45 dwelch Exp $
+/* $Id: zw.h,v 1.27 2000/03/26 22:00:06 dwelch Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
 #ifndef __DDK_ZW_H
 #define __DDK_ZW_H
 
+#include <security.h>
   
 #define LCID ULONG
-#define SECURITY_INFORMATION ULONG
+//#define SECURITY_INFORMATION ULONG
+//typedef ULONG SECURITY_INFORMATION;
 
 
 /*
index 7ab0ca8..e42b8a9 100644 (file)
@@ -1,6 +1,8 @@
 #ifndef __INCLUDE_SECURITY_H
 #define __INCLUDE_SECURITY_H
 
+typedef ULONG SECURITY_INFORMATION, *PSECURITY_INFORMATION; 
+
 typedef enum _TOKEN_INFORMATION_CLASS {
     TokenUser = 1, 
     TokenGroups, 
diff --git a/reactos/include/services/services.h b/reactos/include/services/services.h
new file mode 100644 (file)
index 0000000..c98d5a5
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef __INCLUDE_SERVICES_SERVICES_H
+#define __INCLUDE_SERVICES_SERVICES_H
+
+#define SCM_OPEN_MANAGER              (1)
+#define SCM_LOCK_MANAGER              (10)
+#define SCM_UNLOCK_MANAGER            (11)
+
+#define SCM_CREATE_SERVICE            (2)
+#define SCM_OPEN_SERVICE              (3)
+#define SCM_CHANGE_CONFIG_SERVICE     (4)
+#define SCM_CONTROL_SERVICE           (5)
+#define SCM_DELETE_SERVICE            (6)
+#define SCM_SERVICES_STATUS           (7)
+#define SCM_GET_DISPLAY_NAME_SERVICE  (8)
+#define SCM_GET_KEY_NAME_SERVICE      (9)
+#define SCM_QUERY_CONFIG_SERVICE      (12)
+#define SCM_QUERY_LOCK_STATUS_SERVICE (13)
+#define SCM_QUERY_STATUS_SERVICE      (14)
+#define SCM_START_SERVICE             (15)
+
+#define SCM_REGISTER_CHANDLER         (16)
+#define SCM_SET_STATUS_SERVICE        (17)
+#define SCM_START_CDISPATCHER         (18)
+
+typedef struct
+{
+   ULONG Type;
+} SCM_API_REQUEST;
+
+typedef struct
+{
+   ULONG Status;
+} SCM_API_REPLY;
+
+#endif /* __INCLUDE_SERVICES_SERVICES_H */
index 649df4d..e7d73dc 100644 (file)
@@ -3769,9 +3769,7 @@ typedef struct _SECURITY_ATTRIBUTES {
   LPVOID lpSecurityDescriptor; 
   WINBOOL   bInheritHandle; 
 } SECURITY_ATTRIBUTES, *LPSECURITY_ATTRIBUTES; 
-typedef DWORD SECURITY_INFORMATION, *PSECURITY_INFORMATION; 
+  
 typedef struct _selchange { 
   NMHDR nmhdr; 
   CHARRANGE chrg; 
index 2a936e4..9ae8090 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.10 1999/11/07 08:03:24 ea Exp $
+# $Id: makefile,v 1.11 2000/03/26 22:00:07 dwelch Exp $
 #
 # Makefile for ReactOS advapi32.dll
 #
@@ -25,7 +25,7 @@ REGISTRY_OBJECTS = reg/reg.o
 
 SECURITY_OBJECTS = sec/lsa.o sec/sec.o sec/ac.o
 
-SERVICE_OBJECTS = service/scm.o
+SERVICE_OBJECTS = service/scm.o service/sctrl.o service/undoc.o
 
 TOKEN_OBJECTS = token/token.o
 
index 85d4695..03b7157 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: scm.c,v 1.4 1999/11/07 08:03:25 ea Exp $
+/* $Id: scm.c,v 1.5 2000/03/26 22:00:07 dwelch Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -9,7 +9,13 @@
  *     19990413 EA     created
  *     19990515 EA
  */
+
+/* INCLUDES ******************************************************************/
+
 #include <windows.h>
+#include <ddk/ntddk.h>
+
+/* FUNCTIONS *****************************************************************/
 
 /**********************************************************************
  *     ChangeServiceConfigA
@@ -346,39 +352,6 @@ GetServiceKeyNameW(
        return FALSE;
 }
 
-
-/**********************************************************************
- *     I_ScSetServiceBitsA
- *
- * Undocumented
- *
- * Return value unknown.
- */
-DWORD
-STDCALL
-I_ScSetServiceBitsA(VOID)
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 1;
-}
-
-
-/**********************************************************************
- *     I_ScSetServiceBitsW
- *
- * Undocumented
- *
- * Return value unknown.
- */
-DWORD
-STDCALL
-I_ScSetServiceBitsW(VOID)
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 1;
-}
-
-
 /**********************************************************************
  *     LockServiceDatabase
  */
@@ -396,32 +369,76 @@ LockServiceDatabase(
 /**********************************************************************
  *     OpenSCManagerA
  */
-SC_HANDLE
-STDCALL
-OpenSCManagerA(
-       LPCSTR  lpMachineName,
-       LPCSTR  lpDatabaseName,
-       DWORD   dwDesiredAccess
-       )
-{
-       SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
-       return INVALID_HANDLE_VALUE;
+SC_HANDLE STDCALL OpenSCManagerA(LPCSTR        lpMachineName,
+                                LPCSTR lpDatabaseName,
+                                DWORD  dwDesiredAccess)
+{
+   SC_HANDLE h;
+   UNICODE_STRING MachineNameW;
+   UNICODE_STRING DatabaseNameW;
+   ANSI_STRING MachineNameA;
+   ANSI_STRING DatabaseNameA;
+   
+   RtlInitAnsiString(&MachineNameA, lpMachineName);
+   RtlAnsiStringToUnicodeString(&MachineNameW,
+                               &MachineNameA,
+                               TRUE);
+   RtlInitAnsiString(&DatabaseNameA, lpDatabaseName);
+   RtlAnsiStringToUnicodeString(&DatabaseNameW,
+                               &DatabaseNameA,
+                               TRUE);
+   
+   h = OpenSCManagerW(MachineNameW.Buffer,
+                     DatabaseNameW.Buffer,
+                     dwDesiredAccess);
+   
+   RtlFreeHeap(GetProcessHeap(),
+              0,
+              MachineNameW.Buffer);
+   RtlFreeHeap(GetProcessHeap(),
+              0,
+              DatabaseNameW.Buffer);
+   
+   return(h);
 }
 
 
 /**********************************************************************
  *     OpenSCManagerW
  */
-SC_HANDLE
-STDCALL
-OpenSCManagerW(
-       LPCWSTR lpMachineName,
-       LPCWSTR lpDatabaseName,
-       DWORD   dwDesiredAccess
-       )
-{
-       SetLastError (ERROR_CALL_NOT_IMPLEMENTED);
-       return INVALID_HANDLE_VALUE;
+SC_HANDLE STDCALL OpenSCManagerW(LPCWSTR       lpMachineName,
+                                LPCWSTR        lpDatabaseName,                 
+                                DWORD  dwDesiredAccess)
+{
+   HANDLE h;   
+   
+   if (lpMachineName == NULL ||
+       wcslen(lpMachineName) == 0)
+     {
+       if (lpDatabaseName != NULL &&
+           wcscmp(lpDatabaseName, SERVICES_ACTIVE_DATABASEW) != 0)
+         {
+            return(NULL);
+         }
+       
+       h = CreateFile(L"\\\\.\\pipe\ntsrvctrl",
+                      dwDesiredAccess,
+                      0,
+                      NULL,
+                      OPEN_EXISTING,
+                      0,
+                      NULL);
+       if (h == INVALID_HANDLE_VALUE)
+         {
+            return(NULL);
+         }
+       
+       return(h);
+     }
+   else
+     {
+       return(NULL);
+     }
 }
 
 
@@ -606,79 +623,6 @@ QueryServiceStatusEx(VOID)
 }
 
 
-/**********************************************************************
- *     RegisterServiceCtrlHandlerA
- */
-SERVICE_STATUS_HANDLE
-STDCALL
-RegisterServiceCtrlHandlerA(
-       LPCSTR                  lpServiceName,
-       LPHANDLER_FUNCTION      lpHandlerProc
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-/**********************************************************************
- *     RegisterServiceCtrlHandlerW
- */
-SERVICE_STATUS_HANDLE
-STDCALL
-RegisterServiceCtrlHandlerW(
-       LPCWSTR                 lpServiceName,
-       LPHANDLER_FUNCTION      lpHandlerProc
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 0;
-}
-
-
-/**********************************************************************
- *     SetServiceBits
- */
-BOOL
-STDCALL
-SetServiceBits(VOID)
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return 1;
-}
-
-
-/**********************************************************************
- *     SetServiceObjectSecurity
- */
-BOOL
-STDCALL
-SetServiceObjectSecurity(
-       SC_HANDLE               hService,
-       SECURITY_INFORMATION    dwSecurityInformation,
-       PSECURITY_DESCRIPTOR    lpSecurityDescriptor
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
-}
-
-
-/**********************************************************************
- *     SetServiceStatus
- */
-BOOL
-STDCALL
-SetServiceStatus(
-       SERVICE_STATUS_HANDLE   hServiceStatus,
-       LPSERVICE_STATUS        lpServiceStatus
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
-}
-
-
 /**********************************************************************
  *     StartServiceA
  */
@@ -695,32 +639,6 @@ StartServiceA(
 }
 
 
-/**********************************************************************
- *     StartServiceCtrlDispatcherA
- */
-BOOL
-STDCALL
-StartServiceCtrlDispatcherA(
-       LPSERVICE_TABLE_ENTRYA  lpServiceStartTable
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
-}
-
-
-/**********************************************************************
- *     StartServiceCtrlDispatcherW
- */
-BOOL
-STDCALL
-StartServiceCtrlDispatcherW(
-       LPSERVICE_TABLE_ENTRYW  lpServiceStartTable
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return FALSE;
-}
 
 
 /**********************************************************************
diff --git a/reactos/lib/advapi32/service/sctrl.c b/reactos/lib/advapi32/service/sctrl.c
new file mode 100644 (file)
index 0000000..84cc0f4
--- /dev/null
@@ -0,0 +1,236 @@
+/* $Id: sctrl.c,v 1.1 2000/03/26 22:00:07 dwelch Exp $
+ * 
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS system libraries
+ * FILE:            lib/advapi32/service/sctrl.c
+ * PURPOSE:         Service control manager functions
+ * PROGRAMMER:      Emanuele Aliberti
+ * UPDATE HISTORY:
+ *     19990413 EA     created
+ *     19990515 EA
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <windows.h>
+#include <ddk/ntddk.h>
+
+/* TYPES *********************************************************************/
+
+typedef struct
+{
+   DWORD ThreadId;
+} ACTIVE_SERVICE, *PACTIVE_SERVICE;
+
+/* GLOBALS *******************************************************************/
+
+static ULONG ActiveServiceCount;
+static PACTIVE_SERVICE ActiveServices;
+static PHANDLE ActiveServicesThreadHandles;
+
+/* FUNCTIONS *****************************************************************/
+
+/**********************************************************************
+ *     RegisterServiceCtrlHandlerA
+ */
+SERVICE_STATUS_HANDLE STDCALL RegisterServiceCtrlHandlerA(
+       LPCSTR                  lpServiceName,
+       LPHANDLER_FUNCTION      lpHandlerProc)
+{
+   
+   ANSI_STRING ServiceNameA;
+   UNICODE_STRING ServiceNameU;
+   SERVICE_STATUS_HANDLE SHandle;
+   
+   RtlInitAnsiString(&ServiceNameA, (LPSTR)lpServiceName);
+   RtlAnsiStringToUnicodeString(&ServiceNameU, &ServiceNameA, TRUE);
+   
+   SHandle = RegisterServiceCtrlHandlerW(ServiceNameU.Buffer,
+                                        lpHandlerProc);
+   
+   RtlFreeHeap(RtlGetProcessHeap(), 0, ServiceNameU.Buffer);
+   
+   return(SHandle);
+}
+
+
+/**********************************************************************
+ *     RegisterServiceCtrlHandlerW
+ */
+SERVICE_STATUS_HANDLE STDCALL RegisterServiceCtrlHandlerW(
+       LPCWSTR                 lpServiceName,
+       LPHANDLER_FUNCTION      lpHandlerProc)
+{
+       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+       return 0;
+}
+
+
+/**********************************************************************
+ *     SetServiceBits
+ */
+BOOL STDCALL SetServiceBits(SERVICE_STATUS_HANDLE hServiceStatus,
+                           DWORD dwServiceBits,
+                           BOOL bSetBitsOn,
+                           BOOL bUpdateImmediately)
+{
+   SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+   return(FALSE);
+}
+
+
+/**********************************************************************
+ *     SetServiceObjectSecurity
+ */
+WINBOOL
+STDCALL
+SetServiceObjectSecurity(
+       SC_HANDLE               hService,
+       SECURITY_INFORMATION    dwSecurityInformation,
+       PSECURITY_DESCRIPTOR    lpSecurityDescriptor
+       )
+{
+       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+       return FALSE;
+}
+
+
+/**********************************************************************
+ *     SetServiceStatus
+ */
+BOOL
+STDCALL
+SetServiceStatus(
+       SERVICE_STATUS_HANDLE   hServiceStatus,
+       LPSERVICE_STATUS        lpServiceStatus
+       )
+{
+       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+       return FALSE;
+}
+
+/**********************************************************************
+ *     StartServiceCtrlDispatcherA
+ */
+BOOL STDCALL StartServiceCtrlDispatcherA(
+           LPSERVICE_TABLE_ENTRYA      lpServiceStartTable)
+{
+   LPSERVICE_TABLE_ENTRYW ServiceStartTableW;
+   ANSI_STRING ServiceNameA;
+   UNICODE_STRING ServiceNameW;
+   ULONG i;
+   ULONG Count;
+   BOOL b;
+   
+   i = 0;
+   while (lpServiceStartTable[i].lpServiceProc != NULL)
+     {
+       i++;
+     }
+   Count = i;
+   
+   ServiceStartTableW = RtlAllocateHeap(RtlGetProcessHeap(),
+                                       HEAP_ZERO_MEMORY,
+                                       sizeof(SERVICE_TABLE_ENTRYW) * Count);
+   for (i = 0; i < Count; i++)
+     {
+       RtlInitAnsiString(&ServiceNameA,
+                         lpServiceStartTable[i].lpServiceName);
+       RtlAnsiStringToUnicodeString(&ServiceNameW,
+                                    &ServiceNameA,
+                                    TRUE);
+       ServiceStartTableW[i].lpServiceName = ServiceNameW.Buffer;
+       ServiceStartTableW[i].lpServiceProc = 
+         lpServiceStartTable[i].lpServiceProc;
+     }
+   
+   b = StartServiceCtrlDispatcherW(ServiceStartTableW);
+   
+   for (i = 0; i < Count; i++)
+     {
+       RtlFreeHeap(RtlGetProcessHeap(),
+                   0,
+                   ServiceStartTableW[i].lpServiceName);
+     }
+   RtlFreeHeap(RtlGetProcessHeap(),
+              0,
+              ServiceStartTableW);
+   
+   return(b);
+}
+
+
+/**********************************************************************
+ *     StartServiceCtrlDispatcherW
+ */
+BOOL STDCALL StartServiceCtrlDispatcherW(
+       LPSERVICE_TABLE_ENTRYW  lpServiceStartTable)
+{
+   ULONG i;
+   HANDLE h;
+   DWORD Tid;
+   DWORD r;
+   
+   i = 0;
+   while (lpServiceStartTable[i].lpServiceProc != NULL)
+     {
+       i++;
+     }
+   
+   ActiveServiceCount = i;
+   ActiveServices = RtlAllocateHeap(GetProcessHeap(),
+                                   HEAP_ZERO_MEMORY,
+                                   ActiveServiceCount * 
+                                   sizeof(ACTIVE_SERVICE));
+   ActiveServicesThreadHandles = RtlAllocateHeap(GetProcessHeap(),
+                                                HEAP_ZERO_MEMORY,
+                                                (ActiveServiceCount + 1) *
+                                                sizeof(HANDLE));
+   
+   for (i = 0; i<ActiveServiceCount; i++)
+     {
+       h = CreateThread(NULL,
+                        0,
+                        lpServiceStartTable[i].lpServiceProc,
+                        NULL,
+                        0,
+                        &Tid);
+       if (h == INVALID_HANDLE_VALUE)
+         {
+            return(FALSE);
+         }
+       ActiveServicesThreadHandles[i + 1] = h;
+       ActiveServices[i].ThreadId = Tid;
+     }
+   
+   while (ActiveServiceCount > 0)
+     {
+       r = WaitForMultipleObjects(ActiveServiceCount + 1,
+                                  ActiveServicesThreadHandles,
+                                  FALSE,
+                                  INFINITE);
+       if (r == WAIT_OBJECT_0)
+         {
+            /* Received message from the scm */
+         }
+       else if (r > WAIT_OBJECT_0 &&
+                r < (WAIT_OBJECT_0 + ActiveServiceCount))
+         {
+            /* A service died */
+            
+            ActiveServiceCount--;
+            ActiveServicesThreadHandles[r - WAIT_OBJECT_0 - 1] =
+              ActiveServicesThreadHandles[ActiveServiceCount + 1];
+            memcpy(&ActiveServices[r - WAIT_OBJECT_0 - 2],
+                   &ActiveServices[ActiveServiceCount],
+                   sizeof(ACTIVE_SERVICE));
+         }
+       else
+         {
+            /* Bail */
+         }
+     }
+   return(TRUE);
+}
+
+
diff --git a/reactos/lib/advapi32/service/undoc.c b/reactos/lib/advapi32/service/undoc.c
new file mode 100644 (file)
index 0000000..e60c210
--- /dev/null
@@ -0,0 +1,50 @@
+/* $Id: undoc.c,v 1.1 2000/03/26 22:00:07 dwelch Exp $
+ * 
+ * COPYRIGHT:       See COPYING in the top level directory
+ * PROJECT:         ReactOS system libraries
+ * FILE:            lib/advapi32/service/undoc.c
+ * PURPOSE:         Undocumented service functions
+ * PROGRAMMER:      Emanuele Aliberti
+ * UPDATE HISTORY:
+ *     19990413 EA     created
+ *     19990515 EA
+ */
+
+/* INCLUDES ******************************************************************/
+
+#include <windows.h>
+
+/* FUNCTIONS *****************************************************************/
+
+/**********************************************************************
+ *     I_ScSetServiceBitsA
+ *
+ * Undocumented
+ *
+ * Return value unknown.
+ */
+DWORD
+STDCALL
+I_ScSetServiceBitsA(VOID)
+{
+       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+       return 1;
+}
+
+
+/**********************************************************************
+ *     I_ScSetServiceBitsW
+ *
+ * Undocumented
+ *
+ * Return value unknown.
+ */
+DWORD
+STDCALL
+I_ScSetServiceBitsW(VOID)
+{
+       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
+       return 1;
+}
+
+
index 5516e66..65f8097 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rw.c,v 1.9 2000/03/22 18:35:47 dwelch Exp $
+/* $Id: rw.c,v 1.10 2000/03/26 22:00:07 dwelch Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -100,6 +100,15 @@ WINBOOL STDCALL ReadFile(HANDLE hFile,
    PIO_STATUS_BLOCK IoStatusBlock;
    PLARGE_INTEGER ptrOffset;
    
+   if (IsConsoleHandle(hFile))
+     {
+       return(ReadConsoleA(hFile,
+                           lpBuffer,
+                           nNumberOfBytesToRead,
+                           lpNumberOfBytesRead,
+                           NULL));
+     }
+   
    if (lpOverLapped != NULL) 
      {
         Offset.u.LowPart = lpOverLapped->Offset;
@@ -138,13 +147,18 @@ WINBOOL STDCALL ReadFile(HANDLE hFile,
    return(TRUE);
 }
 
-VOID ApcRoutine(PVOID ApcContext, struct _IO_STATUS_BLOCK* IoStatusBlock, ULONG NumberOfBytesTransfered)
+VOID ApcRoutine(PVOID ApcContext, 
+               struct _IO_STATUS_BLOCK* IoStatusBlock, 
+               ULONG NumberOfBytesTransfered)
 {
-       DWORD dwErrorCode;
-       LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine = (LPOVERLAPPED_COMPLETION_ROUTINE)ApcContext;
-
-       dwErrorCode = RtlNtStatusToDosError( IoStatusBlock->Status);
-       lpCompletionRoutine(  dwErrorCode, NumberOfBytesTransfered, (LPOVERLAPPED)IoStatusBlock );
+   DWORD dwErrorCode;
+   LPOVERLAPPED_COMPLETION_ROUTINE  lpCompletionRoutine = 
+     (LPOVERLAPPED_COMPLETION_ROUTINE)ApcContext;
+   
+   dwErrorCode = RtlNtStatusToDosError( IoStatusBlock->Status);
+   lpCompletionRoutine(dwErrorCode, 
+                      NumberOfBytesTransfered, 
+                      (LPOVERLAPPED)IoStatusBlock);
 }
 
 
index 18f4c7d..468564e 100644 (file)
@@ -138,6 +138,10 @@ WINBOOL STDCALL WriteConsoleA(HANDLE hConsoleOutput,
        return(FALSE);
      }
    
+   HeapFree(GetProcessHeap(),
+           0,
+           Request);
+           
    if (lpNumberOfCharsWritten != NULL)
      {
        *lpNumberOfCharsWritten = 
@@ -193,6 +197,10 @@ WINBOOL STDCALL ReadConsoleA(HANDLE hConsoleInput,
          Reply->Data.ReadConsoleReply.Buffer,
          Reply->Data.ReadConsoleReply.NrCharactersRead);
    
+   HeapFree(GetProcessHeap(),
+           0,
+           Reply);
+   
    return(TRUE);
 }
 
diff --git a/reactos/lib/rpcrt4/midl/Makefile b/reactos/lib/rpcrt4/midl/Makefile
new file mode 100644 (file)
index 0000000..ad5cf6e
--- /dev/null
@@ -0,0 +1,53 @@
+# $Id: Makefile,v 1.1 2000/03/26 22:00:08 dwelch Exp $
+#
+# ReactOS Operating System
+#
+TARGET=midl
+
+BASE_CFLAGS = -I../../include
+
+CFLAGS = $(CFLAGS) 
+
+all: midl$(EXE_POSTFIX)
+
+idl.tab.o: idl.y
+       bison -t -v -d idl.y
+       $(NATIVE_CC) -c idl.tab.c -o idl.tab.o
+
+lex.yy.o: idl.l idl.tab.h
+       flex idl.l
+       $(NATIVE_CC) -c lex.yy.c -o lex.yy.o
+
+midl.o: midl.c midl.h idl.tab.h
+       $(NATIVE_CC) -c midl.c -o midl.o
+
+option.o: option.c midl.h idl.tab.h
+       $(NATIVE_CC) -c option.c -o option.o    
+
+interface.o: interface.c midl.h idl.tab.h
+       $(NATIVE_CC) -c interface.c -o interface.o
+
+types.o: types.c midl.h idl.tab.h types.h
+       $(NATIVE_CC) -c types.c -o types.o
+
+midl$(EXE_POSTFIX): idl.tab.o lex.yy.o midl.o option.o interface.o types.o
+       $(NATIVE_CC) midl.o idl.tab.o lex.yy.o option.o interface.o -lfl \
+       types.o -o midl$(EXE_POSTFIX)
+
+include ../../../rules.mak
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/reactos/lib/rpcrt4/midl/hello.idl b/reactos/lib/rpcrt4/midl/hello.idl
new file mode 100644 (file)
index 0000000..8994182
--- /dev/null
@@ -0,0 +1,10 @@
+[
+uuid(b574a080-aceb-11d3-95f9-aa43ded19f71),
+version(1.0),
+pointer_default(unique)
+]
+interface hello
+{
+        void HelloProc([in] int pszString);
+        void Shutdown(void);
+}
diff --git a/reactos/lib/rpcrt4/midl/idl.l b/reactos/lib/rpcrt4/midl/idl.l
new file mode 100644 (file)
index 0000000..3815a7c
--- /dev/null
@@ -0,0 +1,88 @@
+%{
+#include "midl.h"
+#include "idl.tab.h"
+#include <string.h>
+
+int lineno = 1;
+void yyerror(char* s);
+char* current_file;
+int nr_errors = 0;
+
+#define TOK(n) { yylval.token = n; return n; }
+
+%}
+
+DIGIT [0-9]
+ID    [a-zA-Z][a-zA-Z0-9]*
+UUID  [a-z0-9]*
+
+%%
+
+uuid                { TOK(UUID_KEYWORD); }
+version             { TOK(VERSION_KEYWORD); }
+pointer_default     { TOK(POINTER_DEFAULT_KEYWORD); }
+unique              { TOK(UNIQUE_KEYWORD); }
+interface           { TOK(INTERFACE_KEYWORD); }
+in                  { TOK(IN_KEYWORD); }
+out                 { TOK(OUT_KEYWORD); }
+
+{ID}                { int n;
+                      if ((n = token_to_type(yytext)) != 0)
+                     {
+                         yylval.tval = n;
+                         return(TYPE_KEYWORD);
+                     }
+                     else
+                     {
+                         yylval.id = strdup(yytext); 
+                         return(ID_TOKEN); 
+                     }
+                    }
+
+{DIGIT}+                   { yylval.number = atoi(yytext); 
+                             return(NUMBER_TOKEN); }
+
+{DIGIT}+"."{DIGIT}+        { char* ebuf;
+                             yylval.version.major = strtoul(yytext, &ebuf, 0);
+                            yylval.version.minor = strtoul(ebuf + 1, NULL, 0);
+                            return(VERSION_TOKEN); }
+
+{UUID}+"-"{UUID}+"-"{UUID}+"-"{UUID}+"-"{UUID}+ { yylval.uuid = strdup(yytext);
+                                                  return(UUID_TOKEN); }
+
+";"                                { TOK(LINE_TERMINATOR); }
+
+"("                                { TOK(LEFT_BRACKET); }
+
+")"                                { TOK(RIGHT_BRACKET); }
+
+","                                { TOK(COMMA); }
+
+"{"                                { TOK(LCURLY_BRACKET); }
+
+"}"                                { TOK(RCURLY_BRACKET); }
+
+"["                                { TOK(LSQBRACKET); }
+
+"]"                                { TOK(RSQBRACKET); }
+
+\n                       lineno++;
+
+[ \t\r]+                 ;
+
+.                        yyerror("invalid character");
+
+%%
+
+void yyerror(char* s)
+{
+     nr_errors++;
+     printf("%s:%d: %s at %s\n", current_file, lineno, s, yytext);
+}
+
+void yyerror1(char* s)
+{
+     nr_errors++;
+     printf("%s:%d: %s\n", current_file, lineno, s);
+}
+
diff --git a/reactos/lib/rpcrt4/midl/idl.y b/reactos/lib/rpcrt4/midl/idl.y
new file mode 100644 (file)
index 0000000..d7bed8e
--- /dev/null
@@ -0,0 +1,91 @@
+%{
+#include "midl.h"
+%}
+
+%union {
+int tval;
+int token;
+char* id;
+int number;
+char* uuid;
+char operator;
+struct
+{
+int minor;
+int major;
+} version;
+}
+
+%token <id> ID_TOKEN
+%token <uuid> UUID_TOKEN
+%token NUMBER_TOKEN
+%token <version> VERSION_TOKEN
+
+%token UUID_KEYWORD
+%token VERSION_KEYWORD
+%token POINTER_DEFAULT_KEYWORD 
+%token <token> UNIQUE_KEYWORD
+%token INTERFACE_KEYWORD
+
+%token IN_KEYWORD, OUT_KEYWORD, 
+
+%token LSQBRACKET, RSQBRACKET, LBRACKET, RBRACKET
+%token LCURLY_BRACKET, RCURLY_BRACKET, LINE_TERMINATOR, COMMA
+%token LEFT_BRACKET, RIGHT_BRACKET
+
+%token <tval> TYPE_KEYWORD
+
+%type <tval> type
+
+%%
+
+idl_file:
+       LSQBRACKET options RSQBRACKET interface
+       ;
+
+options:
+       option
+     | option COMMA options
+     ;
+
+option:
+       UUID_KEYWORD LEFT_BRACKET UUID_TOKEN RIGHT_BRACKET 
+                                 { set_uuid($3); }
+     | VERSION_KEYWORD LEFT_BRACKET VERSION_TOKEN RIGHT_BRACKET
+                            { set_version($3.major, $3.minor); }
+     | POINTER_DEFAULT_KEYWORD LEFT_BRACKET UNIQUE_KEYWORD RIGHT_BRACKET
+                                 { set_pointer_default($3); }
+     ;
+
+interface: { start_interface(); } 
+           INTERFACE_KEYWORD ID_TOKEN LCURLY_BRACKET functions RCURLY_BRACKET
+           { end_interface($3); }
+
+functions:                                               
+       | function LINE_TERMINATOR functions
+       ;
+
+function: { start_function(); }
+          type ID_TOKEN LEFT_BRACKET argument_list RIGHT_BRACKET  
+          { end_function($2, $3); }
+       ;
+
+argument_list:                    
+      | TYPE_KEYWORD           { if ($1 != VOID_TYPE) 
+                                 {
+                                  yyerror("parameter name ommitted");
+                                }
+                               }
+      | argument                   
+      | argument COMMA argument_list
+      ;
+
+argument:
+       LSQBRACKET direction RSQBRACKET type ID_TOKEN { add_argument($4, $5); }
+       ;
+
+type:  TYPE_KEYWORD;
+
+direction:
+        IN_KEYWORD
+       ;
diff --git a/reactos/lib/rpcrt4/midl/interface.c b/reactos/lib/rpcrt4/midl/interface.c
new file mode 100644 (file)
index 0000000..21eee45
--- /dev/null
@@ -0,0 +1,74 @@
+#include <stdio.h>
+#include <malloc.h>
+#include <string.h>
+
+#include "midl.h"
+#include "idl.tab.h"
+
+static interface* current_interface;
+static function* current_function;
+
+void add_argument(int type, char* name)
+{
+   argument* arg;
+   
+   arg = malloc(sizeof(argument));
+   
+   arg->type = type;
+   arg->name = strdup(name);
+   
+   arg->next = current_function->arguments;
+   current_function->arguments = arg;
+}
+
+void start_interface(void)
+{
+   current_interface = (interface *)malloc(sizeof(interface));
+}
+
+void start_function(void)
+{
+   function* f;
+   
+   f = (function *)malloc(sizeof(function));
+   
+   f->arguments = NULL;
+   
+   f->next = current_interface->function_list;
+   current_interface->function_list = f;
+   current_function = f;
+}
+
+void end_function(int rtype, char* name)
+{
+   current_function->return_type = rtype;
+   current_function->name = strdup(name);
+}
+
+void end_interface(char* name)
+{
+   function* cur;
+   argument* a;
+   
+   printf("interface_name: %s\n", name);
+   
+   current_interface->name = strdup(name);
+   cur = current_interface->function_list;
+   while (cur != NULL)
+     {
+       print_type(cur->return_type);
+       printf(" function_name: %s (\n", cur->name, cur);
+       
+       a = cur->arguments;
+       while (a != NULL)
+         {
+            printf("\t");
+            print_type(a->type);
+            printf(" %s\n", a->name);
+            a = a->next;
+         }
+       printf(")\n");
+       
+       cur = cur->next;
+     }
+}
diff --git a/reactos/lib/rpcrt4/midl/midl.c b/reactos/lib/rpcrt4/midl/midl.c
new file mode 100644 (file)
index 0000000..d105bc4
--- /dev/null
@@ -0,0 +1,79 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/wait.h>
+
+extern FILE* yyin;
+extern int yyparse(void);
+extern int yydebug;
+extern int nr_errors;
+extern char* current_file;
+
+int main(int argc, char* argv[])
+{
+   int fd;
+   char* tempname;
+   int n, p, status;
+   char* args[9];
+   
+   if (argc == 1)
+     {
+       printf("Not enough arguments\n");
+       exit(1);
+     }
+   
+   tempname = tempnam(NULL, "midl");
+   
+   args[0] = strdup("/usr/bin/gcc");
+   args[1] = strdup("-x");
+   args[2] = strdup("c");
+   args[3] = strdup("-P");
+   args[4] = strdup("-E");
+   args[5] = strdup(argv[1]);
+   args[6] = strdup("-o");
+   args[7] = strdup(tempname);
+   args[8] = NULL;
+   
+   if ((n = fork()) == 0)
+     {
+       execv("/usr/bin/gcc", args);
+       perror("gcc");
+       exit(1);
+     }
+   else if (n == -1)
+     {
+       perror("midl");
+       exit(1);
+     }
+   
+   p = waitpid(n, &status, WUNTRACED);
+   if (p == -1 || p == 0 || !WIFEXITED(status))
+     {
+       perror("midl");
+       exit(1);
+     }
+   if (WEXITSTATUS(status) != 0)
+     {
+       printf("midl: the preprocessor %s failed\n");
+       exit(1);
+     }
+   
+//   yydebug = 1;
+   
+   yyin = fopen(tempname, "r+b");
+   if (yyin == NULL)
+     {
+       perror(argv[1]);
+       exit(1);
+     }
+   
+   current_file = strdup(argv[1]);
+   
+   if (yyparse() != 0 || nr_errors > 0)
+     {
+       exit(1);
+     }
+   
+   unlink(tempname);
+}
diff --git a/reactos/lib/rpcrt4/midl/midl.h b/reactos/lib/rpcrt4/midl/midl.h
new file mode 100644 (file)
index 0000000..582a771
--- /dev/null
@@ -0,0 +1,37 @@
+#ifndef __MIDL_H
+#define __MIDL_H
+
+#include "types.h"
+
+typedef struct _argument
+{
+   int type;
+   char* name;
+   struct _argument* next;
+} argument;
+
+typedef struct _function
+{
+   int return_type;
+   char* name;
+   argument* arguments;
+   struct _function* next;
+} function;
+
+typedef struct
+{
+   char* name;
+   function* function_list;
+} interface;
+
+void set_uuid(char* uuid);
+void set_version(int major, int minor);
+void set_pointer_default(int option);
+
+void start_interface(void);
+void end_interface(char* name);
+void start_function(void);
+void end_function(int rtype, char* name);
+void add_argument(int type, char* name);
+
+#endif __MIDL_H
diff --git a/reactos/lib/rpcrt4/midl/option.c b/reactos/lib/rpcrt4/midl/option.c
new file mode 100644 (file)
index 0000000..a2427cb
--- /dev/null
@@ -0,0 +1,16 @@
+#include <stdio.h>
+
+#include "midl.h"
+#include "idl.tab.h"
+
+void set_uuid(char* uuid)
+{
+}
+
+void set_version(int major, int minor)
+{
+}
+
+void set_pointer_default(int option)
+{
+}
diff --git a/reactos/lib/rpcrt4/midl/types.c b/reactos/lib/rpcrt4/midl/types.c
new file mode 100644 (file)
index 0000000..e69cf41
--- /dev/null
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include "midl.h"
+
+typedef struct
+{
+   char* name;
+   unsigned int value;
+   unsigned int default_sign;
+} type;
+
+static type types[] = {
+     {"boolean", BOOLEAN_TYPE, UNSIGNED_TYPE_OPTION},
+     {"byte", BYTE_TYPE, 0},
+     {"char", CHAR_TYPE, UNSIGNED_TYPE_OPTION},
+     {"double", DOUBLE_TYPE, 0},
+     {"error_status_t", ERROR_STATUS_TYPE, UNSIGNED_TYPE_OPTION},
+     {"float", FLOAT_TYPE, 0},
+     {"handle_t", HANDLE_TYPE, 0},
+     {"hyper", HYPER_TYPE, SIGNED_TYPE_OPTION},
+     {"int", INT_TYPE, SIGNED_TYPE_OPTION},
+     {"__int32", INT32_TYPE, SIGNED_TYPE_OPTION},
+     {"__int3264", INT32OR64_TYPE, SIGNED_TYPE_OPTION},
+     {"__int64", INT64_TYPE, SIGNED_TYPE_OPTION},
+     {"long", LONG_TYPE, SIGNED_TYPE_OPTION},
+     {"short", SHORT_TYPE, SIGNED_TYPE_OPTION},
+     {"small", SMALL_TYPE, SIGNED_TYPE_OPTION},
+     {"void", VOID_TYPE, 0},
+     {"wchar_t", WCHAR_TYPE, UNSIGNED_TYPE_OPTION},
+     {NULL, 0, 0}
+     };
+
+void print_type(int tval)
+{
+   int i;
+   
+   for (i = 0; types[i].name != NULL; i++)
+     {
+       if (tval == types[i].value)
+         {
+            printf("%s", types[i].name);
+            return;
+         }
+     }
+   printf("unknown type");
+}
+
+int token_to_type(char* token)
+{
+   int i;
+   
+   for (i = 0; types[i].name != NULL; i++)
+     {
+       if (strcmp(types[i].name, token) == 0)
+         {
+            return(types[i].value);
+         }
+     }
+   return(0);
+}
diff --git a/reactos/lib/rpcrt4/midl/types.h b/reactos/lib/rpcrt4/midl/types.h
new file mode 100644 (file)
index 0000000..69eb623
--- /dev/null
@@ -0,0 +1,33 @@
+#ifndef __TYPES_H
+#define __TYPES_H
+
+#define BOOLEAN_TYPE       (0x100)
+#define BYTE_TYPE          (0x200)
+#define CHAR_TYPE          (0x400)
+#define DOUBLE_TYPE        (0x800)
+#define ERROR_STATUS_TYPE  (0x1000)
+#define FLOAT_TYPE         (0x2000)
+#define HANDLE_TYPE        (0x4000)
+#define HYPER_TYPE         (0x8000)
+#define INT_TYPE           (0x10000)
+#define INT32_TYPE         (0x20000)
+#define INT32OR64_TYPE     (0x40000)
+#define INT64_TYPE         (0x80000)
+#define LONG_TYPE          (0x100000)
+#define SHORT_TYPE         (0x200000)
+#define SMALL_TYPE         (0x400000)
+#define VOID_TYPE          (0x800000)
+#define WCHAR_TYPE         (0x1000000)
+
+#define UNSIGNED_TYPE_OPTION      (0x1)
+#define SIGNED_TYPE_OPTION        (0x2)
+#define POINTER_TYPE_OPTION       (0x4)
+
+#define IN_TYPE_OPTION            (0x8)
+#define OUT_TYPE_OPTION           (0x10)
+#define STRING_TYPE_OPTION        (0x20)
+
+int token_to_type(char* token);
+void print_type(int tval);
+
+#endif
index ea92ef2..2326f4b 100644 (file)
@@ -1,8 +1,8 @@
 /*
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
- * FILE:            ntoskrnl/ke/bug.c
- * PURPOSE:         Graceful system shutdown if a bug is detected
+ * FILE:            ntoskrnl/io/npipe.c
+ * PURPOSE:         Named pipe helper function
  * PROGRAMMER:      David Welch (welch@mcmail.com)
  * UPDATE HISTORY:
  *                  Created 22/05/98
 /* INCLUDES *****************************************************************/
 
 #include <ddk/ntddk.h>
+#include <internal/ob.h>
+#include <internal/io.h>
 
 #include <internal/debug.h>
 
 /* FUNCTIONS *****************************************************************/
 
-NTSTATUS
-STDCALL
-NtCreateNamedPipeFile (
+NTSTATUS STDCALL NtCreateNamedPipeFile(
        OUT     PHANDLE                 NamedPipeFileHandle,
        IN      ACCESS_MASK             DesiredAccess,               
        IN      POBJECT_ATTRIBUTES      ObjectAttributes,     
@@ -32,8 +32,93 @@ NtCreateNamedPipeFile (
        IN      ULONG                   MaxInstances,
        IN      ULONG                   InBufferSize,
        IN      ULONG                   OutBufferSize,
-       IN      PLARGE_INTEGER          TimeOut
-       )
+       IN      PLARGE_INTEGER          TimeOut)
 {
-       UNIMPLEMENTED;
+   PFILE_OBJECT FileObject;
+   NTSTATUS Status;
+   PIRP Irp;
+   KEVENT Event;
+   PIO_STACK_LOCATION StackLoc;
+   
+   DPRINT1("NtCreateNamedPipeFile(FileHandle %x, DesiredAccess %x, "
+           "ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
+           NamedPipeFileHandle,DesiredAccess,ObjectAttributes,
+           ObjectAttributes->ObjectName->Buffer);   
+   
+   assert_irql(PASSIVE_LEVEL);
+   
+   *NamedPipeFileHandle=0;
+
+   FileObject = ObCreateObject(NamedPipeFileHandle,
+                              DesiredAccess,
+                              ObjectAttributes,
+                              IoFileType);
+   if (FileObject == NULL)
+     {
+       return(STATUS_UNSUCCESSFUL);
+     }
+   
+   if (OpenMode & FILE_SYNCHRONOUS_IO_ALERT)
+     {
+       FileObject->Flags = FileObject->Flags | FO_ALERTABLE_IO;
+       FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
+     }
+   if (OpenMode & FILE_SYNCHRONOUS_IO_NONALERT)
+     {
+       FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
+     }
+      
+   KeInitializeEvent(&Event, NotificationEvent, FALSE);
+   
+   DPRINT("FileObject %x\n", FileObject);
+   DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
+   Irp = IoAllocateIrp(FileObject->DeviceObject->StackSize, FALSE);
+   if (Irp==NULL)
+     {
+       return(STATUS_UNSUCCESSFUL);
+     }
+   
+   StackLoc = IoGetNextIrpStackLocation(Irp);
+   StackLoc->MajorFunction = IRP_MJ_CREATE_NAMED_PIPE;
+   StackLoc->MinorFunction = 0;
+   StackLoc->Flags = 0;
+   StackLoc->Control = 0;
+   StackLoc->DeviceObject = FileObject->DeviceObject;
+   StackLoc->FileObject = FileObject;
+   StackLoc->Parameters.CreateNamedPipe.FileAttributes = FileAttributes;
+   StackLoc->Parameters.CreateNamedPipe.OpenMode = OpenMode;
+   StackLoc->Parameters.CreateNamedPipe.PipeType = PipeType;
+   StackLoc->Parameters.CreateNamedPipe.PipeRead = PipeRead;
+   StackLoc->Parameters.CreateNamedPipe.PipeWait = PipeWait;
+   StackLoc->Parameters.CreateNamedPipe.MaxInstances = MaxInstances;
+   StackLoc->Parameters.CreateNamedPipe.InBufferSize = InBufferSize;
+   StackLoc->Parameters.CreateNamedPipe.OutBufferSize = OutBufferSize;
+   if (TimeOut != NULL)
+     {
+       StackLoc->Parameters.CreateNamedPipe.Timeout = *TimeOut;
+     }
+   else
+     {
+       StackLoc->Parameters.CreateNamedPipe.Timeout.QuadPart = 0;
+     }
+   
+   Status = IoCallDriver(FileObject->DeviceObject,Irp);
+   if (Status == STATUS_PENDING)
+     {
+       KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
+       Status = IoStatusBlock->Status;
+     }
+   
+   if (!NT_SUCCESS(Status))
+     {
+       DPRINT("Failing create request with status %x\n",Status);
+       ZwClose(*NamedPipeFileHandle);
+       (*NamedPipeFileHandle) = 0;
+     }
+   
+   assert_irql(PASSIVE_LEVEL);
+   DPRINT("Finished NtCreateFile() (*FileHandle) %x\n",
+         (*NamedPipeFileHandle));
+   return(Status);
+
 }
index 4d706e5..1c8cde9 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: symlink.c,v 1.11 2000/01/21 23:59:53 phreak Exp $
+/* $Id: symlink.c,v 1.12 2000/03/26 22:00:08 dwelch Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
 
 /* GLOBALS ******************************************************************/
 
-typedef
-struct
+typedef struct
 {
        CSHORT                  Type;
        CSHORT                  Size;
        UNICODE_STRING          TargetName;
-       OBJECT_ATTRIBUTES       Target;
-       
+       OBJECT_ATTRIBUTES       Target; 
 } SYMLNK_OBJECT, *PSYMLNK_OBJECT;
 
-
-POBJECT_TYPE
-IoSymbolicLinkType = NULL;
+POBJECT_TYPE IoSymbolicLinkType = NULL;
 
 /* FUNCTIONS *****************************************************************/
 
@@ -126,41 +122,28 @@ IopParseSymbolicLink (
  *
  * REVISIONS
  */
-VOID
-IoInitSymbolicLinkImplementation (VOID)
+VOID IoInitSymbolicLinkImplementation (VOID)
 {
-       ANSI_STRING AnsiString;
-   
-       IoSymbolicLinkType = ExAllocatePool(
-                               NonPagedPool,
-                               sizeof (OBJECT_TYPE)
-                               );
+   IoSymbolicLinkType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE));
    
-       IoSymbolicLinkType->TotalObjects = 0;
-       IoSymbolicLinkType->TotalHandles = 0;
-       IoSymbolicLinkType->MaxObjects = ULONG_MAX;
-       IoSymbolicLinkType->MaxHandles = ULONG_MAX;
-       IoSymbolicLinkType->PagedPoolCharge = 0;
-       IoSymbolicLinkType->NonpagedPoolCharge = sizeof (SYMLNK_OBJECT);
-       IoSymbolicLinkType->Dump = NULL;
-       IoSymbolicLinkType->Open = NULL;
-       IoSymbolicLinkType->Close = NULL;
-       IoSymbolicLinkType->Delete = NULL;
-       IoSymbolicLinkType->Parse = IopParseSymbolicLink;
-       IoSymbolicLinkType->Security = NULL;
-       IoSymbolicLinkType->QueryName = NULL;
-       IoSymbolicLinkType->OkayToClose = NULL;
-       IoSymbolicLinkType->Create = IopCreateSymbolicLink;
-   
-       RtlInitAnsiString(
-               & AnsiString,
-               "Symbolic Link"
-               );
-       RtlAnsiStringToUnicodeString(
-               & IoSymbolicLinkType->TypeName,
-               & AnsiString,
-               TRUE
-               );
+   IoSymbolicLinkType->TotalObjects = 0;
+   IoSymbolicLinkType->TotalHandles = 0;
+   IoSymbolicLinkType->MaxObjects = ULONG_MAX;
+   IoSymbolicLinkType->MaxHandles = ULONG_MAX;
+   IoSymbolicLinkType->PagedPoolCharge = 0;
+   IoSymbolicLinkType->NonpagedPoolCharge = sizeof (SYMLNK_OBJECT);
+   IoSymbolicLinkType->Dump = NULL;
+   IoSymbolicLinkType->Open = NULL;
+   IoSymbolicLinkType->Close = NULL;
+   IoSymbolicLinkType->Delete = NULL;
+   IoSymbolicLinkType->Parse = IopParseSymbolicLink;
+   IoSymbolicLinkType->Security = NULL;
+   IoSymbolicLinkType->QueryName = NULL;
+   IoSymbolicLinkType->OkayToClose = NULL;
+   IoSymbolicLinkType->Create = IopCreateSymbolicLink;
+    
+   RtlInitUnicodeString(&IoSymbolicLinkType->TypeName,
+                       L"SymbolicLink");
 }
 
 
index ea9ac74..ddcec8e 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dirobj.c,v 1.7 2000/01/12 19:04:22 ekohl Exp $
+/* $Id: dirobj.c,v 1.8 2000/03/26 22:00:09 dwelch Exp $
  *
  * COPYRIGHT:      See COPYING in the top level directory
  * PROJECT:        ReactOS kernel
  * NOTES
  *     Undocumented.
  */
-NTSTATUS
-STDCALL
-NtOpenDirectoryObject (
-       PHANDLE                 DirectoryHandle,
-       ACCESS_MASK             DesiredAccess,
-       POBJECT_ATTRIBUTES      ObjectAttributes
-       )
+NTSTATUS STDCALL NtOpenDirectoryObject(PHANDLE DirectoryHandle,
+                                      ACCESS_MASK DesiredAccess,
+                                      POBJECT_ATTRIBUTES ObjectAttributes)
 {
-       PVOID           Object;
-       NTSTATUS        Status;
+   PVOID Object;
+   NTSTATUS Status;
 
-       *DirectoryHandle = 0;
-
-       Status = ObReferenceObjectByName(
-                       ObjectAttributes->ObjectName,
-                       ObjectAttributes->Attributes,
-                       NULL,
-                       DesiredAccess,
-                       ObDirectoryType,
-                       UserMode,
-                       NULL,
-                       & Object
-                       );
-       if (!NT_SUCCESS(Status))
-       {
-               return Status;
-       }
-
-       Status = ObCreateHandle(
-                       PsGetCurrentProcess(),
-                       Object,
-                       DesiredAccess,
-                       FALSE,
-                       DirectoryHandle
-                       );
-       return STATUS_SUCCESS;
+   *DirectoryHandle = 0;
+   
+   Status = ObReferenceObjectByName(ObjectAttributes->ObjectName,
+                                   ObjectAttributes->Attributes,
+                                   NULL,
+                                   DesiredAccess,
+                                   ObDirectoryType,
+                                   UserMode,
+                                   NULL,
+                                   &Object);
+   if (!NT_SUCCESS(Status))
+     {
+       return Status;
+     }
+   
+   Status = ObCreateHandle(PsGetCurrentProcess(),
+                          Object,
+                          DesiredAccess,
+                          FALSE,
+                          DirectoryHandle);
+   return STATUS_SUCCESS;
 }
 
 
@@ -122,134 +114,133 @@ NtOpenDirectoryObject (
  * RETURN VALUE
  *     Status.
  */
-NTSTATUS
-STDCALL
-NtQueryDirectoryObject (
-       IN      HANDLE                  DirObjHandle,
-       OUT     POBJDIR_INFORMATION     DirObjInformation, 
-       IN      ULONG                   BufferLength, 
-       IN      BOOLEAN                 GetNextIndex, 
-       IN      BOOLEAN                 IgnoreInputIndex, 
-       IN OUT  PULONG                  ObjectIndex,
-       OUT     PULONG                  DataWritten     OPTIONAL
-       )
+NTSTATUS STDCALL NtQueryDirectoryObject (IN HANDLE DirObjHandle,
+                                        OUT POBJDIR_INFORMATION 
+                                                   DirObjInformation, 
+                                        IN ULONG BufferLength, 
+                                        IN BOOLEAN GetNextIndex, 
+                                        IN BOOLEAN IgnoreInputIndex, 
+                                        IN OUT PULONG ObjectIndex,
+                                        OUT PULONG DataWritten OPTIONAL)
 {
-       PDIRECTORY_OBJECT       dir = NULL;
-       ULONG                   EntriesToRead;
-       PLIST_ENTRY             current_entry;
-       POBJECT_HEADER          current;
-       ULONG                   i=0;
-       ULONG                   EntriesToSkip;
-       NTSTATUS                Status;
-
-
-       DPRINT(
-               "NtQueryDirectoryObject(DirObjHandle %x)\n",
-               DirObjHandle
-               );
-       DPRINT(
-               "dir %x namespc_root %x\n",
-               dir,
-               HEADER_TO_BODY(&(namespc_root.hdr))
-               );
-
-//     assert_irql(PASSIVE_LEVEL);
-
-       Status = ObReferenceObjectByHandle(
-                       DirObjHandle,
-                       DIRECTORY_QUERY,
-                       ObDirectoryType,
-                       UserMode,
-                       (PVOID *) & dir,
-                       NULL
-                       );
-       if (Status != STATUS_SUCCESS)
-       {
-               return Status;
-       }
-
-       EntriesToRead = BufferLength / sizeof (OBJDIR_INFORMATION);
-       *DataWritten = 0;
-
-       DPRINT("EntriesToRead %d\n",EntriesToRead);
+   PDIRECTORY_OBJECT dir = NULL;
+   PLIST_ENTRY current_entry;
+   POBJECT_HEADER current;
+   ULONG i = 0;
+   ULONG EntriesToSkip;
+   NTSTATUS Status;
+   ULONG SpaceRequired;
+   ULONG FirstFree;
+   
+   DPRINT("NtQueryDirectoryObject(DirObjHandle %x)\n", DirObjHandle);
 
+   Status = ObReferenceObjectByHandle(DirObjHandle,
+                                     DIRECTORY_QUERY,
+                                     ObDirectoryType,
+                                     UserMode,
+                                     (PVOID*)&dir,
+                                     NULL);
+   if (!NT_SUCCESS(Status))
+     {
+       return(Status);
+     }
+   
+   /*
+    * Optionally, skip over some entries at the start of the directory
+    */
+   if (!IgnoreInputIndex)
+     {
+       CHECKPOINT;
+       
+       EntriesToSkip = *ObjectIndex;
+       i = 0;
        current_entry = dir->head.Flink;
-
-       /*
-        * Optionally, skip over some entries at the start of the directory
-        */
-       if (!IgnoreInputIndex)
-       {
-               CHECKPOINT;
        
-               EntriesToSkip = *ObjectIndex;
-               while ( (i < EntriesToSkip) && (current_entry != NULL))
-               {
-                       current_entry = current_entry->Flink;
-               }
-       }
-
-       DPRINT("DirObjInformation %x\n",DirObjInformation);
-
-       /*
-        * Read the maximum entries possible into the buffer
-        */
-       while ( (i < EntriesToRead) && (current_entry != (&(dir->head))))
-       {
-               current = CONTAINING_RECORD(
-                               current_entry,
-                               OBJECT_HEADER,
-                               Entry
-                               );
-               DPRINT(
-                       "Scanning %S\n",
-                       current->Name.Buffer
-                       );
-               
-               DirObjInformation[i].ObjectName.Buffer = 
-                       ExAllocatePool(
-                               NonPagedPool,
-                               (current->Name.Length + 1) * 2
-                               );
-               DirObjInformation[i].ObjectName.Length =
-                       current->Name.Length;
-               DirObjInformation[i].ObjectName.MaximumLength =
-                       current->Name.Length;
-               
-               DPRINT(
-                       "DirObjInformation[i].ObjectName.Buffer %x\n",
-                       DirObjInformation[i].ObjectName.Buffer
-                       );
+       while ((i < EntriesToSkip) && (current_entry != &dir->head))
+         {
+            current_entry = current_entry->Flink;
+            i++;
+         }
+     }
+   else
+     {
+       current_entry = dir->head.Flink;
+       i = 0;
+     }
+   
+   /*
+    * Check if we have reached the end of the directory
+    */
+   if (current_entry != &dir->head)
+     {
+       *DataWritten = 0;
+       return(STATUS_NO_MORE_ENTRIES);
+     }
+   
+   /*
+    * Read the current entry into the buffer
+    */
+   FirstFree = sizeof(OBJDIR_INFORMATION);
+   
+   current = CONTAINING_RECORD(current_entry, OBJECT_HEADER, Entry);
+   
+   SpaceRequired = (wcslen(current->Name.Buffer) + 1) * 2;
+   SpaceRequired = SpaceRequired + 
+     ((wcslen(current->ObjectType->TypeName.Buffer) + 1) * 2);
+   SpaceRequired = SpaceRequired + sizeof(OBJDIR_INFORMATION);
+   
+   if (SpaceRequired <= BufferLength)
+     {
+       
+       DirObjInformation->ObjectName.Length = 
+         current->Name.Length;
+       DirObjInformation->ObjectName.MaximumLength = 
+         current->Name.Length;
+       DirObjInformation->ObjectName.Buffer = 
+         (((PVOID)DirObjInformation) + FirstFree);
+       FirstFree = FirstFree + (wcslen(current->Name.Buffer + 1) * 2);
+       wcscpy(DirObjInformation->ObjectName.Buffer,
+              current->Name.Buffer);
                
-               RtlCopyUnicodeString(
-                       & DirObjInformation[i].ObjectName,
-                       & (current->Name)
-                       );
-               i++;
-               current_entry = current_entry->Flink;
-               (*DataWritten) = (*DataWritten) + sizeof (OBJDIR_INFORMATION);
-
-               CHECKPOINT;
-       }
-       CHECKPOINT;
-
-       /*
-        * Optionally, count the number of entries in the directory
-        */
-       if (GetNextIndex)
-       {
-               *ObjectIndex = i;
-       }
-       else
-       {
-               while ( current_entry != (&(dir->head)) )
-               {
-                       current_entry = current_entry->Flink;
-                       i++;
-               }
-               *ObjectIndex = i;
-       }
-       return STATUS_SUCCESS;
+       DirObjInformation->ObjectTypeName.Length = 
+         current->ObjectType->TypeName.Length;
+       DirObjInformation->ObjectTypeName.MaximumLength = 
+         current->ObjectType->TypeName.Length;
+       DirObjInformation->ObjectName.Buffer = 
+         (((PVOID)DirObjInformation) + FirstFree);
+       FirstFree = FirstFree + 
+         (wcslen(current->ObjectType->TypeName.Buffer + 1) * 2);
+       wcscpy(DirObjInformation->ObjectTypeName.Buffer,
+              current->ObjectType->TypeName.Buffer);
+       
+       *DataWritten = SpaceRequired;
+       Status = STATUS_SUCCESS;
+     }
+   else
+     {
+       Status = STATUS_BUFFER_TOO_SMALL;
+     }
+   
+   /*
+    * Store into ObjectIndex
+    */
+   if (GetNextIndex)
+     {
+       *ObjectIndex = i + 1;
+     }
+   else
+     {
+       i = 0;
+       current_entry = dir->head.Flink;
+       while (current_entry != (&dir->head))
+         {
+            current_entry = current_entry->Flink;
+            i++;
+         }
+       *ObjectIndex = i;
+     }
+   
+   return(STATUS_SUCCESS);
 }
 
 
@@ -276,23 +267,23 @@ NtQueryDirectoryObject (
  * RETURN VALUE
  *     Status.
  */
-NTSTATUS
-STDCALL
-NtCreateDirectoryObject (
-       PHANDLE                 DirectoryHandle,
-       ACCESS_MASK             DesiredAccess,
-       POBJECT_ATTRIBUTES      ObjectAttributes
-       )
+NTSTATUS STDCALL NtCreateDirectoryObject (PHANDLE DirectoryHandle,
+                                         ACCESS_MASK DesiredAccess,
+                                         POBJECT_ATTRIBUTES ObjectAttributes)
 {
-       PDIRECTORY_OBJECT dir;
+   PDIRECTORY_OBJECT dir;
 
-       dir = ObCreateObject(
-               DirectoryHandle,
-               DesiredAccess,
-               ObjectAttributes,
-               ObDirectoryType
-               );
-       return STATUS_SUCCESS;
+   DPRINT("NtCreateDirectoryObject(DirectoryHandle %x, "
+         "DesiredAccess %x, ObjectAttributes %x, "
+         "ObjectAttributes->ObjectName %S)\n",
+         DirectoryHandle, DesiredAccess, ObjectAttributes,
+         ObjectAttributes->ObjectName);
+   
+   dir = ObCreateObject(DirectoryHandle,
+                       DesiredAccess,
+                       ObjectAttributes,
+                       ObDirectoryType);
+   return(STATUS_SUCCESS);
 }
 
 /* EOF */
index 45f484f..a6c1008 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: handle.c,v 1.18 2000/01/22 00:04:56 phreak Exp $
+/* $Id: handle.c,v 1.19 2000/03/26 22:00:09 dwelch Exp $
  *
  * COPYRIGHT:          See COPYING in the top level directory
  * PROJECT:            ReactOS kernel
@@ -47,7 +47,7 @@ static PHANDLE_REP ObpGetObjectByHandle(PHANDLE_TABLE HandleTable, HANDLE h)
  */
 {
    PLIST_ENTRY current;
-   unsigned int handle = (((unsigned int)h) - 1) >> 3;
+   unsigned int handle = (((unsigned int)h) - 1) >> 2;
    unsigned int count=handle/HANDLE_BLOCK_ENTRIES;
    HANDLE_BLOCK* blk = NULL;
    unsigned int i;
@@ -200,7 +200,7 @@ VOID ObCloseAllHandles(PEPROCESS Process)
                       DPRINT("Deleting handle to %x\n", ObjectBody);
                    }
                  
-          ObReferenceObjectByPointer(ObjectBody,
+                 ObReferenceObjectByPointer(ObjectBody,
                                             GENERIC_ALL,
                                             NULL,
                                             UserMode);
@@ -216,7 +216,7 @@ VOID ObCloseAllHandles(PEPROCESS Process)
                                                 Header->HandleCount);
                    }
                  
-          ObDereferenceObject(ObjectBody);
+                 ObDereferenceObject(ObjectBody);
                  KeAcquireSpinLock(&HandleTable->ListLock, &oldIrql);
                  current_entry = &HandleTable->ListHead;
                  break;
@@ -409,7 +409,7 @@ NTSTATUS ObCreateHandle(PEPROCESS Process,
                  blk->handles[i].GrantedAccess = GrantedAccess;
                  blk->handles[i].Inherit = Inherit;
                  KeReleaseSpinLock(&HandleTable->ListLock, oldlvl);
-                 *HandleReturn = (HANDLE)((handle + i) << 3);
+                 *HandleReturn = (HANDLE)((handle + i) << 2);
                  return(STATUS_SUCCESS);
               }
          }
@@ -429,7 +429,7 @@ NTSTATUS ObCreateHandle(PEPROCESS Process,
    new_blk->handles[0].ObjectBody = ObjectBody;
    new_blk->handles[0].GrantedAccess = GrantedAccess;
    new_blk->handles[0].Inherit = Inherit;
-   *HandleReturn = (HANDLE)(handle << 3);
+   *HandleReturn = (HANDLE)(handle << 2);
    return(STATUS_SUCCESS);   
 }
 
index 023c79e..cfaddef 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: handle.c,v 1.4 2000/03/24 22:25:39 dwelch Exp $
+/* $Id: handle.c,v 1.5 2000/03/26 22:00:10 dwelch Exp $
  *
  * reactos/subsys/csrss/api/handle.c
  *
@@ -20,7 +20,7 @@ NTSTATUS CsrGetObject(PCSRSS_PROCESS_DATA ProcessData,
                      HANDLE Handle,
                      PVOID* Object)
 {
-   *Object = ProcessData->HandleTable[((ULONG)Handle) - 1];
+   *Object = ProcessData->HandleTable[(((ULONG)Handle) >> 2) - 1];
    return(STATUS_SUCCESS);
 }
 
@@ -41,7 +41,7 @@ NTSTATUS CsrInsertObject(PCSRSS_PROCESS_DATA ProcessData,
        if (ProcessData->HandleTable[i] == NULL)
          {
             ProcessData->HandleTable[i] = Object;
-            *Handle = (HANDLE)((i << 8) | 0x3);
+            *Handle = (HANDLE)(((i + 1) << 2) | 0x3);
             return(STATUS_SUCCESS);
          }
      }
@@ -58,7 +58,7 @@ NTSTATUS CsrInsertObject(PCSRSS_PROCESS_DATA ProcessData,
                 ProcessData->HandleTableSize * sizeof(HANDLE));
    ProcessData->HandleTable = NewBlock;
    ProcessData->HandleTable[i] = Object;   
-   *Handle = (HANDLE)(((i + 1) << 8) | 0x3);
+   *Handle = (HANDLE)(((i + 1) << 2) | 0x3);
    ProcessData->HandleTableSize = ProcessData->HandleTableSize + 64;
    
    return(STATUS_SUCCESS);