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 *****************************************************************/
16 #include "../include/debug.h"
18 /* GLOBALS ******************************************************************/
20 ULONG ProcessPipeId
= 0;
22 /* FUNCTIONS ****************************************************************/
27 BOOL STDCALL
CreatePipe(PHANDLE hReadPipe
,
29 LPSECURITY_ATTRIBUTES lpPipeAttributes
,
33 UNICODE_STRING PipeName
;
34 OBJECT_ATTRIBUTES ObjectAttributes
;
35 IO_STATUS_BLOCK StatusBlock
;
36 LARGE_INTEGER DefaultTimeout
;
38 HANDLE ReadPipeHandle
;
39 HANDLE WritePipeHandle
;
42 PSECURITY_DESCRIPTOR SecurityDescriptor
= NULL
;
44 DefaultTimeout
.QuadPart
= 300000000; /* 30 seconds */
46 PipeId
= (ULONG
)InterlockedIncrement((LONG
*)&ProcessPipeId
);
48 L
"\\Device\\NamedPipe\\Win32Pipes.%08x.%08x",
49 NtCurrentTeb()->Cid
.UniqueProcess
,
51 RtlInitUnicodeString (&PipeName
,
54 Attributes
= OBJ_CASE_INSENSITIVE
;
57 SecurityDescriptor
= lpPipeAttributes
->lpSecurityDescriptor
;
58 if (lpPipeAttributes
->bInheritHandle
)
59 Attributes
|= OBJ_INHERIT
;
62 InitializeObjectAttributes(&ObjectAttributes
,
68 Status
= NtCreateNamedPipeFile(&ReadPipeHandle
,
72 FILE_SHARE_READ
| FILE_SHARE_WRITE
,
74 FILE_SYNCHRONOUS_IO_NONALERT
,
82 if (!NT_SUCCESS(Status
))
84 SetLastErrorByStatus(Status
);
88 Status
= NtOpenFile(&WritePipeHandle
,
93 FILE_SYNCHRONOUS_IO_NONALERT
| FILE_NON_DIRECTORY_FILE
);
94 if (!NT_SUCCESS(Status
))
96 NtClose(ReadPipeHandle
);
97 SetLastErrorByStatus(Status
);
101 *hReadPipe
= ReadPipeHandle
;
102 *hWritePipe
= WritePipeHandle
;