Mailslot and named pipe preparations

svn path=/trunk/; revision=1843
This commit is contained in:
Eric Kohl 2001-05-01 11:09:01 +00:00
parent dabd23ba77
commit b76211b20a
13 changed files with 545 additions and 437 deletions

View file

@ -1,13 +1,14 @@
# $Id: Makefile,v 1.3 2000/04/01 14:20:21 ea Exp $
# $Id: Makefile,v 1.4 2001/05/01 11:09:01 ekohl Exp $
#
# Named Pipes File System
#
PATH_TO_TOP = ../../..
TARGETNAME=npfs
BASE_CFLAGS = -I../../../include
#BASE_CFLAGS = -I../../../include
OBJECTS = create.o mount.o npfs.coff \
OBJECTS = create.o fsctrl.o mount.o rw.o npfs.coff \
../../../ntoskrnl/ntoskrnl.a
all: $(TARGETNAME).sys

View file

@ -1,4 +1,4 @@
/* $Id: create.c,v 1.4 2000/05/13 13:51:08 dwelch Exp $
/* $Id: create.c,v 1.5 2001/05/01 11:09:01 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -11,11 +11,12 @@
#include <ddk/ntddk.h>
//#define NDEBUG
#include <internal/debug.h>
#include "npfs.h"
//#define NDEBUG
#include <debug.h>
/* GLOBALS *******************************************************************/
static LIST_ENTRY PipeListHead;
@ -29,8 +30,9 @@ VOID NpfsInitPipeList(VOID)
KeInitializeMutex(&PipeListLock, 0);
}
NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
NTSTATUS STDCALL
NpfsCreate(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
@ -40,6 +42,10 @@ NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject,
PWSTR PipeName;
PNPFS_PIPE current;
PLIST_ENTRY current_entry;
PNPFS_DEVICE_EXTENSION DeviceExt;
KIRQL oldIrql;
DPRINT1("NpfsCreate(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
IoStack = IoGetCurrentIrpStackLocation(Irp);
@ -63,8 +69,8 @@ NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject,
while (current_entry != &PipeListHead)
{
current = CONTAINING_RECORD(current_entry,
PipeListEntry,
NPFS_PIPE);
NPFS_PIPE,
PipeListEntry);
if (wcscmp(Pipe->Name, current->Name) == 0)
{
@ -74,7 +80,7 @@ NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject,
current_entry = current_entry->Flink;
}
if (current_entry == PipeListHead)
if (current_entry == &PipeListHead)
{
ExFreePool(Fcb);
KeUnlockMutex(&PipeListLock);
@ -89,9 +95,9 @@ NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject,
Pipe = current;
KeAcquireSpinLock(&Pipe->FcbListHead, &oldIrql);
KeAcquireSpinLock(&Pipe->FcbListLock, &oldIrql);
InsertTailList(&Pipe->FcbListHead, &Fcb->FcbListEntry);
KeReleaseSpinLock(&Pipe->FcbListHead, oldIrql);
KeReleaseSpinLock(&Pipe->FcbListLock, oldIrql);
Fcb->WriteModeMessage = FALSE;
Fcb->ReadModeMessage = FALSE;
Fcb->NonBlocking = FALSE;
@ -115,19 +121,23 @@ NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject,
return(Status);
}
NTSTATUS NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS STDCALL
NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
NTSTATUS Status;
NTSTATUS Status = STATUS_SUCCESS;
PNPFS_DEVICE_EXTENSION DeviceExt;
PWSTR PipeName;
PNPFS_PIPE Pipe;
PNPFS_FCB Fcb;
NTSTATUS Status;
KIRQL oldIrql;
PLIST_ENTRY current_entry;
PNPFS_PIPE current;
PIO_PIPE_CREATE_BUFFER Buffer;
DPRINT1("NpfsCreateNamedPipe(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
IoStack = IoGetCurrentIrpStackLocation(Irp);
@ -135,6 +145,8 @@ NTSTATUS NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp)
PipeName = FileObject->FileName.Buffer;
Buffer = (PIO_PIPE_CREATE_BUFFER)Irp->Tail.Overlay.AuxiliaryBuffer;
Pipe = ExAllocatePool(NonPagedPool, sizeof(NPFS_PIPE));
if (Pipe == NULL)
{
@ -164,28 +176,31 @@ NTSTATUS NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp)
if (Pipe->Name == NULL)
{
ExFreePool(Pipe);
ExFreePool(Fcb);
ExFreePool(Fcb);
Irp->IoStatus.Status = STATUS_NO_MEMORY;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
}
return(STATUS_NO_MEMORY);
}
wcscpy(Pipe->Name, PipeName);
Pipe->ReferenceCount = 0;
InitializeListHead(&Pipe->FcbListHead);
KeInitializeSpinLock(&Pipe->FcbListLock);
Pipe->MaxInstances = IoStack->Parameters.CreateNamedPipe.MaxInstances;
Pipe->TimeOut = IoStack->Parameters.CreateNamedPipe.TimeOut;
Pipe->MaxInstances = Buffer->MaxInstances;
Pipe->TimeOut = Buffer->TimeOut;
KeLockMutex(&PipeListLock);
current_entry = PipeListHead.Flink;
while (current_entry != &PipeListHead)
{
current = CONTAINING_RECORD(current_entry,
PipeListEntry,
NPFS_PIPE);
NPFS_PIPE,
PipeListEntry);
if (wcscmp(Pipe->Name, current->Name) == 0)
{
@ -208,20 +223,21 @@ NTSTATUS NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp)
}
Pipe->ReferenceCount++;
KeAcquireSpinLock(&Pipe->FcbListHead, &oldIrql);
KeAcquireSpinLock(&Pipe->FcbListLock, &oldIrql);
InsertTailList(&Pipe->FcbListHead, &Fcb->FcbListEntry);
KeReleaseSpinLock(&Pipe->FcbListHead, oldIrql);
Fcb->WriteModeMessage =
IoStack->Parameters.CreateNamedPipe.WriteModeMessage;
Fcb->ReadModeMessage = IoStack->Parameters.CreateNamedPipe.ReadModeMessage;
Fcb->NonBlocking = IoStack->Parameters.CreateNamedPipe.NonBlocking;
Fcb->InBufferSize = IoStack->Parameters.CreateNamedPipe.InBufferSize;
Fcb->OutBufferSize = IoStack->Parameters.CreateNamedPipe.OutBufferSize;
KeReleaseSpinLock(&Pipe->FcbListLock, oldIrql);
Fcb->WriteModeMessage = Buffer->WriteModeMessage;
Fcb->ReadModeMessage = Buffer->ReadModeMessage;
Fcb->NonBlocking = Buffer->NonBlocking;
Fcb->InBufferSize = Buffer->InBufferSize;
Fcb->OutBufferSize = Buffer->OutBufferSize;
Fcb->Pipe = Pipe;
Fcb->IsServer = TRUE;
Fcb->OtherSide = NULL;
KeUnlockMutex(PipeListLock);
KeUnlockMutex(&PipeListLock);
FileObject->FsContext = Fcb;
@ -234,4 +250,31 @@ NTSTATUS NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp)
}
NTSTATUS STDCALL
NpfsClose(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
PNPFS_FCB Fcb;
NTSTATUS Status;
DPRINT1("NpfsClose(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
IoStack = IoGetCurrentIrpStackLocation(Irp);
FileObject = IoStack->FileObject;
Fcb = FileObject->FsContext;
DPRINT1("Closing pipe %S\n", Fcb->Pipe->Name);
Status = STATUS_SUCCESS;
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status);
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: fsctrl.c,v 1.1 2000/05/13 13:51:08 dwelch Exp $
/* $Id: fsctrl.c,v 1.2 2001/05/01 11:09:01 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -10,15 +10,17 @@
/* INCLUDES ******************************************************************/
#include <ddk/ntddk.h>
#include "npfs.h"
//#define NDEBUG
#include <internal/debug.h>
#include <debug.h>
#include "npfs.h"
/* FUNCTIONS *****************************************************************/
NTSTATUS NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS STDCALL
NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
@ -33,7 +35,7 @@ NTSTATUS NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp)
Fcb = FileObject->FsContext;
Pipe = Fcb->Pipe;
switch (stk->Parameters.FileSystemControl.IoControlCode)
switch (IoStack->Parameters.FileSystemControl.IoControlCode)
{
case FSCTL_WAIT_PIPE:
break;

View file

@ -1,4 +1,4 @@
/* $Id: mount.c,v 1.4 2000/05/13 13:51:08 dwelch Exp $
/* $Id: mount.c,v 1.5 2001/05/01 11:09:01 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -10,19 +10,19 @@
/* INCLUDES ******************************************************************/
#include <ddk/ntddk.h>
#include "npfs.h"
//#define NDEBUG
#include <internal/debug.h>
#include <debug.h>
#include "npfs.h"
/* GLOBALS *******************************************************************/
static PDRIVER_OBJECT DriverObject;
//static PDRIVER_OBJECT DriverObject;
/* FUNCTIONS *****************************************************************/
NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
NTSTATUS DriverEntry(PDRIVER_OBJECT DriverObject,
PUNICODE_STRING RegistryPath)
{
PDEVICE_OBJECT DeviceObject;
@ -32,13 +32,14 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
DbgPrint("Named Pipe Filesystem\n");
DriverObject = _DriverObject;
// DriverObject = _DriverObject;
#if 0
RtlInitUnicodeString(&DeviceName, L"\\Device\\Npfs");
Status = IoCreateDevice(DriverObject,
0,
&DeviceName,
FILE_DEVICE_FILE_SYSTEM,
FILE_DEVICE_NAMED_PIPE,
0,
FALSE,
&DeviceObject);
@ -47,35 +48,61 @@ NTSTATUS DriverEntry(PDRIVER_OBJECT _DriverObject,
return(Status);
}
RtlInitUnicodeString(&LinkName, L"\\??\\pipe");
RtlInitUnicodeString(&LinkName, L"\\??\\Pipe");
Status = IoCreateSymbolicLink(&LinkName,
&DeviceName);
#endif
DeviceObject->Flags = 0;
DeviceObject->MajorFunction[IRP_MJ_CLOSE] = NpfsClose;
DeviceObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] =
DriverObject->MajorFunction[IRP_MJ_CREATE] = NpfsCreate;
DriverObject->MajorFunction[IRP_MJ_CREATE_NAMED_PIPE] =
NpfsCreateNamedPipe;
DeviceObject->MajorFunction[IRP_MJ_CREATE] = NpfsCreate;
DeviceObject->MajorFunction[IRP_MJ_READ] = NpfsRead;
DeviceObject->MajorFunction[IRP_MJ_WRITE] = NpfsWrite;
DeviceObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
NpfsDirectoryControl;
DeviceObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
NpfsQueryInformation;
DeviceObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
NpfsSetInformation;
DeviceObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = NpfsFlushBuffers;
DeviceObject->MajorFunction[IRP_MJ_SHUTDOWN] = NpfsShutdown;
DeviceObject->MajorFunction[IRP_MJ_CLEANUP] = NpfsCleanup;
DeviceObject->MajorFunction[IRP_MJ_QUERY_SECURITY] =
NpfsQuerySecurity;
DeviceObject->MajorFunction[IRP_MJ_SET_SECURITY] =
NpfsSetSecurity;
DeviceObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
DriverObject->MajorFunction[IRP_MJ_CLOSE] = NpfsClose;
DriverObject->MajorFunction[IRP_MJ_READ] = NpfsRead;
DriverObject->MajorFunction[IRP_MJ_WRITE] = NpfsWrite;
// DriverObject->MajorFunction[IRP_MJ_DIRECTORY_CONTROL] =
// NpfsDirectoryControl;
// DriverObject->MajorFunction[IRP_MJ_QUERY_INFORMATION] =
// NpfsQueryInformation;
// DriverObject->MajorFunction[IRP_MJ_SET_INFORMATION] =
// NpfsSetInformation;
// DriverObject->MajorFunction[IRP_MJ_FLUSH_BUFFERS] = NpfsFlushBuffers;
// DriverObject->MajorFunction[IRP_MJ_SHUTDOWN] = NpfsShutdown;
// DriverObject->MajorFunction[IRP_MJ_CLEANUP] = NpfsCleanup;
// DriverObject->MajorFunction[IRP_MJ_QUERY_SECURITY] =
// NpfsQuerySecurity;
// DriverObject->MajorFunction[IRP_MJ_SET_SECURITY] =
// NpfsSetSecurity;
DriverObject->MajorFunction[IRP_MJ_FILE_SYSTEM_CONTROL] =
NpfsFileSystemControl;
DriverObject->DriverUnload = NULL;
RtlInitUnicodeString(&DeviceName, L"\\Device\\Npfs");
Status = IoCreateDevice(DriverObject,
0,
&DeviceName,
FILE_DEVICE_NAMED_PIPE,
0,
FALSE,
&DeviceObject);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to create named pipe device! (Status %x)\n", Status);
return(Status);
}
RtlInitUnicodeString(&LinkName, L"\\??\\Pipe");
Status = IoCreateSymbolicLink(&LinkName,
&DeviceName);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to create named pipe symbolic link! (Status %x)\n", Status);
// IoDeleteDevice();
return(Status);
}
NpfsInitPipeList();
return(STATUS_SUCCESS);

