16#define LEVEL_1_OPLOCK 0x2
17#define BATCH_OPLOCK 0x4
18#define FILTER_OPLOCK 0x8
19#define LEVEL_2_OPLOCK 0x10
21#define EXCLUSIVE_LOCK 0x40
22#define PENDING_LOCK 0x80
24#define BROKEN_TO_LEVEL_2 0x100
25#define BROKEN_TO_NONE 0x200
26#define BROKEN_TO_NONE_FROM_LEVEL_2 0x400
27#define BROKEN_TO_CLOSE_PENDING 0x800
28#define BROKEN_ANY (BROKEN_TO_LEVEL_2 | BROKEN_TO_NONE | BROKEN_TO_NONE_FROM_LEVEL_2 | BROKEN_TO_CLOSE_PENDING)
90 DPRINT(
"FsRtlRemoveAndCompleteWaitIrp(%p)\n", WaitCtx);
101 Irp->IoStatus.Information = WaitCtx->SavedInformation;
106 WaitCtx->CompletionRoutine(WaitCtx->CompletionContext,
Irp);
135 NextEntry = NextEntry->
Flink)
139 if (WaitCtx->
Irp->Cancel)
158 DPRINT(
"FsRtlWaitOnIrp(%p, %p, %p, %p, %p, %p)\n", Oplock,
Irp,
CompletionContext,
CompletionRoutine,
PostIrpRoutine, WaitEvent);
245 DPRINT(
"FsRtlOplockBreakNotify(%p, %p, %p)\n", Oplock,
Stack,
Irp);
268 Oplock->FileObject =
NULL;
287 DPRINT(
"FsRtlRemoveAndCompleteIrp(%p)\n",
Irp);
334 NextEntry = NextEntry->
Flink)
380 if (Oplock->FileObject !=
Stack->FileObject)
444 for (NextEntry = Oplock->WaitListHead.
Flink;
445 NextEntry != &Oplock->WaitListHead;
446 NextEntry = NextEntry->
Flink)
458 Oplock->FileObject =
NULL;
480 DPRINT(
"FsRtlOpBatchBreakClosePending(%p, %p, %p)\n", Oplock,
Stack,
Irp);
509 Oplock->FileObject =
NULL;
512 for (NextEntry = Oplock->WaitListHead.
Flink;
513 NextEntry != &Oplock->WaitListHead;
514 NextEntry = NextEntry->
Flink)
548 DPRINT(
"FsRtlAllocateOplock()\n");
618 NextEntry = NextEntry->
Flink)
650 if (IntOplock ==
NULL)
751 if (IntOplock ==
NULL)
824 DPRINT(
"FsRtlOplockCleanup(%p, %p)\n", Oplock,
Stack);
834 for (NextEntry = Oplock->SharedListHead.
Flink;
835 NextEntry != &Oplock->SharedListHead;
836 NextEntry = NextEntry->
Flink)
856 if (Oplock->FileObject ==
Stack->FileObject)
872 Oplock->ExclusiveIrp =
NULL;
882 Oplock->FileObject =
NULL;
886 for (NextEntry = Oplock->WaitListHead.
Flink;
887 NextEntry != &Oplock->WaitListHead;
888 NextEntry = NextEntry->
Flink)
913 DPRINT(
"FsRtlOplockBreakToNone(%p, %p, %p, %p, %p, %p)\n", Oplock,
Stack,
Irp,
Context,
CompletionRoutine,
PostIrpRoutine);
935 if (Oplock->ExclusiveIrp->Cancel)
944 Oplock->ExclusiveIrp =
NULL;
948 Oplock->FileObject =
NULL;
951 for (NextEntry = Oplock->WaitListHead.
Flink;
952 NextEntry != &Oplock->WaitListHead;
953 NextEntry = NextEntry->
Flink)
971 Oplock->ExclusiveIrp =
NULL;
978 for (NextEntry = Oplock->SharedListHead.
Flink;
979 NextEntry != &Oplock->SharedListHead;
980 NextEntry = NextEntry->
Flink)
1003 Oplock->FileObject =
NULL;
1010 if (Oplock->FileObject ==
Stack->FileObject)
1046 DPRINT(
"FsRtlOplockBreakToII(%p, %p, %p, %p, %p, %p)\n", Oplock,
Stack,
Irp,
Context,
CompletionRoutine,
PostIrpRoutine);
1064 Oplock->FileObject =
NULL;
1080 if (Oplock->ExclusiveIrp->Cancel)
1089 Oplock->ExclusiveIrp =
NULL;
1091 Oplock->FileObject =
NULL;
1094 for (NextEntry = Oplock->WaitListHead.
Flink;
1095 NextEntry != &Oplock->WaitListHead;
1096 NextEntry = NextEntry->
Flink)
1121 Oplock->ExclusiveIrp =
NULL;
1182#define BreakToIIIfRequired \
1183 if (IntOplock->Flags != LEVEL_2_OPLOCK || IntOplock->FileObject != Stack->FileObject) \
1184 return FsRtlOplockBreakToII(IntOplock, Stack, Irp, Context, CompletionRoutine, PostIrpRoutine)
1186#define BreakToNoneIfRequired \
1187 if (IntOplock->Flags == LEVEL_2_OPLOCK || IntOplock->FileObject != Stack->FileObject) \
1188 return FsRtlOplockBreakToNone(IntOplock, Stack, Irp, Context, CompletionRoutine, PostIrpRoutine)
1192 IntOplock = *Oplock;
1195 if (IntOplock ==
NULL)
1330 if (
Stack->Parameters.SetFile.AdvanceOnly)
1342#undef BreakToIIIfRequired
1343#undef BreakToNoneIfRequired
1370 DPRINT(
"FsRtlCurrentBatchOplock(%p)\n", Oplock);
1372 IntOplock = *Oplock;
1375 if (IntOplock !=
NULL &&
1405 DPRINT(
"FsRtlInitializeOplock(%p)\n", Oplock);
1441 IntOplock = *Oplock;
1446 switch (
Stack->Parameters.FileSystemControl.FsControlCode)
1570 DPRINT(
"FsRtlOplockIsFastIoPossible(%p)\n", Oplock);
1572 IntOplock = *Oplock;
1575 if (IntOplock !=
NULL &&
1608 DPRINT(
"FsRtlUninitializeOplock(%p)\n", Oplock);
1610 IntOplock = *Oplock;
1613 if (IntOplock ==
NULL)
1628 NextEntry = NextEntry->
Flink)
1640 Irp->IoStatus.Information = 0;
1649 NextEntry = NextEntry->
Flink)
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define FILE_COMPLETE_IF_OPLOCKED
#define RemoveEntryList(Entry)
#define InsertTailList(ListHead, Entry)
#define InsertHeadList(ListHead, Entry)
#define ExAllocatePoolWithTag(hernya, size, tag)
#define IsListEmpty(ListHead)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeSetEvent(pEvt, foo, foo2)
#define InitializeListHead(ListHead)
#define ClearFlag(_F, _SF)
#define BooleanFlagOn(F, SF)
@ FileEndOfFileInformation
@ FileAllocationInformation
@ FileShortNameInformation
enum _FILE_INFORMATION_CLASS FILE_INFORMATION_CLASS
#define FILE_OVERWRITE_IF
#define FILE_RESERVE_OPFILTER
_In_ PIRP _In_opt_ PVOID _In_opt_ POPLOCK_WAIT_COMPLETE_ROUTINE _In_opt_ POPLOCK_FS_PREPOST_IRP PostIrpRoutine
VOID(NTAPI * POPLOCK_FS_PREPOST_IRP)(_In_ PVOID Context, _In_ PIRP Irp)
VOID(NTAPI * POPLOCK_WAIT_COMPLETE_ROUTINE)(_In_ PVOID Context, _In_ PIRP Irp)
VOID FASTCALL ExAcquireFastMutex(IN PFAST_MUTEX FastMutex)
VOID FASTCALL ExReleaseFastMutex(IN PFAST_MUTEX FastMutex)
#define KeGetCurrentThread
IoSetCancelRoutine(Irp, CancelRoutine)
#define ExFreePoolWithTag(_P, _T)
_In_ PMEMORY_AREA _In_ PVOID _In_ BOOLEAN Locked
#define FSCTL_OPLOCK_BREAK_NOTIFY
#define FSCTL_OPLOCK_BREAK_ACKNOWLEDGE
#define FSCTL_REQUEST_OPLOCK_LEVEL_1
#define FILE_READ_ATTRIBUTES
#define FSCTL_REQUEST_FILTER_OPLOCK
#define FILE_SHARE_VALID_FLAGS
#define FILE_WRITE_ATTRIBUTES
#define FSCTL_REQUEST_BATCH_OPLOCK
#define FSCTL_OPBATCH_ACK_CLOSE_PENDING
#define FSCTL_OPLOCK_BREAK_ACK_NO_2
#define FSCTL_REQUEST_OPLOCK_LEVEL_2
VOID FASTCALL ExReleaseFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
VOID FASTCALL ExAcquireFastMutexUnsafe(IN OUT PFAST_MUTEX FastMutex)
VOID FASTCALL IofCompleteRequest(IN PIRP Irp, IN CCHAR PriorityBoost)
#define IoCompleteRequest
BOOLEAN NTAPI IoIsOperationSynchronous(IN PIRP Irp)
VOID NTAPI IoReleaseCancelSpinLock(IN KIRQL Irql)
VOID NTAPI IoAcquireCancelSpinLock(OUT PKIRQL Irql)
#define STATUS_OPLOCK_BREAK_IN_PROGRESS
#define STATUS_INVALID_OPLOCK_PROTOCOL
#define STATUS_OPLOCK_NOT_GRANTED
BOOLEAN NTAPI FsRtlCurrentBatchOplock(IN POPLOCK Oplock)
VOID FsRtlOplockCleanup(IN PINTERNAL_OPLOCK Oplock, IN PIO_STACK_LOCATION Stack)
NTSTATUS NTAPI FsRtlOplockBreakToNone(IN PINTERNAL_OPLOCK Oplock, IN PIO_STACK_LOCATION Stack, IN PIRP Irp, IN PVOID Context, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
NTSTATUS NTAPI FsRtlOplockFsctrl(IN POPLOCK Oplock, IN PIRP Irp, IN ULONG OpenCount)
NTSTATUS FsRtlOpBatchBreakClosePending(IN PINTERNAL_OPLOCK Oplock, IN PIO_STACK_LOCATION Stack, IN PIRP Irp)
VOID FsRtlWaitOnIrp(IN PINTERNAL_OPLOCK Oplock, IN PIRP Irp, IN PVOID CompletionContext, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine, IN PKEVENT WaitEvent)
VOID FsRtlRemoveAndCompleteIrp(IN PIRP Irp)
struct _INTERNAL_OPLOCK * PINTERNAL_OPLOCK
BOOLEAN NTAPI FsRtlOplockIsFastIoPossible(IN POPLOCK Oplock)
VOID NTAPI FsRtlUninitializeOplock(IN POPLOCK Oplock)
NTSTATUS FsRtlOplockBreakNotify(IN PINTERNAL_OPLOCK Oplock, IN PIO_STACK_LOCATION Stack, IN PIRP Irp)
#define BROKEN_TO_NONE_FROM_LEVEL_2
#define BreakToNoneIfRequired
VOID NTAPI FsRtlCancelWaitIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
#define BROKEN_TO_LEVEL_2
NTSTATUS FsRtlAcknowledgeOplockBreak(IN PINTERNAL_OPLOCK Oplock, IN PIO_STACK_LOCATION Stack, IN PIRP Irp, IN BOOLEAN SwitchToLevel2)
VOID NTAPI FsRtlCompletionRoutinePriv(IN PVOID Context, IN PIRP Irp)
struct _INTERNAL_OPLOCK INTERNAL_OPLOCK
VOID FsRtlRemoveAndCompleteWaitIrp(IN PWAIT_CONTEXT WaitCtx)
#define BreakToIIIfRequired
VOID NTAPI FsRtlCancelExclusiveIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS NTAPI FsRtlCheckOplock(IN POPLOCK Oplock, IN PIRP Irp, IN PVOID Context, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
NTSTATUS NTAPI FsRtlOplockBreakToII(IN PINTERNAL_OPLOCK Oplock, IN PIO_STACK_LOCATION Stack, IN PIRP Irp, IN PVOID Context, IN POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine OPTIONAL, IN POPLOCK_FS_PREPOST_IRP PostIrpRoutine OPTIONAL)
#define BROKEN_TO_CLOSE_PENDING
NTSTATUS FsRtlRequestExclusiveOplock(IN POPLOCK Oplock, IN PIO_STACK_LOCATION Stack, IN PIRP Irp, IN ULONG Flags)
VOID NTAPI FsRtlNotifyCompletion(IN PVOID Context, IN PIRP Irp)
VOID NTAPI FsRtlCancelOplockIIIrp(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
PINTERNAL_OPLOCK FsRtlAllocateOplock(VOID)
struct _WAIT_CONTEXT * PWAIT_CONTEXT
NTSTATUS FsRtlRequestOplockII(IN POPLOCK Oplock, IN PIO_STACK_LOCATION Stack, IN PIRP Irp)
VOID NTAPI FsRtlInitializeOplock(IN OUT POPLOCK Oplock)
struct _WAIT_CONTEXT WAIT_CONTEXT
#define _SEH2_AbnormalTermination()
#define IRP_MJ_LOCK_CONTROL
#define IRP_MJ_SET_INFORMATION
#define FSCTL_SET_ZERO_DATA
PULONG MinorVersion OPTIONAL
LIST_ENTRY SharedListHead
struct _LIST_ENTRY * Blink
struct _LIST_ENTRY * Flink
POPLOCK_WAIT_COMPLETE_ROUTINE CompletionRoutine
ULONG_PTR SavedInformation
#define RtlZeroMemory(Destination, Length)
#define CONTAINING_RECORD(address, type, field)
#define STATUS_INVALID_PARAMETER
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ WDFDEVICE _In_ ULONG _In_ ACCESS_MASK DesiredAccess
_Must_inspect_result_ _In_opt_ WDFKEY _In_ PCUNICODE_STRING _In_ ACCESS_MASK _In_ ULONG _Out_opt_ PULONG CreateDisposition
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE _In_opt_ __drv_aliasesMem WDFCONTEXT CompletionContext
_In_ WDFREQUEST _In_ PIO_STACK_LOCATION Stack
_In_ WDFREQUEST _In_opt_ PFN_WDF_REQUEST_COMPLETION_ROUTINE CompletionRoutine
_Must_inspect_result_ _In_ ULONG Flags
FORCEINLINE VOID ExInitializeFastMutex(_Out_ PFAST_MUTEX FastMutex)
#define IRP_MJ_FILE_SYSTEM_CONTROL
#define POOL_COLD_ALLOCATION
#define FO_CLEANUP_COMPLETE
#define IRP_MJ_FLUSH_BUFFERS
#define IO_DISK_INCREMENT
#define IRP_SYNCHRONOUS_PAGING_IO
#define FILE_OPLOCK_BROKEN_TO_LEVEL_2
#define POOL_RAISE_IF_ALLOCATION_FAILURE
#define FILE_OPLOCK_BROKEN_TO_NONE
#define ObDereferenceObject
#define ObReferenceObject