Updated the minix driver
authorDavid Welch <welch@cwcom.net>
Wed, 22 Mar 2000 18:36:00 +0000 (18:36 +0000)
committerDavid Welch <welch@cwcom.net>
Wed, 22 Mar 2000 18:36:00 +0000 (18:36 +0000)
Moved console handling into csrss
Gave each process a name for debugging purposes

svn path=/trunk/; revision=1088

48 files changed:
reactos/Makefile
reactos/apps/tests/pteb/Makefile [new file with mode: 0644]
reactos/apps/tests/pteb/pteb.c [new file with mode: 0644]
reactos/apps/utils/shell/shell.c
reactos/drivers/fs/minix/block.c
reactos/drivers/fs/minix/blockdev.c
reactos/drivers/fs/minix/dir.c
reactos/drivers/fs/minix/inode.c
reactos/drivers/fs/minix/makefile_rex
reactos/drivers/fs/minix/minix.c
reactos/drivers/fs/minix/minix.h
reactos/drivers/fs/minix/mount.c
reactos/drivers/fs/minix/rw.c
reactos/include/csrss/csrss.h
reactos/include/ddk/zw.h
reactos/include/ddk/zwtypes.h
reactos/include/internal/teb.h
reactos/include/ntdll/csr.h
reactos/include/structs.h
reactos/install-system.sh
reactos/install.sh
reactos/lib/kernel32/file/rw.c
reactos/lib/kernel32/misc/console.c
reactos/lib/kernel32/misc/dllmain.c
reactos/lib/kernel32/misc/stubs.c
reactos/lib/kernel32/process/create.c
reactos/lib/kernel32/thread/tls.c
reactos/lib/ntdll/csr/api.c
reactos/lib/ntdll/def/ntdll.def
reactos/lib/ntdll/def/ntdll.edf
reactos/lib/ntdll/ldr/startup.c
reactos/lib/ntdll/rtl/ppb.c
reactos/lib/ntdll/rtl/process.c
reactos/lib/ntdll/stubs/stubs.c
reactos/ntoskrnl/hal/x86/thread.c [deleted file]
reactos/ntoskrnl/ke/i386/exp.c
reactos/ntoskrnl/ldr/loader.c
reactos/ntoskrnl/ps/create.c
reactos/ntoskrnl/ps/process.c
reactos/subsys/csrss/api.h
reactos/subsys/csrss/api/conio.c
reactos/subsys/csrss/api/handle.c
reactos/subsys/csrss/api/process.c
reactos/subsys/csrss/api/wapi.c
reactos/subsys/csrss/csrss.c
reactos/subsys/csrss/init.c
reactos/subsys/csrss/makefile
reactos/subsys/smss/init.c

index 34c071a..a351bda 100644 (file)
@@ -34,13 +34,14 @@ LOADERS = dos
 #
 # Select the device drivers and filesystems you want
 #
-DEVICE_DRIVERS = blue ide keyboard null parallel serial vidport vga/display vga/miniport
+DEVICE_DRIVERS = blue ide keyboard null parallel serial vidport
 # DEVICE_DRIVERS = beep event floppy ide_test mouse sound test test1
-FS_DRIVERS = vfat
+FS_DRIVERS = vfat minix
 # FS_DRIVERS = minix ext2 template
 KERNEL_SERVICES = $(DEVICE_DRIVERS) $(FS_DRIVERS)
 
-APPS = args hello shell test cat bench apc shm lpc thread event file gditest
+APPS = args hello shell test cat bench apc shm lpc thread event file gditest \
+       pteb
 
 all: buildno $(COMPONENTS) $(DLLS) $(SUBSYS) $(LOADERS) $(KERNEL_SERVICES) $(APPS)
 
@@ -232,7 +233,8 @@ $(SUBSYS:%=%_dist): %_dist:
 
 install: all
        ./install.sh /mnt/hda1
-
+       ./install.sh /mnt/hda4
+       
 make_floppy_dirs:
 ifeq ($(DOSCLI),yes)
        mkdir $(FLOPPY_DIR)\dlls
