--- trunk/reactos/lib/kernel32/file/npipe.c 2005-10-30 13:55:28 UTC (rev 18882)
+++ trunk/reactos/lib/kernel32/file/npipe.c 2005-10-30 14:51:12 UTC (rev 18883)
@@ -15,6 +15,12 @@
#define NDEBUG
#include "../include/debug.h"
+/* FIXME - defined in ntifs.h */
+#if !defined(FILE_PIPE_BYTE_STREAM_TYPE) && !defined(FILE_PIPE_MESSAGE_TYPE)
+#define FILE_PIPE_BYTE_STREAM_TYPE 0x00000000
+#define FILE_PIPE_MESSAGE_TYPE 0x00000001
+#endif
+
/* FUNCTIONS ****************************************************************/
/*
@@ -72,7 +78,6 @@
HANDLE PipeHandle;
ACCESS_MASK DesiredAccess;
ULONG CreateOptions;
- ULONG CreateDisposition;
ULONG WriteModeMessage;
ULONG ReadModeMessage;
ULONG NonBlocking;
@@ -80,6 +85,12 @@
ULONG ShareAccess, Attributes;
LARGE_INTEGER DefaultTimeOut;
PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
+
+ if (nMaxInstances == 0 || nMaxInstances > PIPE_UNLIMITED_INSTANCES)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return INVALID_HANDLE_VALUE;
+ }
Result = RtlDosPathNameToNtPathName_U((LPWSTR)lpName,
&NamedPipeName,
@@ -108,78 +119,48 @@
NULL,
SecurityDescriptor);
- DesiredAccess = 0;
+ DesiredAccess = SYNCHRONIZE | (dwOpenMode & (WRITE_DAC | WRITE_OWNER | ACCESS_SYSTEM_SECURITY));
ShareAccess = 0;
- CreateDisposition = FILE_OPEN_IF;
CreateOptions = 0;
+
if (dwOpenMode & FILE_FLAG_WRITE_THROUGH)
- {
- CreateOptions = CreateOptions | FILE_WRITE_THROUGH;
- }
+ CreateOptions |= FILE_WRITE_THROUGH;
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED))
- {
- CreateOptions = CreateOptions | FILE_SYNCHRONOUS_IO_NONALERT;
- }
- if (dwOpenMode & PIPE_ACCESS_DUPLEX)
- {
- CreateOptions = CreateOptions | FILE_PIPE_FULL_DUPLEX;
- DesiredAccess |= (FILE_GENERIC_READ | FILE_GENERIC_WRITE);
- }
- else if (dwOpenMode & PIPE_ACCESS_INBOUND)
- {
- CreateOptions = CreateOptions | FILE_PIPE_INBOUND;
- DesiredAccess |= FILE_GENERIC_READ;
- }
- else if (dwOpenMode & PIPE_ACCESS_OUTBOUND)
- {
- CreateOptions = CreateOptions | FILE_PIPE_OUTBOUND;
- DesiredAccess |= FILE_GENERIC_WRITE;
- }
+ CreateOptions |= FILE_SYNCHRONOUS_IO_NONALERT;
- if (dwPipeMode & PIPE_TYPE_BYTE)
+ switch (dwOpenMode & PIPE_ACCESS_DUPLEX)
{
- WriteModeMessage = FILE_PIPE_BYTE_STREAM_MODE;
+ case PIPE_ACCESS_INBOUND:
+ ShareAccess |= FILE_SHARE_WRITE;
+ DesiredAccess |= GENERIC_READ;
+ break;
+
+ case PIPE_ACCESS_OUTBOUND:
+ ShareAccess |= FILE_SHARE_READ;
+ DesiredAccess |= GENERIC_WRITE;
+ break;
+
+ case PIPE_ACCESS_DUPLEX:
+ ShareAccess |= FILE_SHARE_READ | FILE_SHARE_WRITE;
+ DesiredAccess |= GENERIC_READ | GENERIC_WRITE;
+ break;
}
- else if (dwPipeMode & PIPE_TYPE_MESSAGE)
- {
- WriteModeMessage = FILE_PIPE_MESSAGE_MODE;
- }
+
+ if (dwPipeMode & PIPE_TYPE_MESSAGE)
+ WriteModeMessage = FILE_PIPE_MESSAGE_TYPE;
else
- {
- WriteModeMessage = FILE_PIPE_BYTE_STREAM_MODE;
- }
+ WriteModeMessage = FILE_PIPE_BYTE_STREAM_TYPE;
- if (dwPipeMode & PIPE_READMODE_BYTE)
- {
- ReadModeMessage = FILE_PIPE_BYTE_STREAM_MODE;
- }
- else if (dwPipeMode & PIPE_READMODE_MESSAGE)
- {
- ReadModeMessage = FILE_PIPE_MESSAGE_MODE;
- }
+ if (dwPipeMode & PIPE_READMODE_MESSAGE)
+ ReadModeMessage = FILE_PIPE_MESSAGE_MODE;
else
- {
- ReadModeMessage = FILE_PIPE_BYTE_STREAM_MODE;
- }
+ ReadModeMessage = FILE_PIPE_BYTE_STREAM_MODE;
- if (dwPipeMode & PIPE_WAIT)
- {
- NonBlocking = FILE_PIPE_QUEUE_OPERATION;
- }
- else if (dwPipeMode & PIPE_NOWAIT)
- {
- NonBlocking = FILE_PIPE_COMPLETE_OPERATION;
- }
+ if (dwPipeMode & PIPE_NOWAIT)
+ NonBlocking = FILE_PIPE_COMPLETE_OPERATION;
else
- {
- NonBlocking = FILE_PIPE_QUEUE_OPERATION;
- }
+ NonBlocking = FILE_PIPE_QUEUE_OPERATION;
- if (nMaxInstances >= PIPE_UNLIMITED_INSTANCES)
- {
- nMaxInstances = 0xFFFFFFFF;
- }
-
DefaultTimeOut.QuadPart = nDefaultTimeOut * -10000LL;
Status = NtCreateNamedPipeFile(&PipeHandle,
@@ -187,7 +168,7 @@
&ObjectAttributes,
&Iosb,
ShareAccess,
- CreateDisposition,
+ FILE_OPEN_IF,
CreateOptions,
WriteModeMessage,
ReadModeMessage,
--- trunk/reactos/lib/kernel32/file/pipe.c 2005-10-30 13:55:28 UTC (rev 18882)
+++ trunk/reactos/lib/kernel32/file/pipe.c 2005-10-30 14:51:12 UTC (rev 18883)
@@ -59,6 +59,9 @@
Attributes |= OBJ_INHERIT;
}
+ /* use default buffer size if desired */
+ if (nSize == 0) nSize = 0x1000;
+
InitializeObjectAttributes(&ObjectAttributes,
&PipeName,
Attributes,
@@ -66,7 +69,7 @@
SecurityDescriptor);
Status = NtCreateNamedPipeFile(&ReadPipeHandle,
- FILE_GENERIC_READ,
+ FILE_GENERIC_READ | FILE_WRITE_ATTRIBUTES | SYNCHRONIZE,
&ObjectAttributes,
&StatusBlock,
FILE_SHARE_READ | FILE_SHARE_WRITE,
@@ -86,10 +89,10 @@
}
Status = NtOpenFile(&WritePipeHandle,
- FILE_GENERIC_WRITE,
+ FILE_GENERIC_WRITE | SYNCHRONIZE,
&ObjectAttributes,
&StatusBlock,
- 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
if (!NT_SUCCESS(Status))
{