/* Now try opening it for write access */
Status = NtOpenFile(&WritePipeHandle,
- FILE_GENERIC_WRITE | SYNCHRONIZE,
+ FILE_GENERIC_WRITE,
&ObjectAttributes,
&StatusBlock,
FILE_SHARE_READ,
NTSTATUS Status;
/* Calculate the buffer space that we'll need and allocate it */
- BufferSize = nBufferSize + sizeof(FILE_PIPE_PEEK_BUFFER);
+ BufferSize = FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[nBufferSize]);
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, BufferSize);
if (Buffer == NULL)
{
/* Check if caller requested bytes available */
if (lpTotalBytesAvail)
+ {
+ /* Return bytes available */
*lpTotalBytesAvail = Buffer->ReadDataAvailable;
+ }
/* Calculate the bytes returned, minus our structure overhead */
BytesRead = (ULONG)(Iosb.Information -
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]));
+ ASSERT(BytesRead <= nBufferSize);
/* Check if caller requested bytes read */
if (lpBytesRead)