diff --git a/reactos/apps/tests/pteb/Makefile b/reactos/apps/tests/pteb/Makefile
new file mode 100644 (file)
index 0000000..8723058
--- /dev/null
@@ -0,0 +1,39 @@
+#
+#
+#
+OBJECTS = pteb.o
+PROGS = pteb.exe
+LIBS = 
+CLEAN_FILES = pteb.o pteb.exe
+
+all: pteb.exe
+
+clean: $(CLEAN_FILES:%=%_clean)
+
+$(CLEAN_FILES:%=%_clean): %_clean:
+       - $(RM) $*
+
+.phony: clean $(CLEAN_FILES:%=%_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
+
+pteb.exe: $(OBJECTS)
+       $(CC) $(OBJECTS) -o pteb.exe
+
+include ../../rules.mak
diff --git a/reactos/apps/tests/pteb/pteb.c b/reactos/apps/tests/pteb/pteb.c
new file mode 100644 (file)
index 0000000..777b2d4
--- /dev/null
@@ -0,0 +1,14 @@
+#include <stdio.h>
+
+
+int main(int argc, char* argv[])
+{  
+   int x;
+   
+   printf("TEB dumpper\n");
+   __asm__("movl %%fs:0x18, %0\n\t"
+          : "=g" (x)
+          : /* no inputs */);
+   printf("fs[0x18] %x\n", x);
+   return(0);
+}
index 4d6a007..8c3fcd4 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: shell.c,v 1.35 2000/03/16 20:02:44 ekohl Exp $
+/* $Id: shell.c,v 1.36 2000/03/22 18:35:45 dwelch Exp $
  *
  * PROJECT    : ReactOS Operating System
  * DESCRIPTION: ReactOS' Native Shell
@@ -454,7 +454,7 @@ void ParseCommandLine (void)
 int main(void)
 {
    static char line[255];
-
+   
    AllocConsole();
    InputHandle = GetStdHandle(STD_INPUT_HANDLE);
    OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
@@ -462,7 +462,6 @@ int main(void)
    debug_printf("Shell Starting...\n");
 
    ParseCommandLine ();
-//   SetCurrentDirectoryA("C:\\");
 
    for(;;)
      {
index ff8dafa..b47af0d 100644 (file)
@@ -11,7 +11,7 @@
 
 #include <ddk/ntddk.h>
 
-#define NDEBUG
+//#define NDEBUG
 #include <internal/debug.h>
 
 #include "minix.h"
@@ -25,13 +25,12 @@ static unsigned int MinixGetBlock(PDEVICE_OBJECT DeviceObject,
 {
    int block;
    PVOID BaseAddress;
-   PCACHE_SEGMENT CacheSeg;
    ULONG blk;
+      
+   blk = FileOffset / BLOCKSIZE;
    
    DPRINT("MinixGetBlock(inode %x, blk %d)\n",inode,blk);
    
-   blk = FileOffset / BLOCKSIZE;
-   
    /*
     * The first few blocks are available in the inode
     */
@@ -49,17 +48,15 @@ static unsigned int MinixGetBlock(PDEVICE_OBJECT DeviceObject,
      {
        block = inode->i_zone[7];
        
-       MinixRequestCacheBlock(DeviceObject,
-                              DeviceExt->Bcb,
-                              block * BLOCKSIZE,
-                              &BaseAddress,
-                              &CacheSeg);
-                              
-       block = ((PUSHORT)BaseAddress)[blk];
+       BaseAddress = ExAllocatePool(NonPagedPool, 512);
+       
+       MinixReadSector(DeviceObject,
+                       block, 
+                       BaseAddress);
+       
+       block = ((PUSHORT)(BaseAddress))[blk];
 
-       CcReleaseCachePage(DeviceExt->Bcb,
-                          CacheSeg,
-                          TRUE);
+       ExFreePool(BaseAddress);
        
        return(block);
      }
@@ -69,31 +66,27 @@ static unsigned int MinixGetBlock(PDEVICE_OBJECT DeviceObject,
     */
    blk = blk - 512;
    block = inode->i_zone[8];
-
-   MinixRequestCacheBlock(DeviceObject,
-                         DeviceExt->Bcb,
-                         block * BLOCKSIZE,
-                         &BaseAddress,
-                         &CacheSeg);
+   
+   BaseAddress = ExAllocatePool(NonPagedPool, 512);
+   
+   MinixReadSector(DeviceObject,
+                  block,
+                  BaseAddress);
    
    block = ((PUSHORT)BaseAddress)[(blk>>9)&511];
 
-   CcReleaseCachePage(DeviceExt->Bcb,
-                     CacheSeg,
-                     TRUE);
+   ExFreePool(BaseAddress);
    
-   MinixRequestCacheBlock(DeviceObject,
-                         DeviceExt->Bcb,
-                         block * BLOCKSIZE,
-                         &BaseAddress,
-                         &CacheSeg);
+   
+   BaseAddress = ExAllocatePool(NonPagedPool, 512);
+      
+   MinixReadSector(DeviceObject,
+                  block,
+                  BaseAddress);
    
    block = ((PUSHORT)BaseAddress)[blk&512];
 
-   CcReleaseCachePage(DeviceExt->Bcb,
-                     CacheSeg,
-                     TRUE);
-
+   ExFreePool(BaseAddress);
    
    return(block);
 }
@@ -105,7 +98,6 @@ NTSTATUS MinixReadBlock(PDEVICE_OBJECT DeviceObject,
                        PULONG DiskOffset)
 {
    unsigned int block;
-   NTSTATUS Status;
    
    DPRINT("MinixReadBlock()\n");
    
index e21fa77..fe60b86 100644 (file)
@@ -20,7 +20,7 @@
 
 /* FUNCTIONS ***************************************************************/
 
-BOLEAN MinixReadPage(PDEVICE_OBJECT DeviceObject,
+BOOLEAN MinixReadPage(PDEVICE_OBJECT DeviceObject,
                     ULONG Offset,
                     PVOID Buffer)
 {
@@ -37,12 +37,12 @@ BOLEAN MinixReadPage(PDEVICE_OBJECT DeviceObject,
             return(Result);
          }
      }
-   return(True);
+   return(TRUE);
 }
 
 BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
                        IN ULONG        DiskSector,
-                       IN UCHAR*       Buffer)
+                       IN PVOID        Buffer)
 {
     LARGE_INTEGER   sectorNumber;
     PIRP            irp;
@@ -107,7 +107,7 @@ BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
 
 BOOLEAN MinixWriteSector(IN PDEVICE_OBJECT pDeviceObject,
                        IN ULONG        DiskSector,
-                       IN UCHAR*       Buffer)
+                       IN PVOID        Buffer)
 {
     LARGE_INTEGER   sectorNumber;
     PIRP            irp;
index c361663..8be6436 100644 (file)
 #include <ddk/ntddk.h>
 #include <string.h>
 
-#define NDEBUG
+//#define NDEBUG
 #include <internal/debug.h>
 
 #include "minix.h"
 
 /* FUNCTIONS ****************************************************************/
 
-BOOLEAN MinixCompareUnicodeStringToAnsi(PCH AnsiStr, PWCHAR UnicodeStr,
+BOOLEAN MinixCompareUnicodeStringToAnsi(PCH AnsiStr, 
+                                       PWCHAR UnicodeStr,
                                        ULONG MaxLen)
 {
    unsigned int i = 0;
@@ -44,6 +45,7 @@ BOOLEAN MinixCompareUnicodeStringToAnsi(PCH AnsiStr, PWCHAR UnicodeStr,
 #define ENTRIES_PER_BLOCK (BLOCKSIZE / MINIX_DIR_ENTRY_SIZE)
 
 ULONG MinixDirLookup(PMINIX_DEVICE_EXTENSION DeviceExt,
+                    PDEVICE_OBJECT DeviceObject,
                     struct minix_inode* dir,
                     PWCHAR Name)
 {
@@ -51,69 +53,66 @@ ULONG MinixDirLookup(PMINIX_DEVICE_EXTENSION DeviceExt,
    unsigned int offset;
    unsigned int i;
    unsigned int inode;
-   PCCB Ccb = NULL;
+   PVOID Block;
+   ULONG DiskOffset;
    
    DPRINT("MinixDirLookup(DeviceExt %x, dir %x, Name %S)\n",DeviceExt,dir,
          Name);
    
+   Block = ExAllocatePool(NonPagedPool, 512);
+   
    for (i=0;i<(dir->i_size/MINIX_DIR_ENTRY_SIZE);i++)
      {
        CHECKPOINT;
        offset = i*MINIX_DIR_ENTRY_SIZE;
        if ((offset%BLOCKSIZE)==0)
          {
-            CHECKPOINT;
-            if (Ccb != NULL)
-              {
-                 CHECKPOINT;
-                 CbReleaseFromRead(&DeviceExt->Dccb,Ccb);
-              }
-            CHECKPOINT;
-            MinixReadBlock(DeviceExt,
+            MinixReadBlock(DeviceObject,
+                           DeviceExt,
                            dir,
                            offset/BLOCKSIZE,
-                           &Ccb);
+                           &DiskOffset);
+            MinixReadSector(DeviceObject,
+                            DiskOffset,
+                            Block);
          }
        current_entry = (struct minix_dir_entry *)
-         (Ccb->Buffer+offset%BLOCKSIZE);
+         (Block+offset%BLOCKSIZE);
        DPRINT("Inode %x Name %.30s\n",current_entry->inode,
               current_entry->name);
         if (MinixCompareUnicodeStringToAnsi(current_entry->name,
                                            Name,30))
          {
             inode = current_entry->inode;
-            CbReleaseFromRead(&DeviceExt->Dccb,Ccb);
+            ExFreePool(Block);
             DPRINT("MinixDirLookup() = %d\n",inode);
             return(inode);
          }
      }
    CHECKPOINT;
-   if (Ccb != NULL)
-     {
-       CbReleaseFromRead(&DeviceExt->Dccb,Ccb);
-     }
+   ExFreePool(Block);
    DPRINT("MinixDirLookup() = %d\n",0);
    return(0);
 }
 
 NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
                   MINIX_DEVICE_EXTENSION* DeviceExt,
-                  PFILE_OBJECT FileObject;
+                  PFILE_OBJECT FileObject,
                   PMINIX_FSCONTEXT result,
                   PULONG Information)
 {
    PWSTR current;
    PWSTR next;
-   PWSTR string = DeviceName;
+   PWSTR string;
    struct minix_inode current_dir;
    unsigned int current_ino;
-   PWSTR DeviceName;
    
-   DeviceName = FileObject->FileName.Buffer;
+   string = ExAllocatePool(NonPagedPool, 
+                          2*(wcslen(FileObject->FileName.Buffer)+1));
+   wcscpy(string, FileObject->FileName.Buffer);
    
    DbgPrint("MinixOpen(DeviceObject %x, DeviceName %S, result %x)\n",
-         DeviceObject,DeviceName,result);
-   DPRINT("DeviceName %x\n",DeviceName);
+         DeviceObject,string,result);
    
    
    next = &string[0];
@@ -135,7 +134,10 @@ NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
             *next=0;
          }
        
-        current_ino = MinixDirLookup(DeviceExt,&current_dir,current);
+        current_ino = MinixDirLookup(DeviceExt,
+                                    DeviceObject,
+                                    &current_dir,
+                                    current);
      }
    if (next==NULL && current_ino!=0)
      {
@@ -149,8 +151,6 @@ NTSTATUS MinixOpen(PDEVICE_OBJECT DeviceObject,
    
    result = ExAllocatePool(NonPagedPool, sizeof(MINIX_FSCONTEXT));
    memcpy(&result->inode,&current_dir,sizeof(struct minix_inode));
-   CcInitializeFileCache(FileObject, 
-                        &result->Bcb);
    
    DPRINT("MinxOpen() = STATUS_SUCCESS\n",0);
    return(STATUS_SUCCESS);
@@ -176,7 +176,7 @@ NTSTATUS MinixDirectoryControl(PDEVICE_OBJECT DeviceObject,
                               PIRP Irp)
 {
    PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
-   PFILE_OBJECT FileObject = Stack->FileObject;
+//   PFILE_OBJECT FileObject = Stack->FileObject;
    
    if (Stack->MinorFunction != IRP_MN_QUERY_DIRECTORY)
      {
@@ -195,7 +195,7 @@ NTSTATUS MinixCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp)
    PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
    PFILE_OBJECT FileObject = Stack->FileObject;
    NTSTATUS Status;
-   struct minix_inode* result;
+   PMINIX_FSCONTEXT result;
    MINIX_DEVICE_EXTENSION* DeviceExt;
    
    DPRINT("MinixCreate(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
index 19d0852..88472e7 100644 (file)
@@ -15,7 +15,7 @@
 #include <internal/bitops.h>
 #include <ddk/ntifs.h>
 
-//#define NDEBUG
+#define NDEBUG
 #include <internal/debug.h>
 
 #include "minix.h"
@@ -106,13 +106,9 @@ NTSTATUS MinixReadInode(PDEVICE_OBJECT DeviceObject,
                        ULONG ino, 
                        struct minix_inode* result)
 {
-   PCCB Ccb;
    int block;
    struct minix_inode* inodes;
-   NTSTATUS Status;
    PVOID BaseAddress;
-   BOOLEAN UptoDate;
-   PCACHE_SEGMENT* CacheSeg;
    
    DPRINT("MinixReadInode(ino %x, result %x)\n",ino,result);
    
@@ -121,29 +117,21 @@ NTSTATUS MinixReadInode(PDEVICE_OBJECT DeviceObject,
    DPRINT("Reading block %x offset %x\n",block,block*BLOCKSIZE);
    DPRINT("Index %x\n",(ino-1)%MINIX_INODES_PER_BLOCK);
    
-   Status = CcRequestCachePage(DeviceExt->Bcb,
-                              block,
-                              &BaseAddress,
-                              &UptoDate,
-                              &CacheSeg);
-   
-   if (!UptoDate)
-     {
-       MinixReadPage(DeviceExt,
-                     PAGE_ROUND_DOWN(block),
-                     BaseAddress);
-     }
+   BaseAddress = ExAllocatePool(NonPagedPool, PAGESIZE);
    
+   MinixReadPage(DeviceObject,
+                block,
+                BaseAddress);
+
    inodes = (struct minix_inode *)(BaseAddress + ((block % 4) * 512));
      
-   memcpy(result,&inodes[(ino-1)%MINIX_INODES_PER_BLOCK],
+   memcpy(result,
+         &inodes[(ino-1)%MINIX_INODES_PER_BLOCK],
          sizeof(struct minix_inode));
    DPRINT("result->i_uid %x\n",result->i_uid);
    DPRINT("result->i_size %x\n",result->i_size);
-
-   CcFreeCacheSegment(DeviceExt->FileObject,
-                     DeviceExt->Bcb,
-                     CacheSeg);
    
+   ExFreePool(BaseAddress);
+
    return(STATUS_SUCCESS);
 }
index 3e1c72c..07b9ab8 100644 (file)
@@ -38,4 +38,5 @@ minixfs.sys: $(OBJECTS)
        - $(RM) temp.exp
 
 WIN32_LEAN_AND_MEAN = yes
+WARNINGS_ARE_ERRORS = yes
 include ../../../rules.mak
index 95660dc..62f2479 100644 (file)
@@ -5,7 +5,7 @@
  * PURPOSE:          Minix FSD
  * PROGRAMMER:       David Welch (welch@mcmail.com)
  * UPDATE HISTORY: 
- */
+4 */
 
 /* INCLUDES *****************************************************************/
 
@@ -421,24 +421,27 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
  */
 {
    PDEVICE_OBJECT DeviceObject;
-   NTSTATUS ret;
-   UNICODE_STRING ustr;
-   ANSI_STRING astr;
+   NTSTATUS Status;
+   UNICODE_STRING DeviceName;
    
    DbgPrint("Minix FSD 0.0.1\n");
           
    DriverObject = _DriverObject;
    
-   RtlInitAnsiString(&astr,"\\Device\\Minix");
-   RtlAnsiStringToUnicodeString(&ustr,&astr,TRUE);
-   ret = IoCreateDevice(DriverObject,0,&ustr,
-                        FILE_DEVICE_PARALLEL_PORT,0,FALSE,&DeviceObject);
-   if (ret!=STATUS_SUCCESS)
+   RtlInitUnicodeString(&DeviceName, "\\Device\\Minix");
+   Status = IoCreateDevice(DriverObject,
+                          0,
+                          &DeviceName,
+                          FILE_DEVICE_FILE_SYSTEM,
+                          0,
+                          FALSE,
+                          &DeviceObject);
+   if (!NT_SUCCESS(Status))
      {
-       return(ret);
+       return(Status);
      }
 
-   DeviceObject->Flags=0;
+   DeviceObject->Flags = DO_DIRECT_IO;
    DriverObject->MajorFunction[IRP_MJ_CLOSE] = MinixClose;
    DriverObject->MajorFunction[IRP_MJ_CREATE] = MinixCreate;
    DriverObject->MajorFunction[IRP_MJ_READ] = MinixRead;
index 5bd5f5a..9fc6b7c 100644 (file)
@@ -78,10 +78,10 @@ struct minix_dir_entry {
 
 BOOLEAN MinixReadSector(IN PDEVICE_OBJECT pDeviceObject,
                        IN ULONG        DiskSector,
-                       IN UCHAR*       Buffer);
+                       IN PVOID        Buffer);
 BOOLEAN MinixWriteSector(IN PDEVICE_OBJECT pDeviceObject,
                        IN ULONG        DiskSector,
-                       IN UCHAR*       Buffer);
+                       IN PVOID        Buffer);
 
 #define BLOCKSIZE (1024)
 
@@ -94,12 +94,10 @@ typedef struct
    char superblock_buf[BLOCKSIZE];
    struct minix_super_block* sb;
    PFILE_OBJECT FileObject;
-   PBCB Bcb;
 } MINIX_DEVICE_EXTENSION, *PMINIX_DEVICE_EXTENSION;
 
 typedef struct
 {
-   PBCB Bcb;
    struct minix_inode inode;
 } MINIX_FSCONTEXT, *PMINIX_FSCONTEXT;
 
@@ -129,9 +127,6 @@ NTSTATUS MinixReadBlock(PDEVICE_OBJECT DeviceObject,
                        ULONG FileOffset,
                        PULONG DiskOffset);
 
-
-NTSTATUS MinixRequestCacheBlock(PDEVICE_OBJECT DeviceObject,
-                               PBCB Bcb,
-                               ULONG FileOffset,
-                               PVOID* BaseAddress,
-                               PCACHE_SEGMENT* CacheSeg);
+BOOLEAN MinixReadPage(PDEVICE_OBJECT DeviceObject,
+                     ULONG Offset,
+                     PVOID Buffer);
index a5c3a62..faae6fa 100644 (file)
@@ -44,14 +44,12 @@ VOID MinixMount(PDEVICE_OBJECT DeviceToMount)
    DeviceExt->AttachedDevice = IoAttachDeviceToDeviceStack(DeviceObject,
                                                           DeviceToMount);
    DeviceExt->FileObject = IoCreateStreamFileObject(NULL, DeviceObject);
-   CcInitializeFileCache(DeviceExt->FileObject,
-                        &DeviceExt->Bcb);
 }
 
 NTSTATUS MinixFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
 {
    PIO_STACK_LOCATION Stack = IoGetCurrentIrpStackLocation(Irp);
-   PVPB        vpb = Stack->Parameters.Mount.Vpb;
+//   PVPB      vpb = Stack->Parameters.Mount.Vpb;
    PDEVICE_OBJECT DeviceToMount = Stack->Parameters.Mount.DeviceObject;
    NTSTATUS Status;
    char* superblock_buf;
index 649057f..dae256e 100644 (file)
@@ -32,37 +32,24 @@ static NTSTATUS MinixReadFilePage(PDEVICE_OBJECT DeviceObject,
                                  PMINIX_DEVICE_EXTENSION DeviceExt,
                                  PMINIX_FSCONTEXT FsContext,
                                  ULONG Offset,
-                                 PVOID* Buffer,
-                                 PCACHE_SEGMENT* CacheSeg)
+                                 PVOID* Buffer)
 {
-   BOOLEAN UptoDate;
    NTSTATUS Status;
    ULONG i;
    ULONG DiskOffset;
-   
-   Status = CcRequestCachePage(FsContext->Bcb,
-                              Offset,
-                              Buffer,
-                              &UptoDate,
-                              CacheSeg);
-   if (!NT_SUCCESS(Status))
-     {
-       return(Status);
-     }
-   
-   if (!UptoDate)
+
+   *Buffer = ExAllocatePool(NonPagedPool, 4096);
+
+   for (i=0; i<4; i++)
      {
-       for (i=0; i<4; i++)
-         {
-            Status = MinixReadBlock(DeviceObject,
-                                    DeviceExt,
-                                    &FsContext->inode,
-                                    Offset + (i * BLOCKSIZE),
-                                    &DiskOffset);
-            MinixReadSector(DeviceObject,
-                            DiskOffset / BLOCKSIZE,
-                            (*Buffer) + (i * BLOCKSIZE));
-         }
+       Status = MinixReadBlock(DeviceObject,
+                               DeviceExt,
+                               &FsContext->inode,
+                               Offset + (i * BLOCKSIZE),
+                               &DiskOffset);
+       MinixReadSector(DeviceObject,
+                       DiskOffset / BLOCKSIZE,
+                       (*Buffer) + (i * BLOCKSIZE));
      }
    return(STATUS_SUCCESS);
 }
@@ -79,7 +66,6 @@ NTSTATUS MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
    PMINIX_FSCONTEXT FsContext = (PMINIX_FSCONTEXT)FileObject->FsContext;
    unsigned int i;
    PVOID DiskBuffer;
-   PCACHE_SEGMENT CacheSeg;
    
    DPRINT("MinixRead(DeviceObject %x, Irp %x)\n",DeviceObject,Irp);
    
@@ -113,16 +99,13 @@ NTSTATUS MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
                          DeviceExt,
                          FsContext,
                          CurrentOffset,
-                         &DiskBuffer,
-                         &CacheSeg);
+                         &DiskBuffer);
 
        memcpy(Buffer,
               DiskBuffer+(Offset%PAGESIZE),
               min(PAGESIZE - (Offset%PAGESIZE),Length));
        
-       CcReleaseCachePage(FsContext->Bcb,
-                          CacheSeg,
-                          TRUE);
+       ExFreePool(DiskBuffer);
        
        DPRINT("(BLOCKSIZE - (Offset%BLOCKSIZE)) %d\n",
               (BLOCKSIZE - (Offset%BLOCKSIZE)));
@@ -143,14 +126,11 @@ NTSTATUS MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
                          DeviceExt,
                          FsContext,
                          CurrentOffset,
-                         &DiskBuffer,
-                         &CacheSeg);
+                         &DiskBuffer);
        memcpy(Buffer, DiskBuffer, PAGESIZE);
        
-       CcReleaseCachePage(FsContext->Bcb,
-                          CacheSeg,
-                          TRUE);
-
+       ExFreePool(DiskBuffer);
+       
        CurrentOffset = CurrentOffset + PAGESIZE;
        Buffer = Buffer + PAGESIZE;
      }
@@ -164,14 +144,11 @@ NTSTATUS MinixRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
                          DeviceExt,
                          FsContext,
                          CurrentOffset,
-                         &DiskBuffer,
-                         &CacheSeg);
+                         &DiskBuffer);
 
        memcpy(Buffer, DiskBuffer, (Length%PAGESIZE));
 
-       CcReleaseCachePage(FsContext->Bcb,
-                          CacheSeg,
-                          TRUE);
+       ExFreePool(DiskBuffer);
 
      }
    
index 9ab31f4..fec23cc 100644 (file)
@@ -3,8 +3,46 @@
 
 typedef struct
 {
-   
-} CONNECT_INFO, *PCONNECT_INFO;
+} CSRSS_CONNECT_PROCESS_REQUEST, PCSRSS_CONNECT_PROCESS_REQUEST;
+
+typedef struct
+{
+} CSRSS_CONNECT_PROCESS_REPLY, PCSRSS_CONNECT_PROCESS_REPLY;
+
+typedef struct
+{
+   ULONG NewProcessId;
+   ULONG Flags;
+} CSRSS_CREATE_PROCESS_REQUEST, *PCSRSS_CREATE_PROCESS_REQUEST;
+
+typedef struct
+{
+   HANDLE ConsoleHandle;
+} CSRSS_CREATE_PROCESS_REPLY, *PCSRSS_CREATE_PROCESS_REPLY;
+
+typedef struct
+{
+   HANDLE ConsoleHandle;
+   ULONG NrCharactersToWrite;
+   BYTE Buffer[1];
+} CSRSS_WRITE_CONSOLE_REQUEST, *PCSRSS_WRITE_CONSOLE_REQUEST;
+
+typedef struct
+{
+   ULONG NrCharactersWritten;
+} CSRSS_WRITE_CONSOLE_REPLY, *PCSRSS_WRITE_CONSOLE_REPLY;
+
+typedef struct
+{
+   HANDLE ConsoleHandle;
+   ULONG NrCharactersToRead;
+} CSRSS_READ_CONSOLE_REQUEST, *PCSRSS_READ_CONSOLE_REQUEST;
+
+typedef struct
+{
+   ULONG NrCharactersRead;
+   BYTE Buffer[1];
+} CSRSS_READ_CONSOLE_REPLY, *PCSRSS_READ_CONSOLE_REPLY;
 
 #define CSRSS_CREATE_PROCESS            (0x1)
 #define CSRSS_TERMINATE_PROCESS         (0x2)
@@ -17,27 +55,25 @@ typedef struct
 typedef struct
 {
    ULONG Type;
-   BYTE Data[0x12C];
+   union
+     {
+       CSRSS_CREATE_PROCESS_REQUEST CreateProcessRequest;
+       CSRSS_CONNECT_PROCESS_REQUEST ConnectRequest;
+       CSRSS_WRITE_CONSOLE_REQUEST WriteConsoleRequest;
+       CSRSS_READ_CONSOLE_REQUEST ReadConsoleRequest;
+     } Data;
 } CSRSS_API_REQUEST, *PCSRSS_API_REQUEST;
 
 typedef struct
 {
    NTSTATUS Status;
-   ULONG Count;
-   HANDLE Handle;
+   union
+     {
+       CSRSS_CREATE_PROCESS_REPLY CreateProcessReply;
+       CSRSS_CONNECT_PROCESS_REPLY ConnectReply;
+       CSRSS_WRITE_CONSOLE_REPLY WriteConsoleReply;
+       CSRSS_READ_CONSOLE_REPLY ReadConsoleReply;
+     } Data;
 } CSRSS_API_REPLY, *PCSRSS_API_REPLY;
 
-typedef struct
-{
-   ULONG NewProcessId;
-   ULONG Flags;
-} CSRSS_CREATE_PROCESS_REQUEST, *PCSRSS_CREATE_PROCESS_REQUEST;
-
-BOOL
-STDCALL
-CsrServerInitialization (
-       ULONG ArgumentCount,
-       PWSTR *ArgumentArray
-       );
-
 #endif /* __INCLUDE_CSRSS_CSRSS_H */
