mirror of
https://github.com/reactos/reactos.git
synced 2024-12-29 02:25:17 +00:00
implemented GetNamedPipeHandleStateA() and a few fixes for GetNamedPipeHandleStateW()
svn path=/trunk/; revision=11237
This commit is contained in:
parent
4664a1f6ed
commit
db533baf58
1 changed files with 104 additions and 32 deletions
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: npipe.c,v 1.18 2004/03/17 15:00:39 gdalsnes Exp $
|
/* $Id: npipe.c,v 1.19 2004/10/08 21:25:18 weiden 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
|
||||||
|
@ -599,51 +599,86 @@ GetNamedPipeHandleStateW(HANDLE hNamedPipe,
|
||||||
LPWSTR lpUserName,
|
LPWSTR lpUserName,
|
||||||
DWORD nMaxUserNameSize)
|
DWORD nMaxUserNameSize)
|
||||||
{
|
{
|
||||||
FILE_PIPE_LOCAL_INFORMATION LocalInfo;
|
|
||||||
FILE_PIPE_INFORMATION PipeInfo;
|
|
||||||
IO_STATUS_BLOCK StatusBlock;
|
IO_STATUS_BLOCK StatusBlock;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
if (lpState != NULL)
|
if(lpState != NULL)
|
||||||
{
|
{
|
||||||
|
FILE_PIPE_INFORMATION PipeInfo;
|
||||||
|
|
||||||
Status = NtQueryInformationFile(hNamedPipe,
|
Status = NtQueryInformationFile(hNamedPipe,
|
||||||
&StatusBlock,
|
&StatusBlock,
|
||||||
&PipeInfo,
|
&PipeInfo,
|
||||||
sizeof(FILE_PIPE_INFORMATION),
|
sizeof(FILE_PIPE_INFORMATION),
|
||||||
FilePipeInformation);
|
FilePipeInformation);
|
||||||
if (!NT_SUCCESS(Status))
|
if(!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
|
||||||
*lpState = 0; /* FIXME */
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lpCurInstances != NULL)
|
*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,
|
Status = NtQueryInformationFile(hNamedPipe,
|
||||||
&StatusBlock,
|
&StatusBlock,
|
||||||
&LocalInfo,
|
&LocalInfo,
|
||||||
sizeof(FILE_PIPE_LOCAL_INFORMATION),
|
sizeof(FILE_PIPE_LOCAL_INFORMATION),
|
||||||
FilePipeLocalInformation);
|
FilePipeLocalInformation);
|
||||||
if (!NT_SUCCESS(Status))
|
if(!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
SetLastErrorByStatus(Status);
|
SetLastErrorByStatus(Status);
|
||||||
return(FALSE);
|
return FALSE;
|
||||||
}
|
|
||||||
*lpCurInstances = min(LocalInfo.CurrentInstances, 255);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*lpCurInstances = min(LocalInfo.CurrentInstances, PIPE_UNLIMITED_INSTANCES);
|
||||||
|
}
|
||||||
|
|
||||||
/* FIXME: retrieve remaining information */
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
return(TRUE);
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* @unimplemented
|
* @implemented
|
||||||
*/
|
*/
|
||||||
BOOL STDCALL
|
BOOL STDCALL
|
||||||
GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
||||||
|
@ -654,8 +689,45 @@ GetNamedPipeHandleStateA(HANDLE hNamedPipe,
|
||||||
LPSTR lpUserName,
|
LPSTR lpUserName,
|
||||||
DWORD nMaxUserNameSize)
|
DWORD nMaxUserNameSize)
|
||||||
{
|
{
|
||||||
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
UNICODE_STRING UserNameW;
|
||||||
return FALSE;
|
ANSI_STRING UserNameA;
|
||||||
|
BOOL Ret;
|
||||||
|
|
||||||
|
if(lpUserName != NULL)
|
||||||
|
{
|
||||||
|
UserNameW.Length = 0;
|
||||||
|
UserNameW.MaximumLength = nMaxUserNameSize * sizeof(WCHAR);
|
||||||
|
UserNameW.Buffer = HeapAlloc(GetCurrentProcess(), 0, UserNameW.MaximumLength);
|
||||||
|
|
||||||
|
UserNameA.Buffer = lpUserName;
|
||||||
|
UserNameA.Length = 0;
|
||||||
|
UserNameA.MaximumLength = nMaxUserNameSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ret = GetNamedPipeHandleStateW(hNamedPipe,
|
||||||
|
lpState,
|
||||||
|
lpCurInstances,
|
||||||
|
lpMaxCollectionCount,
|
||||||
|
lpCollectDataTimeout,
|
||||||
|
UserNameW.Buffer,
|
||||||
|
nMaxUserNameSize);
|
||||||
|
|
||||||
|
if(Ret && lpUserName != NULL)
|
||||||
|
{
|
||||||
|
NTSTATUS Status = RtlUnicodeStringToAnsiString(&UserNameA, &UserNameW, FALSE);
|
||||||
|
if(!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
SetLastErrorByStatus(Status);
|
||||||
|
Ret = FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(UserNameW.Buffer != NULL)
|
||||||
|
{
|
||||||
|
HeapFree(GetCurrentProcess(), 0, UserNameW.Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue