1 /* $Id: pipe.c,v 1.7 2002/09/08 10:22:42 chorns Exp $
3 * COPYRIGHT: See COPYING in the top level directory
4 * PROJECT: ReactOS system libraries
5 * FILE: lib/kernel32/file/create.c
6 * PURPOSE: Directory functions
7 * PROGRAMMER: Ariadne ( ariadne@xs4all.nl)
11 /* INCLUDES *****************************************************************/
13 #include <ddk/ntddk.h>
14 #include <kernel32/error.h>
16 #include <kernel32/kernel32.h>
18 /* GLOBALS ******************************************************************/
20 ULONG ProcessPipeId
= 0;
22 /* FUNCTIONS ****************************************************************/
24 BOOL STDCALL
CreatePipe(PHANDLE hReadPipe
,
26 LPSECURITY_ATTRIBUTES lpPipeAttributes
,
30 UNICODE_STRING PipeName
;
31 OBJECT_ATTRIBUTES ObjectAttributes
;
32 IO_STATUS_BLOCK StatusBlock
;
33 LARGE_INTEGER DefaultTimeout
;
35 HANDLE ReadPipeHandle
;
36 HANDLE WritePipeHandle
;
37 PSECURITY_DESCRIPTOR SecurityDescriptor
= NULL
;
39 DefaultTimeout
.QuadPart
= 300000000; /* 30 seconds */
43 L
"\\Device\\NamedPipe\\Win32Pipes.%08x.%08x",
44 NtCurrentTeb()->Cid
.UniqueProcess
,
46 RtlInitUnicodeString (&PipeName
,
51 SecurityDescriptor
= lpPipeAttributes
->lpSecurityDescriptor
;
54 InitializeObjectAttributes(&ObjectAttributes
,
61 if(lpPipeAttributes
->bInheritHandle
)
62 ObjectAttributes
.Attributes
|= OBJ_INHERIT
;
63 if (lpPipeAttributes
->lpSecurityDescriptor
)
64 ObjectAttributes
.SecurityDescriptor
= lpPipeAttributes
->lpSecurityDescriptor
;
67 Status
= NtCreateNamedPipeFile(&ReadPipeHandle
,
71 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
73 FILE_SYNCHRONOUS_IO_NONALERT
,
81 if (!NT_SUCCESS(Status
))
83 SetLastErrorByStatus(Status
);
87 Status
= NtOpenFile(&WritePipeHandle
,
91 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
92 FILE_SYNCHRONOUS_IO_NONALERT
| FILE_NON_DIRECTORY_FILE
);
93 if (!NT_SUCCESS(Status
))
95 NtClose(ReadPipeHandle
);
96 SetLastErrorByStatus(Status
);
100 *hReadPipe
= ReadPipeHandle
;
101 *hWritePipe
= WritePipeHandle
;