index f58afb4..3214a59 100644 (file)
@@ -1,5 +1,5 @@
 
-/* $Id: zw.h,v 1.25 2000/01/05 21:56:58 dwelch Exp $
+/* $Id: zw.h,v 1.26 2000/03/22 18:35:45 dwelch Exp $
  *
  * COPYRIGHT:        See COPYING in the top level directory
  * PROJECT:          ReactOS kernel
@@ -1139,10 +1139,12 @@ ZwCreateToken(
  * FUNCTION: Returns the callers thread TEB.
  * RETURNS: The resulting teb.
  */
-NT_TEB *
+#if 0
+ NT_TEB *
 STDCALL 
 NtCurrentTeb(VOID
        );
+#endif
 
 /*
  * FUNCTION: Delays the execution of the calling thread.
index 5e51821..da5abaa 100644 (file)
@@ -92,7 +92,8 @@ typedef struct _LPCMESSAGE
 #define ProcessWx86Information                 19
 #define ProcessHandleCount                     20
 #define ProcessAffinityMask                    21
-#define MaxProcessInfoClass                    22
+#define ProcessImageFileName                    22
+#define MaxProcessInfoClass                    23
 
 // thread query / set information class
 #define ThreadBasicInformation                 0
index 93500ba..88c7c58 100644 (file)
@@ -215,6 +215,21 @@ typedef struct _NT_TEB
 
 #define PEB_STARTUPINFO (0xb0003000)
 
-#define NtCurrentPeb() ((PPEB)PEB_BASE)
+//#define NtCurrentPeb() ((PPEB)PEB_BASE)
+#define NtCurrentPeb() (NtCurrentTeb()->Peb)
+
+static inline PNT_TEB NtCurrentTeb(VOID)
+{
+   int x;
+   
+   __asm__ __volatile__("movl %%fs:0x18, %0\n\t"
+                       : "=g" (x)
+                       : /* no inputs */
+                       );
+   
+   return((PNT_TEB)x);
+}
+
+
 
 #endif /* __INCLUDE_INTERNAL_TEB */
index e31d7a8..f77c358 100644 (file)
@@ -1,32 +1,17 @@
-/* $Id: csr.h,v 1.1 2000/02/27 02:01:24 ekohl Exp $
+/* $Id: csr.h,v 1.2 2000/03/22 18:35:47 dwelch Exp $
  *
  */
 
 #ifndef __INCLUDE_NTDLL_CSR_H
 #define __INCLUDE_NTDLL_CSR_H
 
+#include <csrss/csrss.h>
 
-/*
-NTSTATUS
-STDCALL
-CsrClientCallServer (
-       ULONG Unknown1,
-       ULONG Unknown2,
-       ULONG Unknown3,
-       ULONG Unknown4
-       );
-*/
-
-NTSTATUS
-STDCALL
-CsrClientConnectToServer (
-       ULONG Unknown1,
-       ULONG Unknown2,
-       ULONG Unknown3,
-       ULONG Unknown4,
-       ULONG Unknown5,
-       ULONG Unknown6
-       );
+NTSTATUS STDCALL CsrClientConnectToServer(VOID);
+NTSTATUS STDCALL CsrClientCallServer(PCSRSS_API_REQUEST Request,
+                                    PCSRSS_API_REPLY Reply,
+                                    ULONG Length,
+                                    ULONG ReplyLength);
 
 #endif /* __INCLUDE_NTDLL_CSR_H */
 