View file

@ -14,7 +14,7 @@ typedef struct
LIST_ENTRY FcbListHead;
ULONG ReferenceCount;
ULONG MaxInstances;
LARGE_INTEGER TimeOut;
LARGE_INTEGER TimeOut;
} NPFS_PIPE, *PNPFS_PIPE;
typedef struct _NPFS_FCB
@ -40,4 +40,13 @@ VOID NpfsPipeList(VOID);
#define KeUnlockMutex(x) KeReleaseMutex(x, FALSE);
NTSTATUS STDCALL NpfsCreate(PDEVICE_OBJECT DeviceObject, PIRP Irp);
NTSTATUS STDCALL NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp);
NTSTATUS STDCALL NpfsClose(PDEVICE_OBJECT DeviceObject, PIRP Irp);
NTSTATUS STDCALL NpfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp);
NTSTATUS STDCALL NpfsWrite(PDEVICE_OBJECT DeviceObject, PIRP Irp);
NTSTATUS STDCALL NpfsFileSystemControl(PDEVICE_OBJECT DeviceObject, PIRP Irp);
#endif /* __SERVICES_FS_NP_NPFS_H */

View file

@ -1,4 +1,4 @@
/* $Id: rw.c,v 1.1 2000/03/26 22:00:09 dwelch Exp $
/* $Id: rw.c,v 1.2 2001/05/01 11:09:01 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -10,31 +10,36 @@
/* INCLUDES ******************************************************************/
#include <ddk/ntddk.h>
#include "npfs.h"
//#define NDEBUG
#include <internal/debug.h>
#include <debug.h>
#include "npfs.h"
/* FUNCTIONS *****************************************************************/
NTSTATUS NpfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
NTSTATUS STDCALL
NpfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
PFILE_OBJECT FileObject;
NTSTATUS Status;
PNPFS_DEVICE_EXTENSION DeviceExt;
PWSTR PipeName;
PNPFS_FSCONTEXT PipeDescr;
NTSTATUS Status;
// PNPFS_FSCONTEXT PipeDescr;
KIRQL oldIrql;
PLIST_ENTRY current_entry;
PNPFS_CONTEXT current;
// PNPFS_CONTEXT current;
ULONG Information;
DeviceExt = (PNPFS_DEVICE_EXTENSION)DeviceObject->DeviceExtension;
IoStack = IoGetCurrentIrpStackLocation(Irp);
FileObject = IoStack->FileObject;
Status = STATUS_SUCCESS;
Information = 0;
#if 0
PipeDescr = FileObject->FsContext;
if (PipeType & NPFS_READMODE_BYTE)
@ -68,6 +73,7 @@ NTSTATUS NpfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
else
{
}
#endif
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = Information;
@ -78,4 +84,22 @@ NTSTATUS NpfsRead(PDEVICE_OBJECT DeviceObject, PIRP Irp)
}
NTSTATUS STDCALL
NpfsWrite(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
NTSTATUS Status;
DPRINT1("NpfsWrite()\n");
Status = STATUS_SUCCESS;
Irp->IoStatus.Status = Status;
Irp->IoStatus.Information = 0;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return(Status);
}
/* EOF */

