mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[KERNEL32] Fix a FIXME in WaitNamedPipeW(): allow waiting on a remote pipe
This commit is contained in:
parent
ec9912f334
commit
ebe9735835
1 changed files with 44 additions and 1 deletions
|
@ -468,6 +468,7 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
HANDLE FileHandle;
|
HANDLE FileHandle;
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
IO_STATUS_BLOCK IoStatusBlock;
|
||||||
ULONG WaitPipeInfoSize;
|
ULONG WaitPipeInfoSize;
|
||||||
|
PVOID DevicePathBuffer;
|
||||||
PFILE_PIPE_WAIT_FOR_BUFFER WaitPipeInfo;
|
PFILE_PIPE_WAIT_FOR_BUFFER WaitPipeInfo;
|
||||||
|
|
||||||
/* Start by making a unicode string of the name */
|
/* Start by making a unicode string of the name */
|
||||||
|
@ -486,6 +487,8 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
if (NamedPipeName.Buffer[i] == L'/') NamedPipeName.Buffer[i] = L'\\';
|
if (NamedPipeName.Buffer[i] == L'/') NamedPipeName.Buffer[i] = L'\\';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DevicePathBuffer = NULL;
|
||||||
|
|
||||||
/* Find the path type of the name we were given */
|
/* Find the path type of the name we were given */
|
||||||
NewName = NamedPipeName;
|
NewName = NamedPipeName;
|
||||||
Type = RtlDetermineDosPathNameType_U(lpNamedPipeName);
|
Type = RtlDetermineDosPathNameType_U(lpNamedPipeName);
|
||||||
|
@ -515,6 +518,8 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
}
|
}
|
||||||
else if (Type == RtlPathTypeUncAbsolute)
|
else if (Type == RtlPathTypeUncAbsolute)
|
||||||
{
|
{
|
||||||
|
PWSTR PipeName;
|
||||||
|
|
||||||
/* The path is \\server\\pipe\name; find the pipename itself */
|
/* The path is \\server\\pipe\name; find the pipename itself */
|
||||||
p = &NewName.Buffer[2];
|
p = &NewName.Buffer[2];
|
||||||
|
|
||||||
|
@ -543,7 +548,34 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: Open \DosDevices\Unc\Server\Pipe\Name */
|
/* Skip first backslash */
|
||||||
|
NewName.Buffer++;
|
||||||
|
/* And skip pipe for copying name */
|
||||||
|
PipeName = p + ((sizeof(L"pipe\\") - sizeof(UNICODE_NULL)) / sizeof(WCHAR));
|
||||||
|
/* Update the string */
|
||||||
|
NewName.Length = (USHORT)((ULONG_PTR)PipeName - (ULONG_PTR)NewName.Buffer);
|
||||||
|
NewName.MaximumLength = (USHORT)((ULONG_PTR)PipeName - (ULONG_PTR)NewName.Buffer);
|
||||||
|
|
||||||
|
/* DevicePath will contain the pipename + the DosDevice prefix */
|
||||||
|
DevicePath.MaximumLength = (USHORT)((ULONG_PTR)PipeName - (ULONG_PTR)NewName.Buffer) + sizeof(L"\\DosDevices\\UNC\\");
|
||||||
|
|
||||||
|
/* Allocate the buffer for DevicePath */
|
||||||
|
DevicePathBuffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, DevicePath.MaximumLength);
|
||||||
|
if (DevicePathBuffer == NULL)
|
||||||
|
{
|
||||||
|
RtlFreeUnicodeString(&NamedPipeName);
|
||||||
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Copy the prefix first */
|
||||||
|
DevicePath.Buffer = DevicePathBuffer;
|
||||||
|
RtlCopyMemory(DevicePathBuffer, L"\\DosDevices\\UNC\\", sizeof(L"\\DosDevices\\UNC\\") - sizeof(UNICODE_NULL));
|
||||||
|
DevicePath.Length = sizeof(L"\\DosDevices\\UNC\\") - sizeof(UNICODE_NULL);
|
||||||
|
/* And append the rest */
|
||||||
|
RtlAppendUnicodeStringToString(&DevicePath, &NewName);
|
||||||
|
/* And fix pipe name without its prefix */
|
||||||
|
RtlInitUnicodeString(&NewName, PipeName + 1);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -559,6 +591,11 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
WaitPipeInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, WaitPipeInfoSize);
|
WaitPipeInfo = RtlAllocateHeap(RtlGetProcessHeap(), 0, WaitPipeInfoSize);
|
||||||
if (WaitPipeInfo == NULL)
|
if (WaitPipeInfo == NULL)
|
||||||
{
|
{
|
||||||
|
if (DevicePathBuffer != NULL)
|
||||||
|
{
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, DevicePathBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
RtlFreeUnicodeString(&NamedPipeName);
|
RtlFreeUnicodeString(&NamedPipeName);
|
||||||
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -579,6 +616,12 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||||
&IoStatusBlock,
|
&IoStatusBlock,
|
||||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||||
|
|
||||||
|
if (DevicePathBuffer != NULL)
|
||||||
|
{
|
||||||
|
RtlFreeHeap(RtlGetProcessHeap(), 0, DevicePathBuffer);
|
||||||
|
}
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
{
|
{
|
||||||
/* Fail; couldn't open */
|
/* Fail; couldn't open */
|
||||||
|
|
Loading…
Reference in a new issue