2013-09-11 23:19:20 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Named Pipe FileSystem
|
|
|
|
* LICENSE: BSD - See COPYING.ARM in the top level directory
|
|
|
|
* FILE: drivers/filesystems/npfs/waitsup.c
|
|
|
|
* PURPOSE: Pipes Waiting Support
|
|
|
|
* PROGRAMMERS: ReactOS Portable Systems Group
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES *******************************************************************/
|
|
|
|
|
2013-09-07 15:32:29 +00:00
|
|
|
#include "npfs.h"
|
|
|
|
|
2013-09-12 00:05:54 +00:00
|
|
|
// File ID number for NPFS bugchecking support
|
|
|
|
#define NPFS_BUGCHECK_FILE_ID (NPFS_BUGCHECK_WAITSUP)
|
|
|
|
|
2013-09-11 23:19:20 +00:00
|
|
|
/* FUNCTIONS ******************************************************************/
|
|
|
|
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
2014-08-07 10:24:07 +00:00
|
|
|
NpCancelWaitQueueIrp(IN PDEVICE_OBJECT DeviceObject,
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
IN PIRP Irp)
|
|
|
|
{
|
|
|
|
KIRQL OldIrql;
|
|
|
|
PNP_WAIT_QUEUE_ENTRY WaitEntry;
|
|
|
|
PNP_WAIT_QUEUE WaitQueue;
|
|
|
|
|
|
|
|
IoReleaseCancelSpinLock(Irp->CancelIrql);
|
|
|
|
|
2014-08-14 19:35:00 +00:00
|
|
|
WaitQueue = Irp->Tail.Overlay.DriverContext[0];
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2013-09-13 12:46:32 +00:00
|
|
|
KeAcquireSpinLock(&WaitQueue->WaitLock, &OldIrql);
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2014-08-14 19:35:00 +00:00
|
|
|
WaitEntry = Irp->Tail.Overlay.DriverContext[1];
|
For our 60000th commit, I bring you a complete rewrite of the Named Pipe File System. It is not yet "active", but I consider this to now be largely code complete and worthy of the prize (and I didn't want to delay other commiters any further). Once the code is reviewed, fixed, tested, and commented, it will replace our old and aging NPFS. This driver is cross-compatible with Windows Server 2003. It is expected to fix winetest incompatiblities, speed up performance, and reduce bizare RPC/SCM issues. This commit is dedicated to my best friend Rachel, who has not only always been there for me, but was also the motivating factor behind my return to my passion -- ReactOS :)
[NPFS-NEW]: Implement QueryVolume, QuerySecurity, SetSecurity. Everything but Directory Query, Fast I/O, and a few rare FSCTLs is implemented now. The former two will come in an upcoming commit.
[NPFS-NEW]: Major cleanup in the way some member variables were being addressed. Reference them as array members based on the correct FILE_PIPE defines from now on. Also fix a lot of formatting issues. Fix a bunch of bugs that were found. Use FILE_PIPE_SERVER_END and FILE_PIPE_CLIENT_END intead of a BOOLEAN. Use TRUE/FALSE/STATUS_SUCCESS/NULL/etc when needed intead of 0/1. The code formatting can/should still be improved, but this was a big help.
svn path=/trunk/; revision=60000
2013-09-10 08:36:25 +00:00
|
|
|
if (WaitEntry)
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
{
|
|
|
|
RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
|
For our 60000th commit, I bring you a complete rewrite of the Named Pipe File System. It is not yet "active", but I consider this to now be largely code complete and worthy of the prize (and I didn't want to delay other commiters any further). Once the code is reviewed, fixed, tested, and commented, it will replace our old and aging NPFS. This driver is cross-compatible with Windows Server 2003. It is expected to fix winetest incompatiblities, speed up performance, and reduce bizare RPC/SCM issues. This commit is dedicated to my best friend Rachel, who has not only always been there for me, but was also the motivating factor behind my return to my passion -- ReactOS :)
[NPFS-NEW]: Implement QueryVolume, QuerySecurity, SetSecurity. Everything but Directory Query, Fast I/O, and a few rare FSCTLs is implemented now. The former two will come in an upcoming commit.
[NPFS-NEW]: Major cleanup in the way some member variables were being addressed. Reference them as array members based on the correct FILE_PIPE defines from now on. Also fix a lot of formatting issues. Fix a bunch of bugs that were found. Use FILE_PIPE_SERVER_END and FILE_PIPE_CLIENT_END intead of a BOOLEAN. Use TRUE/FALSE/STATUS_SUCCESS/NULL/etc when needed intead of 0/1. The code formatting can/should still be improved, but this was a big help.
svn path=/trunk/; revision=60000
2013-09-10 08:36:25 +00:00
|
|
|
if (!KeCancelTimer(&WaitEntry->Timer))
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
{
|
|
|
|
WaitEntry->Irp = NULL;
|
|
|
|
WaitEntry = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-13 12:46:32 +00:00
|
|
|
KeReleaseSpinLock(&WaitQueue->WaitLock, OldIrql);
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
For our 60000th commit, I bring you a complete rewrite of the Named Pipe File System. It is not yet "active", but I consider this to now be largely code complete and worthy of the prize (and I didn't want to delay other commiters any further). Once the code is reviewed, fixed, tested, and commented, it will replace our old and aging NPFS. This driver is cross-compatible with Windows Server 2003. It is expected to fix winetest incompatiblities, speed up performance, and reduce bizare RPC/SCM issues. This commit is dedicated to my best friend Rachel, who has not only always been there for me, but was also the motivating factor behind my return to my passion -- ReactOS :)
[NPFS-NEW]: Implement QueryVolume, QuerySecurity, SetSecurity. Everything but Directory Query, Fast I/O, and a few rare FSCTLs is implemented now. The former two will come in an upcoming commit.
[NPFS-NEW]: Major cleanup in the way some member variables were being addressed. Reference them as array members based on the correct FILE_PIPE defines from now on. Also fix a lot of formatting issues. Fix a bunch of bugs that were found. Use FILE_PIPE_SERVER_END and FILE_PIPE_CLIENT_END intead of a BOOLEAN. Use TRUE/FALSE/STATUS_SUCCESS/NULL/etc when needed intead of 0/1. The code formatting can/should still be improved, but this was a big help.
svn path=/trunk/; revision=60000
2013-09-10 08:36:25 +00:00
|
|
|
if (WaitEntry)
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
{
|
2013-09-13 07:49:42 +00:00
|
|
|
ObDereferenceObject(WaitEntry->FileObject);
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
ExFreePool(WaitEntry);
|
|
|
|
}
|
|
|
|
|
|
|
|
Irp->IoStatus.Information = 0;
|
|
|
|
Irp->IoStatus.Status = STATUS_CANCELLED;
|
For our 60000th commit, I bring you a complete rewrite of the Named Pipe File System. It is not yet "active", but I consider this to now be largely code complete and worthy of the prize (and I didn't want to delay other commiters any further). Once the code is reviewed, fixed, tested, and commented, it will replace our old and aging NPFS. This driver is cross-compatible with Windows Server 2003. It is expected to fix winetest incompatiblities, speed up performance, and reduce bizare RPC/SCM issues. This commit is dedicated to my best friend Rachel, who has not only always been there for me, but was also the motivating factor behind my return to my passion -- ReactOS :)
[NPFS-NEW]: Implement QueryVolume, QuerySecurity, SetSecurity. Everything but Directory Query, Fast I/O, and a few rare FSCTLs is implemented now. The former two will come in an upcoming commit.
[NPFS-NEW]: Major cleanup in the way some member variables were being addressed. Reference them as array members based on the correct FILE_PIPE defines from now on. Also fix a lot of formatting issues. Fix a bunch of bugs that were found. Use FILE_PIPE_SERVER_END and FILE_PIPE_CLIENT_END intead of a BOOLEAN. Use TRUE/FALSE/STATUS_SUCCESS/NULL/etc when needed intead of 0/1. The code formatting can/should still be improved, but this was a big help.
svn path=/trunk/; revision=60000
2013-09-10 08:36:25 +00:00
|
|
|
IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
}
|
2014-08-07 10:24:07 +00:00
|
|
|
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
NpTimerDispatch(IN PKDPC Dpc,
|
|
|
|
IN PVOID Context,
|
|
|
|
IN PVOID Argument1,
|
|
|
|
IN PVOID Argument2)
|
|
|
|
{
|
|
|
|
PIRP Irp;
|
|
|
|
KIRQL OldIrql;
|
|
|
|
PNP_WAIT_QUEUE_ENTRY WaitEntry = Context;
|
|
|
|
|
2013-09-13 12:46:32 +00:00
|
|
|
KeAcquireSpinLock(&WaitEntry->WaitQueue->WaitLock, &OldIrql);
|
2013-09-13 07:49:42 +00:00
|
|
|
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
Irp = WaitEntry->Irp;
|
For our 60000th commit, I bring you a complete rewrite of the Named Pipe File System. It is not yet "active", but I consider this to now be largely code complete and worthy of the prize (and I didn't want to delay other commiters any further). Once the code is reviewed, fixed, tested, and commented, it will replace our old and aging NPFS. This driver is cross-compatible with Windows Server 2003. It is expected to fix winetest incompatiblities, speed up performance, and reduce bizare RPC/SCM issues. This commit is dedicated to my best friend Rachel, who has not only always been there for me, but was also the motivating factor behind my return to my passion -- ReactOS :)
[NPFS-NEW]: Implement QueryVolume, QuerySecurity, SetSecurity. Everything but Directory Query, Fast I/O, and a few rare FSCTLs is implemented now. The former two will come in an upcoming commit.
[NPFS-NEW]: Major cleanup in the way some member variables were being addressed. Reference them as array members based on the correct FILE_PIPE defines from now on. Also fix a lot of formatting issues. Fix a bunch of bugs that were found. Use FILE_PIPE_SERVER_END and FILE_PIPE_CLIENT_END intead of a BOOLEAN. Use TRUE/FALSE/STATUS_SUCCESS/NULL/etc when needed intead of 0/1. The code formatting can/should still be improved, but this was a big help.
svn path=/trunk/; revision=60000
2013-09-10 08:36:25 +00:00
|
|
|
if (Irp)
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
{
|
|
|
|
RemoveEntryList(&Irp->Tail.Overlay.ListEntry);
|
2013-09-13 07:49:42 +00:00
|
|
|
|
For our 60000th commit, I bring you a complete rewrite of the Named Pipe File System. It is not yet "active", but I consider this to now be largely code complete and worthy of the prize (and I didn't want to delay other commiters any further). Once the code is reviewed, fixed, tested, and commented, it will replace our old and aging NPFS. This driver is cross-compatible with Windows Server 2003. It is expected to fix winetest incompatiblities, speed up performance, and reduce bizare RPC/SCM issues. This commit is dedicated to my best friend Rachel, who has not only always been there for me, but was also the motivating factor behind my return to my passion -- ReactOS :)
[NPFS-NEW]: Implement QueryVolume, QuerySecurity, SetSecurity. Everything but Directory Query, Fast I/O, and a few rare FSCTLs is implemented now. The former two will come in an upcoming commit.
[NPFS-NEW]: Major cleanup in the way some member variables were being addressed. Reference them as array members based on the correct FILE_PIPE defines from now on. Also fix a lot of formatting issues. Fix a bunch of bugs that were found. Use FILE_PIPE_SERVER_END and FILE_PIPE_CLIENT_END intead of a BOOLEAN. Use TRUE/FALSE/STATUS_SUCCESS/NULL/etc when needed intead of 0/1. The code formatting can/should still be improved, but this was a big help.
svn path=/trunk/; revision=60000
2013-09-10 08:36:25 +00:00
|
|
|
if (!IoSetCancelRoutine(Irp, NULL))
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
{
|
|
|
|
Irp->Tail.Overlay.DriverContext[1] = NULL;
|
|
|
|
Irp = NULL;
|
|
|
|
}
|
|
|
|
}
|
2013-09-13 07:49:42 +00:00
|
|
|
|
2013-09-13 12:46:32 +00:00
|
|
|
KeReleaseSpinLock(&WaitEntry->WaitQueue->WaitLock, OldIrql);
|
2013-09-13 07:49:42 +00:00
|
|
|
|
For our 60000th commit, I bring you a complete rewrite of the Named Pipe File System. It is not yet "active", but I consider this to now be largely code complete and worthy of the prize (and I didn't want to delay other commiters any further). Once the code is reviewed, fixed, tested, and commented, it will replace our old and aging NPFS. This driver is cross-compatible with Windows Server 2003. It is expected to fix winetest incompatiblities, speed up performance, and reduce bizare RPC/SCM issues. This commit is dedicated to my best friend Rachel, who has not only always been there for me, but was also the motivating factor behind my return to my passion -- ReactOS :)
[NPFS-NEW]: Implement QueryVolume, QuerySecurity, SetSecurity. Everything but Directory Query, Fast I/O, and a few rare FSCTLs is implemented now. The former two will come in an upcoming commit.
[NPFS-NEW]: Major cleanup in the way some member variables were being addressed. Reference them as array members based on the correct FILE_PIPE defines from now on. Also fix a lot of formatting issues. Fix a bunch of bugs that were found. Use FILE_PIPE_SERVER_END and FILE_PIPE_CLIENT_END intead of a BOOLEAN. Use TRUE/FALSE/STATUS_SUCCESS/NULL/etc when needed intead of 0/1. The code formatting can/should still be improved, but this was a big help.
svn path=/trunk/; revision=60000
2013-09-10 08:36:25 +00:00
|
|
|
if (Irp)
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
{
|
|
|
|
Irp->IoStatus.Status = STATUS_IO_TIMEOUT;
|
For our 60000th commit, I bring you a complete rewrite of the Named Pipe File System. It is not yet "active", but I consider this to now be largely code complete and worthy of the prize (and I didn't want to delay other commiters any further). Once the code is reviewed, fixed, tested, and commented, it will replace our old and aging NPFS. This driver is cross-compatible with Windows Server 2003. It is expected to fix winetest incompatiblities, speed up performance, and reduce bizare RPC/SCM issues. This commit is dedicated to my best friend Rachel, who has not only always been there for me, but was also the motivating factor behind my return to my passion -- ReactOS :)
[NPFS-NEW]: Implement QueryVolume, QuerySecurity, SetSecurity. Everything but Directory Query, Fast I/O, and a few rare FSCTLs is implemented now. The former two will come in an upcoming commit.
[NPFS-NEW]: Major cleanup in the way some member variables were being addressed. Reference them as array members based on the correct FILE_PIPE defines from now on. Also fix a lot of formatting issues. Fix a bunch of bugs that were found. Use FILE_PIPE_SERVER_END and FILE_PIPE_CLIENT_END intead of a BOOLEAN. Use TRUE/FALSE/STATUS_SUCCESS/NULL/etc when needed intead of 0/1. The code formatting can/should still be improved, but this was a big help.
svn path=/trunk/; revision=60000
2013-09-10 08:36:25 +00:00
|
|
|
IoCompleteRequest(Irp, IO_NAMED_PIPE_INCREMENT);
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
}
|
2013-09-13 07:49:42 +00:00
|
|
|
|
|
|
|
ObDereferenceObject(WaitEntry->FileObject);
|
For our 60000th commit, I bring you a complete rewrite of the Named Pipe File System. It is not yet "active", but I consider this to now be largely code complete and worthy of the prize (and I didn't want to delay other commiters any further). Once the code is reviewed, fixed, tested, and commented, it will replace our old and aging NPFS. This driver is cross-compatible with Windows Server 2003. It is expected to fix winetest incompatiblities, speed up performance, and reduce bizare RPC/SCM issues. This commit is dedicated to my best friend Rachel, who has not only always been there for me, but was also the motivating factor behind my return to my passion -- ReactOS :)
[NPFS-NEW]: Implement QueryVolume, QuerySecurity, SetSecurity. Everything but Directory Query, Fast I/O, and a few rare FSCTLs is implemented now. The former two will come in an upcoming commit.
[NPFS-NEW]: Major cleanup in the way some member variables were being addressed. Reference them as array members based on the correct FILE_PIPE defines from now on. Also fix a lot of formatting issues. Fix a bunch of bugs that were found. Use FILE_PIPE_SERVER_END and FILE_PIPE_CLIENT_END intead of a BOOLEAN. Use TRUE/FALSE/STATUS_SUCCESS/NULL/etc when needed intead of 0/1. The code formatting can/should still be improved, but this was a big help.
svn path=/trunk/; revision=60000
2013-09-10 08:36:25 +00:00
|
|
|
ExFreePool(WaitEntry);
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
}
|
|
|
|
|
2013-09-07 15:32:29 +00:00
|
|
|
VOID
|
|
|
|
NTAPI
|
|
|
|
NpInitializeWaitQueue(IN PNP_WAIT_QUEUE WaitQueue)
|
|
|
|
{
|
|
|
|
InitializeListHead(&WaitQueue->WaitList);
|
|
|
|
KeInitializeSpinLock(&WaitQueue->WaitLock);
|
|
|
|
}
|
|
|
|
|
2014-10-16 16:40:13 +00:00
|
|
|
static
|
|
|
|
BOOLEAN
|
|
|
|
NpEqualUnicodeString(IN PCUNICODE_STRING String1,
|
|
|
|
IN PCUNICODE_STRING String2)
|
|
|
|
{
|
|
|
|
SIZE_T EqualLength;
|
|
|
|
|
|
|
|
if (String1->Length != String2->Length)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
EqualLength = RtlCompareMemory(String1->Buffer,
|
|
|
|
String2->Buffer,
|
|
|
|
String1->Length);
|
|
|
|
return EqualLength == String1->Length;
|
|
|
|
}
|
|
|
|
|
2013-09-07 15:32:29 +00:00
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
NpCancelWaiter(IN PNP_WAIT_QUEUE WaitQueue,
|
2014-08-14 19:35:00 +00:00
|
|
|
IN PUNICODE_STRING PipePath,
|
2013-09-07 15:32:29 +00:00
|
|
|
IN NTSTATUS Status,
|
2013-09-13 07:49:42 +00:00
|
|
|
IN PLIST_ENTRY List)
|
2013-09-07 15:32:29 +00:00
|
|
|
{
|
2014-08-14 19:35:00 +00:00
|
|
|
UNICODE_STRING PipePathUpper;
|
2013-09-07 15:32:29 +00:00
|
|
|
KIRQL OldIrql;
|
|
|
|
PWCHAR Buffer;
|
2013-09-13 07:49:42 +00:00
|
|
|
PLIST_ENTRY NextEntry;
|
|
|
|
PNP_WAIT_QUEUE_ENTRY WaitEntry, Linkage;
|
|
|
|
PIRP WaitIrp;
|
|
|
|
PFILE_PIPE_WAIT_FOR_BUFFER WaitBuffer;
|
2014-08-14 19:35:00 +00:00
|
|
|
UNICODE_STRING WaitName, PipeName;
|
2013-09-07 15:32:29 +00:00
|
|
|
|
2013-09-13 07:49:42 +00:00
|
|
|
Linkage = NULL;
|
|
|
|
|
|
|
|
Buffer = ExAllocatePoolWithTag(NonPagedPool,
|
2014-08-14 19:35:00 +00:00
|
|
|
PipePath->Length,
|
2013-09-13 07:49:42 +00:00
|
|
|
NPFS_WAIT_BLOCK_TAG);
|
2013-09-07 15:32:29 +00:00
|
|
|
if (!Buffer) return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
|
2014-08-14 19:35:00 +00:00
|
|
|
RtlInitEmptyUnicodeString(&PipePathUpper, Buffer, PipePath->Length);
|
|
|
|
RtlUpcaseUnicodeString(&PipePathUpper, PipePath, FALSE);
|
2013-09-07 15:32:29 +00:00
|
|
|
|
2013-09-13 12:46:32 +00:00
|
|
|
KeAcquireSpinLock(&WaitQueue->WaitLock, &OldIrql);
|
2013-09-07 15:32:29 +00:00
|
|
|
|
2014-08-14 19:35:00 +00:00
|
|
|
NextEntry = WaitQueue->WaitList.Flink;
|
|
|
|
while (NextEntry != &WaitQueue->WaitList)
|
2013-09-13 07:49:42 +00:00
|
|
|
{
|
|
|
|
WaitIrp = CONTAINING_RECORD(NextEntry, IRP, Tail.Overlay.ListEntry);
|
2014-08-14 19:35:00 +00:00
|
|
|
NextEntry = NextEntry->Flink;
|
2013-09-13 07:49:42 +00:00
|
|
|
WaitEntry = WaitIrp->Tail.Overlay.DriverContext[1];
|
|
|
|
|
|
|
|
if (WaitEntry->AliasName.Length)
|
|
|
|
{
|
|
|
|
ASSERT(FALSE);
|
2014-08-14 19:35:00 +00:00
|
|
|
/* We have an alias. Use that for comparison */
|
|
|
|
WaitName = WaitEntry->AliasName;
|
|
|
|
PipeName = PipePathUpper;
|
2013-09-13 07:49:42 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-08-14 19:35:00 +00:00
|
|
|
/* Use the name from the wait buffer to compare */
|
2013-09-13 07:49:42 +00:00
|
|
|
WaitBuffer = WaitIrp->AssociatedIrp.SystemBuffer;
|
2014-08-14 19:35:00 +00:00
|
|
|
WaitName.Buffer = WaitBuffer->Name;
|
|
|
|
WaitName.Length = WaitBuffer->NameLength;
|
|
|
|
WaitName.MaximumLength = WaitName.Length;
|
|
|
|
|
|
|
|
/* WaitName doesn't have a leading backslash,
|
|
|
|
* so skip the one in PipePathUpper for the comparison */
|
|
|
|
PipeName.Buffer = PipePathUpper.Buffer + 1;
|
|
|
|
PipeName.Length = PipePathUpper.Length - sizeof(WCHAR);
|
|
|
|
PipeName.MaximumLength = PipeName.Length;
|
|
|
|
}
|
2013-09-13 07:49:42 +00:00
|
|
|
|
2014-10-16 16:40:13 +00:00
|
|
|
/* Can't use RtlEqualUnicodeString with a spinlock held */
|
|
|
|
if (NpEqualUnicodeString(&WaitName, &PipeName))
|
2014-08-14 19:35:00 +00:00
|
|
|
{
|
|
|
|
/* Found a matching wait. Cancel it */
|
|
|
|
RemoveEntryList(&WaitIrp->Tail.Overlay.ListEntry);
|
|
|
|
if (KeCancelTimer(&WaitEntry->Timer))
|
|
|
|
{
|
|
|
|
WaitEntry->WaitQueue = (PNP_WAIT_QUEUE)Linkage;
|
|
|
|
Linkage = WaitEntry;
|
|
|
|
}
|
|
|
|
else
|
2013-09-13 07:49:42 +00:00
|
|
|
{
|
2014-08-14 19:35:00 +00:00
|
|
|
WaitEntry->Irp = NULL;
|
|
|
|
WaitIrp->Tail.Overlay.DriverContext[1] = NULL;
|
|
|
|
}
|
2013-09-13 07:49:42 +00:00
|
|
|
|
2014-08-14 19:35:00 +00:00
|
|
|
if (IoSetCancelRoutine(WaitIrp, NULL))
|
|
|
|
{
|
|
|
|
WaitIrp->IoStatus.Information = 0;
|
|
|
|
WaitIrp->IoStatus.Status = Status;
|
|
|
|
InsertTailList(List, &WaitIrp->Tail.Overlay.ListEntry);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WaitIrp->Tail.Overlay.DriverContext[1] = NULL;
|
2013-09-13 07:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-09-07 15:32:29 +00:00
|
|
|
|
2013-09-13 12:46:32 +00:00
|
|
|
KeReleaseSpinLock(&WaitQueue->WaitLock, OldIrql);
|
2013-09-13 07:49:42 +00:00
|
|
|
|
2014-08-14 19:35:00 +00:00
|
|
|
ExFreePoolWithTag(Buffer, NPFS_WAIT_BLOCK_TAG);
|
2013-09-13 07:49:42 +00:00
|
|
|
|
|
|
|
while (Linkage)
|
|
|
|
{
|
|
|
|
WaitEntry = Linkage;
|
|
|
|
Linkage = (PNP_WAIT_QUEUE_ENTRY)Linkage->WaitQueue;
|
|
|
|
ObDereferenceObject(WaitEntry->FileObject);
|
|
|
|
ExFreePool(WaitEntry);
|
|
|
|
}
|
|
|
|
|
2013-09-07 15:32:29 +00:00
|
|
|
return STATUS_SUCCESS;
|
|
|
|
}
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
|
|
|
NTSTATUS
|
|
|
|
NTAPI
|
|
|
|
NpAddWaiter(IN PNP_WAIT_QUEUE WaitQueue,
|
|
|
|
IN LARGE_INTEGER WaitTime,
|
2013-09-13 07:49:42 +00:00
|
|
|
IN PIRP Irp,
|
|
|
|
IN PUNICODE_STRING AliasName)
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
{
|
|
|
|
PIO_STACK_LOCATION IoStack;
|
|
|
|
KIRQL OldIrql;
|
|
|
|
NTSTATUS Status;
|
|
|
|
PNP_WAIT_QUEUE_ENTRY WaitEntry;
|
|
|
|
PFILE_PIPE_WAIT_FOR_BUFFER WaitBuffer;
|
|
|
|
LARGE_INTEGER DueTime;
|
|
|
|
ULONG i;
|
|
|
|
|
|
|
|
IoStack = IoGetCurrentIrpStackLocation(Irp);
|
|
|
|
|
2013-09-16 17:37:47 +00:00
|
|
|
WaitEntry = ExAllocatePoolWithQuotaTag(NonPagedPool | POOL_QUOTA_FAIL_INSTEAD_OF_RAISE,
|
2013-09-13 07:49:42 +00:00
|
|
|
sizeof(*WaitEntry),
|
|
|
|
NPFS_WRITE_BLOCK_TAG);
|
|
|
|
if (!WaitEntry)
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
{
|
2013-09-13 07:49:42 +00:00
|
|
|
return STATUS_INSUFFICIENT_RESOURCES;
|
|
|
|
}
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2013-09-13 07:49:42 +00:00
|
|
|
KeInitializeDpc(&WaitEntry->Dpc, NpTimerDispatch, WaitEntry);
|
|
|
|
KeInitializeTimer(&WaitEntry->Timer);
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2013-09-13 07:49:42 +00:00
|
|
|
if (AliasName)
|
|
|
|
{
|
|
|
|
WaitEntry->AliasName = *AliasName;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WaitEntry->AliasName.Length = 0;
|
|
|
|
WaitEntry->AliasName.Buffer = NULL;
|
|
|
|
}
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2013-09-13 07:49:42 +00:00
|
|
|
WaitEntry->WaitQueue = WaitQueue;
|
|
|
|
WaitEntry->Irp = Irp;
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2014-08-07 10:24:07 +00:00
|
|
|
WaitBuffer = Irp->AssociatedIrp.SystemBuffer;
|
2013-09-13 07:49:42 +00:00
|
|
|
if (WaitBuffer->TimeoutSpecified)
|
|
|
|
{
|
|
|
|
DueTime = WaitBuffer->Timeout;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
DueTime = WaitTime;
|
|
|
|
}
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2013-09-13 07:49:42 +00:00
|
|
|
for (i = 0; i < WaitBuffer->NameLength / sizeof(WCHAR); i++)
|
|
|
|
{
|
|
|
|
WaitBuffer->Name[i] = RtlUpcaseUnicodeChar(WaitBuffer->Name[i]);
|
|
|
|
}
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2013-09-13 07:49:42 +00:00
|
|
|
Irp->Tail.Overlay.DriverContext[0] = WaitQueue;
|
|
|
|
Irp->Tail.Overlay.DriverContext[1] = WaitEntry;
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2013-09-13 12:46:32 +00:00
|
|
|
KeAcquireSpinLock(&WaitQueue->WaitLock, &OldIrql);
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2013-09-13 07:49:42 +00:00
|
|
|
IoSetCancelRoutine(Irp, NpCancelWaitQueueIrp);
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
|
2013-09-13 07:49:42 +00:00
|
|
|
if (Irp->Cancel && IoSetCancelRoutine(Irp, NULL))
|
|
|
|
{
|
|
|
|
Status = STATUS_CANCELLED;
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-09-13 07:49:42 +00:00
|
|
|
InsertTailList(&WaitQueue->WaitList, &Irp->Tail.Overlay.ListEntry);
|
|
|
|
|
|
|
|
IoMarkIrpPending(Irp);
|
|
|
|
Status = STATUS_PENDING;
|
|
|
|
|
|
|
|
WaitEntry->FileObject = IoStack->FileObject;
|
|
|
|
ObReferenceObject(WaitEntry->FileObject);
|
|
|
|
|
|
|
|
KeSetTimer(&WaitEntry->Timer, DueTime, &WaitEntry->Dpc);
|
|
|
|
WaitEntry = NULL;
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
}
|
2013-09-13 07:49:42 +00:00
|
|
|
|
2013-09-13 12:46:32 +00:00
|
|
|
KeReleaseSpinLock(&WaitQueue->WaitLock, OldIrql);
|
2013-09-13 07:49:42 +00:00
|
|
|
if (WaitEntry) ExFreePool(WaitEntry);
|
|
|
|
|
[NPFS-NEW]: Implement Close, Cleanup, Disconnect, Flush, Listen, Peek, SetInfo, Transceive, Wait, Write. Only QueryInfo remains as critical functionality to support the Kernel32 APIs. Code is WIP, untested, and ugly! But it is now 90% complete. r60000 should hopefully finalize the implementation. As long as I didn't forget a file :)
svn path=/trunk/; revision=59999
2013-09-10 02:23:32 +00:00
|
|
|
return Status;
|
|
|
|
}
|
2013-09-11 23:19:20 +00:00
|
|
|
|
|
|
|
/* EOF */
|