View file

@ -52,17 +52,17 @@ enum
enum
{
IRP_NOCACHE = 0x1,
IRP_PAGING_IO = 0x2,
IRP_MOUNT_COMPLETION = 0x4,
IRP_SYNCHRONOUS_API = 0x8,
IRP_PAGING_IO = 0x2,
IRP_MOUNT_COMPLETION = 0x4,
IRP_SYNCHRONOUS_API = 0x8,
IRP_ASSOCIATED_IRP = 0x10,
IRP_BUFFERED_IO = 0x20,
IRP_DEALLOCATE_BUFFER = 0x40,
IRP_INPUT_OPERATION = 0x80,
IRP_SYNCHRONOUS_PAGING_IO = 0x100,
IRP_CREATE_OPERATION = 0x200,
IRP_READ_OPERATION = 0x400,
IRP_WRITE_OPERATION = 0x800,
IRP_BUFFERED_IO = 0x20,
IRP_DEALLOCATE_BUFFER = 0x40,
IRP_INPUT_OPERATION = 0x80,
IRP_SYNCHRONOUS_PAGING_IO = 0x100,
IRP_CREATE_OPERATION = 0x200,
IRP_READ_OPERATION = 0x400,
IRP_WRITE_OPERATION = 0x800,
IRP_CLOSE_OPERATION = 0x1000,
IRP_DEFER_IO_COMPLETION = 0x2000,
};
@ -192,7 +192,7 @@ typedef enum _INTERFACE_TYPE
enum
{
{
IRP_MJ_CREATE,
IRP_MJ_CREATE_NAMED_PIPE,
IRP_MJ_CLOSE,
@ -206,7 +206,7 @@ enum
IRP_MJ_QUERY_VOLUME_INFORMATION,
IRP_MJ_SET_VOLUME_INFORMATION,
IRP_MJ_DIRECTORY_CONTROL,
IRP_MJ_FILE_SYSTEM_CONTROL,
IRP_MJ_FILE_SYSTEM_CONTROL,
IRP_MJ_DEVICE_CONTROL,
IRP_MJ_INTERNAL_DEVICE_CONTROL,
IRP_MJ_SHUTDOWN,

View file

@ -1,4 +1,4 @@
/* $Id: iotypes.h,v 1.26 2001/04/26 01:31:35 phreak Exp $
/* $Id: iotypes.h,v 1.27 2001/05/01 11:04:52 ekohl Exp $
*
*/
@ -110,8 +110,8 @@ typedef struct _IO_SECURITY_CONTEXT
typedef struct _IO_STACK_LOCATION
{
UCHAR MajorFunction;
UCHAR MinorFunction;
UCHAR Flags;
UCHAR MinorFunction;
UCHAR Flags;
UCHAR Control;
union
@ -155,31 +155,37 @@ typedef struct _IO_STACK_LOCATION
struct _VPB* Vpb;
struct _DEVICE_OBJECT* DeviceObject;
} Mount;
struct {
ULONG Length;
FILE_INFORMATION_CLASS FileInformationClass;
} QueryFile;
struct {
ULONG Length;
FS_INFORMATION_CLASS FileInformationClass;
} QueryVolume;
struct {
ULONG Length;
FS_INFORMATION_CLASS FileInformationClass;
} SetVolume;
struct {
ULONG Length;
FILE_INFORMATION_CLASS FileInformationClass;
struct _FILE_OBJECT* FileObject;
union {
struct {
BOOLEAN ReplaceIfExists;
BOOLEAN AdvanceOnly;
} d;
ULONG ClusterCount;
HANDLE DeleteHandle;
} u;
} SetFile;
struct
{
ULONG Length;
FILE_INFORMATION_CLASS FileInformationClass;
} QueryFile;
struct
{
ULONG Length;
FS_INFORMATION_CLASS FileInformationClass;
} QueryVolume;
struct
{
ULONG Length;
FS_INFORMATION_CLASS FileInformationClass;
} SetVolume;
struct
{
ULONG Length;
FILE_INFORMATION_CLASS FileInformationClass;
struct _FILE_OBJECT* FileObject;
union
{
struct
{
BOOLEAN ReplaceIfExists;
BOOLEAN AdvanceOnly;
} d;
ULONG ClusterCount;
HANDLE DeleteHandle;
} u;
} SetFile;
struct
{
ULONG Length;
@ -187,26 +193,11 @@ typedef struct _IO_STACK_LOCATION
FILE_INFORMATION_CLASS FileInformationClass;
ULONG FileIndex;
} QueryDirectory;
/*
struct
{
ULONG CreateDisposition;
ULONG CreateOptions;
ULONG ShareAccess;
BOOLEAN WriteModeMessage;
BOOLEAN ReadModeMessage;
BOOLEAN NonBlocking;
ULONG MaxInstances;
ULONG InBufferSize;
ULONG OutBufferSize;
LARGE_INTEGER TimeOut;
} CreateNamedPipe;
*/
} Parameters;
struct _DEVICE_OBJECT* DeviceObject;
struct _FILE_OBJECT* FileObject;
PIO_COMPLETION_ROUTINE CompletionRoutine;
PVOID CompletionContext;
@ -218,6 +209,27 @@ typedef struct _IO_STATUS_BLOCK
ULONG Information;
} IO_STATUS_BLOCK, *PIO_STATUS_BLOCK;
typedef struct _IO_PIPE_CREATE_BUFFER
{
BOOLEAN WriteModeMessage;
BOOLEAN ReadModeMessage;
BOOLEAN NonBlocking;
ULONG MaxInstances;
ULONG InBufferSize;
ULONG OutBufferSize;
LARGE_INTEGER TimeOut;
} IO_PIPE_CREATE_BUFFER, *PIO_PIPE_CREATE_BUFFER;
typedef struct _IO_MAILSLOT_CREATE_BUFFER
{
ULONG Param; /* ?? */
ULONG MaxMessageSize;
LARGE_INTEGER TimeOut;
} IO_MAILSLOT_CREATE_BUFFER, *PIO_MAILSLOT_CREATE_BUFFER;
/*
* Driver entry point declaration
*/

