mirror of
https://github.com/reactos/reactos.git
synced 2024-07-30 08:08:56 +00:00
Implemented CreatePipe()
svn path=/trunk/; revision=1372
This commit is contained in:
parent
99434057af
commit
bd6afcb8ba
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: pipe.c,v 1.3 2000/06/03 14:47:32 ea Exp $
|
/* $Id: pipe.c,v 1.4 2000/09/27 01:24:37 ekohl Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS system libraries
|
* PROJECT: ReactOS system libraries
|
||||||
|
@ -11,12 +11,14 @@
|
||||||
/* INCLUDES *****************************************************************/
|
/* INCLUDES *****************************************************************/
|
||||||
|
|
||||||
#include <ddk/ntddk.h>
|
#include <ddk/ntddk.h>
|
||||||
#include <windows.h>
|
#include <kernel32/error.h>
|
||||||
#include <wchar.h>
|
|
||||||
#include <string.h>
|
|
||||||
|
|
||||||
#include <kernel32/kernel32.h>
|
#include <kernel32/kernel32.h>
|
||||||
|
|
||||||
|
/* GLOBALS ******************************************************************/
|
||||||
|
|
||||||
|
ULONG ProcessPipeId = 0;
|
||||||
|
|
||||||
/* FUNCTIONS ****************************************************************/
|
/* FUNCTIONS ****************************************************************/
|
||||||
|
|
||||||
BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
|
BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
|
||||||
|
@ -24,8 +26,74 @@ BOOL STDCALL CreatePipe(PHANDLE hReadPipe,
|
||||||
LPSECURITY_ATTRIBUTES lpPipeAttributes,
|
LPSECURITY_ATTRIBUTES lpPipeAttributes,
|
||||||
DWORD nSize)
|
DWORD nSize)
|
||||||
{
|
{
|
||||||
DPRINT("CreatePipe is unimplemented\n");
|
WCHAR Buffer[64];
|
||||||
return(FALSE);
|
UNICODE_STRING PipeName;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
IO_STATUS_BLOCK StatusBlock;
|
||||||
|
LARGE_INTEGER DefaultTimeout;
|
||||||
|
NTSTATUS Status;
|
||||||
|
HANDLE ReadPipeHandle;
|
||||||
|
HANDLE WritePipeHandle;
|
||||||
|
PSECURITY_DESCRIPTOR SecurityDescriptor = NULL;
|
||||||
|
|
||||||
|
DefaultTimeout.QuadPart = 300000000; /* 30 seconds */
|
||||||
|
|
||||||
|
ProcessPipeId++;
|
||||||
|
swprintf(Buffer,
|
||||||
|
L"\\Device\\NamedPipe\\Win32Pipes.%08x.%08x",
|
||||||
|
NtCurrentTeb()->Cid.UniqueProcess,
|
||||||
|
ProcessPipeId);
|
||||||
|
RtlInitUnicodeString (&PipeName,
|
||||||
|
Buffer);
|
||||||
|
|
||||||
|
if (lpPipeAttributes)
|
||||||
|
{
|
||||||
|
SecurityDescriptor = lpPipeAttributes->lpSecurityDescriptor;
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
&PipeName,
|
||||||
|
OBJ_CASE_INSENSITIVE,
|
||||||
|
NULL,
|
||||||
|
SecurityDescriptor);
|
||||||
|
|
||||||
|
Status = NtCreateNamedPipeFile(&ReadPipeHandle,
|
||||||
|
FILE_GENERIC_READ,
|
||||||
|
&ObjectAttributes,
|
||||||
|
&StatusBlock,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
|
FILE_CREATE,
|
||||||
|
FILE_SYNCHRONOUS_IO_NONALERT,
|
||||||
|
FALSE,
|
||||||
|
FALSE,
|
||||||
|
FALSE,
|
||||||
|
1,
|
||||||
|
nSize,
|
||||||
|
nSize,
|
||||||
|
&DefaultTimeout);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status = NtOpenFile(&WritePipeHandle,
|
||||||
|
FILE_GENERIC_WRITE,
|
||||||
|
&ObjectAttributes,
|
||||||
|
&StatusBlock,
|
||||||
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
|
FILE_SYNCHRONOUS_IO_NONALERT | FILE_NON_DIRECTORY_FILE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
NtClose(ReadPipeHandle);
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*hReadPipe = ReadPipeHandle;
|
||||||
|
*hWritePipe = WritePipeHandle;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Reference in a new issue