index 9908fc9..649df4d 100644 (file)
 
 typedef union _LARGE_INTEGER
 {
-  struct
-  {
-    DWORD LowPart;
-    LONG  HighPart;
-  };
   struct
   {
     DWORD LowPart;
@@ -50,11 +45,6 @@ typedef union _LARGE_INTEGER
 
 typedef union _ULARGE_INTEGER
 {
-  struct
-  {
-    DWORD LowPart;
-    DWORD HighPart;
-  };
   struct
   {
     DWORD LowPart;
@@ -4557,6 +4547,7 @@ typedef struct
 /* PE executable header.  */
 /* Windows.h now includes pe.h to avoid conflicts! */
 
+
 #ifdef __cplusplus
 }
 #endif /* __cplusplus */
index 68a1de9..fee26e8 100644 (file)
@@ -8,6 +8,7 @@ cp services/fs/vfat/vfatfs.sys $1
 cp services/dd/ide/ide.sys $1
 cp services/dd/keyboard/keyboard.sys $1/reactos/system32/drivers
 cp services/dd/blue/blue.sys $1/reactos/system32/drivers
-cp services/dd/vga/miniport/vgamp.sys $1/reactos/system32/drivers
-cp services/dd/vga/display/vgaddi.dll $1/reactos/system32/drivers
-cp services/dd/vidport/vidport.sys $1/reactos/system32/drivers
+#cp services/dd/vga/miniport/vgamp.sys $1/reactos/system32/drivers
+#cp services/dd/vga/display/vgaddi.dll $1/reactos/system32/drivers
+#cp services/dd/vidport/vidport.sys $1/reactos/system32/drivers
+cp services/fs/minix/minixfs.sys $1/reactos/system32/drivers
index ca84692..20701f3 100644 (file)
@@ -24,3 +24,4 @@ cp apps/lpc/lpcclt.exe $1/reactos/bin
 cp apps/thread/thread.exe $1/reactos/bin
 cp apps/event/event.exe $1/reactos/bin
 cp apps/file/file.exe $1/reactos/bin
+cp apps/pteb/pteb.exe $1/reactos/bin
index 5b10cb8..5516e66 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: rw.c,v 1.8 2000/01/11 17:30:16 ekohl Exp $
+/* $Id: rw.c,v 1.9 2000/03/22 18:35:47 dwelch Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -34,6 +34,15 @@ WINBOOL STDCALL WriteFile(HANDLE hFile,
    IO_STATUS_BLOCK IIosb;
    PIO_STATUS_BLOCK IoStatusBlock;
    PLARGE_INTEGER ptrOffset;
+
+   if (IsConsoleHandle(hFile))
+     {
+       return(WriteConsoleA(hFile,
+                            lpBuffer,
+                            nNumberOfBytesToWrite,
+                            lpNumberOfBytesWritten,
+                            NULL));
+     }
    
    DPRINT("WriteFile(hFile %x)\n",hFile);
    
index 3772194..282333a 100644 (file)
@@ -18,6 +18,9 @@
 #include <assert.h>
 #include <wchar.h>
 
+#include <csrss/csrss.h>
+#include <ntdll/csr.h>
+
 #define NDEBUG
 #include <kernel32/kernel32.h>
 
@@ -96,117 +99,118 @@ WINBASEAPI BOOL WINAPI SetStdHandle(DWORD nStdHandle,
 /*--------------------------------------------------------------
  *     WriteConsoleA
  */
-WINBOOL
-STDCALL
-WriteConsoleA(
-    HANDLE hConsoleOutput,
-    CONST VOID *lpBuffer,
-    DWORD nNumberOfCharsToWrite,
-    LPDWORD lpNumberOfCharsWritten,
-    LPVOID lpReserved
-    )
+WINBOOL STDCALL WriteConsoleA(HANDLE hConsoleOutput,
+                             CONST VOID *lpBuffer,
+                             DWORD nNumberOfCharsToWrite,
+                             LPDWORD lpNumberOfCharsWritten,
+                             LPVOID lpReserved)
 {
-       return WriteFile(hConsoleOutput, lpBuffer, nNumberOfCharsToWrite,lpNumberOfCharsWritten, lpReserved);
+   PCSRSS_API_REQUEST Request;
+   CSRSS_API_REPLY Reply;
+   NTSTATUS Status;
+   
+   Request = HeapAlloc(GetProcessHeap(),
+                      HEAP_ZERO_MEMORY,
+                      sizeof(CSRSS_API_REQUEST) + nNumberOfCharsToWrite);
+   if (Request == NULL)
+     {
+       return(FALSE);
+     }
+   
+   Request->Type = CSRSS_WRITE_CONSOLE;
+   Request->Data.WriteConsoleRequest.ConsoleHandle = hConsoleOutput;
+   Request->Data.WriteConsoleRequest.NrCharactersToWrite =
+     nNumberOfCharsToWrite;
+//   DbgPrint("nNumberOfCharsToWrite %d\n", nNumberOfCharsToWrite);
+//   DbgPrint("Buffer %s\n", Request->Data.WriteConsoleRequest.Buffer);
+   memcpy(Request->Data.WriteConsoleRequest.Buffer,
+         lpBuffer,
+         nNumberOfCharsToWrite);
+   
+   Status = CsrClientCallServer(Request, 
+                               &Reply,
+                               sizeof(CSRSS_API_REQUEST) + 
+                               nNumberOfCharsToWrite,
+                               sizeof(CSRSS_API_REPLY));
+   if (!NT_SUCCESS(Status))
+     {
+       return(FALSE);
+     }
+   
+   if (lpNumberOfCharsWritten != NULL)
+     {
+       *lpNumberOfCharsWritten = 
+         Reply.Data.WriteConsoleReply.NrCharactersWritten;
+     }
+   
+   return(TRUE);
 }
 
 
 /*--------------------------------------------------------------
  *     ReadConsoleA
  */
-WINBOOL
-STDCALL
-ReadConsoleA(HANDLE hConsoleInput,
+WINBOOL STDCALL ReadConsoleA(HANDLE hConsoleInput,
                             LPVOID lpBuffer,
                             DWORD nNumberOfCharsToRead,
                             LPDWORD lpNumberOfCharsRead,
                             LPVOID lpReserved)
 {
-   KEY_EVENT_RECORD KeyEventRecord;
-   BOOL  stat = TRUE;
-   PCHAR Buffer = (PCHAR)lpBuffer;
-   DWORD Result;
-   int   i;
+   CSRSS_API_REQUEST Request;
+   PCSRSS_API_REPLY Reply;
+   NTSTATUS Status;
    
-   for (i=0; (stat && i<nNumberOfCharsToRead);)     
+   Reply = HeapAlloc(GetProcessHeap(),
+                    HEAP_ZERO_MEMORY,
+                    sizeof(CSRSS_API_REPLY) + nNumberOfCharsToRead);
+   if (Reply == NULL)
      {
-       stat = ReadFile(hConsoleInput,
-                       &KeyEventRecord,
-                        sizeof(KEY_EVENT_RECORD),
-                       &Result,
-                       NULL);
-        if (stat && KeyEventRecord.bKeyDown && KeyEventRecord.uChar.AsciiChar != 0)
-         {
-             Buffer[i] = KeyEventRecord.uChar.AsciiChar;
-            i++;
-         }
+       return(FALSE);
      }
+   
+   Request.Type = CSRSS_READ_CONSOLE;
+   Request.Data.ReadConsoleRequest.ConsoleHandle = hConsoleInput;
+   Request.Data.ReadConsoleRequest.NrCharactersToRead =
+     nNumberOfCharsToRead;
+   
+   Status = CsrClientCallServer(&Request, 
+                               Reply,
+                               sizeof(CSRSS_API_REQUEST),
+                               sizeof(CSRSS_API_REPLY) + 
+                               nNumberOfCharsToRead);
+   if (!NT_SUCCESS(Status) || !NT_SUCCESS(Reply->Status))
+     {
+       return(FALSE);
+     }
+   
    if (lpNumberOfCharsRead != NULL)
      {
-       *lpNumberOfCharsRead = i;
+       *lpNumberOfCharsRead =
+         Reply->Data.ReadConsoleReply.NrCharactersRead;
      }
-   return(stat);
+   memcpy(lpBuffer, 
+         Reply->Data.ReadConsoleReply.Buffer,
+         Reply->Data.ReadConsoleReply.NrCharactersRead);
+   
+   return(TRUE);
 }
 
 
 /*--------------------------------------------------------------
  *     AllocConsole
  */
-WINBOOL
-STDCALL
-AllocConsole( VOID )
+WINBOOL STDCALL AllocConsole(VOID)
 {
-       /* FIXME: add CreateFile error checking */
-       StdInput = CreateFile("\\\\.\\Keyboard",
-                              FILE_GENERIC_READ,
-                              0,
-                              NULL,
-                              OPEN_EXISTING,
-                              0,
-                              NULL);
-   
-       StdOutput = CreateFile("\\\\.\\BlueScreen",
-                              FILE_GENERIC_WRITE|FILE_GENERIC_READ,
-                              0,
-                              NULL,
-                              OPEN_EXISTING,
-                              0,
-                              NULL);
-
-       StdError = StdOutput;
-
-       return TRUE;
+   DbgPrint("AllocConsole() is unimplemented\n");
 }
 
 
 /*--------------------------------------------------------------
  *     FreeConsole
  */
-WINBOOL
-STDCALL
-FreeConsole( VOID )
+WINBOOL STDCALL FreeConsole(VOID)
 {
-       if (StdInput == INVALID_HANDLE_VALUE)
-       {
-               SetLastError(0); /* FIXME: What error code? */
-               return FALSE;
-       }
-       SetLastError(ERROR_SUCCESS);
-       CloseHandle(StdInput);
-
-       if (StdError != INVALID_HANDLE_VALUE)
-       {
-               if (StdError != StdOutput)
-                       CloseHandle(StdError);
-               StdError = INVALID_HANDLE_VALUE;
-       }
-
-       CloseHandle(StdOutput);
-
-#ifdef EXTENDED_CONSOLE
-       CloseHandle(StdAux);
-       CloseHandle(StdPrint);
-#endif
-       return TRUE; /* FIXME: error check needed? */
+   DbgPrint("FreeConsole() is unimplemented");
 }
 
 
index 0f03af0..f1ae41b 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: dllmain.c,v 1.10 2000/02/27 02:04:06 ekohl Exp $
+/* $Id: dllmain.c,v 1.11 2000/03/22 18:35:47 dwelch Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -41,18 +41,6 @@ WINBOOL STDCALL DllMain(HANDLE hInst,
          {
             NTSTATUS Status;
             DPRINT("DLL_PROCESS_ATTACH\n");
-
-            /*
-             * 
-             */
-            Status = CsrClientConnectToServer(0,0,0,0,0,0);
-            if (!NT_SUCCESS(Status))
-              {
-                 DbgPrint("Failed to connect to csrss.exe: expect trouble\n");
-                 /* return FALSE; */
-              }
-
-            AllocConsole();
             break;
          }
       case DLL_PROCESS_DETACH:
@@ -67,4 +55,4 @@ WINBOOL STDCALL DllMain(HANDLE hInst,
    return TRUE;
 }
 
-/* EOF */
\ No newline at end of file
+/* EOF */
index 598f6ee..1e51c09 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: stubs.c,v 1.12 2000/02/14 22:10:46 ea Exp $
+/* $Id: stubs.c,v 1.13 2000/03/22 18:35:47 dwelch Exp $
  *
  * KERNEL32.DLL stubs (unimplemented functions)
  * Remove from this file, if you implement them.
@@ -3714,15 +3714,6 @@ ShowConsoleCursor (
 
 
 
-LPVOID
-STDCALL
-TlsGetValue (
-       DWORD   dwTlsIndex
-       )
-{
-       SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
-       return NULL;
-}
 
 
 WINBOOL
index 4322c30..6fe13d4 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: create.c,v 1.24 2000/03/18 19:55:53 ekohl Exp $
+/* $Id: create.c,v 1.25 2000/03/22 18:35:48 dwelch Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -22,6 +22,8 @@
 #include <internal/teb.h>
 #include <ntdll/base.h>
 #include <ntdll/rtl.h>
+#include <csrss/csrss.h>
+#include <ntdll/csr.h>
 
 #define NDEBUG
 #include <kernel32/kernel32.h>
@@ -383,10 +385,43 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
    ULONG retlen;
    PRTL_USER_PROCESS_PARAMETERS Ppb;
    UNICODE_STRING CommandLine_U;
-
+   CSRSS_API_REQUEST CsrRequest;
+   CSRSS_API_REPLY CsrReply;
+   HANDLE ConsoleHandle;
+   CHAR ImageFileName[8];
+   PWCHAR s;
+   PWCHAR e;
+   ULONG i;
+   
    DPRINT("CreateProcessW(lpApplicationName '%S', lpCommandLine '%S')\n",
           lpApplicationName,lpCommandLine);
 
+   /*
+    * Store the image file name for the process
+    */
+   s = wcsrchr(lpApplicationName, '\\');
+   if (s == NULL)
+     {
+       s = lpApplicationName;
+     }
+   else
+     {
+       s++;
+     } 
+   e = wcschr(s, '.');
+   if (e != NULL)
+     {
+       *e = 0;
+     } 
+   for (i = 0; i < 8; i++)
+     {
+       ImageFileName[i] = (CHAR)(s[i]);
+     }
+   if (e != NULL)
+     {
+       *e = 0;
+     }
+   
    /*
     * Process the application name and command line
     */
@@ -434,8 +469,7 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
    
    /*
     * Create a new process
-    */
-   
+    */   
    Status = NtCreateProcess(&hProcess,
                            PROCESS_ALL_ACCESS,
                            NULL,
@@ -447,8 +481,7 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
    
    /*
     * Get some information about the process
-    */
-   
+    */   
    ZwQueryInformationProcess(hProcess,
                             ProcessBasicInformation,
                             &ProcessBasicInfo,
@@ -457,21 +490,50 @@ WINBOOL STDCALL CreateProcessW(LPCWSTR lpApplicationName,
    DPRINT("ProcessBasicInfo.UniqueProcessId %d\n",
          ProcessBasicInfo.UniqueProcessId);
    lpProcessInformation->dwProcessId = ProcessBasicInfo.UniqueProcessId;
-
+   
    /*
-    * Create Process Environment Block
+    * Tell the csrss server we are creating a new process
     */
+   CsrRequest.Type = CSRSS_CREATE_PROCESS;
+   CsrRequest.Data.CreateProcessRequest.NewProcessId = 
+     ProcessBasicInfo.UniqueProcessId;
+   CsrRequest.Data.CreateProcessRequest.Flags = 0;
+   Status = CsrClientCallServer(&CsrRequest, 
+                               &CsrReply,
+                               sizeof(CSRSS_API_REQUEST),
+                               sizeof(CSRSS_API_REPLY));
+   if (!NT_SUCCESS(Status) || !NT_SUCCESS(CsrReply.Status))
+     {
+       DbgPrint("Failed to tell csrss about new process. Expect trouble.\n");
+     }
+   ConsoleHandle = CsrReply.Data.CreateProcessReply.ConsoleHandle;
+   
+//   DbgPrint("ConsoleHandle %x\n", ConsoleHandle);
+   
+   /*
+    * Create Process Environment Block
+    */   
    DPRINT("Creating peb\n");
+   
+   Ppb->ConsoleHandle = ConsoleHandle;      
    KlInitPeb(hProcess, Ppb);
 
    RtlDestroyProcessParameters (Ppb);
 
+   Status = NtSetInformationProcess(hProcess,
+                                   ProcessImageFileName,
+                                   ImageFileName,
+                                   8);
+   
    DPRINT("Creating thread for process\n");
    lpStartAddress = (LPTHREAD_START_ROUTINE)
      ((PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET(NTDLL_BASE))->
      AddressOfEntryPoint + 
      ((PIMAGE_OPTIONAL_HEADER)OPTHDROFFSET(NTDLL_BASE))->ImageBase;
-   
+      
+   /*
+    * Create the thread for the kernel
+    */
    hThread =  KlCreateFirstThread(hProcess,
                                  lpThreadAttributes,
 //                               Headers.OptionalHeader.SizeOfStackReserve,
index 02a0208..dd5d1a2 100644 (file)
 #include <windows.h>
 #include <kernel32/thread.h>
 #include <string.h>
+#include <ntdll/rtl.h>
 
 /* FUNCTIONS *****************************************************************/
 
 DWORD STDCALL TlsAlloc(VOID)
 {
-#if 0
-   DWORD dwTlsIndex = GetTeb()->dwTlsIndex;
-   void        **TlsData = GetTeb()->TlsData;
-       
-   if (dwTlsIndex < (sizeof(TlsData) / sizeof(TlsData[0])))
-     {
-       TlsData[dwTlsIndex] = NULL;
-       return (dwTlsIndex++);
+   PULONG TlsBitmap = NtCurrentPeb()->TlsBitmapBits;
+   ULONG i, j;
+   
+   RtlAcquirePebLock();
+   
+   for (i = 0; i < 2; i++)
+     { 
+       for (j = 0; j < 32; j++)
+         {
+            if ((TlsBitmap[i] & (1 << j)) == 0)
+              {
+                 TlsBitmap[i] = TlsBitmap[i] | (1 << j);
+                 RtlReleasePebLock();
+                 return((i * 32) + j);
+              }
+         }
      }
+
+   RtlReleasePebLock();
    return (0xFFFFFFFFUL);
-#endif
 }
 
 WINBOOL        STDCALL TlsFree(DWORD dwTlsIndex)
 {
-#if 0
-   return (TRUE);
-#endif
+   PULONG TlsBitmap = NtCurrentPeb()->TlsBitmapBits;
+   
+   RtlAcquirePebLock();
+   TlsBitmap[dwTlsIndex / 32] =
+     TlsBitmap[dwTlsIndex / 32] & ~(1 << (dwTlsIndex % 32));
+   RtlReleasePebLock();
+   return(TRUE);
 }
 
-LPVOID STDCALL TlsGetVlue(DWORD dwTlsIndex)
+LPVOID STDCALL TlsGetValue(DWORD dwTlsIndex)
 {
-#if 0
-   void        **TlsData = GetTeb()->TlsData;
-       
-   if (dwTlsIndex < (sizeof(TlsData) / sizeof(TlsData[0])))
-     {
-       SetLastError(NO_ERROR);
-       return (TlsData[dwTlsIndex]);
-     }
-   SetLastError(1);
-   return (NULL);
-#endif
+   return(NtCurrentTeb()->TlsSlots[dwTlsIndex]);
 }
 
 WINBOOL        STDCALL TlsSetValue(DWORD dwTlsIndex, LPVOID lpTlsValue)
 {
-#if 0
-   void        **TlsData = GetTeb()->TlsData;
-       
-   if (dwTlsIndex < (sizeof(TlsData) / sizeof(TlsData[0])))
-     {
-       TlsData[dwTlsIndex] = lpTlsValue;
-       return (TRUE);
-     }
-   return (FALSE);
-#endif
+   NtCurrentTeb()->TlsSlots[dwTlsIndex] = lpTlsValue;
+   return(TRUE);
 }
index 2871ee2..1d4aeff 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: api.c,v 1.3 2000/02/27 02:05:06 ekohl Exp $
+/* $Id: api.c,v 1.4 2000/03/22 18:35:50 dwelch Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -23,35 +23,30 @@ static HANDLE WindowsApiPort;
 
 /* FUNCTIONS *****************************************************************/
 
-NTSTATUS
-STDCALL
-CsrClientCallServer(PCSRSS_API_REQUEST Request,
-                   PCSRSS_API_REPLY Reply,
-                   ULONG Unknown3,
-                   ULONG Unknown4)
+NTSTATUS STDCALL CsrClientCallServer(PCSRSS_API_REQUEST Request,
+                                    PCSRSS_API_REPLY Reply,
+                                    ULONG Length,
+                                    ULONG ReplyLength)
 {
    LPCMESSAGE LpcRequest;
    LPCMESSAGE LpcReply;
    NTSTATUS Status;
    
-   LpcRequest.ActualMessageLength = MAX_MESSAGE_DATA;
-   LpcRequest.TotalMessageLength = sizeof(LPCMESSAGE);
-   memcpy(LpcRequest.MessageData, Request, sizeof(CSRSS_API_REQUEST));
+//   DbgPrint("Length %d\n", Length);
+   
+   LpcRequest.ActualMessageLength = Length;
+   LpcRequest.TotalMessageLength = sizeof(LPCMESSAGE) + Length;
+   memcpy(LpcRequest.MessageData, Request, Length);
    
    Status = NtRequestWaitReplyPort(WindowsApiPort,
                                   &LpcRequest,
                                   &LpcReply);
+   memcpy(Reply, LpcReply.MessageData, ReplyLength);
+//   DbgPrint("Status %x Reply.Status %x\n", Status, Reply->Status);
    return(Status);
 }
 
-NTSTATUS
-STDCALL
-CsrClientConnectToServer(ULONG Unknown1,
-                        ULONG Unknown2,
-                        ULONG Unknown3,
-                        ULONG Unknown4,
-                        ULONG Unknown5,
-                        ULONG Unknown6)
+NTSTATUS STDCALL CsrClientConnectToServer(VOID)
 {
    NTSTATUS Status;
    UNICODE_STRING PortName;
@@ -77,7 +72,8 @@ CsrClientConnectToServer(ULONG Unknown1,
    Request.Type = CSRSS_CONNECT_PROCESS;
    Status = CsrClientCallServer(&Request,
                                &Reply,
-                               0, 0);
+                               sizeof(CSRSS_API_REQUEST),
+                               sizeof(CSRSS_API_REPLY));
    if (!NT_SUCCESS(Status))
      {
        return(Status);
index d0ebd7e..8aba51c 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: ntdll.def,v 1.47 2000/03/18 13:58:33 ekohl Exp $
+; $Id: ntdll.def,v 1.48 2000/03/22 18:35:50 dwelch Exp $
 ;
 ; ReactOS Operating System
 ;
@@ -6,7 +6,7 @@ LIBRARY ntdll.dll
 
 EXPORTS
 CsrClientCallServer@16
-CsrClientConnectToServer@24
+;CsrClientConnectToServer@24
 DbgBreakPoint@0
 DbgPrint
 DbgUserBreakPoint@0
index 8c987ae..43fc1fa 100644 (file)
@@ -1,4 +1,4 @@
-; $Id: ntdll.edf,v 1.36 2000/03/18 13:58:33 ekohl Exp $
+; $Id: ntdll.edf,v 1.37 2000/03/22 18:35:51 dwelch Exp $
 ;
 ; ReactOS Operating System
 ;
@@ -6,7 +6,7 @@ LIBRARY ntdll.dll
 
 EXPORTS
 CsrClientCallServer=CsrClientCallServer@16
-CsrClientConnectToServer=CsrClientConnectToServer@24
+;CsrClientConnectToServer=CsrClientConnectToServer@24
 DbgBreakPoint=DbgBreakPoint@0
 DbgPrint
 DbgUserBreakPoint=DbgUserBreakPoint@0
index 8389116..729d850 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: startup.c,v 1.21 2000/03/18 13:57:02 ekohl Exp $
+/* $Id: startup.c,v 1.22 2000/03/22 18:35:51 dwelch Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -16,6 +16,7 @@
 #include <ntdll/ldr.h>
 #include <ntdll/rtl.h>
 #include <csrss/csrss.h>
+#include <ntdll/csr.h>
 
 #define NDEBUG
 #include <ntdll/ntdll.h>
@@ -97,6 +98,16 @@ VOID LdrStartup(VOID)
        ZwTerminateProcess(NtCurrentProcess(),STATUS_UNSUCCESSFUL);
      }
 
+   /*
+    * Connect to the csrss server
+    */
+   Status = CsrClientConnectToServer();
+   if (!NT_SUCCESS(Status))
+     {
+       DbgPrint("Failed to connect to csrss.exe: expect trouble\n");
+//     ZwTerminateProcess(NtCurrentProcess(), Status);
+     }
+   
    DbgPrint("Transferring control to image at %x\n",EntryPoint);
    Status = EntryPoint(Peb);
    ZwTerminateProcess(NtCurrentProcess(),Status);
index d54c4ad..13073ac 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: ppb.c,v 1.5 2000/03/18 13:56:01 ekohl Exp $
+/* $Id: ppb.c,v 1.6 2000/03/22 18:35:51 dwelch Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -75,47 +75,47 @@ RtlCreateProcessParameters (
        PUNICODE_STRING RuntimeData
        )
 {
-       NTSTATUS Status = STATUS_SUCCESS;
-       PRTL_USER_PROCESS_PARAMETERS Param = NULL;
-       ULONG RegionSize = 0;
-       ULONG Length = 0;
-       PWCHAR Dest;
-       UNICODE_STRING EmptyString;
-       HANDLE CurrentDirectoryHandle;
-       HANDLE ConsoleHandle;
-       ULONG ConsoleFlags;
-
-       DPRINT ("RtlCreateProcessParameters\n");
-
-       RtlAcquirePebLock ();
-
-       EmptyString.Length = 0;
-       EmptyString.MaximumLength = sizeof(WCHAR);
-       EmptyString.Buffer = L"";
-
-       if (NtCurrentPeb()->ProcessParameters)
-       {
-               if (DllPath == NULL)
-                       DllPath = &NtCurrentPeb()->ProcessParameters->DllPath;
-               if (Environment == NULL)
-                       Environment  = NtCurrentPeb()->ProcessParameters->Environment;
-               if (CurrentDirectory == NULL)
-                       CurrentDirectory = &NtCurrentPeb()->ProcessParameters->CurrentDirectory.DosPath;
-               CurrentDirectoryHandle = NtCurrentPeb()->ProcessParameters->CurrentDirectory.Handle;
-               ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
-               ConsoleFlags = NtCurrentPeb()->ProcessParameters->ConsoleFlags;
-       }
-       else
-       {
-               if (DllPath == NULL)
-                       DllPath = &EmptyString;
-               if (CurrentDirectory == NULL)
-                       CurrentDirectory = &EmptyString;
-               CurrentDirectoryHandle = NULL;
-               ConsoleHandle = NULL;
-               ConsoleFlags = 0;
-       }
-
+   NTSTATUS Status = STATUS_SUCCESS;
+   PRTL_USER_PROCESS_PARAMETERS Param = NULL;
+   ULONG RegionSize = 0;
+   ULONG Length = 0;
+   PWCHAR Dest;
+   UNICODE_STRING EmptyString;
+   HANDLE CurrentDirectoryHandle;
+   HANDLE ConsoleHandle;
+   ULONG ConsoleFlags;
+
+   DPRINT ("RtlCreateProcessParameters\n");
+   
+   RtlAcquirePebLock ();
+
+   EmptyString.Length = 0;
+   EmptyString.MaximumLength = sizeof(WCHAR);
+   EmptyString.Buffer = L"";
+
+   if (NtCurrentPeb()->ProcessParameters)
+     {
+       if (DllPath == NULL)
+         DllPath = &NtCurrentPeb()->ProcessParameters->DllPath;
+       if (Environment == NULL)
+         Environment  = NtCurrentPeb()->ProcessParameters->Environment;
+       if (CurrentDirectory == NULL)
+         CurrentDirectory = &NtCurrentPeb()->ProcessParameters->CurrentDirectory.DosPath;
+       CurrentDirectoryHandle = NtCurrentPeb()->ProcessParameters->CurrentDirectory.Handle;
+       ConsoleHandle = NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+       ConsoleFlags = NtCurrentPeb()->ProcessParameters->ConsoleFlags;
+     }
+   else
+     {
+       if (DllPath == NULL)
+         DllPath = &EmptyString;
+       if (CurrentDirectory == NULL)
+         CurrentDirectory = &EmptyString;
+       CurrentDirectoryHandle = NULL;
+       ConsoleHandle = NULL;
+       ConsoleFlags = 0;
+     }
+   
        if (ImagePathName == NULL)
                ImagePathName = CommandLine;
        if (WindowTitle == NULL)
index 7a8d201..b8635a2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: process.c,v 1.17 2000/03/18 13:56:01 ekohl Exp $
+/* $Id: process.c,v 1.18 2000/03/22 18:35:51 dwelch Exp $
  *
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS system libraries
@@ -97,18 +97,24 @@ HANDLE STDCALL KlCreateFirstThread(HANDLE ProcessHandle,
 static NTSTATUS RtlpMapFile(
 PRTL_USER_PROCESS_PARAMETERS   Ppb,
 //PUNICODE_STRING ApplicationName,
-                           PHANDLE Section)
+                           PHANDLE Section,
+                           PCHAR ImageFileName)
 {
    HANDLE hFile;
    IO_STATUS_BLOCK IoStatusBlock;
    OBJECT_ATTRIBUTES ObjectAttributes;
    PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
    NTSTATUS Status;
-
+   PWCHAR s;
+   PWCHAR e;
+   ULONG i;
+   
    hFile = NULL;
 
    RtlDeNormalizeProcessParams (Ppb);
 
+//   DbgPrint("ImagePathName %x\n", Ppb->ImagePathName.Buffer);
+   
    InitializeObjectAttributes(&ObjectAttributes,
 //                           ApplicationName,
                              &(Ppb->ImagePathName),
@@ -117,7 +123,35 @@ PRTL_USER_PROCESS_PARAMETERS       Ppb,
                              SecurityDescriptor);
 
    RtlNormalizeProcessParams (Ppb);
-
+   
+   /*
+    * 
+    */
+//   DbgPrint("ImagePathName %x\n", Ppb->ImagePathName.Buffer);
+//   DbgPrint("ImagePathName %S\n", Ppb->ImagePathName.Buffer);
+   s = wcsrchr(Ppb->ImagePathName.Buffer, '\\');
+   if (s == NULL)
+     {
+       s = Ppb->ImagePathName.Buffer;
+     }
+   else
+     {
+       s++;
+     }
+   e = wcschr(s, '.');
+   if (e != NULL)
+     {
+       *e = 0;
+     }
+   for (i = 0; i < 8; i++)
+     {
+       ImageFileName[i] = (CHAR)(s[i]);     
+     }
+   if (e != NULL)
+     {
+       *e = '.';
+     }
+   
    /*
     * Try to open the executable
     */
@@ -269,12 +303,14 @@ RtlCreateUserProcess (
    LPTHREAD_START_ROUTINE  lpStartAddress = NULL;
    PROCESS_BASIC_INFORMATION ProcessBasicInfo;
    ULONG retlen;
-
+   CHAR ImageFileName[8];
+   
    DPRINT("RtlCreateUserProcess\n");
    
 //   Status = RtlpMapFile(CommandLine,
    Status = RtlpMapFile(Ppb,
-                       &hSection);
+                       &hSection,
+                       ImageFileName);
    
    /*
     * Create a new process
@@ -305,7 +341,12 @@ RtlCreateUserProcess (
    DPRINT("ProcessBasicInfo.UniqueProcessId %d\n",
          ProcessBasicInfo.UniqueProcessId);
    ProcessInfo->ClientId.UniqueProcess = (HANDLE)ProcessBasicInfo.UniqueProcessId;
-
+                         
+   Status = NtSetInformationProcess(ProcessInfo->ProcessHandle,
+                                   ProcessImageFileName,
+                                   ImageFileName,
+                                   8);
+                         
    /*
     * Create Process Environment Block
     */
index 17f78df..9408d31 100644 (file)
@@ -18,7 +18,6 @@ STUB(CsrAllocateMessagePointer)
 STUB(CsrCaptureMessageBuffer)
 STUB(CsrCaptureMessageString)
 STUB(CsrCaptureTimeout)
-STUB(CsrClientConnectToServer)
 STUB(CsrFreeCaptureBuffer)
 STUB(CsrIdentifyAlertableThread)
 STUB(CsrNewThread)
diff --git a/reactos/ntoskrnl/hal/x86/thread.c b/reactos/ntoskrnl/hal/x86/thread.c
deleted file mode 100644 (file)
index e6ce8fd..0000000
+++ /dev/null
@@ -1,341 +0,0 @@
-/*
- * COPYRIGHT:            See COPYING in the top level directory
- * PROJECT:              ReactOS kernel
- * FILE:                 ntoskrnl/hal/x86/thread.c
- * PURPOSE:              HAL multitasking functions
- * PROGRAMMER:           David Welch (welch@cwcom.net)
- * REVISION HISTORY:
- *             27/06/98: Created
- */
-
-/* INCLUDES ****************************************************************/
-
-#include <ddk/ntddk.h>
-#include <internal/ntoskrnl.h>
-#include <internal/ps.h>
-#include <string.h>
-#include <internal/string.h>
-#include <internal/hal.h>
-#include <internal/i386/segment.h>
-#include <internal/mmhal.h>
-#include <internal/ke.h>
-
-#define NDEBUG
-#include <internal/debug.h>
-
-/* GLOBALS ***************************************************************/
-
-#define NR_TASKS 128
-
-#define FIRST_TSS_SELECTOR (KERNEL_DS + 0x8)
-#define FIRST_TSS_OFFSET (FIRST_TSS_SELECTOR / 8)
-
-static char KiNullLdt[8] = {0,};
-static unsigned int KiNullLdtSel = 0;
-static PETHREAD FirstThread = NULL;
-
-/* FUNCTIONS **************************************************************/
-
-VOID HalTaskSwitch(PKTHREAD thread)
-/*
- * FUNCTION: Switch tasks
- * ARGUMENTS:
- *         thread = Thread to switch to
- * NOTE: This function will not return until the current thread is scheduled
- * again (possibly never);
- */
-{
-   DPRINT("Scheduling thread %x\n",thread);
-   DPRINT("Scheduling thread %x\n",thread->Context.nr);
-   DPRINT("previous task %x reserved1 %x esp0 %x ss0 %x\n",
-          thread->Context.previous_task,thread->Context.reserved1,
-          thread->Context.esp0,thread->Context.ss0);
-   DPRINT("reserved2 %x esp1 %x ss1 %x reserved3 %x esp2 %x ss2 %x\n",
-          thread->Context.reserved2,thread->Context.esp1,thread->Context.ss1,
-          thread->Context.reserved3,thread->Context.esp2,thread->Context.ss2);
-   DPRINT("reserved4 %x cr3 %x eip %x eflags %x eax %x\n",
-          thread->Context.reserved4,thread->Context.cr3,thread->Context.eip,
-          thread->Context.eflags,thread->Context.eax);
-   DPRINT("ecx %x edx %x ebx %x esp %x ebp %x esi %x\n",
-          thread->Context.ecx,thread->Context.edx,thread->Context.ebx,
-          thread->Context.esp,thread->Context.ebp,thread->Context.esi);
-   DPRINT("edi %x es %x reserved5 %x cs %x reserved6 %x\n",
-          thread->Context.edi,thread->Context.es,thread->Context.reserved5,
-          thread->Context.cs,thread->Context.reserved6);
-   DPRINT("ss %x reserved7 %x ds %x reserved8 %x fs %x\n",
-          thread->Context.ss,thread->Context.reserved7,thread->Context.ds,
-          thread->Context.reserved8,thread->Context.fs);
-   DPRINT("reserved9 %x gs %x reserved10 %x ldt %x reserved11 %x\n",
-          thread->Context.reserved9,thread->Context.gs,
-          thread->Context.reserved10,thread->Context.ldt,
-          thread->Context.reserved11);
-   DPRINT("trap %x iomap_base %x nr %x io_bitmap[0] %x\n",
-          thread->Context.trap,thread->Context.iomap_base,
-          thread->Context.nr,thread->Context.io_bitmap[0]);
-   DPRINT("thread->Context.cr3 %x\n",thread->Context.cr3);
-   __asm__("pushfl\n\t"
-          "cli\n\t"
-          "ljmp %0\n\t"
-          "popfl\n\t"
-          : /* No outputs */
-          : "m" (*(((unsigned char *)(&(thread->Context.nr)))-4) )
-          : "ax","dx");
-}
-
-#define FLAG_NT (1<<14)
-#define FLAG_VM (1<<17)
-#define FLAG_IF (1<<9)
-#define FLAG_IOPL ((1<<12)+(1<<13))
-
-NTSTATUS KeValidateUserContext(PCONTEXT Context)
-/*
- * FUNCTION: Validates a processor context
- * ARGUMENTS:
- *        Context = Context to validate
- * RETURNS: Status
- * NOTE: This only validates the context as not violating system security, it
- * doesn't guararantee the thread won't crash at some point
- * NOTE2: This relies on there only being two selectors which can access 
- * system space
- */
-{
-   if (Context->Eip >= KERNEL_BASE)
-     {
-       return(STATUS_UNSUCCESSFUL);
-     }
-   if (Context->SegCs == KERNEL_CS)
-     {
-       return(STATUS_UNSUCCESSFUL);
-     }
-   if (Context->SegDs == KERNEL_DS)
-     {
-       return(STATUS_UNSUCCESSFUL);
-     }
-   if (Context->SegEs == KERNEL_DS)
-     {
-       return(STATUS_UNSUCCESSFUL);
-     }
-   if (Context->SegFs == KERNEL_DS)
-     {
-       return(STATUS_UNSUCCESSFUL);
-     }
-   if (Context->SegGs == KERNEL_DS)
-     {
-       return(STATUS_UNSUCCESSFUL);
-     }
-   if ((Context->EFlags & FLAG_IOPL) != 0 ||
-       (Context->EFlags & FLAG_NT) ||
-       (Context->EFlags & FLAG_VM) ||
-       (!(Context->EFlags & FLAG_IF)))
-     {
-        return(STATUS_UNSUCCESSFUL);
-     }
-   return(STATUS_SUCCESS);
-}
-
-NTSTATUS HalReleaseTask(PETHREAD Thread)
-/*
- * FUNCTION: Releases the resource allocated for a thread by
- * HalInitTaskWithContext or HalInitTask
- * NOTE: The thread had better not be running when this is called
- */
-{
-   KeFreeGdtSelector(Thread->Tcb.Context.nr);
-   ExFreePool(Thread->Tcb.Context.KernelStackBase);
-   if (Thread->Tcb.Context.SavedKernelStackBase != NULL)
-     {
-       ExFreePool(Thread->Tcb.Context.SavedKernelStackBase);
-     }
-   return(STATUS_SUCCESS);
-}
-
-NTSTATUS HalInitTaskWithContext(PETHREAD Thread, PCONTEXT Context)
-/*
- * FUNCTION: Initialize a task with a user mode context
- * ARGUMENTS:
- *        Thread = Thread to initialize
- *        Context = Processor context to initialize it with
- * RETURNS: Status
- */
-{
-   unsigned int desc;
-   unsigned int length;
-   unsigned int base;
-   PVOID kernel_stack;
-   NTSTATUS Status;
-   PVOID stack_start;
-   ULONG GdtDesc[2];
-   
-   DPRINT("HalInitTaskWithContext(Thread %x, Context %x)\n",
-          Thread,Context);
-
-   assert(sizeof(hal_thread_state)>=0x68);
-   
-   if ((Status=KeValidateUserContext(Context))!=STATUS_SUCCESS)
-     {
-       return(Status);
-     }
-      
-   length = sizeof(hal_thread_state) - 1;
-   base = (unsigned int)(&(Thread->Tcb.Context));
-//   kernel_stack = ExAllocatePool(NonPagedPool,PAGESIZE);
-   kernel_stack = ExAllocatePool(NonPagedPool, 3*PAGESIZE);
-   
-   /*
-    * Setup a TSS descriptor
-    */
-   GdtDesc[0] = (length & 0xffff) | ((base & 0xffff) << 16);
-   GdtDesc[1] = ((base & 0xff0000)>>16) | 0x8900 | (length & 0xf0000)
-                 | (base & 0xff000000);
-   desc = KeAllocateGdtSelector(GdtDesc);
-   if (desc == 0)
-     {
-       return(STATUS_UNSUCCESSFUL);
-     }
-   
-   stack_start = kernel_stack + 4096 - sizeof(CONTEXT);
-   memcpy(stack_start, Context, sizeof(CONTEXT));
-   
-   /*
-    * Initialize the thread context
-    */
-   memset(&Thread->Tcb.Context,0,sizeof(hal_thread_state));
-   Thread->Tcb.Context.ldt = KiNullLdtSel;
-   Thread->Tcb.Context.eflags = (1<<1) + (1<<9);
-   Thread->Tcb.Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
-   Thread->Tcb.Context.esp0 = (ULONG)stack_start;
-   Thread->Tcb.Context.ss0 = KERNEL_DS;
-   Thread->Tcb.Context.esp = (ULONG)stack_start;
-   Thread->Tcb.Context.ss = KERNEL_DS;
-   Thread->Tcb.Context.cs = KERNEL_CS;
-   Thread->Tcb.Context.eip = (ULONG)PsBeginThreadWithContextInternal;
-   Thread->Tcb.Context.io_bitmap[0] = 0xff;
-   Thread->Tcb.Context.cr3 = (ULONG)
-     Thread->ThreadsProcess->Pcb.PageTableDirectory;
-   Thread->Tcb.Context.ds = KERNEL_DS;
-   Thread->Tcb.Context.es = KERNEL_DS;
-   Thread->Tcb.Context.fs = KERNEL_DS;
-   Thread->Tcb.Context.gs = KERNEL_DS;
-
-   Thread->Tcb.Context.nr = desc * 8;
-   Thread->Tcb.Context.KernelStackBase = kernel_stack;
-   Thread->Tcb.Context.SavedKernelEsp = 0;
-   Thread->Tcb.Context.SavedKernelStackBase = NULL;
-   
-   return(STATUS_SUCCESS);
-}
-
-NTSTATUS HalInitTask(PETHREAD thread, PKSTART_ROUTINE fn, PVOID StartContext)
-/*
- * FUNCTION: Initializes the HAL portion of a thread object
- * ARGUMENTS:
- *       thread = Object describes the thread
- *       fn = Entrypoint for the thread
- *       StartContext = parameter to pass to the thread entrypoint
- * RETURNS: True if the function succeeded
- */
-{
-   unsigned int desc;
-   unsigned int length = sizeof(hal_thread_state) - 1;
-   unsigned int base = (unsigned int)(&(thread->Tcb.Context));
-//   PULONG KernelStack = ExAllocatePool(NonPagedPool,4096);
-   PULONG KernelStack;
-   ULONG GdtDesc[2];
-   
-   DPRINT("HalInitTask(Thread %x, fn %x, StartContext %x)\n",
-          thread,fn,StartContext);
-   DPRINT("thread->ThreadsProcess %x\n",thread->ThreadsProcess);
-   
-   KernelStack = ExAllocatePool(NonPagedPool, 3*PAGESIZE);
-   
-   /*
-    * Make sure
-    */
-   assert(sizeof(hal_thread_state)>=0x68);
-   
-   /*
-    * Setup a TSS descriptor
-    */
-   GdtDesc[0] = (length & 0xffff) | ((base & 0xffff) << 16);
-   GdtDesc[1] = ((base & 0xff0000)>>16) | 0x8900 | (length & 0xf0000)
-                 | (base & 0xff000000);
-   desc = KeAllocateGdtSelector(GdtDesc);
-   if (desc == 0)
-     {
-       return(STATUS_UNSUCCESSFUL);
-     }
-   
-   
-//   DPRINT("sizeof(descriptor) %d\n",sizeof(descriptor));
-//   DPRINT("desc %d\n",desc);
-   
-   /*
-    * Initialize the stack for the thread (including the two arguments to 
-    * the general start routine).                                         
-    */
-   KernelStack[1023] = (unsigned int)StartContext;
-   KernelStack[1022] = (unsigned int)fn;
-   KernelStack[1021] = 0;     
-   
-   /*
-    * Initialize the thread context
-    */
-   memset(&thread->Tcb.Context,0,sizeof(hal_thread_state));
-   thread->Tcb.Context.ldt = KiNullLdtSel;
-   thread->Tcb.Context.eflags = (1<<1)+(1<<9);
-   thread->Tcb.Context.iomap_base = FIELD_OFFSET(hal_thread_state,io_bitmap);
-   thread->Tcb.Context.esp0 = (ULONG)&KernelStack[1021];
-   thread->Tcb.Context.ss0 = KERNEL_DS;
-   thread->Tcb.Context.esp = (ULONG)&KernelStack[1021];
-   thread->Tcb.Context.ss = KERNEL_DS;
-   thread->Tcb.Context.cs = KERNEL_CS;
-   thread->Tcb.Context.eip = (ULONG)PsBeginThread;
-   thread->Tcb.Context.io_bitmap[0] = 0xff;
-   thread->Tcb.Context.cr3 = (ULONG)
-     thread->ThreadsProcess->Pcb.PageTableDirectory;
-   thread->Tcb.Context.ds = KERNEL_DS;
-   thread->Tcb.Context.es = KERNEL_DS;
-   thread->Tcb.Context.fs = KERNEL_DS;
-   thread->Tcb.Context.gs = KERNEL_DS;
-   thread->Tcb.Context.nr = desc * 8;
-   thread->Tcb.Context.KernelStackBase = KernelStack;
-   thread->Tcb.Context.SavedKernelEsp = 0;
-   thread->Tcb.Context.SavedKernelStackBase = NULL;
-   DPRINT("Allocated %x\n",desc*8);
-   
-   return(STATUS_SUCCESS);
-}
-
-void HalInitFirstTask(PETHREAD thread)
-/*
- * FUNCTION: Called to setup the HAL portion of a thread object for the 
- * initial thread
- */
-{
-   ULONG base;
-   ULONG length;
-   ULONG desc;
-   ULONG GdtDesc[2];
-   
-   memset(KiNullLdt, 0, sizeof(KiNullLdt));
-   base = (unsigned int)&KiNullLdt;
-   length = sizeof(KiNullLdt) - 1;
-   GdtDesc[0] = (length & 0xffff) | ((base & 0xffff) << 16);
-   GdtDesc[1] = ((base & 0xff0000)>>16) | 0x8200 | (length & 0xf0000)
-                | (base & 0xff000000);
-   desc = KeAllocateGdtSelector(GdtDesc);
-   KiNullLdtSel = desc*8;
-   
-   /*
-    * Initialize the thread context
-    */
-   HalInitTask(thread,NULL,NULL);
-
-   /*
-    * Load the task register
-    */
-   __asm__("ltr %%ax" 
-          : /* no output */
-           : "a" (thread->Tcb.Context.nr));
-   FirstThread = thread;
-}
index ffe61a3..4a6eba1 100644 (file)
@@ -251,7 +251,8 @@ asmlinkage void exception_handler(unsigned int edi,
    DbgPrint("Process: %x\n",PsGetCurrentProcess());
    if (PsGetCurrentProcess() != NULL)
      {
-       DbgPrint("Process id: %x\n", PsGetCurrentProcess()->UniqueProcessId);
+       DbgPrint("Process id: %x <", PsGetCurrentProcess()->UniqueProcessId);
+       DbgPrint("%.8s>", PsGetCurrentProcess()->ImageFileName);
      }
    if (PsGetCurrentThread() != NULL)
      {
@@ -280,32 +281,34 @@ asmlinkage void exception_handler(unsigned int edi,
      }
   if ((cs & 0xffff) == KERNEL_CS)
     {
-      DbgPrint("ESP %x\n",esp);
+       DbgPrint("ESP %x\n",esp);
        stack = (PULONG) (esp + 24);
-       stack = (PULONG)(((ULONG)stack) & (~0x3));
+//       stack = (PULONG)(((ULONG)stack) & (~0x3));
        
-      DbgPrint("Stack:\n");
-      for (i = 0; i < 16; i = i + 4)
-        {
-          DbgPrint("%.8x %.8x %.8x %.8x\n", 
-                   stack[i], 
-                   stack[i+1], 
-                   stack[i+2], 
-                   stack[i+3]);
-        }
-      DbgPrint("Frames:\n");
-      for (i = 0; i < 32; i++)
-        {
-          if (stack[i] > ((unsigned int) &stext) &&
+       DbgPrint("stack: %p\n", stack);
+        
+        DbgPrint("Stack:\n");
+       for (i = 0; i < 16; i = i + 4)
+        {
+           DbgPrint("%.8x %.8x %.8x %.8x\n", 
+                    stack[i], 
+                    stack[i+1], 
+                    stack[i+2], 
+                    stack[i+3]);
+        }
+       DbgPrint("Frames:\n");
+       for (i = 0; i < 32; i++)
+        {
+           if (stack[i] > ((unsigned int) &stext) &&
              !(stack[i] >= ((ULONG)&init_stack) &&
                stack[i] <= ((ULONG)&init_stack_top)))
-            {
-//              DbgPrint("  %.8x", stack[i]);
-              print_address((PVOID)stack[i]);
-              DbgPrint(" ");
-            }
-        }
-     }
+             {
+                //              DbgPrint("  %.8x", stack[i]);
+                print_address((PVOID)stack[i]);
+                DbgPrint(" ");
+             }
+        }
+    }
    else
      {
 #if 0
index 3fbccb7..4aca0e1 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: loader.c,v 1.50 2000/03/19 09:14:50 ea Exp $
+/* $Id: loader.c,v 1.51 2000/03/22 18:35:56 dwelch Exp $
  * 
  * COPYRIGHT:       See COPYING in the top level directory
  * PROJECT:         ReactOS kernel
@@ -208,6 +208,7 @@ VOID LdrLoadAutoConfigDrivers (VOID)
          * VGA Miniport driver
          */
 //        LdrLoadAutoConfigDriver( L"vgamp.sys" ); moving to win32k
+//   LdrLoadAutoConfigDriver(L"minixfs.sys");
 }
 
 
@@ -318,7 +319,7 @@ LdrLoadModule(PUNICODE_STRING Filename)
       return  0;
     }
   CHECKPOINT;
-
+   
   /*  Load driver into memory chunk  */
   Status = ZwReadFile(FileHandle, 
                       0, 0, 0, 0, 
@@ -541,6 +542,7 @@ LdrPEProcessModule(PVOID ModuleLoadBase, PUNICODE_STRING pModuleName)
       DbgPrint("Failed to allocate a virtual section for driver\n");
       return 0;
     }
+   DbgPrint("DriverBase: %x\n", DriverBase);
   CHECKPOINT;
   /*  Copy headers over */
   memcpy(DriverBase, ModuleLoadBase, PEOptionalHeader->SizeOfHeaders);
index 288235e..07c54f2 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: create.c,v 1.11 2000/03/16 18:44:57 dwelch Exp $
+/* $Id: create.c,v 1.12 2000/03/22 18:35:57 dwelch Exp $
  *
  * COPYRIGHT:              See COPYING in the top level directory
  * PROJECT:                ReactOS kernel
@@ -422,7 +422,7 @@ static NTSTATUS PsCreateTeb (HANDLE ProcessHandle,
                                          PAGE_READWRITE);
         if (NT_SUCCESS(Status))
           {
-             DPRINT1 ("TEB allocated at %x\n", TebBase);
+//             DPRINT1 ("TEB allocated at %x\n", TebBase);
              break;
           }
         else
@@ -444,7 +444,8 @@ static NTSTATUS PsCreateTeb (HANDLE ProcessHandle,
      {
         Teb.Peb = Thread->ThreadsProcess->Peb; /* No PEB yet!! */
      }
-
+//   DPRINT1("Teb.Peb %x\n", Teb.Peb);
+   
    /* store stack information from InitialTeb */
    if (InitialTeb != NULL)
      {
@@ -488,14 +489,12 @@ static NTSTATUS PsCreateTeb (HANDLE ProcessHandle,
         return Status;
      }
 
-   /* FIXME: fs:[0] = TEB */
-
    if (TebPtr != NULL)
      {
         *TebPtr = (PNT_TEB)TebBase;
      }
 
-   DPRINT1 ("TEB allocated at %p\n", TebBase);
+//   DPRINT1 ("TEB allocated at %p\n", TebBase);
 
    return Status;
 }
index 5133fd4..ccb3260 100644 (file)
@@ -173,6 +173,8 @@ VOID PsInitProcessManagment(VOID)
    InitializeListHead( &KProcess->ThreadListHead );
    KeReleaseSpinLock(&PsProcessListLock, oldIrql);
    
+   strcpy(SystemProcess->ImageFileName, "SYSTEM");
+   
    ObCreateHandle(SystemProcess,
                  SystemProcess,
                  PROCESS_ALL_ACCESS,
@@ -195,7 +197,8 @@ VOID PiDeleteProcess(PVOID ObjectBody)
 
 
 static NTSTATUS PsCreatePeb(HANDLE ProcessHandle,
-                           PVOID ImageBase)
+                           PVOID ImageBase,
+                           PVOID* RPeb)
 {
    NTSTATUS Status;
    PVOID PebBase;
@@ -226,7 +229,9 @@ static NTSTATUS PsCreatePeb(HANDLE ProcessHandle,
                        &BytesWritten);
 
    DPRINT("PsCreatePeb: Peb created at %x\n", PebBase);
-
+   
+   *RPeb = PebBase;
+   
    return(STATUS_SUCCESS);
 }
 
@@ -297,6 +302,7 @@ NTSTATUS STDCALL NtCreateProcess (OUT PHANDLE ProcessHandle,
    KIRQL oldIrql;
    PVOID LdrStartupAddr;
    PVOID ImageBase;
+   PVOID Peb;
    
    DPRINT("NtCreateProcess(ObjectAttributes %x)\n",ObjectAttributes);
 
@@ -383,12 +389,14 @@ NTSTATUS STDCALL NtCreateProcess (OUT PHANDLE ProcessHandle,
     */
    DPRINT("Creating PEB\n");
    Status = PsCreatePeb(*ProcessHandle,
-                       ImageBase);
+                       ImageBase,
+                       &Peb);
    if (!NT_SUCCESS(Status))
      {
         DbgPrint("NtCreateProcess() Peb creation failed: Status %x\n",Status);
        return(Status);
      }
+   Process->Peb = Peb;
    
    ObDereferenceObject(Process);
    ObDereferenceObject(ParentProcess);
@@ -617,6 +625,12 @@ NTSTATUS STDCALL NtSetInformationProcess(IN HANDLE ProcessHandle,
        Status = PspAssignPrimaryToken(Process, *ProcessAccessTokenP);
        break;
        
+      case ProcessImageFileName:
+       memcpy(Process->ImageFileName, ProcessInformation, 8);
+//     DPRINT1("Process->ImageFileName %.8s\n", Process->ImageFileName);
+       Status = STATUS_SUCCESS;
+       break;
+         
       case ProcessLdtInformation:
       case ProcessLdtSize:
       case ProcessDefaultHardErrorMode:
index 6f34273..8ed3762 100644 (file)
@@ -24,28 +24,32 @@ typedef struct
 VOID CsrInitProcessData(VOID);
 
 NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData,
-                          PCSRSS_API_REQUEST LpcMessage);
+                          PCSRSS_CREATE_PROCESS_REQUEST Request,
+                          PLPCMESSAGE* Reply);
 
 NTSTATUS CsrTerminateProcess(PCSRSS_PROCESS_DATA ProcessData,
-                            PCSRSS_API_REQUEST LpcMessage);
+                            PCSRSS_API_REQUEST LpcMessage,
+                            PLPCMESSAGE* Reply);
 
 NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData,
-                        PCSRSS_API_REQUEST LpcMessage, 
-                        PULONG CharCount);
+                        PCSRSS_API_REQUEST LpcMessage,
+                        PLPCMESSAGE* Reply);
 
 NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData,
-                        PCSRSS_API_REQUEST LpcMessage, 
-                        PHANDLE ReturnedHandle);
+                        PCSRSS_API_REQUEST LpcMessage,
+                        PLPCMESSAGE* Reply);
 
 NTSTATUS CsrFreeConsole(PCSRSS_PROCESS_DATA ProcessData,
-                       PCSRSS_API_REQUEST LpcMessage);
+                       PCSRSS_API_REQUEST LpcMessage,
+                       PLPCMESSAGE* Reply);
 
 NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
-                       PCSRSS_API_REQUEST LpcMessage, 
-                       PULONG CharCount);
+                       PCSRSS_API_REQUEST LpcMessage,
+                       PLPCMESSAGE* Reply);
 
 NTSTATUS CsrConnectProcess(PCSRSS_PROCESS_DATA ProcessData,
-                          PCSRSS_API_REQUEST Request);
+                          PCSRSS_API_REQUEST Request,
+                          PLPCMESSAGE* Reply);
 
 /* print.c */
 VOID DisplayString(LPCWSTR lpwString);
@@ -59,6 +63,18 @@ extern HANDLE CsrssApiHeap;
 /* api/conio.c */
 VOID CsrInitConsole(PCSRSS_PROCESS_DATA ProcessData,
                    PCSRSS_CONSOLE Console);
+VOID CsrInitConsoleSupport(VOID);
 
 /* api/process.c */
 PCSRSS_PROCESS_DATA CsrGetProcessData(ULONG ProcessId);
+
+/* api/handle.c */
+NTSTATUS CsrInsertObject(PCSRSS_PROCESS_DATA ProcessData,
+                        PHANDLE Handle,
+                        PVOID Object);
+NTSTATUS CsrGetObject(PCSRSS_PROCESS_DATA ProcessData,
+                     HANDLE Handle,
+                     PVOID* Object);
+
+BOOL STDCALL CsrServerInitialization (ULONG ArgumentCount,
+                                     PWSTR *ArgumentArray);
index 8cc2c91..a0eb811 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: conio.c,v 1.2 1999/12/30 01:51:42 dwelch Exp $
+/* $Id: conio.c,v 1.3 2000/03/22 18:35:59 dwelch Exp $
  *
  * reactos/subsys/csrss/api/conio.c
  *
 
 /* GLOBALS *******************************************************************/
 
-static HANDLE ConsoleDevice;
-static HANDLE KeyboardDevice;
+static HANDLE ConsoleDeviceHandle;
+static HANDLE KeyboardDeviceHandle;
 
 /* FUNCTIONS *****************************************************************/
 
 NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData,
-                        PCSRSS_API_REQUEST LpcMessage, 
-                        PHANDLE ReturnedHandle)
+                        PCSRSS_API_REQUEST LpcMessage,
+                        PLPCMESSAGE* LpcReply)
 {
+   PCSRSS_API_REPLY Reply;
+   
+   (*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
+                                HEAP_ZERO_MEMORY,
+                                sizeof(LPCMESSAGE));
+   (*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
+   (*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
+   Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
+
+   Reply->Status = STATUS_NOT_IMPLEMENTED;
+   
    return(STATUS_NOT_IMPLEMENTED);
 }
 
 NTSTATUS CsrFreeConsole(PCSRSS_PROCESS_DATA ProcessData,
-                       PCSRSS_API_REQUEST LpcMessage)
+                       PCSRSS_API_REQUEST LpcMessage,
+                       PLPCMESSAGE* LpcReply)
 {
-   return(STATUS_NOT_IMPLEMENTED);
-}
+   PCSRSS_API_REPLY Reply;
+   
+   (*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
+                                HEAP_ZERO_MEMORY,
+                                sizeof(LPCMESSAGE));
+   (*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
+   (*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
+   Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
 
-NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
-                       PCSRSS_API_REQUEST LpcMessage, 
-                       PULONG CharCount)
-{
+   Reply->Status = STATUS_NOT_IMPLEMENTED;
+   
    return(STATUS_NOT_IMPLEMENTED);
 }
 
-
-NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData,
-                        PCSRSS_API_REQUEST Message, 
-                        PULONG CharCount)
+NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
+                       PCSRSS_API_REQUEST LpcMessage,
+                       PLPCMESSAGE* LpcReply)
 {
+   KEY_EVENT_RECORD KeyEventRecord;
+   BOOL  stat = TRUE;
+   PCHAR Buffer;
+   DWORD Result;
+   int   i;
+   ULONG nNumberOfCharsToRead;
    NTSTATUS Status;
-   PCSRSS_CONSOLE Console;
+   IO_STATUS_BLOCK Iosb;
+   PCSRSS_API_REPLY Reply;
    
-   if (ProcessData->Console == NULL)
-     {
-       return(STATUS_UNSUCCESSFUL);
-     }
-   Console = ProcessData->Console;
+//   DbgPrint("CSR: CsrReadConsole()\n");
    
-   Status = NtWaitForSingleObject(Console->LockMutant,
-                                 TRUE,
-                                 NULL);
-   if (!NT_SUCCESS(Status))
-     {
-       return(Status);
-     }
-   if (Status == STATUS_ALERTED ||
-       Status == STATUS_USER_APC)
-     {
-       return(Status);
-     }
+   nNumberOfCharsToRead = 
+     LpcMessage->Data.ReadConsoleRequest.NrCharactersToRead;
    
-   if (Console->TopLevel == TRUE)
+//   DbgPrint("CSR: NrCharactersToRead %d\n", nNumberOfCharsToRead);
+   
+   (*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
+                                HEAP_ZERO_MEMORY,
+                                sizeof(LPCMESSAGE));
+   (*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY) + 
+     nNumberOfCharsToRead;
+   (*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
+   Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);   
+   Buffer = Reply->Data.ReadConsoleReply.Buffer;
+   
+   Status = STATUS_SUCCESS;
+   
+   for (i=0; (NT_SUCCESS(Status) && i<nNumberOfCharsToRead);)     
      {
-       Status = NtReleaseMutant(Console->LockMutant, NULL);
+//     DbgPrint("CSR: Doing read file (KeyboardDeviceHandle %x)\n",
+//              KeyboardDeviceHandle);
+       Status = NtReadFile(KeyboardDeviceHandle,
+                           NULL,
+                           NULL,
+                           NULL,
+                           &Iosb,
+                           &KeyEventRecord,
+                           sizeof(KEY_EVENT_RECORD),
+                           NULL,
+                           0);
        if (!NT_SUCCESS(Status))
          {
-            return(Status);
+            DbgPrint("CSR: Read failed, bailing\n");
          }
-       
-       return(Status);
-     }
-   else
-     {
-       Status = NtReleaseMutant(Console->LockMutant, NULL);
-       if (!NT_SUCCESS(Status))
+        if (KeyEventRecord.bKeyDown && KeyEventRecord.uChar.AsciiChar != 0)
          {
-            return(Status);
+            Buffer[i] = KeyEventRecord.uChar.AsciiChar;
+            //DbgPrint("CSR: Read '%c'\n", Buffer[i]);
+            i++;
          }
-       
+     }
+   Reply->Data.ReadConsoleReply.NrCharactersRead = i;
+   Reply->Status = Status;
+   return(Status);
+}
+
+
+NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData,
+                        PCSRSS_API_REQUEST Message,
+                        PLPCMESSAGE* LpcReply)
+{
+   IO_STATUS_BLOCK Iosb;
+   NTSTATUS Status;
+   PCSRSS_API_REPLY Reply;
+   
+   (*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
+                                HEAP_ZERO_MEMORY,
+                                sizeof(LPCMESSAGE));
+   (*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
+   (*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
+   Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
+
+//   DbgPrint("CSR: CsrWriteConsole()\n");
+//   DbgPrint("CSR: ConsoleDeviceHandle %x\n", ConsoleDeviceHandle);
+//   DbgPrint("CSR: NrCharactersToWrite %d\n",
+//         Message->Data.WriteConsoleRequest.NrCharactersToWrite);
+//   DbgPrint("CSR: Buffer %s\n",
+//         Message->Data.WriteConsoleRequest.Buffer);
+   
+   Status = NtWriteFile(ConsoleDeviceHandle,
+                       NULL,
+                       NULL,
+                       NULL,
+                       &Iosb,
+                       Message->Data.WriteConsoleRequest.Buffer,
+                       Message->Data.WriteConsoleRequest.NrCharactersToWrite,
+                       NULL,
+                       0);
+   if (!NT_SUCCESS(Status))
+     {
+//     DbgPrint("CSR: Write failed\n");
        return(Status);
      }
+   Reply->Data.WriteConsoleReply.NrCharactersWritten = Iosb.Information;
+   Reply->Status = STATUS_SUCCESS;
+   return(STATUS_SUCCESS);
 }
 
 VOID CsrInitConsole(PCSRSS_PROCESS_DATA ProcessData,
@@ -95,4 +165,52 @@ VOID CsrInitConsole(PCSRSS_PROCESS_DATA ProcessData,
 {
 }
 
+VOID CsrInitConsoleSupport(VOID)
+{
+   OBJECT_ATTRIBUTES ObjectAttributes;
+   UNICODE_STRING DeviceName;
+   NTSTATUS Status;
+   IO_STATUS_BLOCK Iosb;
+   
+   DbgPrint("CSR: CsrInitConsoleSupport()\n");
+   
+   RtlInitUnicodeString(&DeviceName, L"\\??\\BlueScreen");
+   InitializeObjectAttributes(&ObjectAttributes,
+                             &DeviceName,
+                             0,
+                             NULL,
+                             NULL);
+   Status = NtOpenFile(&ConsoleDeviceHandle,
+                      FILE_ALL_ACCESS,
+                      &ObjectAttributes,
+                      &Iosb,
+                      0,
+                      FILE_SYNCHRONOUS_IO_ALERT);
+   if (!NT_SUCCESS(Status))
+     {
+       DbgPrint("CSR: Failed to open console. Expect problems.\n");
+     }
+//   DbgPrint("CSR: ConsoleDeviceHandle %x\n", ConsoleDeviceHandle);
+   
+   RtlInitUnicodeString(&DeviceName, L"\\??\\Keyboard");
+   InitializeObjectAttributes(&ObjectAttributes,
+                             &DeviceName,
+                             0,
+                             NULL,
+                             NULL);
+   Status = NtOpenFile(&KeyboardDeviceHandle,
+                      FILE_ALL_ACCESS,
+                      &ObjectAttributes,
+                      &Iosb,
+                      0,
+                      FILE_SYNCHRONOUS_IO_ALERT);
+   if (!NT_SUCCESS(Status))
+     {
+       DbgPrint("CSR: Failed to open keyboard. Expect problems.\n");
+       for(;;);
+     }
+   
+   DbgPrint("CSR: KeyboardDeviceHandle %x\n", KeyboardDeviceHandle);
+}
+
 /* EOF */
index 6ce15de..30f9095 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: handle.c,v 1.2 1999/12/30 01:51:42 dwelch Exp $
+/* $Id: handle.c,v 1.3 2000/03/22 18:36:00 dwelch Exp $
  *
  * reactos/subsys/csrss/api/handle.c
  *
@@ -11,7 +11,7 @@
 
 #include <ddk/ntddk.h>
 
-#include "csrss.h"
+#include <csrss/csrss.h>
 #include "api.h"
 
 /* FUNCTIONS *****************************************************************/
@@ -51,7 +51,7 @@ NTSTATUS CsrInsertObject(PCSRSS_PROCESS_DATA ProcessData,
                              sizeof(HANDLE));
    if (NewBlock == NULL)
      {
-       return(STATUS_NO_MORE_MEMORY);
+       return(STATUS_UNSUCCESSFUL);
      }
    RtlCopyMemory(NewBlock, 
                 ProcessData->HandleTable,
index e8bb7ff..d06ea0a 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: process.c,v 1.5 2000/02/27 02:12:07 ekohl Exp $
+/* $Id: process.c,v 1.6 2000/03/22 18:36:00 dwelch Exp $
  *
  * reactos/subsys/csrss/api/process.c
  *
@@ -30,13 +30,14 @@ VOID CsrInitProcessData(VOID)
      {
        ProcessData[i] = NULL;
      }
+   NrProcess = 256;
 }
 
 PCSRSS_PROCESS_DATA CsrGetProcessData(ULONG ProcessId)
 {
    ULONG i;
    
-   for (i=0; i<256/*NrProcess*/; i++)
+   for (i=0; i<NrProcess; i++)
      {
        if (ProcessData[i] &&
            ProcessData[i]->ProcessId == ProcessId)
@@ -44,30 +45,45 @@ PCSRSS_PROCESS_DATA CsrGetProcessData(ULONG ProcessId)
             return(ProcessData[i]);
          }
      }
-   ProcessData[i] = RtlAllocateHeap(CsrssApiHeap,
-                                   HEAP_ZERO_MEMORY,
-                                   sizeof(CSRSS_PROCESS_DATA));
-   if (ProcessData[i] == NULL)
+   for (i=0; i<NrProcess; i++)
      {
-       return(NULL);
+       if (ProcessData[i] == NULL)
+         {         
+            ProcessData[i] = RtlAllocateHeap(CsrssApiHeap,
+                                             HEAP_ZERO_MEMORY,
+                                             sizeof(CSRSS_PROCESS_DATA));
+            if (ProcessData[i] == NULL)
+              {
+                 return(NULL);
+              }
+            ProcessData[i]->ProcessId = ProcessId;
+            return(ProcessData[i]);
+         }
      }
-   ProcessData[i]->ProcessId = ProcessId;
-   return(ProcessData[i]);
+   DbgPrint("CSR: CsrGetProcessData() failed\n");
+   return(NULL);
 }
 
 
 NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData,
-                          PCSRSS_API_REQUEST LpcMessage)
+                          PCSRSS_CREATE_PROCESS_REQUEST Request,
+                          PLPCMESSAGE* LpcReply)
 {
-   PCSRSS_CREATE_PROCESS_REQUEST Request;
    PCSRSS_PROCESS_DATA NewProcessData;
+   PCSRSS_API_REPLY Reply;
    
-   Request = (PCSRSS_CREATE_PROCESS_REQUEST)LpcMessage->Data;
+   (*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
+                                HEAP_ZERO_MEMORY,
+                                sizeof(LPCMESSAGE));
+   (*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
+   (*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
+   Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
    
    NewProcessData = CsrGetProcessData(Request->NewProcessId);
    
    if (NewProcessData == NULL)
      {
+       Reply->Status = STATUS_NO_MEMORY;
        return(STATUS_NO_MEMORY);
      }
    
@@ -91,18 +107,50 @@ NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData,
        NewProcessData->Console = ProcessData->Console;
      }
    
-   return(STATUS_NOT_IMPLEMENTED);
+   CsrInsertObject(NewProcessData,
+                  &Reply->Data.CreateProcessReply.ConsoleHandle,
+                  NewProcessData->Console);
+   
+   DbgPrint("CSR: ConsoleHandle %x\n",
+           Reply->Data.CreateProcessReply.ConsoleHandle);
+   DisplayString(L"CSR: Did CreateProcess successfully\n");
+   
+   return(STATUS_SUCCESS);
 }
 
 NTSTATUS CsrTerminateProcess(PCSRSS_PROCESS_DATA ProcessData,
-                            PCSRSS_API_REQUEST LpcMessage)
+                            PCSRSS_API_REQUEST LpcMessage,
+                            PLPCMESSAGE* LpcReply)
 {
+      PCSRSS_API_REPLY Reply;
+   
+   (*LpcReply) = (PLPCMESSAGE)RtlAllocateHeap(CsrssApiHeap,
+                                             HEAP_ZERO_MEMORY,
+                                             sizeof(LPCMESSAGE));
+   (*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
+   (*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
+   Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
+   
+   Reply->Status = STATUS_NOT_IMPLEMENTED;
+   
    return(STATUS_NOT_IMPLEMENTED);
 }
 
 NTSTATUS CsrConnectProcess(PCSRSS_PROCESS_DATA ProcessData,
-                          PCSRSS_API_REQUEST Request)
+                          PCSRSS_API_REQUEST Request,
+                          PLPCMESSAGE* LpcReply)
 {
+      PCSRSS_API_REPLY Reply;
+   
+   (*LpcReply) = RtlAllocateHeap(CsrssApiHeap,
+                                HEAP_ZERO_MEMORY,
+                                sizeof(LPCMESSAGE));
+   (*LpcReply)->ActualMessageLength = sizeof(CSRSS_API_REPLY);
+   (*LpcReply)->TotalMessageLength = sizeof(LPCMESSAGE);
+   Reply = (PCSRSS_API_REPLY)((*LpcReply)->MessageData);
+   
+   Reply->Status = STATUS_SUCCESS;
+   
    return(STATUS_SUCCESS);
 }
 
index cbe26eb..4c9e0fb 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: wapi.c,v 1.4 2000/02/29 23:57:46 ea Exp $
+/* $Id: wapi.c,v 1.5 2000/03/22 18:36:00 dwelch Exp $
  * 
  * reactos/subsys/csrss/api/wapi.c
  *
@@ -28,8 +28,8 @@ static void Thread_Api2(HANDLE ServerPort)
    PLPCMESSAGE LpcReply;
    LPCMESSAGE LpcRequest;
    PCSRSS_API_REQUEST Request;
-   CSRSS_API_REPLY Reply;
    PCSRSS_PROCESS_DATA ProcessData;
+   PCSRSS_API_REPLY Reply;
    
    LpcReply = NULL;
    
@@ -43,58 +43,78 @@ static void Thread_Api2(HANDLE ServerPort)
          {
             DisplayString(L"CSR: NtReplyWaitReceivePort failed\n");
          }
+       if (LpcReply != NULL)
+         {
+            RtlFreeHeap(CsrssApiHeap,
+                        0,
+                        LpcReply);
+         }
        
        Request = (PCSRSS_API_REQUEST)LpcRequest.MessageData;
+       LpcReply = NULL;
+       Reply = NULL;
        
        ProcessData = CsrGetProcessData(LpcRequest.ClientProcessId);
        
-       DisplayString(L"CSR: Received request\n");
+//     DisplayString(L"CSR: Received request\n");
        
        switch (Request->Type)
          {
           case CSRSS_CREATE_PROCESS:
-            Reply.Status = CsrCreateProcess(ProcessData, 
-                                            Request);
+            Status = CsrCreateProcess(ProcessData, 
+                                      &Request->Data.CreateProcessRequest,
+                                      &LpcReply);
             break;
             
           case CSRSS_TERMINATE_PROCESS:
-            Reply.Status = CsrTerminateProcess(ProcessData, 
-                                               Request);
+            Status = CsrTerminateProcess(ProcessData, 
+                                         Request,
+                                         &LpcReply);
             break;
             
           case CSRSS_WRITE_CONSOLE:
-            Reply.Status = CsrWriteConsole(ProcessData, 
-                                           Request, 
-                                           &Reply.Count);
+            Status = CsrWriteConsole(ProcessData, 
+                                     Request,
+                                     &LpcReply);
             break;
             
           case CSRSS_READ_CONSOLE:
-            Reply.Status = CsrReadConsole(ProcessData, 
-                                          Request,
-                                          &Reply.Count);
+            Status = CsrReadConsole(ProcessData, 
+                                    Request,
+                                    &LpcReply);
             break;
             
           case CSRSS_ALLOC_CONSOLE:
-            Reply.Status = CsrAllocConsole(ProcessData, 
-                                           Request, 
-                                           &Reply.Handle);
+            Status = CsrAllocConsole(ProcessData, 
+                                     Request,
+                                     &LpcReply);
             break;
             
           case CSRSS_FREE_CONSOLE:
-            Reply.Status = CsrFreeConsole(ProcessData, 
-                                          Request);
+            Status = CsrFreeConsole(ProcessData, 
+                                    Request,
+                                    &LpcReply);
             break;
             
           case CSRSS_CONNECT_PROCESS:
-            Reply.Status = CsrConnectProcess(ProcessData, 
-                                             Request);
+            Status = CsrConnectProcess(ProcessData, 
+                                       Request,
+                                       &LpcReply);
+            break;
             
           default:
-            Reply.Status = STATUS_NOT_IMPLEMENTED;
+            LpcReply = RtlAllocateHeap(CsrssApiHeap,
+                                       HEAP_ZERO_MEMORY,
+                                       sizeof(LPCMESSAGE));
+            Reply = (PCSRSS_API_REPLY)(LpcReply->MessageData);
+            Reply->Status = STATUS_NOT_IMPLEMENTED;
          }
        
-       LpcReply = &LpcRequest;
-       RtlCopyMemory(LpcReply->MessageData, &Reply, sizeof(Reply));
+       Reply = (PCSRSS_API_REPLY)(LpcReply->MessageData);
+       if (Reply->Status == STATUS_SUCCESS)
+         {
+//          DisplayString(L"CSR: Returning STATUS_SUCCESS\n");
+         }
      }
 }
 
@@ -125,7 +145,8 @@ void Thread_Api(PVOID PortHandle)
      }
 
    CsrInitProcessData();
-
+   CsrInitConsoleSupport();
+   
    for (;;)
      {
        Status = NtListenPort(PortHandle, &Request);
index b177cf0..df8aecd 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: csrss.c,v 1.5 2000/02/27 02:11:54 ekohl Exp $
+/* $Id: csrss.c,v 1.6 2000/03/22 18:35:58 dwelch Exp $
  *
  * csrss.c - Client/Server Runtime subsystem
  * 
@@ -35,6 +35,8 @@
 #include <ntdll/rtl.h>
 #include <csrss/csrss.h>
 
+#include "api.h"
+
 VOID PrintString (char* fmt, ...);
 
 /* Native process' entry point */
@@ -47,7 +49,11 @@ VOID NtProcessStartup(PPEB Peb)
    ULONG argc = 0;
    int i = 0;
    int afterlastspace = 0;
-
+   OBJECT_ATTRIBUTES ObjectAttributes;
+   HANDLE CsrssInitEvent;
+   UNICODE_STRING UnicodeString;
+   NTSTATUS Status;
+   
    DisplayString(L"Client/Server Runtime Subsystem\n");
 
    ProcParams = RtlNormalizeProcessParams (Peb->ProcessParameters);
@@ -85,11 +91,29 @@ VOID NtProcessStartup(PPEB Peb)
        ArgBuffer[i] = L'\0';
        argv[argc-1] = &(ArgBuffer[afterlastspace]);
      }