View file

@ -501,6 +501,7 @@ extern "C" {
#define PIPE_READMODE_MESSAGE (2)
#define PIPE_WAIT (0)
#define PIPE_NOWAIT (1)
#define PIPE_UNLIMITED_INSTANCES (255)
/* CreatePen, ExtCreatePen */
#define PS_GEOMETRIC (65536)

View file

@ -1,10 +1,10 @@
/* $Id: create.c,v 1.38 2001/03/21 23:30:20 chorns Exp $
/* $Id: create.c,v 1.39 2001/05/01 11:05:42 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
* FILE: ntoskrnl/io/create.c
* PURPOSE: Handling file create/open apis
* PROGRAMMER: David Welch (welch@cwcom.net)
* PROGRAMMER: David Welch (welch@cwcom.net)
* UPDATE HISTORY:
* 24/05/98: Created
*/
@ -83,7 +83,7 @@ IopCreateFile (PVOID ObjectBody,
}
if (IoDeviceObjectType != BODY_TO_HEADER(Parent)->ObjectType)
{
DPRINT ("Parent is not a device type\n");
DPRINT("Parent is not a device type\n");
return (STATUS_UNSUCCESSFUL);
}
Status = ObReferenceObjectByPointer (DeviceObject,
@ -92,13 +92,13 @@ IopCreateFile (PVOID ObjectBody,
UserMode);
if (STATUS_SUCCESS != Status)
{
CHECKPOINT;
CHECKPOINT1;
return (Status);
}
DeviceObject = IoGetAttachedDevice (DeviceObject);
DPRINT ("DeviceObject %x\n", DeviceObject);
DPRINT("DeviceObject %x\n", DeviceObject);
if (NULL == RemainingPath)
{
@ -109,37 +109,40 @@ IopCreateFile (PVOID ObjectBody,
TAG_FILE_NAME);
FileObject->FileName.Length = ObjectAttributes->ObjectName->Length;
FileObject->FileName.MaximumLength =
ObjectAttributes->ObjectName->MaximumLength;
ObjectAttributes->ObjectName->MaximumLength;
RtlCopyUnicodeString(&(FileObject->FileName),
ObjectAttributes->ObjectName);
}
else
{
if ((DeviceObject->DeviceType != FILE_DEVICE_FILE_SYSTEM)
&& (DeviceObject->DeviceType != FILE_DEVICE_DISK)
&& (DeviceObject->DeviceType != FILE_DEVICE_NETWORK))
&& (DeviceObject->DeviceType != FILE_DEVICE_NETWORK)
&& (DeviceObject->DeviceType != FILE_DEVICE_NAMED_PIPE)
&& (DeviceObject->DeviceType != FILE_DEVICE_MAILSLOT))
{
DPRINT ("Device was wrong type\n");
DPRINT("Device was wrong type\n");
return (STATUS_UNSUCCESSFUL);
}
if (DeviceObject->DeviceType != FILE_DEVICE_NETWORK)
{
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
if (DeviceObject->DeviceType != FILE_DEVICE_NETWORK
&& (DeviceObject->DeviceType != FILE_DEVICE_NAMED_PIPE)
&& (DeviceObject->DeviceType != FILE_DEVICE_MAILSLOT))
{
DPRINT("Trying to mount storage device\n");
Status = IoTryToMountStorageDevice (DeviceObject);
DPRINT("Status %x\n", Status);
if (!NT_SUCCESS(Status))
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
{
DPRINT("Failed to mount storage device (statux %x)\n",
Status);
return (Status);
DPRINT("Trying to mount storage device\n");
Status = IoTryToMountStorageDevice (DeviceObject);
DPRINT("Status %x\n", Status);
if (!NT_SUCCESS(Status))
{
DPRINT("Failed to mount storage device (statux %x)\n",
Status);
return (Status);
}
DeviceObject = IoGetAttachedDevice(DeviceObject);
}
DeviceObject = IoGetAttachedDevice(DeviceObject);
}
}
RtlCreateUnicodeString(&(FileObject->FileName),
RemainingPath);
}
@ -177,8 +180,8 @@ IopCreateFile (PVOID ObjectBody,
*
*/
PFILE_OBJECT STDCALL
IoCreateStreamFileObject (PFILE_OBJECT FileObject,
PDEVICE_OBJECT DeviceObject)
IoCreateStreamFileObject(PFILE_OBJECT FileObject,
PDEVICE_OBJECT DeviceObject)
{
HANDLE FileHandle;
PFILE_OBJECT CreatedFileObject;
@ -262,10 +265,10 @@ IoCreateStreamFileObject (PFILE_OBJECT FileObject,
* Undocumented;
*
* CreateFileType
* Undocumented;
* Type of file (normal, named pipe, mailslot) to create;
*
* ExtraCreateParameters
* Undocumented;
* ExtraCreateParameters [OPTIONAL]
* Additional creation data for named pipe and mailsots;
*
* Options
* Undocumented.
@ -281,9 +284,8 @@ IoCreateStreamFileObject (PFILE_OBJECT FileObject,
* REVISIONS
*
*/
NTSTATUS
STDCALL
IoCreateFile (
NTSTATUS STDCALL
IoCreateFile(
OUT PHANDLE FileHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
@ -297,103 +299,118 @@ IoCreateFile (
IN ULONG EaLength,
IN CREATE_FILE_TYPE CreateFileType,
IN PVOID ExtraCreateParameters OPTIONAL,
IN ULONG Options
)
IN ULONG Options)
{
PFILE_OBJECT FileObject;
NTSTATUS Status;
PIRP Irp;
KEVENT Event;
PIO_STACK_LOCATION StackLoc;
PFILE_OBJECT FileObject;
NTSTATUS Status;
PIRP Irp;
KEVENT Event;
PIO_STACK_LOCATION StackLoc;
DPRINT("IoCreateFile(FileHandle %x, DesiredAccess %x, "
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
FileHandle,DesiredAccess,ObjectAttributes,
ObjectAttributes->ObjectName->Buffer);
DPRINT("IoCreateFile(FileHandle %x, DesiredAccess %x, "
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
FileHandle,DesiredAccess,ObjectAttributes,
ObjectAttributes->ObjectName->Buffer);
assert_irql(PASSIVE_LEVEL);
assert_irql(PASSIVE_LEVEL);
*FileHandle = 0;
*FileHandle = 0;
FileObject = ObCreateObject (FileHandle,
DesiredAccess,
ObjectAttributes,
IoFileObjectType);
if (FileObject == NULL)
{
return (STATUS_UNSUCCESSFUL);
}
if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
{
//FileObject->Flags = FileObject->Flags | FO_ALERTABLE_IO;
//FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
FileObject->Flags |= (FO_ALERTABLE_IO | FO_SYNCHRONOUS_IO);
}
if (CreateOptions & FILE_SYNCHRONOUS_IO_NONALERT)
{
//FileObject->Flags |= FileObject->Flags | FO_SYNCHRONOUS_IO;
FileObject->Flags |= FO_SYNCHRONOUS_IO;
}
KeInitializeEvent (&FileObject->Lock, NotificationEvent, TRUE);
KeInitializeEvent (&Event, NotificationEvent, FALSE);
FileObject = ObCreateObject(FileHandle,
DesiredAccess,
ObjectAttributes,
IoFileObjectType);
if (FileObject == NULL)
{
DPRINT1("ObCreateObject() failed!\n");
return (STATUS_UNSUCCESSFUL);
}
if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
{
//FileObject->Flags = FileObject->Flags | FO_ALERTABLE_IO;
//FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
FileObject->Flags |= (FO_ALERTABLE_IO | FO_SYNCHRONOUS_IO);
}
if (CreateOptions & FILE_SYNCHRONOUS_IO_NONALERT)
{
//FileObject->Flags |= FileObject->Flags | FO_SYNCHRONOUS_IO;
FileObject->Flags |= FO_SYNCHRONOUS_IO;
}
KeInitializeEvent(&FileObject->Lock, NotificationEvent, TRUE);
KeInitializeEvent(&Event, NotificationEvent, FALSE);
DPRINT("FileObject %x\n", FileObject);
DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
/*
* Create a new IRP to hand to
* the FS driver: this may fail
* due to resource shortage.
*/
Irp = IoAllocateIrp(FileObject->DeviceObject->StackSize, FALSE);
if (Irp == NULL)
{
return (STATUS_UNSUCCESSFUL);
}
Irp->AssociatedIrp.SystemBuffer = EaBuffer;
Irp->Tail.Overlay.AuxiliaryBuffer = (PCHAR)ExtraCreateParameters;
/*
* Get the stack location for the new
* IRP and prepare it.
*/
StackLoc = IoGetNextIrpStackLocation(Irp);
switch (CreateFileType)
{
default:
case CreateFileTypeNone:
StackLoc->MajorFunction = IRP_MJ_CREATE;
break;
DPRINT("FileObject %x\n", FileObject);
DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
/*
* Create a new IRP to hand to
* the FS driver: this may fail
* due to resource shortage.
*/
Irp = IoAllocateIrp (FileObject->DeviceObject->StackSize, FALSE);
if (Irp == NULL)
{
return (STATUS_UNSUCCESSFUL);
}
Irp->AssociatedIrp.SystemBuffer = EaBuffer;
/*
* Get the stack location for the new
* IRP and prepare it.
*/
StackLoc = IoGetNextIrpStackLocation (Irp);
StackLoc->MajorFunction = IRP_MJ_CREATE;
StackLoc->MinorFunction = 0;
StackLoc->Flags = 0;
StackLoc->Control = 0;
StackLoc->DeviceObject = FileObject->DeviceObject;
StackLoc->FileObject = FileObject;
StackLoc->Parameters.Create.Options = (CreateOptions & FILE_VALID_OPTION_FLAGS);
StackLoc->Parameters.Create.Options |= (CreateDisposition << 24);
/*
* Now call the driver and
* possibly wait if it can
* not complete the request
* immediately.
*/
Status = IofCallDriver (FileObject->DeviceObject, Irp );
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject (&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = IoStatusBlock->Status;
}
if (!NT_SUCCESS(Status))
{
DPRINT("Failing create request with status %x\n", Status);
ZwClose (*FileHandle);
(*FileHandle) = 0;
}
assert_irql(PASSIVE_LEVEL);
case CreateFileTypeNamedPipe:
StackLoc->MajorFunction = IRP_MJ_CREATE_NAMED_PIPE;
break;
DPRINT("Finished IoCreateFile() (*FileHandle) %x\n", (*FileHandle));
return (Status);
case CreateFileTypeMailslot:
StackLoc->MajorFunction = IRP_MJ_CREATE_MAILSLOT;
break;
}
StackLoc->MinorFunction = 0;
StackLoc->Flags = 0;
StackLoc->Control = 0;
StackLoc->DeviceObject = FileObject->DeviceObject;
StackLoc->FileObject = FileObject;
StackLoc->Parameters.Create.Options = (CreateOptions & FILE_VALID_OPTION_FLAGS);
StackLoc->Parameters.Create.Options |= (CreateDisposition << 24);
/*
* Now call the driver and
* possibly wait if it can
* not complete the request
* immediately.
*/
Status = IofCallDriver(FileObject->DeviceObject, Irp );
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,
Executive,
KernelMode,
FALSE,
NULL);
Status = IoStatusBlock->Status;
}
if (!NT_SUCCESS(Status))
{
DPRINT1("Failing create request with status %x\n", Status);
ZwClose(*FileHandle);
(*FileHandle) = 0;
}
assert_irql(PASSIVE_LEVEL);
DPRINT("Finished IoCreateFile() (*FileHandle) %x\n", (*FileHandle));
return (Status);
}
@ -415,39 +432,33 @@ IoCreateFile (
* 2000-03-25 (ea)
* Code originally in NtCreateFile moved in IoCreateFile.
*/
NTSTATUS
STDCALL
NtCreateFile (
PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
PLARGE_INTEGER AllocateSize,
ULONG FileAttributes,
ULONG ShareAccess,
ULONG CreateDisposition,
ULONG CreateOptions,
PVOID EaBuffer,
ULONG EaLength
)
NTSTATUS STDCALL
NtCreateFile(PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
PLARGE_INTEGER AllocateSize,
ULONG FileAttributes,
ULONG ShareAccess,
ULONG CreateDisposition,
ULONG CreateOptions,
PVOID EaBuffer,
ULONG EaLength)
{
return IoCreateFile (
FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
AllocateSize,
FileAttributes,
ShareAccess,
CreateDisposition,
CreateOptions,
EaBuffer,
EaLength,
0, /* CreateFileType */
NULL, /* ExtraCreateParameters */
0 /* Options */
);
return IoCreateFile(FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
AllocateSize,
FileAttributes,
ShareAccess,
CreateDisposition,
CreateOptions,
EaBuffer,
EaLength,
CreateFileTypeNone,
NULL,
0);
}
@ -456,7 +467,7 @@ NtCreateFile (
* NtOpenFile@24
*
* DESCRIPTION
* Opens a file (simpler than NtCreateFile).
* Opens an existing file (simpler than NtCreateFile).
*
* ARGUMENTS
* FileHandle (OUT)
@ -477,41 +488,35 @@ NtCreateFile (
*
* OpenOptions
* Options for the file open.
*
*
* RETURN VALUE
* Status.
*
* NOTE
* Undocumented.
*/
NTSTATUS
STDCALL
NtOpenFile (
PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
ULONG ShareAccess,
ULONG OpenOptions
)
NTSTATUS STDCALL
NtOpenFile(PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
ULONG ShareAccess,
ULONG OpenOptions)
{
return IoCreateFile (
FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
NULL,
0,
ShareAccess,
FILE_OPEN,
OpenOptions,
NULL,
0,
0, /* CreateFileType */
NULL, /* ExtraCreateParameters */
0 /* Options */
);
return IoCreateFile(FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
NULL,
0,
ShareAccess,
FILE_OPEN,
OpenOptions,
NULL,
0,
CreateFileTypeNone,
NULL,
0);
}
/* EOF */

View file

@ -13,22 +13,55 @@
#include <ddk/ntddk.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
NTSTATUS
STDCALL
NtCreateMailslotFile (
OUT PHANDLE MailSlotFileHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG FileAttributes,
IN ULONG ShareAccess,
IN ULONG MaxMessageSize,
IN PLARGE_INTEGER TimeOut
)
NTSTATUS STDCALL
NtCreateMailslotFile(OUT PHANDLE FileHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG CreateOptions,
IN ULONG Param, /* FIXME: ??? */
IN ULONG MaxMessageSize,
IN PLARGE_INTEGER TimeOut)
{
UNIMPLEMENTED;
IO_MAILSLOT_CREATE_BUFFER Buffer;
DPRINT("NtCreateMailslotFile(FileHandle %x, DesiredAccess %x, "
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
FileHandle,DesiredAccess,ObjectAttributes,
ObjectAttributes->ObjectName->Buffer);
assert_irql(PASSIVE_LEVEL);
if (TimeOut != NULL)
{
Buffer.TimeOut.QuadPart = TimeOut->QuadPart;
}
else
{
Buffer.TimeOut.QuadPart = 0;
}
Buffer.Param = Param; /* FIXME: ??? */
Buffer.MaxMessageSize = MaxMessageSize;
return IoCreateFile(FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_CREATE,
CreateOptions,
NULL,
0,
CreateFileTypeMailslot,
(PVOID)&Buffer,
0);
}
/* EOF */

View file

@ -11,122 +11,66 @@
/* INCLUDES *****************************************************************/
#include <ddk/ntddk.h>
#include <internal/ob.h>
#include <internal/io.h>
#define NDEBUG
#include <internal/debug.h>
/* FUNCTIONS *****************************************************************/
NTSTATUS STDCALL NtCreateNamedPipeFile(
OUT PHANDLE NamedPipeFileHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PIO_STATUS_BLOCK IoStatusBlock,
ULONG ShareAccess,
ULONG CreateDisposition,
ULONG CreateOptions,
BOOLEAN WriteModeMessage,
BOOLEAN ReadModeMessage,
BOOLEAN NonBlocking,
ULONG MaxInstances,
IN ULONG InBufferSize,
IN ULONG OutBufferSize,
IN PLARGE_INTEGER TimeOut)
NTSTATUS STDCALL
NtCreateNamedPipeFile(PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
ULONG ShareAccess,
ULONG CreateDisposition,
ULONG CreateOptions,
BOOLEAN WriteModeMessage,
BOOLEAN ReadModeMessage,
BOOLEAN NonBlocking,
ULONG MaxInstances,
ULONG InBufferSize,
ULONG OutBufferSize,
PLARGE_INTEGER TimeOut)
{
PFILE_OBJECT FileObject;
NTSTATUS Status;
PIRP Irp;
KEVENT Event;
PIO_STACK_LOCATION StackLoc;
IO_PIPE_CREATE_BUFFER Buffer;
DPRINT1("NtCreateNamedPipeFile(FileHandle %x, DesiredAccess %x, "
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
NamedPipeFileHandle,DesiredAccess,ObjectAttributes,
ObjectAttributes->ObjectName->Buffer);
DPRINT("NtCreateNamedPipeFile(FileHandle %x, DesiredAccess %x, "
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
FileHandle,DesiredAccess,ObjectAttributes,
ObjectAttributes->ObjectName->Buffer);
assert_irql(PASSIVE_LEVEL);
*NamedPipeFileHandle=0;
FileObject = ObCreateObject(NamedPipeFileHandle,
DesiredAccess,
ObjectAttributes,
IoFileObjectType);
if (FileObject == NULL)
{
return(STATUS_UNSUCCESSFUL);
}
if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
{
FileObject->Flags = FileObject->Flags | FO_ALERTABLE_IO;
FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
}
if (CreateOptions & FILE_SYNCHRONOUS_IO_NONALERT)
{
FileObject->Flags = FileObject->Flags | FO_SYNCHRONOUS_IO;
}
KeInitializeEvent(&Event, NotificationEvent, FALSE);
DPRINT("FileObject %x\n", FileObject);
DPRINT("FileObject->DeviceObject %x\n", FileObject->DeviceObject);
Irp = IoAllocateIrp(FileObject->DeviceObject->StackSize, FALSE);
if (Irp==NULL)
{
return(STATUS_UNSUCCESSFUL);
}
StackLoc = IoGetNextIrpStackLocation(Irp);
StackLoc->MajorFunction = IRP_MJ_CREATE_NAMED_PIPE;
StackLoc->MinorFunction = 0;
StackLoc->Flags = 0;
StackLoc->Control = 0;
StackLoc->DeviceObject = FileObject->DeviceObject;
StackLoc->FileObject = FileObject;
StackLoc->Parameters.Create.Options = (CreateOptions & FILE_VALID_OPTION_FLAGS);
StackLoc->Parameters.Create.Options |= (CreateDisposition << 24);
// StackLoc->Parameters.CreateNamedPipe.CreateDisposition =
// CreateDisposition;
// StackLoc->Parameters.CreateNamedPipe.CreateOptions = CreateOptions;
/*
FIXME : this informations can't be added in Parameters struct because this struct
must be four WORDs long
StackLoc->Parameters.CreateNamedPipe.ShareAccess = ShareAccess;
StackLoc->Parameters.CreateNamedPipe.WriteModeMessage = WriteModeMessage;
StackLoc->Parameters.CreateNamedPipe.ReadModeMessage = ReadModeMessage;
StackLoc->Parameters.CreateNamedPipe.NonBlocking = NonBlocking;
StackLoc->Parameters.CreateNamedPipe.MaxInstances = MaxInstances;
StackLoc->Parameters.CreateNamedPipe.InBufferSize = InBufferSize;
StackLoc->Parameters.CreateNamedPipe.OutBufferSize = OutBufferSize;
if (TimeOut != NULL)
{
StackLoc->Parameters.CreateNamedPipe.TimeOut = *TimeOut;
Buffer.TimeOut.QuadPart = TimeOut->QuadPart;
}
else
{
StackLoc->Parameters.CreateNamedPipe.TimeOut.QuadPart = 0;
Buffer.TimeOut.QuadPart = 0;
}
*/
Buffer.WriteModeMessage = WriteModeMessage;
Buffer.ReadModeMessage = ReadModeMessage;
Buffer.NonBlocking = NonBlocking;
Buffer.MaxInstances = MaxInstances;
Buffer.InBufferSize = InBufferSize;
Buffer.OutBufferSize = OutBufferSize;
Status = IoCallDriver(FileObject->DeviceObject,Irp);
if (Status == STATUS_PENDING)
{
KeWaitForSingleObject(&Event,Executive,KernelMode,FALSE,NULL);
Status = IoStatusBlock->Status;
}
if (!NT_SUCCESS(Status))
{
DPRINT("Failing create request with status %x\n",Status);
ZwClose(*NamedPipeFileHandle);
(*NamedPipeFileHandle) = 0;
}
assert_irql(PASSIVE_LEVEL);
DPRINT("Finished NtCreateFile() (*FileHandle) %x\n",
(*NamedPipeFileHandle));
return(Status);
return IoCreateFile(FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
ShareAccess,
CreateDisposition,
CreateOptions,
NULL,
0,
CreateFileTypeNamedPipe,
(PVOID)&Buffer,
0);
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: object.c,v 1.34 2001/03/07 16:48:45 dwelch Exp $
/* $Id: object.c,v 1.35 2001/05/01 11:06:24 ekohl Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel
@ -220,10 +220,11 @@ NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
*
* RETURN VALUE
*/
PVOID STDCALL ObCreateObject(PHANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
POBJECT_TYPE Type)
PVOID STDCALL
ObCreateObject(PHANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
POBJECT_TYPE Type)
{
PVOID Parent = NULL;
UNICODE_STRING RemainingPath;
@ -243,10 +244,15 @@ PVOID STDCALL ObCreateObject(PHANDLE Handle,
if (ObjectAttributes != NULL &&
ObjectAttributes->ObjectName != NULL)
{
ObFindObject(ObjectAttributes,
&Parent,
&RemainingPath,
NULL);
Status = ObFindObject(ObjectAttributes,
&Parent,
&RemainingPath,
NULL);
if (!NT_SUCCESS(Status))
{
DPRINT("ObFindObject() failed! (Status 0x%x)\n", Status);
return (NULL);
}
}
else
{
@ -264,8 +270,8 @@ PVOID STDCALL ObCreateObject(PHANDLE Handle,
DesiredAccess,
Type,
ObjectAttributes);
if (Header->ObjectType != NULL &&
Header->ObjectType->Create != NULL)
if ((Header->ObjectType != NULL) &&
(Header->ObjectType->Create != NULL))
{
DPRINT("Calling %x\n", Header->ObjectType);
DPRINT("Calling %x\n", Header->ObjectType->Create);
@ -286,10 +292,11 @@ PVOID STDCALL ObCreateObject(PHANDLE Handle,
return(HEADER_TO_BODY(Header));
}
NTSTATUS STDCALL ObReferenceObjectByPointer(PVOID ObjectBody,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode)
NTSTATUS STDCALL
ObReferenceObjectByPointer(PVOID ObjectBody,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode)
/*
* FUNCTION: Increments the pointer reference count for a given object
* ARGUMENTS: