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,7 +30,8 @@ VOID NpfsInitPipeList(VOID)
KeInitializeMutex(&PipeListLock, 0);
}
NTSTATUS NpfsCreate(PDEVICE_OBJECT DeviceObject,
NTSTATUS STDCALL
NpfsCreate(PDEVICE_OBJECT DeviceObject,
PIRP Irp)
{
PIO_STACK_LOCATION IoStack;
@ -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)
{
@ -170,22 +182,25 @@ NTSTATUS NpfsCreateNamedPipe(PDEVICE_OBJECT DeviceObject, PIRP Irp)
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

@ -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

@ -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 $
*
*/
@ -155,24 +155,30 @@ typedef struct _IO_STACK_LOCATION
struct _VPB* Vpb;
struct _DEVICE_OBJECT* DeviceObject;
} Mount;
struct {
struct
{
ULONG Length;
FILE_INFORMATION_CLASS FileInformationClass;
} QueryFile;
struct {
struct
{
ULONG Length;
FS_INFORMATION_CLASS FileInformationClass;
} QueryVolume;
struct {
struct
{
ULONG Length;
FS_INFORMATION_CLASS FileInformationClass;
} SetVolume;
struct {
struct
{
ULONG Length;
FILE_INFORMATION_CLASS FileInformationClass;
struct _FILE_OBJECT* FileObject;
union {
struct {
union
{
struct
{
BOOLEAN ReplaceIfExists;
BOOLEAN AdvanceOnly;
} d;
@ -187,21 +193,6 @@ 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;
@ -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,4 +1,4 @@
/* $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
@ -92,7 +92,7 @@ IopCreateFile (PVOID ObjectBody,
UserMode);
if (STATUS_SUCCESS != Status)
{
CHECKPOINT;
CHECKPOINT1;
return (Status);
}
@ -115,16 +115,19 @@ IopCreateFile (PVOID ObjectBody,
}
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");
return (STATUS_UNSUCCESSFUL);
}
if (DeviceObject->DeviceType != FILE_DEVICE_NETWORK)
if (DeviceObject->DeviceType != FILE_DEVICE_NETWORK
&& (DeviceObject->DeviceType != FILE_DEVICE_NAMED_PIPE)
&& (DeviceObject->DeviceType != FILE_DEVICE_MAILSLOT))
{
if (!(DeviceObject->Vpb->Flags & VPB_MOUNTED))
{
@ -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,8 +284,7 @@ IoCreateStreamFileObject (PFILE_OBJECT FileObject,
* REVISIONS
*
*/
NTSTATUS
STDCALL
NTSTATUS STDCALL
IoCreateFile(
OUT PHANDLE FileHandle,
IN ACCESS_MASK DesiredAccess,
@ -297,8 +299,7 @@ IoCreateFile (
IN ULONG EaLength,
IN CREATE_FILE_TYPE CreateFileType,
IN PVOID ExtraCreateParameters OPTIONAL,
IN ULONG Options
)
IN ULONG Options)
{
PFILE_OBJECT FileObject;
NTSTATUS Status;
@ -321,6 +322,7 @@ IoCreateFile (
IoFileObjectType);
if (FileObject == NULL)
{
DPRINT1("ObCreateObject() failed!\n");
return (STATUS_UNSUCCESSFUL);
}
if (CreateOptions & FILE_SYNCHRONOUS_IO_ALERT)
@ -351,13 +353,28 @@ IoCreateFile (
}
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;
case CreateFileTypeNamedPipe:
StackLoc->MajorFunction = IRP_MJ_CREATE_NAMED_PIPE;
break;
case CreateFileTypeMailslot:
StackLoc->MajorFunction = IRP_MJ_CREATE_MAILSLOT;
break;
}
StackLoc->MinorFunction = 0;
StackLoc->Flags = 0;
StackLoc->Control = 0;
@ -384,7 +401,7 @@ IoCreateFile (
}
if (!NT_SUCCESS(Status))
{
DPRINT("Failing create request with status %x\n", Status);
DPRINT1("Failing create request with status %x\n", Status);
ZwClose(*FileHandle);
(*FileHandle) = 0;
}
@ -415,10 +432,8 @@ IoCreateFile (
* 2000-03-25 (ea)
* Code originally in NtCreateFile moved in IoCreateFile.
*/
NTSTATUS
STDCALL
NtCreateFile (
PHANDLE FileHandle,
NTSTATUS STDCALL
NtCreateFile(PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
@ -428,11 +443,9 @@ NtCreateFile (
ULONG CreateDisposition,
ULONG CreateOptions,
PVOID EaBuffer,
ULONG EaLength
)
ULONG EaLength)
{
return IoCreateFile (
FileHandle,
return IoCreateFile(FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
@ -443,11 +456,9 @@ NtCreateFile (
CreateOptions,
EaBuffer,
EaLength,
0, /* CreateFileType */
NULL, /* ExtraCreateParameters */
0 /* Options */
);
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)
@ -484,19 +495,15 @@ NtCreateFile (
* NOTE
* Undocumented.
*/
NTSTATUS
STDCALL
NtOpenFile (
PHANDLE FileHandle,
NTSTATUS STDCALL
NtOpenFile(PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
ULONG ShareAccess,
ULONG OpenOptions
)
ULONG OpenOptions)
{
return IoCreateFile (
FileHandle,
return IoCreateFile(FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
@ -507,11 +514,9 @@ NtOpenFile (
OpenOptions,
NULL,
0,
0, /* CreateFileType */
NULL, /* ExtraCreateParameters */
0 /* Options */
);
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,
NTSTATUS STDCALL
NtCreateMailslotFile(OUT PHANDLE FileHandle,
IN ACCESS_MASK DesiredAccess,
IN POBJECT_ATTRIBUTES ObjectAttributes,
OUT PIO_STATUS_BLOCK IoStatusBlock,
IN ULONG FileAttributes,
IN ULONG ShareAccess,
IN ULONG CreateOptions,
IN ULONG Param, /* FIXME: ??? */
IN ULONG MaxMessageSize,
IN PLARGE_INTEGER TimeOut
)
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,18 +11,17 @@
/* 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,
NTSTATUS STDCALL
NtCreateNamedPipeFile(PHANDLE FileHandle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
PIO_STATUS_BLOCK IoStatusBlock,
ULONG ShareAccess,
ULONG CreateDisposition,
ULONG CreateOptions,
@ -30,103 +29,48 @@ NTSTATUS STDCALL NtCreateNamedPipeFile(
BOOLEAN ReadModeMessage,
BOOLEAN NonBlocking,
ULONG MaxInstances,
IN ULONG InBufferSize,
IN ULONG OutBufferSize,
IN PLARGE_INTEGER TimeOut)
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, "
DPRINT("NtCreateNamedPipeFile(FileHandle %x, DesiredAccess %x, "
"ObjectAttributes %x ObjectAttributes->ObjectName->Buffer %S)\n",
NamedPipeFileHandle,DesiredAccess,ObjectAttributes,
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;
return IoCreateFile(FileHandle,
DesiredAccess,
ObjectAttributes,
IoStatusBlock,
NULL,
FILE_ATTRIBUTE_NORMAL,
ShareAccess,
CreateDisposition,
CreateOptions,
NULL,
0,
CreateFileTypeNamedPipe,
(PVOID)&Buffer,
0);
}
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);
}
/* 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,7 +220,8 @@ NTSTATUS ObFindObject(POBJECT_ATTRIBUTES ObjectAttributes,
*
* RETURN VALUE
*/
PVOID STDCALL ObCreateObject(PHANDLE Handle,
PVOID STDCALL
ObCreateObject(PHANDLE Handle,
ACCESS_MASK DesiredAccess,
POBJECT_ATTRIBUTES ObjectAttributes,
POBJECT_TYPE Type)
@ -243,10 +244,15 @@ PVOID STDCALL ObCreateObject(PHANDLE Handle,
if (ObjectAttributes != NULL &&
ObjectAttributes->ObjectName != NULL)
{
ObFindObject(ObjectAttributes,
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,7 +292,8 @@ PVOID STDCALL ObCreateObject(PHANDLE Handle,
return(HEADER_TO_BODY(Header));
}
NTSTATUS STDCALL ObReferenceObjectByPointer(PVOID ObjectBody,
NTSTATUS STDCALL
ObReferenceObjectByPointer(PVOID ObjectBody,
ACCESS_MASK DesiredAccess,
POBJECT_TYPE ObjectType,
KPROCESSOR_MODE AccessMode)