-
+   
+   RtlInitUnicodeString(&UnicodeString,
+                       L"\\CsrssInitDone");
+   InitializeObjectAttributes(&ObjectAttributes,
+                             &UnicodeString,
+                             EVENT_ALL_ACCESS,
+                             0,
+                             NULL);
+   Status = NtOpenEvent(&CsrssInitEvent,
+                       EVENT_ALL_ACCESS,
+                       &ObjectAttributes);
+   if (!NT_SUCCESS(Status))
+     {
+       DbgPrint("CSR: Failed to open csrss notification event\n");
+     }
+   
    if (CsrServerInitialization (argc, argv) == TRUE)
      {
        DisplayString( L"CSR: Subsystem initialized.\n" );
 
+       NtSetEvent(CsrssInitEvent,
+                  NULL);
+       
        RtlFreeHeap (Peb->ProcessHeap,
                     0, argv);
        RtlFreeHeap (Peb->ProcessHeap,
index 49fc00a..0423c99 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: init.c,v 1.6 2000/02/29 23:57:45 ea Exp $
+/* $Id: init.c,v 1.7 2000/03/22 18:35:58 dwelch Exp $
  * 
  * reactos/subsys/csrss/init.c
  *
@@ -101,7 +101,7 @@ CsrServerInitialization (
        PrintString("CSR: Unable to parse the command line (Status: %x)\n", Status);
        return(FALSE);
      }
-
+   
    /* NEW NAMED PORT: \ApiPort */
    RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort");
    InitializeObjectAttributes(&ObAttributes,
index d69f077..f578508 100644 (file)
@@ -1,4 +1,4 @@
-# $Id: makefile,v 1.5 2000/02/27 02:11:54 ekohl Exp $
+# $Id: makefile,v 1.6 2000/03/22 18:35:58 dwelch Exp $
 #
 # CSRSS: Client/server runtime subsystem
 #
@@ -8,7 +8,7 @@ TARGET=csrss
 
 BASE_CFLAGS = -I../../include -I.
 
-OBJECTS_API = api/process.o api/wapi.o api/conio.o
+OBJECTS_API = api/process.o api/wapi.o api/conio.o api/handle.o
 
 OBJECTS_SBAPI =
 
index 91f3abc..e84590f 100644 (file)
@@ -1,4 +1,4 @@
-/* $Id: init.c,v 1.15 2000/02/27 15:47:17 ekohl Exp $
+/* $Id: init.c,v 1.16 2000/03/22 18:36:00 dwelch Exp $
  *
  * init.c - Session Manager initialization
  * 
@@ -34,7 +34,7 @@
 #define NDEBUG
 
 /* uncomment to run csrss.exe */
-//#define RUN_CSRSS
+#define RUN_CSRSS
 
 /* GLOBAL VARIABLES *********************************************************/
 
@@ -155,147 +155,169 @@ SmSetEnvironmentVariables (VOID)
 }
 
 
-BOOL
-InitSessionManager (
-       HANDLE  Children[]
-       )
+BOOL InitSessionManager (HANDLE        Children[])
 {
-       NTSTATUS Status;
-       UNICODE_STRING UnicodeString;
-       OBJECT_ATTRIBUTES ObjectAttributes;
-       UNICODE_STRING CmdLineW;
-       UNICODE_STRING CurrentDirectoryW;
-       PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
-       RTL_USER_PROCESS_INFO ProcessInfo;
-
-       /* Create the "\SmApiPort" object (LPC) */
-       RtlInitUnicodeString (&UnicodeString,
-                             L"\\SmApiPort");
-       InitializeObjectAttributes (&ObjectAttributes,
-                                   &UnicodeString,
-                                   0xff,
-                                   NULL,
-                                   NULL);
-
-       Status = NtCreatePort (&SmApiPort,
-                              &ObjectAttributes,
-                              0,
-                              0,
-                              0);
-
-       if (!NT_SUCCESS(Status))
-       {
-               return FALSE;
-       }
-
+   NTSTATUS Status;
+   UNICODE_STRING UnicodeString;
+   OBJECT_ATTRIBUTES ObjectAttributes;
+   UNICODE_STRING CmdLineW;
+   UNICODE_STRING CurrentDirectoryW;
+   PRTL_USER_PROCESS_PARAMETERS ProcessParameters;
+   RTL_USER_PROCESS_INFO ProcessInfo;
+   HANDLE CsrssInitEvent;
+   
+   /* Create the "\SmApiPort" object (LPC) */
+   RtlInitUnicodeString (&UnicodeString,
+                        L"\\SmApiPort");
+   InitializeObjectAttributes (&ObjectAttributes,
+                              &UnicodeString,
+                              0xff,
+                              NULL,
+                              NULL);
+   
+   Status = NtCreatePort (&SmApiPort,
+                         &ObjectAttributes,
+                         0,
+                         0,
+                         0);
+
+   if (!NT_SUCCESS(Status))
+     {
+       return FALSE;
+     }
+   
 #ifndef NDEBUG
-       DisplayString (L"SM: \\SmApiPort created...\n");
+   DisplayString (L"SM: \\SmApiPort created...\n");
 #endif
-
-       /* Create two threads for "\SmApiPort" */
-       RtlCreateUserThread (NtCurrentProcess (),
-                            NULL,
-                            FALSE,
-                            0,
-                            NULL,
-                            NULL,
-                            (PTHREAD_START_ROUTINE)SmApiThread,
-                            (PVOID)SmApiPort,
-                            NULL,
-                            NULL);
-
-       RtlCreateUserThread (NtCurrentProcess (),
-                            NULL,
-                            FALSE,
-                            0,
-                            NULL,
-                            NULL,
-                            (PTHREAD_START_ROUTINE)SmApiThread,
-                            (PVOID)SmApiPort,
-                            NULL,
-                            NULL);
-
-       /* Create the system environment */
-       Status = RtlCreateEnvironment (TRUE,
-                                      &SmSystemEnvironment);
-       if (!NT_SUCCESS(Status))
-               return FALSE;
+   
+   /* Create two threads for "\SmApiPort" */
+   RtlCreateUserThread (NtCurrentProcess (),
+                       NULL,
+                       FALSE,
+                       0,
+                       NULL,
+                       NULL,
+                       (PTHREAD_START_ROUTINE)SmApiThread,
+                       (PVOID)SmApiPort,
+                       NULL,
+                       NULL);
+
+   RtlCreateUserThread (NtCurrentProcess (),
+                       NULL,
+                       FALSE,
+                       0,
+                       NULL,
+                       NULL,
+                       (PTHREAD_START_ROUTINE)SmApiThread,
+                       (PVOID)SmApiPort,
+                       NULL,
+                       NULL);
+   
+   /* Create the system environment */
+   Status = RtlCreateEnvironment (TRUE,
+                                 &SmSystemEnvironment);
+   if (!NT_SUCCESS(Status))
+     return FALSE;
 #ifndef NDEBUG
-       DisplayString (L"SM: System Environment created\n");
+   DisplayString (L"SM: System Environment created\n");
 #endif
 
-       /* FIXME: Define symbolic links to kernel devices (MS-DOS names) */
-
-       /* FIXME: Run all programs in the boot execution list */
-
-       /* FIXME: Process the file rename list */
-
-       /* FIXME: Load the well known DLLs */
-
+   /* FIXME: Define symbolic links to kernel devices (MS-DOS names) */
+   
+   /* FIXME: Run all programs in the boot execution list */
+   
+   /* FIXME: Process the file rename list */
+   
+   /* FIXME: Load the well known DLLs */
+   
 #if 0
-       /* Create paging files */
-       SmCreatePagingFiles ();
+   /* Create paging files */
+   SmCreatePagingFiles ();
 #endif
-
+   
 #if 0
-       /* Load missing registry hives */
-       NtInitializeRegistry (FALSE);
+   /* Load missing registry hives */
+   NtInitializeRegistry (FALSE);
 #endif
-
-       /* Set environment variables from registry */
-       SmSetEnvironmentVariables ();
-
-       /* Load the kernel mode driver win32k.sys */
-       RtlInitUnicodeString (&CmdLineW,
-                             L"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys");
-       Status = NtLoadDriver (&CmdLineW);
-
-       if (!NT_SUCCESS(Status))
-       {
-               return FALSE;
-       }
-
+   
+   /* Set environment variables from registry */
+   SmSetEnvironmentVariables ();
+
+   /* Load the kernel mode driver win32k.sys */
+   RtlInitUnicodeString (&CmdLineW,
+                        L"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys");
+   Status = NtLoadDriver (&CmdLineW);
+   
+   if (!NT_SUCCESS(Status))
+     {
+       return FALSE;
+     }
+   
 #ifdef RUN_CSRSS
-       /* Start the Win32 subsystem (csrss.exe) */
-       DisplayString (L"SM: Executing csrss.exe\n");
-
-       RtlInitUnicodeString (&UnicodeString,
-                             L"\\??\\C:\\reactos\\system32\\csrss.exe");
-
-       /* initialize current directory */
-       RtlInitUnicodeString (&CurrentDirectoryW,
-                             L"C:\\reactos\\system32\\");
-
-       RtlCreateProcessParameters (&ProcessParameters,
-                                   &UnicodeString,
-                                   NULL,
-                                   &CurrentDirectoryW,
-                                   NULL,
-                                   SmSystemEnvironment,
-                                   NULL,
-                                   NULL,
-                                   NULL,
-                                   NULL);
-
-       Status = RtlCreateUserProcess (&UnicodeString,
-                                      0,
-                                      ProcessParameters,
-                                      NULL,
-                                      NULL,
-                                      FALSE,
-                                      0,
-                                      0,
+   RtlInitUnicodeString(&UnicodeString,
+                       L"\\CsrssInitDone");
+   InitializeObjectAttributes(&ObjectAttributes,
+                             &UnicodeString,
+                             EVENT_ALL_ACCESS,
+                             0,
+                             NULL);
+   Status = NtCreateEvent(&CsrssInitEvent,
+                         EVENT_ALL_ACCESS,
+                         &ObjectAttributes,
+                         TRUE,
+                         FALSE);
+   if (!NT_SUCCESS(Status))
+     {
+       DbgPrint("Failed to create csrss notification event\n");
+     }
+   
+   /* Start the Win32 subsystem (csrss.exe) */
+   DisplayString (L"SM: Executing csrss.exe\n");
+   
+   RtlInitUnicodeString (&UnicodeString,
+                        L"\\??\\C:\\reactos\\system32\\csrss.exe");
+   
+   /* initialize current directory */
+   RtlInitUnicodeString (&CurrentDirectoryW,
+                        L"C:\\reactos\\system32\\");
+   
+   RtlCreateProcessParameters (&ProcessParameters,
+                              &UnicodeString,
+                              NULL,
+                              &CurrentDirectoryW,
+                              NULL,
+                              SmSystemEnvironment,
+                              NULL,
+                              NULL,
+                              NULL,
+                              NULL);
+
+   Status = RtlCreateUserProcess (&UnicodeString,
+                                 0,
+                                 ProcessParameters,
+                                 NULL,
+                                 NULL,
+                                 FALSE,
+                                 0,
+                                 0,
                                       0,
-                                      &ProcessInfo);
-
-       RtlDestroyProcessParameters (ProcessParameters);
-
-       if (!NT_SUCCESS(Status))
-       {
-               DisplayString (L"SM: Loading csrss.exe failed!\n");
-               return FALSE;
-       }
-       Children[CHILD_CSRSS] = ProcessInfo.ProcessHandle;
+                                 &ProcessInfo);
+   
+   RtlDestroyProcessParameters (ProcessParameters);
+   
+   if (!NT_SUCCESS(Status))
+     {
+       DisplayString (L"SM: Loading csrss.exe failed!\n");
+       return FALSE;
+     }
+   
+   DbgPrint("SM: Waiting for csrss\n");
+   NtWaitForSingleObject(CsrssInitEvent,
+                        FALSE,
+                        NULL);
+   DbgPrint("SM: Finished waiting for csrss\n");
+   
+   Children[CHILD_CSRSS] = ProcessInfo.ProcessHandle;
 #endif /* RUN_CSRSS */