mirror of
https://github.com/reactos/reactos.git
synced 2025-07-10 12:44:21 +00:00
- Fix indentation.
- Replace tabs by spaces. - Replace STDCALL by WINAPI. - Replace Alex' unreadable single-line statements by readable ones. - No code changes. svn path=/trunk/; revision=27514
This commit is contained in:
parent
c57c69624e
commit
add1532e20
1 changed files with 355 additions and 335 deletions
|
@ -49,6 +49,7 @@ CreateNamedPipeA(LPCSTR lpName,
|
||||||
lpSecurityAttributes);
|
lpSecurityAttributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -87,7 +88,8 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Convert to NT syntax */
|
/* Convert to NT syntax */
|
||||||
if (nMaxInstances == PIPE_UNLIMITED_INSTANCES) nMaxInstances = -1;
|
if (nMaxInstances == PIPE_UNLIMITED_INSTANCES)
|
||||||
|
nMaxInstances = -1;
|
||||||
|
|
||||||
/* Convert the name */
|
/* Convert the name */
|
||||||
Result = RtlDosPathNameToNtPathName_U(lpName,
|
Result = RtlDosPathNameToNtPathName_U(lpName,
|
||||||
|
@ -98,7 +100,7 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
{
|
{
|
||||||
/* Conversion failed */
|
/* Conversion failed */
|
||||||
SetLastError(ERROR_PATH_NOT_FOUND);
|
SetLastError(ERROR_PATH_NOT_FOUND);
|
||||||
return(INVALID_HANDLE_VALUE);
|
return INVALID_HANDLE_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
DPRINT("Pipe name: %wZ\n", &NamedPipeName);
|
DPRINT("Pipe name: %wZ\n", &NamedPipeName);
|
||||||
|
@ -112,7 +114,8 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
SecurityDescriptor = lpSecurityAttributes->lpSecurityDescriptor;
|
SecurityDescriptor = lpSecurityAttributes->lpSecurityDescriptor;
|
||||||
|
|
||||||
/* And check if this is pipe's handle will beinheritable */
|
/* And check if this is pipe's handle will beinheritable */
|
||||||
if(lpSecurityAttributes->bInheritHandle) Attributes |= OBJ_INHERIT;
|
if (lpSecurityAttributes->bInheritHandle)
|
||||||
|
Attributes |= OBJ_INHERIT;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Now we can initialize the object attributes */
|
/* Now we can initialize the object attributes */
|
||||||
|
@ -132,6 +135,7 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
{
|
{
|
||||||
CreateOptions |= FILE_WRITE_THROUGH;
|
CreateOptions |= FILE_WRITE_THROUGH;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED))
|
if (!(dwOpenMode & FILE_FLAG_OVERLAPPED))
|
||||||
{
|
{
|
||||||
CreateOptions |= FILE_SYNCHRONOUS_IO_NONALERT;
|
CreateOptions |= FILE_SYNCHRONOUS_IO_NONALERT;
|
||||||
|
@ -143,6 +147,7 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
ShareAccess |= FILE_SHARE_READ;
|
ShareAccess |= FILE_SHARE_READ;
|
||||||
DesiredAccess |= GENERIC_WRITE;
|
DesiredAccess |= GENERIC_WRITE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dwOpenMode & PIPE_ACCESS_INBOUND)
|
if (dwOpenMode & PIPE_ACCESS_INBOUND)
|
||||||
{
|
{
|
||||||
ShareAccess |= FILE_SHARE_WRITE;
|
ShareAccess |= FILE_SHARE_WRITE;
|
||||||
|
@ -232,6 +237,7 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
return PipeHandle;
|
return PipeHandle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -256,6 +262,7 @@ WaitNamedPipeA(LPCSTR lpNamedPipeName,
|
||||||
return r;
|
return r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* When NPFS will work properly, use this code instead. It is compatible with
|
* When NPFS will work properly, use this code instead. It is compatible with
|
||||||
* Microsoft's NPFS.SYS. The main difference is that:
|
* Microsoft's NPFS.SYS. The main difference is that:
|
||||||
|
@ -387,7 +394,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
RtlFreeUnicodeString(&NamedPipeName);
|
RtlFreeUnicodeString(&NamedPipeName);
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, WaitPipeInfo);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, WaitPipeInfo);
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check what timeout we got */
|
/* Check what timeout we got */
|
||||||
|
@ -454,25 +461,24 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL
|
||||||
|
WINAPI
|
||||||
WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
DWORD nTimeOut)
|
DWORD nTimeOut)
|
||||||
{
|
{
|
||||||
UNICODE_STRING NamedPipeName;
|
UNICODE_STRING NamedPipeName;
|
||||||
BOOL r;
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
FILE_PIPE_WAIT_FOR_BUFFER WaitPipe;
|
FILE_PIPE_WAIT_FOR_BUFFER WaitPipe;
|
||||||
HANDLE FileHandle;
|
HANDLE FileHandle;
|
||||||
IO_STATUS_BLOCK Iosb;
|
IO_STATUS_BLOCK Iosb;
|
||||||
|
|
||||||
r = RtlDosPathNameToNtPathName_U(lpNamedPipeName,
|
if (RtlDosPathNameToNtPathName_U(lpNamedPipeName,
|
||||||
&NamedPipeName,
|
&NamedPipeName,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL) == FALSE)
|
||||||
if (!r)
|
|
||||||
{
|
{
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
InitializeObjectAttributes(&ObjectAttributes,
|
InitializeObjectAttributes(&ObjectAttributes,
|
||||||
|
@ -489,7 +495,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
WaitPipe.Timeout.QuadPart = nTimeOut * -10000LL;
|
WaitPipe.Timeout.QuadPart = nTimeOut * -10000LL;
|
||||||
|
@ -508,17 +514,19 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL
|
||||||
|
WINAPI
|
||||||
ConnectNamedPipe(IN HANDLE hNamedPipe,
|
ConnectNamedPipe(IN HANDLE hNamedPipe,
|
||||||
IN LPOVERLAPPED lpOverlapped)
|
IN LPOVERLAPPED lpOverlapped)
|
||||||
{
|
{
|
||||||
|
@ -586,11 +594,12 @@ ConnectNamedPipe(IN HANDLE hNamedPipe,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL
|
BOOL
|
||||||
STDCALL
|
WINAPI
|
||||||
SetNamedPipeHandleState(HANDLE hNamedPipe,
|
SetNamedPipeHandleState(HANDLE hNamedPipe,
|
||||||
LPDWORD lpMode,
|
LPDWORD lpMode,
|
||||||
LPDWORD lpMaxCollectionCount,
|
LPDWORD lpMaxCollectionCount,
|
||||||
|
@ -621,7 +630,7 @@ SetNamedPipeHandleState(HANDLE hNamedPipe,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,11 +647,10 @@ SetNamedPipeHandleState(HANDLE hNamedPipe,
|
||||||
&RemoteSettings,
|
&RemoteSettings,
|
||||||
sizeof(FILE_PIPE_REMOTE_INFORMATION),
|
sizeof(FILE_PIPE_REMOTE_INFORMATION),
|
||||||
FilePipeRemoteInformation);
|
FilePipeRemoteInformation);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -653,9 +661,8 @@ SetNamedPipeHandleState(HANDLE hNamedPipe,
|
||||||
if (lpCollectDataTimeout)
|
if (lpCollectDataTimeout)
|
||||||
{
|
{
|
||||||
/* Convert it to Quad */
|
/* Convert it to Quad */
|
||||||
RemoteSettings.CollectDataTime.QuadPart = -(LONGLONG)
|
RemoteSettings.CollectDataTime.QuadPart =
|
||||||
UInt32x32To64(10000,
|
-(LONGLONG)UInt32x32To64(10000, *lpCollectDataTimeout);
|
||||||
*lpCollectDataTimeout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Tell the driver to change them */
|
/* Tell the driver to change them */
|
||||||
|
@ -664,18 +671,17 @@ SetNamedPipeHandleState(HANDLE hNamedPipe,
|
||||||
&RemoteSettings,
|
&RemoteSettings,
|
||||||
sizeof(FILE_PIPE_REMOTE_INFORMATION),
|
sizeof(FILE_PIPE_REMOTE_INFORMATION),
|
||||||
FilePipeRemoteInformation);
|
FilePipeRemoteInformation);
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* All done */
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -706,6 +712,7 @@ CallNamedPipeA(LPCSTR lpNamedPipeName,
|
||||||
nTimeOut);
|
nTimeOut);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -736,10 +743,12 @@ CallNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* Success, break out */
|
/* Success, break out */
|
||||||
if (hPipe != INVALID_HANDLE_VALUE) break;
|
if (hPipe != INVALID_HANDLE_VALUE)
|
||||||
|
break;
|
||||||
|
|
||||||
/* Already tried twice, give up */
|
/* Already tried twice, give up */
|
||||||
if (bRetry == FALSE) return FALSE;
|
if (bRetry == FALSE)
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
/* Wait on it */
|
/* Wait on it */
|
||||||
WaitNamedPipeW(lpNamedPipeName, nTimeOut);
|
WaitNamedPipeW(lpNamedPipeName, nTimeOut);
|
||||||
|
@ -767,11 +776,13 @@ CallNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
lpBytesRead,
|
lpBytesRead,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* Close the handle and return */
|
/* Close the handle */
|
||||||
CloseHandle(hPipe);
|
CloseHandle(hPipe);
|
||||||
|
|
||||||
return bError;
|
return bError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -797,7 +808,8 @@ DisconnectNamedPipe(HANDLE hNamedPipe)
|
||||||
{
|
{
|
||||||
/* Wait on NPFS to finish and get updated status */
|
/* Wait on NPFS to finish and get updated status */
|
||||||
Status = NtWaitForSingleObject(hNamedPipe, FALSE, NULL);
|
Status = NtWaitForSingleObject(hNamedPipe, FALSE, NULL);
|
||||||
if (NT_SUCCESS(Status)) Status = Iosb.Status;
|
if (NT_SUCCESS(Status))
|
||||||
|
Status = Iosb.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check for error */
|
/* Check for error */
|
||||||
|
@ -811,10 +823,12 @@ DisconnectNamedPipe(HANDLE hNamedPipe)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL
|
||||||
|
WINAPI
|
||||||
GetNamedPipeHandleStateW(HANDLE hNamedPipe,
|
GetNamedPipeHandleStateW(HANDLE hNamedPipe,
|
||||||
LPDWORD lpState,
|
LPDWORD lpState,
|
||||||
LPDWORD lpCurInstances,
|
LPDWORD lpCurInstances,
|
||||||
|
@ -904,7 +918,8 @@ GetNamedPipeHandleStateW(HANDLE hNamedPipe,
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL
|
||||||
|
WINAPI
|
||||||
GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
||||||
LPDWORD lpState,
|
LPDWORD lpState,
|
||||||
LPDWORD lpCurInstances,
|
LPDWORD lpCurInstances,
|
||||||
|
@ -939,7 +954,6 @@ GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
||||||
lpCollectDataTimeout,
|
lpCollectDataTimeout,
|
||||||
UserNameW.Buffer,
|
UserNameW.Buffer,
|
||||||
nMaxUserNameSize);
|
nMaxUserNameSize);
|
||||||
|
|
||||||
if (Ret && lpUserName != NULL)
|
if (Ret && lpUserName != NULL)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
@ -965,7 +979,8 @@ GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL
|
||||||
|
WINAPI
|
||||||
GetNamedPipeInfo(HANDLE hNamedPipe,
|
GetNamedPipeInfo(HANDLE hNamedPipe,
|
||||||
LPDWORD lpFlags,
|
LPDWORD lpFlags,
|
||||||
LPDWORD lpOutBufferSize,
|
LPDWORD lpOutBufferSize,
|
||||||
|
@ -984,7 +999,7 @@ GetNamedPipeInfo(HANDLE hNamedPipe,
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpFlags != NULL)
|
if (lpFlags != NULL)
|
||||||
|
@ -1007,9 +1022,10 @@ GetNamedPipeInfo(HANDLE hNamedPipe,
|
||||||
*lpMaxInstances = PipeLocalInformation.MaximumInstances;
|
*lpMaxInstances = PipeLocalInformation.MaximumInstances;
|
||||||
}
|
}
|
||||||
|
|
||||||
return(TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
|
@ -1025,6 +1041,7 @@ PeekNamedPipe(HANDLE hNamedPipe,
|
||||||
PFILE_PIPE_PEEK_BUFFER Buffer;
|
PFILE_PIPE_PEEK_BUFFER Buffer;
|
||||||
IO_STATUS_BLOCK Iosb;
|
IO_STATUS_BLOCK Iosb;
|
||||||
ULONG BufferSize;
|
ULONG BufferSize;
|
||||||
|
ULONG BytesRead;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
/* Calculate the buffer space that we'll need and allocate it */
|
/* Calculate the buffer space that we'll need and allocate it */
|
||||||
|
@ -1051,11 +1068,13 @@ PeekNamedPipe(HANDLE hNamedPipe,
|
||||||
{
|
{
|
||||||
/* Wait for npfs to be done, and update the status */
|
/* Wait for npfs to be done, and update the status */
|
||||||
Status = NtWaitForSingleObject(hNamedPipe, FALSE, NULL);
|
Status = NtWaitForSingleObject(hNamedPipe, FALSE, NULL);
|
||||||
if (NT_SUCCESS(Status)) Status = Iosb.Status;
|
if (NT_SUCCESS(Status))
|
||||||
|
Status = Iosb.Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Overflow is success for us */
|
/* Overflow is success for us */
|
||||||
if (Status == STATUS_BUFFER_OVERFLOW) Status = STATUS_SUCCESS;
|
if (Status == STATUS_BUFFER_OVERFLOW)
|
||||||
|
Status = STATUS_SUCCESS;
|
||||||
|
|
||||||
/* If we failed */
|
/* If we failed */
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
|
@ -1067,23 +1086,25 @@ PeekNamedPipe(HANDLE hNamedPipe,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if caller requested bytes available */
|
/* Check if caller requested bytes available */
|
||||||
if (lpTotalBytesAvail) *lpTotalBytesAvail = Buffer->ReadDataAvailable;
|
if (lpTotalBytesAvail)
|
||||||
|
*lpTotalBytesAvail = Buffer->ReadDataAvailable;
|
||||||
|
|
||||||
|
/* Calculate the bytes returned, minus our structure overhead */
|
||||||
|
BytesRead = (ULONG)(Iosb.Information -
|
||||||
|
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]))
|
||||||
|
|
||||||
/* Check if caller requested bytes read */
|
/* Check if caller requested bytes read */
|
||||||
if (lpBytesRead)
|
if (lpBytesRead)
|
||||||
{
|
{
|
||||||
/* Calculate the bytes returned, minus our structure overhead */
|
/* Return the bytes read */
|
||||||
*lpBytesRead = (ULONG)(Iosb.Information -
|
*lpBytesRead = BytesRead;
|
||||||
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if caller requested bytes left */
|
/* Check if caller requested bytes left */
|
||||||
if (lpBytesLeftThisMessage)
|
if (lpBytesLeftThisMessage)
|
||||||
{
|
{
|
||||||
/* Calculate total minus what we returned and our structure overhead */
|
/* Calculate total minus what we returned and our structure overhead */
|
||||||
*lpBytesLeftThisMessage = Buffer->MessageLength -
|
*lpBytesLeftThisMessage = Buffer->MessageLength - BytesRead;
|
||||||
(ULONG)(Iosb.Information -
|
|
||||||
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if the caller wanted to see the actual data */
|
/* Check if the caller wanted to see the actual data */
|
||||||
|
@ -1092,19 +1113,21 @@ PeekNamedPipe(HANDLE hNamedPipe,
|
||||||
/* Give him what he wants */
|
/* Give him what he wants */
|
||||||
RtlCopyMemory(lpBuffer,
|
RtlCopyMemory(lpBuffer,
|
||||||
Buffer->Data,
|
Buffer->Data,
|
||||||
Iosb.Information -
|
BytesRead);
|
||||||
FIELD_OFFSET(FILE_PIPE_PEEK_BUFFER, Data[0]));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Free the buffer and return success */
|
/* Free the buffer */
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
RtlFreeHeap(RtlGetProcessHeap(), 0, Buffer);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL
|
||||||
|
WINAPI
|
||||||
TransactNamedPipe(IN HANDLE hNamedPipe,
|
TransactNamedPipe(IN HANDLE hNamedPipe,
|
||||||
IN LPVOID lpInBuffer,
|
IN LPVOID lpInBuffer,
|
||||||
IN DWORD nInBufferSize,
|
IN DWORD nInBufferSize,
|
||||||
|
@ -1137,8 +1160,6 @@ TransactNamedPipe(IN HANDLE hNamedPipe,
|
||||||
nInBufferSize,
|
nInBufferSize,
|
||||||
lpOutBuffer,
|
lpOutBuffer,
|
||||||
nOutBufferSize);
|
nOutBufferSize);
|
||||||
|
|
||||||
/* return FALSE in case of failure and pending operations! */
|
|
||||||
if (!NT_SUCCESS(Status) || Status == STATUS_PENDING)
|
if (!NT_SUCCESS(Status) || Status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
|
@ -1165,18 +1186,14 @@ TransactNamedPipe(IN HANDLE hNamedPipe,
|
||||||
nInBufferSize,
|
nInBufferSize,
|
||||||
lpOutBuffer,
|
lpOutBuffer,
|
||||||
nOutBufferSize);
|
nOutBufferSize);
|
||||||
|
|
||||||
/* wait in case operation is pending */
|
|
||||||
if (Status == STATUS_PENDING)
|
if (Status == STATUS_PENDING)
|
||||||
{
|
{
|
||||||
Status = NtWaitForSingleObject(hNamedPipe,
|
Status = NtWaitForSingleObject(hNamedPipe,
|
||||||
FALSE,
|
FALSE,
|
||||||
NULL);
|
NULL);
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
|
||||||
Status = Iosb.Status;
|
Status = Iosb.Status;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (NT_SUCCESS(Status))
|
if (NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
|
@ -1200,16 +1217,19 @@ TransactNamedPipe(IN HANDLE hNamedPipe,
|
||||||
lpInBuffer = (LPVOID)((char *) lpInBuffer + nActualBytes);
|
lpInBuffer = (LPVOID)((char *) lpInBuffer + nActualBytes);
|
||||||
nInBufferSize -= nActualBytes;
|
nInBufferSize -= nActualBytes;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (0 != nInBufferSize)
|
if (0 != nInBufferSize)
|
||||||
{
|
{
|
||||||
/* Must have dropped out of the while 'cause WriteFile failed */
|
/* Must have dropped out of the while 'cause WriteFile failed */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ReadFile(hNamedPipe, lpOutBuffer, nOutBufferSize, &nActualBytes,
|
if (!ReadFile(hNamedPipe, lpOutBuffer, nOutBufferSize, &nActualBytes,
|
||||||
NULL))
|
NULL))
|
||||||
{
|
{
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (NULL != lpBytesRead)
|
if (NULL != lpBytesRead)
|
||||||
{
|
{
|
||||||
*lpBytesRead = nActualBytes;
|
*lpBytesRead = nActualBytes;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue