24#define CLASS_INIT_GUID 0
47#pragma alloc_text(PAGE, ClassCreateClose)
48#pragma alloc_text(PAGE, ClasspCreateClose)
49#pragma alloc_text(PAGE, ClasspCleanupProtectedLocks)
50#pragma alloc_text(PAGE, ClasspEjectionControl)
51#pragma alloc_text(PAGE, ClasspCleanupDisableMcn)
52#pragma alloc_text(PAGE, ClassGetFsContext)
172 "ClasspCREATEClose: create received for device %p\n",
175 "ClasspCREATEClose: desired access %lx\n",
178 "ClasspCREATEClose: file object %p\n",
196 (
PVOID *)&fsContext);
213 "ClasspCreateCLOSE: close received for device %p\n",
216 "ClasspCreateCLOSE: file object %p\n",
222 ClassGetFsContext(commonExtension, irpStack->
FileObject);
225 "ClasspCreateCLOSE: file extension %p\n",
228 if(fsContext !=
NULL) {
231 "ClasspCreateCLOSE: extension is ours - "
251 "ClasspCreateClose: %s for devobj %p\n",
283 "ClasspCreateClose: Lower driver failed, but we "
284 "succeeded. This is a problem, lock counts will be "
285 "out of sync between levels.\n"));
301 FsContext->DeviceObject->DeviceExtension;
306 ULONG newDeviceLockCount = 1;
311 "ClasspCleanupProtectedLocks called for %p\n",
314 "ClasspCleanupProtectedLocks - FsContext %p is locked "
352 "ClasspCleanupProtectedLocks: FDO secured lock count = %d "
357 if ((newDeviceLockCount == 0) && (fdoExtension->
LockCount == 0)) {
367 "ClasspCleanupProtectedLocks: FDO lock count dropped "
372 #pragma prefast(suppress:26015, "InitializeStorageRequestBlock ensures buffer access is bounded")
420 "ClasspCleanupProtectedLocks: unlock request to drive "
421 "returned status %lx\n",
status));
439 FsContext->DeviceObject->DeviceExtension;
447 "ClasspCleanupDisableMcn called for %p\n",
450 "ClasspCleanupDisableMcn - FsContext %p is disabled "
460 ClassEnableMediaChangeDetection(fdoExtension);
507 "ClasspEjectionControl: "
508 "Received request for %s lock type\n",
529 if (fileObject !=
NULL) {
530 fsContext = ClassGetFsContext(commonExtension, fileObject);
533 if (fsContext ==
NULL) {
693 "ClasspEjectionControl: FAILED status %x -- "
694 "reverting lock counts\n",
status));
751 "ClasspEjectionControl: Succeeded\n"));
756 "ClasspEjectionControl: "
757 "Current Counts: Internal: %x Secure: %x Simple: %x\n",
822 fsContext = ClassGetFsContext(commonExt, thisSp->
FileObject);
830 fileHandleOk =
FALSE;
static PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(PIRP Irp)
#define InterlockedDecrement
#define TEST_FLAG(Flags, Bit)
_In_ WDFREQUEST _In_ MEDIA_LOCK_TYPE LockType
#define SCSIOP_MEDIUM_REMOVAL
NTSTATUS InitializeStorageRequestBlock(_Inout_bytecount_(ByteSize) PSTORAGE_REQUEST_BLOCK Srb, _In_ USHORT AddressType, _In_ ULONG ByteSize, _In_ ULONG NumSrbExData,...)
VOID FreeDictionaryEntry(IN PDICTIONARY Dictionary, IN PVOID Entry)
PTRANSFER_PACKET DequeueFreeTransferPacket(PDEVICE_OBJECT Fdo, BOOLEAN AllocIfNeeded)
NTSTATUS AllocateDictionaryEntry(IN PDICTIONARY Dictionary, IN ULONGLONG Key, IN ULONG Size, IN ULONG Tag, OUT PVOID *Entry)
NTSTATUS SubmitTransferPacket(PTRANSFER_PACKET Pkt)
VOID ClassFreeOrReuseSrb(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN __drv_freesMem(mem) PSCSI_REQUEST_BLOCK Srb)
VOID SetupEjectionTransferPacket(TRANSFER_PACKET *Pkt, BOOLEAN PreventMediaRemoval, PKEVENT SyncEventPtr, PIRP OriginalIrp)
PVOID GetDictionaryEntry(IN PDICTIONARY Dictionary, IN ULONGLONG Key)
IO_COMPLETION_ROUTINE ClassSignalCompletion
#define CLASS_TAG_FILE_OBJECT_EXTENSION
#define ClassAcquireRemoveLock(devobj, tag)
#define ClasspAllocateSrb(ext)
#define CLASS_SRBEX_SCSI_CDB16_BUFFER_SIZE
#define IS_CLEANUP_REQUEST(majorFunction)
#define NT_SUCCESS(StatCode)
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
NTSTATUS NTAPI ClassSendSrbSynchronous(_In_ PDEVICE_OBJECT Fdo, _Inout_ PSCSI_REQUEST_BLOCK _Srb, _In_reads_bytes_opt_(BufferLength) PVOID BufferAddress, _In_ ULONG BufferLength, _In_ BOOLEAN WriteToDevice)
VOID ClasspCleanupDisableMcn(IN PFILE_OBJECT_EXTENSION FsContext)
NTSTATUS NTAPI ClassCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
VOID ClasspCleanupProtectedLocks(IN PFILE_OBJECT_EXTENSION FsContext)
NTSTATUS ClasspCreateClose(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
NTSTATUS ClasspEjectionControl(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN MEDIA_LOCK_TYPE LockType, IN BOOLEAN Lock)
const PCSZ LockTypeStrings[]
VOID NTAPI ClassCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _In_ PIRP Irp, _In_ CCHAR PriorityBoost)
VOID NTAPI ClassReleaseRemoveLock(_In_ PDEVICE_OBJECT DeviceObject, _In_opt_ PIRP Tag)
struct _SCSI_REQUEST_BLOCK * PSCSI_REQUEST_BLOCK
#define _IRQL_requires_max_(irql)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define KeSetEvent(pEvt, foo, foo2)
_Inout_ PLIST_ENTRY _In_ PVOID FsContext
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
#define KeLeaveCriticalRegion()
#define KeEnterCriticalRegion()
#define FILE_REMOVABLE_MEDIA
#define IoCopyCurrentIrpStackLocationToNext(Irp)
#define STATUS_INTERNAL_ERROR
#define STATUS_DEVICE_DOES_NOT_EXIST
#define SRB_TYPE_STORAGE_REQUEST_BLOCK
#define STORAGE_ADDRESS_TYPE_BTL8
FORCEINLINE VOID SrbSetCdbLength(_In_ PVOID Srb, _In_ UCHAR CdbLength)
FORCEINLINE VOID SrbSetTimeOutValue(_In_ PVOID Srb, _In_ ULONG TimeOutValue)
#define TRACE_LEVEL_ERROR
#define TRACE_LEVEL_INFORMATION
PCLASS_CREATE_CLOSE ClassCreateClose
DICTIONARY FileObjectDictionary
PDEVICE_OBJECT LowerDeviceObject
struct _FUNCTIONAL_DEVICE_EXTENSION * PartitionZeroExtension
PDEVICE_OBJECT DeviceObject
PDEVICE_OBJECT DeviceObject
KEVENT EjectSynchronizationEvent
PSTORAGE_ADAPTER_DESCRIPTOR AdapterDescriptor
ACCESS_MASK DesiredAccess
struct _IO_STACK_LOCATION::@3974::@3975 Create
union _IO_STACK_LOCATION::@1575 Parameters
#define RtlZeroMemory(Destination, Length)
#define STATUS_INVALID_PARAMETER
#define STATUS_OBJECT_NAME_COLLISION
#define STATUS_INVALID_DEVICE_STATE
#define STATUS_INSUFFICIENT_RESOURCES
struct _CDB::_MEDIA_REMOVAL MEDIA_REMOVAL
_In_ PDEVICE_OBJECT DeviceObject
_In_ WDFREQUEST _In_ WDFFILEOBJECT FileObject
_Must_inspect_result_ _In_ WDFDEVICE Fdo
_Must_inspect_result_ _In_opt_ PWDF_OBJECT_ATTRIBUTES _Out_ WDFWAITLOCK * Lock