mirror of
https://github.com/reactos/reactos.git
synced 2025-07-23 11:14:01 +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,
|
||||||
|
@ -97,8 +99,8 @@ CreateNamedPipeW(LPCWSTR lpName,
|
||||||
if (!Result)
|
if (!Result)
|
||||||
{
|
{
|
||||||
/* 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:
|
||||||
|
@ -342,8 +349,8 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
{
|
{
|
||||||
/* The name is invalid */
|
/* The name is invalid */
|
||||||
DPRINT1("Invalid name!\n");
|
DPRINT1("Invalid name!\n");
|
||||||
SetLastErrorByStatus(STATUS_OBJECT_PATH_SYNTAX_BAD);
|
SetLastErrorByStatus(STATUS_OBJECT_PATH_SYNTAX_BAD);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Open \DosDevices\Unc\Server\Pipe\Name */
|
/* FIXME: Open \DosDevices\Unc\Server\Pipe\Name */
|
||||||
|
@ -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,78 +461,79 @@ 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,
|
||||||
&NamedPipeName,
|
&NamedPipeName,
|
||||||
OBJ_CASE_INSENSITIVE,
|
OBJ_CASE_INSENSITIVE,
|
||||||
NULL,
|
NULL,
|
||||||
NULL);
|
NULL);
|
||||||
Status = NtOpenFile(&FileHandle,
|
Status = NtOpenFile(&FileHandle,
|
||||||
FILE_READ_ATTRIBUTES | SYNCHRONIZE,
|
FILE_READ_ATTRIBUTES | SYNCHRONIZE,
|
||||||
&ObjectAttributes,
|
&ObjectAttributes,
|
||||||
&Iosb,
|
&Iosb,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||||
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;
|
||||||
|
|
||||||
Status = NtFsControlFile(FileHandle,
|
Status = NtFsControlFile(FileHandle,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
NULL,
|
NULL,
|
||||||
&Iosb,
|
&Iosb,
|
||||||
FSCTL_PIPE_WAIT,
|
FSCTL_PIPE_WAIT,
|
||||||
&WaitPipe,
|
&WaitPipe,
|
||||||
sizeof(WaitPipe),
|
sizeof(WaitPipe),
|
||||||
NULL,
|
NULL,
|
||||||
0);
|
0);
|
||||||
NtClose(FileHandle);
|
NtClose(FileHandle);
|
||||||
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)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
if (lpOverlapped != NULL)
|
if (lpOverlapped != NULL)
|
||||||
{
|
{
|
||||||
PVOID ApcContext;
|
PVOID ApcContext;
|
||||||
|
|
||||||
lpOverlapped->Internal = STATUS_PENDING;
|
lpOverlapped->Internal = STATUS_PENDING;
|
||||||
|
@ -544,13 +552,13 @@ ConnectNamedPipe(IN HANDLE hNamedPipe,
|
||||||
|
|
||||||
/* return FALSE in case of failure and pending operations! */
|
/* 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);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK Iosb;
|
IO_STATUS_BLOCK Iosb;
|
||||||
|
|
||||||
Status = NtFsControlFile(hNamedPipe,
|
Status = NtFsControlFile(hNamedPipe,
|
||||||
|
@ -566,31 +574,32 @@ ConnectNamedPipe(IN HANDLE hNamedPipe,
|
||||||
|
|
||||||
/* wait in case operation is pending */
|
/* 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))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
@ -766,16 +775,18 @@ CallNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
nOutBufferSize,
|
nOutBufferSize,
|
||||||
lpBytesRead,
|
lpBytesRead,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
/* Close the handle and return */
|
/* Close the handle */
|
||||||
CloseHandle(hPipe);
|
CloseHandle(hPipe);
|
||||||
|
|
||||||
return bError;
|
return bError;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL
|
BOOL
|
||||||
WINAPI
|
WINAPI
|
||||||
DisconnectNamedPipe(HANDLE hNamedPipe)
|
DisconnectNamedPipe(HANDLE hNamedPipe)
|
||||||
{
|
{
|
||||||
|
@ -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 */
|
||||||
|
@ -806,210 +818,214 @@ DisconnectNamedPipe(HANDLE hNamedPipe)
|
||||||
/* Fail */
|
/* Fail */
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @unimplemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL
|
||||||
|
WINAPI
|
||||||
GetNamedPipeHandleStateW(HANDLE hNamedPipe,
|
GetNamedPipeHandleStateW(HANDLE hNamedPipe,
|
||||||
LPDWORD lpState,
|
LPDWORD lpState,
|
||||||
LPDWORD lpCurInstances,
|
LPDWORD lpCurInstances,
|
||||||
LPDWORD lpMaxCollectionCount,
|
LPDWORD lpMaxCollectionCount,
|
||||||
LPDWORD lpCollectDataTimeout,
|
LPDWORD lpCollectDataTimeout,
|
||||||
LPWSTR lpUserName,
|
LPWSTR lpUserName,
|
||||||
DWORD nMaxUserNameSize)
|
DWORD nMaxUserNameSize)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK StatusBlock;
|
IO_STATUS_BLOCK StatusBlock;
|
||||||
NTSTATUS Status;
|
|
||||||
|
|
||||||
if (lpState != NULL)
|
|
||||||
{
|
|
||||||
FILE_PIPE_INFORMATION PipeInfo;
|
|
||||||
|
|
||||||
Status = NtQueryInformationFile(hNamedPipe,
|
|
||||||
&StatusBlock,
|
|
||||||
&PipeInfo,
|
|
||||||
sizeof(FILE_PIPE_INFORMATION),
|
|
||||||
FilePipeInformation);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
SetLastErrorByStatus(Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*lpState = ((PipeInfo.CompletionMode != FILE_PIPE_QUEUE_OPERATION) ? PIPE_NOWAIT : PIPE_WAIT);
|
|
||||||
*lpState |= ((PipeInfo.ReadMode != FILE_PIPE_BYTE_STREAM_MODE) ? PIPE_READMODE_MESSAGE : PIPE_READMODE_BYTE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lpCurInstances != NULL)
|
|
||||||
{
|
|
||||||
FILE_PIPE_LOCAL_INFORMATION LocalInfo;
|
|
||||||
|
|
||||||
Status = NtQueryInformationFile(hNamedPipe,
|
|
||||||
&StatusBlock,
|
|
||||||
&LocalInfo,
|
|
||||||
sizeof(FILE_PIPE_LOCAL_INFORMATION),
|
|
||||||
FilePipeLocalInformation);
|
|
||||||
if(!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
SetLastErrorByStatus(Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*lpCurInstances = min(LocalInfo.CurrentInstances, PIPE_UNLIMITED_INSTANCES);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lpMaxCollectionCount != NULL || lpCollectDataTimeout != NULL)
|
|
||||||
{
|
|
||||||
FILE_PIPE_REMOTE_INFORMATION RemoteInfo;
|
|
||||||
|
|
||||||
Status = NtQueryInformationFile(hNamedPipe,
|
|
||||||
&StatusBlock,
|
|
||||||
&RemoteInfo,
|
|
||||||
sizeof(FILE_PIPE_REMOTE_INFORMATION),
|
|
||||||
FilePipeRemoteInformation);
|
|
||||||
if(!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
SetLastErrorByStatus(Status);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lpMaxCollectionCount != NULL)
|
|
||||||
{
|
|
||||||
*lpMaxCollectionCount = RemoteInfo.MaximumCollectionCount;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lpCollectDataTimeout != NULL)
|
|
||||||
{
|
|
||||||
/* FIXME */
|
|
||||||
*lpCollectDataTimeout = 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(lpUserName != NULL)
|
|
||||||
{
|
|
||||||
/* FIXME - open the thread token, call ImpersonateNamedPipeClient() and
|
|
||||||
retreive the user name with GetUserName(), revert the impersonation
|
|
||||||
and finally restore the thread token */
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* @implemented
|
|
||||||
*/
|
|
||||||
BOOL STDCALL
|
|
||||||
GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
|
||||||
LPDWORD lpState,
|
|
||||||
LPDWORD lpCurInstances,
|
|
||||||
LPDWORD lpMaxCollectionCount,
|
|
||||||
LPDWORD lpCollectDataTimeout,
|
|
||||||
LPSTR lpUserName,
|
|
||||||
DWORD nMaxUserNameSize)
|
|
||||||
{
|
|
||||||
UNICODE_STRING UserNameW = {0};
|
|
||||||
ANSI_STRING UserNameA;
|
|
||||||
BOOL Ret;
|
|
||||||
|
|
||||||
if(lpUserName != NULL)
|
|
||||||
{
|
|
||||||
UserNameW.MaximumLength = (USHORT)nMaxUserNameSize * sizeof(WCHAR);
|
|
||||||
UserNameW.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, UserNameW.MaximumLength);
|
|
||||||
if (UserNameW.Buffer == NULL)
|
|
||||||
{
|
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
UserNameA.Buffer = lpUserName;
|
|
||||||
UserNameA.Length = 0;
|
|
||||||
UserNameA.MaximumLength = (USHORT)nMaxUserNameSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ret = GetNamedPipeHandleStateW(hNamedPipe,
|
|
||||||
lpState,
|
|
||||||
lpCurInstances,
|
|
||||||
lpMaxCollectionCount,
|
|
||||||
lpCollectDataTimeout,
|
|
||||||
UserNameW.Buffer,
|
|
||||||
nMaxUserNameSize);
|
|
||||||
|
|
||||||
if(Ret && lpUserName != NULL)
|
|
||||||
{
|
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
RtlInitUnicodeString(&UserNameW, UserNameW.Buffer);
|
if (lpState != NULL)
|
||||||
Status = RtlUnicodeStringToAnsiString(&UserNameA, &UserNameW, FALSE);
|
|
||||||
if(!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
FILE_PIPE_INFORMATION PipeInfo;
|
||||||
Ret = FALSE;
|
|
||||||
|
Status = NtQueryInformationFile(hNamedPipe,
|
||||||
|
&StatusBlock,
|
||||||
|
&PipeInfo,
|
||||||
|
sizeof(FILE_PIPE_INFORMATION),
|
||||||
|
FilePipeInformation);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*lpState = ((PipeInfo.CompletionMode != FILE_PIPE_QUEUE_OPERATION) ? PIPE_NOWAIT : PIPE_WAIT);
|
||||||
|
*lpState |= ((PipeInfo.ReadMode != FILE_PIPE_BYTE_STREAM_MODE) ? PIPE_READMODE_MESSAGE : PIPE_READMODE_BYTE);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if(UserNameW.Buffer != NULL)
|
if(lpCurInstances != NULL)
|
||||||
{
|
{
|
||||||
RtlFreeHeap(RtlGetProcessHeap(), 0, UserNameW.Buffer);
|
FILE_PIPE_LOCAL_INFORMATION LocalInfo;
|
||||||
}
|
|
||||||
|
|
||||||
return Ret;
|
Status = NtQueryInformationFile(hNamedPipe,
|
||||||
|
&StatusBlock,
|
||||||
|
&LocalInfo,
|
||||||
|
sizeof(FILE_PIPE_LOCAL_INFORMATION),
|
||||||
|
FilePipeLocalInformation);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*lpCurInstances = min(LocalInfo.CurrentInstances, PIPE_UNLIMITED_INSTANCES);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lpMaxCollectionCount != NULL || lpCollectDataTimeout != NULL)
|
||||||
|
{
|
||||||
|
FILE_PIPE_REMOTE_INFORMATION RemoteInfo;
|
||||||
|
|
||||||
|
Status = NtQueryInformationFile(hNamedPipe,
|
||||||
|
&StatusBlock,
|
||||||
|
&RemoteInfo,
|
||||||
|
sizeof(FILE_PIPE_REMOTE_INFORMATION),
|
||||||
|
FilePipeRemoteInformation);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lpMaxCollectionCount != NULL)
|
||||||
|
{
|
||||||
|
*lpMaxCollectionCount = RemoteInfo.MaximumCollectionCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(lpCollectDataTimeout != NULL)
|
||||||
|
{
|
||||||
|
/* FIXME */
|
||||||
|
*lpCollectDataTimeout = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lpUserName != NULL)
|
||||||
|
{
|
||||||
|
/* FIXME - open the thread token, call ImpersonateNamedPipeClient() and
|
||||||
|
retreive the user name with GetUserName(), revert the impersonation
|
||||||
|
and finally restore the thread token */
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @implemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL
|
||||||
GetNamedPipeInfo(HANDLE hNamedPipe,
|
WINAPI
|
||||||
LPDWORD lpFlags,
|
GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
||||||
LPDWORD lpOutBufferSize,
|
LPDWORD lpState,
|
||||||
LPDWORD lpInBufferSize,
|
LPDWORD lpCurInstances,
|
||||||
LPDWORD lpMaxInstances)
|
LPDWORD lpMaxCollectionCount,
|
||||||
|
LPDWORD lpCollectDataTimeout,
|
||||||
|
LPSTR lpUserName,
|
||||||
|
DWORD nMaxUserNameSize)
|
||||||
{
|
{
|
||||||
FILE_PIPE_LOCAL_INFORMATION PipeLocalInformation;
|
UNICODE_STRING UserNameW = {0};
|
||||||
IO_STATUS_BLOCK StatusBlock;
|
ANSI_STRING UserNameA;
|
||||||
NTSTATUS Status;
|
BOOL Ret;
|
||||||
|
|
||||||
Status = NtQueryInformationFile(hNamedPipe,
|
if(lpUserName != NULL)
|
||||||
&StatusBlock,
|
|
||||||
&PipeLocalInformation,
|
|
||||||
sizeof(FILE_PIPE_LOCAL_INFORMATION),
|
|
||||||
FilePipeLocalInformation);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
UserNameW.MaximumLength = (USHORT)nMaxUserNameSize * sizeof(WCHAR);
|
||||||
return(FALSE);
|
UserNameW.Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, UserNameW.MaximumLength);
|
||||||
|
if (UserNameW.Buffer == NULL)
|
||||||
|
{
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
UserNameA.Buffer = lpUserName;
|
||||||
|
UserNameA.Length = 0;
|
||||||
|
UserNameA.MaximumLength = (USHORT)nMaxUserNameSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpFlags != NULL)
|
Ret = GetNamedPipeHandleStateW(hNamedPipe,
|
||||||
|
lpState,
|
||||||
|
lpCurInstances,
|
||||||
|
lpMaxCollectionCount,
|
||||||
|
lpCollectDataTimeout,
|
||||||
|
UserNameW.Buffer,
|
||||||
|
nMaxUserNameSize);
|
||||||
|
if (Ret && lpUserName != NULL)
|
||||||
{
|
{
|
||||||
*lpFlags = (PipeLocalInformation.NamedPipeEnd == FILE_PIPE_SERVER_END) ? PIPE_SERVER_END : PIPE_CLIENT_END;
|
NTSTATUS Status;
|
||||||
*lpFlags |= (PipeLocalInformation.NamedPipeType == 1) ? PIPE_TYPE_MESSAGE : PIPE_TYPE_BYTE;
|
|
||||||
|
RtlInitUnicodeString(&UserNameW, UserNameW.Buffer);
|
||||||
|
Status = RtlUnicodeStringToAnsiString(&UserNameA, &UserNameW, FALSE);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
Ret = FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpOutBufferSize != NULL)
|
if (UserNameW.Buffer != NULL)
|
||||||
*lpOutBufferSize = PipeLocalInformation.OutboundQuota;
|
|
||||||
|
|
||||||
if (lpInBufferSize != NULL)
|
|
||||||
*lpInBufferSize = PipeLocalInformation.InboundQuota;
|
|
||||||
|
|
||||||
if (lpMaxInstances != NULL)
|
|
||||||
{
|
{
|
||||||
if (PipeLocalInformation.MaximumInstances >= 255)
|
RtlFreeHeap(RtlGetProcessHeap(), 0, UserNameW.Buffer);
|
||||||
*lpMaxInstances = PIPE_UNLIMITED_INSTANCES;
|
|
||||||
else
|
|
||||||
*lpMaxInstances = PipeLocalInformation.MaximumInstances;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return(TRUE);
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
* @implemented
|
||||||
|
*/
|
||||||
|
BOOL
|
||||||
|
WINAPI
|
||||||
|
GetNamedPipeInfo(HANDLE hNamedPipe,
|
||||||
|
LPDWORD lpFlags,
|
||||||
|
LPDWORD lpOutBufferSize,
|
||||||
|
LPDWORD lpInBufferSize,
|
||||||
|
LPDWORD lpMaxInstances)
|
||||||
|
{
|
||||||
|
FILE_PIPE_LOCAL_INFORMATION PipeLocalInformation;
|
||||||
|
IO_STATUS_BLOCK StatusBlock;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
Status = NtQueryInformationFile(hNamedPipe,
|
||||||
|
&StatusBlock,
|
||||||
|
&PipeLocalInformation,
|
||||||
|
sizeof(FILE_PIPE_LOCAL_INFORMATION),
|
||||||
|
FilePipeLocalInformation);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lpFlags != NULL)
|
||||||
|
{
|
||||||
|
*lpFlags = (PipeLocalInformation.NamedPipeEnd == FILE_PIPE_SERVER_END) ? PIPE_SERVER_END : PIPE_CLIENT_END;
|
||||||
|
*lpFlags |= (PipeLocalInformation.NamedPipeType == 1) ? PIPE_TYPE_MESSAGE : PIPE_TYPE_BYTE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lpOutBufferSize != NULL)
|
||||||
|
*lpOutBufferSize = PipeLocalInformation.OutboundQuota;
|
||||||
|
|
||||||
|
if (lpInBufferSize != NULL)
|
||||||
|
*lpInBufferSize = PipeLocalInformation.InboundQuota;
|
||||||
|
|
||||||
|
if (lpMaxInstances != NULL)
|
||||||
|
{
|
||||||
|
if (PipeLocalInformation.MaximumInstances >= 255)
|
||||||
|
*lpMaxInstances = PIPE_UNLIMITED_INSTANCES;
|
||||||
|
else
|
||||||
|
*lpMaxInstances = PipeLocalInformation.MaximumInstances;
|
||||||
|
}
|
||||||
|
|
||||||
|
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,
|
||||||
|
@ -1113,15 +1136,15 @@ TransactNamedPipe(IN HANDLE hNamedPipe,
|
||||||
OUT LPDWORD lpBytesRead OPTIONAL,
|
OUT LPDWORD lpBytesRead OPTIONAL,
|
||||||
IN LPOVERLAPPED lpOverlapped OPTIONAL)
|
IN LPOVERLAPPED lpOverlapped OPTIONAL)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
if (lpBytesRead != NULL)
|
if (lpBytesRead != NULL)
|
||||||
{
|
{
|
||||||
*lpBytesRead = 0;
|
*lpBytesRead = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpOverlapped != NULL)
|
if (lpOverlapped != NULL)
|
||||||
{
|
{
|
||||||
PVOID ApcContext;
|
PVOID ApcContext;
|
||||||
|
|
||||||
ApcContext = (((ULONG_PTR)lpOverlapped->hEvent & 0x1) ? NULL : lpOverlapped);
|
ApcContext = (((ULONG_PTR)lpOverlapped->hEvent & 0x1) ? NULL : lpOverlapped);
|
||||||
|
@ -1137,21 +1160,19 @@ 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);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpBytesRead != NULL)
|
if (lpBytesRead != NULL)
|
||||||
{
|
{
|
||||||
*lpBytesRead = lpOverlapped->InternalHigh;
|
*lpBytesRead = lpOverlapped->InternalHigh;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
#if 0 /* We don't implement FSCTL_PIPE_TRANSCEIVE yet */
|
#if 0 /* We don't implement FSCTL_PIPE_TRANSCEIVE yet */
|
||||||
IO_STATUS_BLOCK Iosb;
|
IO_STATUS_BLOCK Iosb;
|
||||||
|
|
||||||
|
@ -1165,59 +1186,58 @@ 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))
|
||||||
{
|
{
|
||||||
/* lpNumberOfBytesRead must not be NULL here, in fact Win doesn't
|
/* lpNumberOfBytesRead must not be NULL here, in fact Win doesn't
|
||||||
check that case either and crashes (only after the operation
|
check that case either and crashes (only after the operation
|
||||||
completed) */
|
completed) */
|
||||||
*lpBytesRead = Iosb.Information;
|
*lpBytesRead = Iosb.Information;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
#else /* Workaround while FSCTL_PIPE_TRANSCEIVE not available */
|
#else /* Workaround while FSCTL_PIPE_TRANSCEIVE not available */
|
||||||
DWORD nActualBytes;
|
DWORD nActualBytes;
|
||||||
|
|
||||||
while (0 != nInBufferSize &&
|
while (0 != nInBufferSize &&
|
||||||
WriteFile(hNamedPipe, lpInBuffer, nInBufferSize, &nActualBytes,
|
WriteFile(hNamedPipe, lpInBuffer, nInBufferSize, &nActualBytes,
|
||||||
NULL))
|
NULL))
|
||||||
{
|
{
|
||||||
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,
|
|
||||||
NULL))
|
|
||||||
{
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
if (NULL != lpBytesRead)
|
|
||||||
{
|
|
||||||
*lpBytesRead = nActualBytes;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
return TRUE;
|
if (!ReadFile(hNamedPipe, lpOutBuffer, nOutBufferSize, &nActualBytes,
|
||||||
|
NULL))
|
||||||
|
{
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NULL != lpBytesRead)
|
||||||
|
{
|
||||||
|
*lpBytesRead = nActualBytes;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue