mirror of
https://github.com/reactos/reactos.git
synced 2024-07-07 13:15:07 +00:00
[NPFS/KERNEL32]
Switch back to the old pipe wait code but keep the new code in place (disabled). svn path=/trunk/; revision=49701
This commit is contained in:
parent
2b6a79d9c9
commit
8b5175e0ab
|
@ -14,7 +14,7 @@
|
|||
#include <debug.h>
|
||||
DEBUG_CHANNEL(kernel32file);
|
||||
|
||||
#define USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
//#define USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
|
||||
/* FUNCTIONS ****************************************************************/
|
||||
|
||||
|
@ -264,6 +264,16 @@ WaitNamedPipeA(LPCSTR lpNamedPipeName,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* When NPFS will work properly, use this code instead. It is compatible with
|
||||
* Microsoft's NPFS.SYS. The main difference is that:
|
||||
* - This code actually respects the timeout instead of ignoring it!
|
||||
* - This code validates and creates the proper names for both UNC and local pipes
|
||||
* - On NT, you open the *root* pipe directory (either \DosDevices\Pipe or
|
||||
* \DosDevices\Unc\Server\Pipe) and then send the pipe to wait on in the
|
||||
* FILE_PIPE_WAIT_FOR_BUFFER structure.
|
||||
*/
|
||||
#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
|
@ -448,6 +458,95 @@ WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
|||
/* Success */
|
||||
return TRUE;
|
||||
}
|
||||
#else
|
||||
/*
|
||||
* @implemented
|
||||
*/
|
||||
BOOL
|
||||
WINAPI
|
||||
WaitNamedPipeW(LPCWSTR lpNamedPipeName,
|
||||
DWORD nTimeOut)
|
||||
{
|
||||
UNICODE_STRING NamedPipeName;
|
||||
NTSTATUS Status;
|
||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||
FILE_PIPE_WAIT_FOR_BUFFER WaitPipe;
|
||||
HANDLE FileHandle;
|
||||
IO_STATUS_BLOCK Iosb;
|
||||
|
||||
if (RtlDosPathNameToNtPathName_U(lpNamedPipeName,
|
||||
&NamedPipeName,
|
||||
NULL,
|
||||
NULL) == FALSE)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
InitializeObjectAttributes(&ObjectAttributes,
|
||||
&NamedPipeName,
|
||||
OBJ_CASE_INSENSITIVE,
|
||||
NULL,
|
||||
NULL);
|
||||
Status = NtOpenFile(&FileHandle,
|
||||
FILE_READ_ATTRIBUTES | SYNCHRONIZE,
|
||||
&ObjectAttributes,
|
||||
&Iosb,
|
||||
FILE_SHARE_READ | FILE_SHARE_WRITE,
|
||||
FILE_SYNCHRONOUS_IO_NONALERT);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastErrorByStatus(Status);
|
||||
RtlFreeUnicodeString(&NamedPipeName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Check what timeout we got */
|
||||
if (nTimeOut == NMPWAIT_USE_DEFAULT_WAIT)
|
||||
{
|
||||
/* Don't use a timeout */
|
||||
WaitPipe.TimeoutSpecified = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Check if we should wait forever */
|
||||
if (nTimeOut == NMPWAIT_WAIT_FOREVER)
|
||||
{
|
||||
/* Set the max */
|
||||
WaitPipe.Timeout.LowPart = 0;
|
||||
WaitPipe.Timeout.HighPart = 0x80000000;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Convert to NT format */
|
||||
WaitPipe.Timeout.QuadPart = UInt32x32To64(-10000, nTimeOut);
|
||||
}
|
||||
|
||||
/* In both cases, we do have a timeout */
|
||||
WaitPipe.TimeoutSpecified = TRUE;
|
||||
}
|
||||
|
||||
Status = NtFsControlFile(FileHandle,
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
&Iosb,
|
||||
FSCTL_PIPE_WAIT,
|
||||
&WaitPipe,
|
||||
sizeof(WaitPipe),
|
||||
NULL,
|
||||
0);
|
||||
NtClose(FileHandle);
|
||||
if (!NT_SUCCESS(Status))
|
||||
{
|
||||
SetLastErrorByStatus(Status);
|
||||
RtlFreeUnicodeString(&NamedPipeName);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
RtlFreeUnicodeString(&NamedPipeName);
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
//#define USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
PNPFS_FCB
|
||||
|
@ -146,6 +148,9 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
|||
PNPFS_VCB Vcb;
|
||||
ACCESS_MASK DesiredAccess;
|
||||
NTSTATUS Status;
|
||||
#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
BOOLEAN SpecialAccess;
|
||||
#endif
|
||||
|
||||
DPRINT("NpfsCreate(DeviceObject %p Irp %p)\n", DeviceObject, Irp);
|
||||
|
||||
|
@ -161,6 +166,14 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
|||
|
||||
Irp->IoStatus.Information = 0;
|
||||
|
||||
#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
SpecialAccess = ((DesiredAccess & SPECIFIC_RIGHTS_ALL) == FILE_READ_ATTRIBUTES);
|
||||
if (SpecialAccess)
|
||||
{
|
||||
DPRINT("NpfsCreate() open client end for special use!\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
if (FileName->Length == 2 && FileName->Buffer[0] == L'\\' && RelatedFileObject == NULL)
|
||||
{
|
||||
DPRINT("Open the root directory\n");
|
||||
|
@ -217,8 +230,11 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
|||
ClientCcb->Fcb = Fcb;
|
||||
ClientCcb->PipeEnd = FILE_PIPE_CLIENT_END;
|
||||
ClientCcb->OtherSide = NULL;
|
||||
// ClientCcb->PipeState = SpecialAccess ? 0 : FILE_PIPE_DISCONNECTED_STATE;
|
||||
#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
ClientCcb->PipeState = SpecialAccess ? 0 : FILE_PIPE_DISCONNECTED_STATE;
|
||||
#else
|
||||
ClientCcb->PipeState = FILE_PIPE_DISCONNECTED_STATE;
|
||||
#endif
|
||||
InitializeListHead(&ClientCcb->ReadRequestListHead);
|
||||
|
||||
DPRINT("CCB: %p\n", ClientCcb);
|
||||
|
@ -256,10 +272,10 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
|||
/*
|
||||
* Step 3. Search for listening server CCB.
|
||||
*/
|
||||
/*
|
||||
#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
if (!SpecialAccess)
|
||||
{
|
||||
*/
|
||||
#endif
|
||||
/*
|
||||
* WARNING: Point of no return! Once we get the server CCB it's
|
||||
* possible that we completed a wait request and so we have to
|
||||
|
@ -315,7 +331,7 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
|||
/* FIXME: Merge this with the NpfsFindListeningServerInstance routine. */
|
||||
NpfsSignalAndRemoveListeningServerInstance(Fcb, ServerCcb);
|
||||
}
|
||||
/*
|
||||
#ifndef USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
}
|
||||
else if (IsListEmpty(&Fcb->ServerCcbListHead))
|
||||
{
|
||||
|
@ -333,7 +349,7 @@ NpfsCreate(PDEVICE_OBJECT DeviceObject,
|
|||
IoCompleteRequest(Irp, IO_NO_INCREMENT);
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
*/
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Step 4. Add the client CCB to a list and connect it if possible.
|
||||
|
|
|
@ -15,6 +15,8 @@
|
|||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
//#define USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
static DRIVER_CANCEL NpfsListeningCancelRoutine;
|
||||
|
@ -293,18 +295,21 @@ NpfsWaitPipe(PIRP Irp,
|
|||
PNPFS_CCB Ccb)
|
||||
{
|
||||
PLIST_ENTRY current_entry;
|
||||
PNPFS_VCB Vcb;
|
||||
PNPFS_FCB Fcb;
|
||||
PNPFS_CCB ServerCcb;
|
||||
PFILE_PIPE_WAIT_FOR_BUFFER WaitPipe;
|
||||
LARGE_INTEGER TimeOut;
|
||||
UNICODE_STRING PipeName;
|
||||
NTSTATUS Status;
|
||||
#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
PNPFS_VCB Vcb;
|
||||
UNICODE_STRING PipeName;
|
||||
#endif
|
||||
|
||||
DPRINT("NpfsWaitPipe\n");
|
||||
|
||||
WaitPipe = (PFILE_PIPE_WAIT_FOR_BUFFER)Irp->AssociatedIrp.SystemBuffer;
|
||||
|
||||
#ifdef USING_PROPER_NPFS_WAIT_SEMANTICS
|
||||
/* Fail, if the CCB does not represent the root directory */
|
||||
if (Ccb->Type != CCB_DIRECTORY)
|
||||
return STATUS_ILLEGAL_FUNCTION;
|
||||
|
@ -352,6 +357,15 @@ NpfsWaitPipe(PIRP Irp,
|
|||
}
|
||||
|
||||
DPRINT("Fcb %p\n", Fcb);
|
||||
#else
|
||||
Fcb = Ccb->Fcb;
|
||||
|
||||
if (Ccb->PipeState != 0)
|
||||
{
|
||||
DPRINT("Pipe is not in passive (waiting) state!\n");
|
||||
return STATUS_UNSUCCESSFUL;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* search for listening server */
|
||||
current_entry = Fcb->ServerCcbListHead.Flink;
|
||||
|
|
Loading…
Reference in a new issue