ReactOS  0.4.14-dev-599-g2d4d3f5
classp.h File Reference
#include <ntddk.h>
#include <classpnp.h>
#include <ioevent.h>
#include <pseh/pseh2.h>
#include "debug.h"
Include dependency graph for classp.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _MEDIA_CHANGE_DETECTION_INFO
 
struct  _FAILURE_PREDICTION_INFO
 
struct  _CLASS_RETRY_INFO
 
struct  _CSCAN_LIST
 
struct  _CLASS_ERROR_LOG_DATA
 
struct  _TRANSFER_PACKET
 
struct  _CLASS_PRIVATE_FDO_DATA
 

Macros

#define CLASSP_REG_SUBKEY_NAME   (L"Classpnp")
 
#define CLASSP_REG_HACK_VALUE_NAME   (L"HackMask")
 
#define CLASSP_REG_MMC_DETECTION_VALUE_NAME   (L"MMCDetectionState")
 
#define CLASSP_REG_WRITE_CACHE_VALUE_NAME   (L"WriteCacheEnableOverride")
 
#define CLASSP_REG_PERF_RESTORE_VALUE_NAME   (L"RestorePerfAtCount")
 
#define CLASSP_REG_REMOVAL_POLICY_VALUE_NAME   (L"UserRemovalPolicy")
 
#define CLASS_PERF_RESTORE_MINIMUM   (0x10)
 
#define CLASS_ERROR_LEVEL_1   (0x4)
 
#define CLASS_ERROR_LEVEL_2   (0x8)
 
#define FDO_HACK_CANNOT_LOCK_MEDIA   (0x00000001)
 
#define FDO_HACK_GESN_IS_BAD   (0x00000002)
 
#define FDO_HACK_NO_SYNC_CACHE   (0x00000004)
 
#define FDO_HACK_VALID_FLAGS   (0x00000007)
 
#define FDO_HACK_INVALID_FLAGS   (~FDO_HACK_VALID_FLAGS)
 
#define NUM_LOCKMEDIAREMOVAL_RETRIES   1
 
#define NUM_MODESENSE_RETRIES   1
 
#define NUM_DRIVECAPACITY_RETRIES   1
 
#define CLASS_FILE_OBJECT_EXTENSION_KEY   'eteP'
 
#define CLASSP_VOLUME_VERIFY_CHECKED   0x34
 
#define CLASS_TAG_PRIVATE_DATA   'CPcS'
 
#define CLASS_TAG_PRIVATE_DATA_FDO   'FPcS'
 
#define CLASS_TAG_PRIVATE_DATA_PDO   'PPcS'
 
#define NUM_ERROR_LOG_ENTRIES   16
 
#define MIN_INITIAL_TRANSFER_PACKETS   1
 
#define MIN_WORKINGSET_TRANSFER_PACKETS_Consumer   4
 
#define MAX_WORKINGSET_TRANSFER_PACKETS_Consumer   64
 
#define MIN_WORKINGSET_TRANSFER_PACKETS_Server   64
 
#define MAX_WORKINGSET_TRANSFER_PACKETS_Server   1024
 
#define MIN_WORKINGSET_TRANSFER_PACKETS_Enterprise   256
 
#define MAX_WORKINGSET_TRANSFER_PACKETS_Enterprise   2048
 
#define MIN(a, b)   ((a) < (b) ? (a) : (b))
 
#define MAX(a, b)   ((a) > (b) ? (a) : (b))
 
#define NOT_READY_RETRY_INTERVAL   10
 
#define MINIMUM_RETRY_UNITS   ((LONGLONG)32)
 

Typedefs

typedef enum MEDIA_LOCK_TYPEPMEDIA_LOCK_TYPE
 
typedef struct _FAILURE_PREDICTION_INFO FAILURE_PREDICTION_INFO
 
typedef struct _FAILURE_PREDICTION_INFOPFAILURE_PREDICTION_INFO
 
typedef struct _CLASS_RETRY_INFO CLASS_RETRY_INFO
 
typedef struct _CLASS_RETRY_INFOPCLASS_RETRY_INFO
 
typedef struct _CSCAN_LIST CSCAN_LIST
 
typedef struct _CSCAN_LISTPCSCAN_LIST
 
typedef enum _CLASS_DETECTION_STATE CLASS_DETECTION_STATE
 
typedef enum _CLASS_DETECTION_STATEPCLASS_DETECTION_STATE
 
typedef struct _CLASS_ERROR_LOG_DATA CLASS_ERROR_LOG_DATA
 
typedef struct _CLASS_ERROR_LOG_DATAPCLASS_ERROR_LOG_DATA
 
typedef struct _TRANSFER_PACKET TRANSFER_PACKET
 
typedef struct _TRANSFER_PACKETPTRANSFER_PACKET
 

Enumerations

enum  MEDIA_LOCK_TYPE { SimpleMediaLock, SecureMediaLock, InternalMediaLock }
 
enum  _CLASS_DETECTION_STATE { ClassDetectionUnknown = 0, ClassDetectionUnsupported = 1, ClassDetectionSupported = 2 }
 

Functions

static VOID SimpleInitSlistHdr (SLIST_ENTRY *SListHdr)
 
static VOID SimplePushSlist (SLIST_ENTRY *SListHdr, SLIST_ENTRY *SListEntry)
 
static SLIST_ENTRYSimplePopSlist (SLIST_ENTRY *SListHdr)
 
static BOOLEAN SimpleIsSlistEmpty (SLIST_ENTRY *SListHdr)
 
NTSTATUS NTAPI ClasspCreateClose (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI ClasspCleanupProtectedLocks (IN PFILE_OBJECT_EXTENSION FsContext)
 
NTSTATUS NTAPI ClasspEjectionControl (IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN MEDIA_LOCK_TYPE LockType, IN BOOLEAN Lock)
 
NTSTATUS NTAPI ClassPnpStartDevice (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI ClassShutdownFlush (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI RetryRequest (PDEVICE_OBJECT DeviceObject, PIRP Irp, PSCSI_REQUEST_BLOCK Srb, BOOLEAN Associated, ULONG RetryInterval)
 
NTSTATUS NTAPI ClassIoCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
 
NTSTATUS NTAPI ClassPnpQueryFdoRelations (IN PDEVICE_OBJECT Fdo, IN PIRP Irp)
 
NTSTATUS NTAPI ClassRetrieveDeviceRelations (IN PDEVICE_OBJECT Fdo, IN DEVICE_RELATION_TYPE RelationType, OUT PDEVICE_RELATIONS *DeviceRelations)
 
NTSTATUS NTAPI ClassGetPdoId (IN PDEVICE_OBJECT Pdo, IN BUS_QUERY_ID_TYPE IdType, IN PUNICODE_STRING IdString)
 
NTSTATUS NTAPI ClassQueryPnpCapabilities (IN PDEVICE_OBJECT PhysicalDeviceObject, IN PDEVICE_CAPABILITIES Capabilities)
 
NTSTATUS NTAPI ClasspPagingNotificationCompletion (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PDEVICE_OBJECT RealDeviceObject)
 
NTSTATUS NTAPI ClasspMediaChangeCompletion (PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
 
PFILE_OBJECT_EXTENSION NTAPI ClasspGetFsContext (IN PCOMMON_DEVICE_EXTENSION CommonExtension, IN PFILE_OBJECT FileObject)
 
NTSTATUS NTAPI ClasspMcnControl (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PIRP Irp, IN PSCSI_REQUEST_BLOCK Srb)
 
VOID NTAPI ClasspRegisterMountedDeviceInterface (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI ClasspDisableTimer (PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI ClasspEnableTimer (PDEVICE_OBJECT DeviceObject)
 
VOID NTAPI InitializeDictionary (IN PDICTIONARY Dictionary)
 
BOOLEAN NTAPI TestDictionarySignature (IN PDICTIONARY Dictionary)
 
NTSTATUS NTAPI AllocateDictionaryEntry (IN PDICTIONARY Dictionary, IN ULONGLONG Key, IN ULONG Size, IN ULONG Tag, OUT PVOID *Entry)
 
PVOID NTAPI GetDictionaryEntry (IN PDICTIONARY Dictionary, IN ULONGLONG Key)
 
VOID NTAPI FreeDictionaryEntry (IN PDICTIONARY Dictionary, IN PVOID Entry)
 
NTSTATUS NTAPI ClasspAllocateReleaseRequest (IN PDEVICE_OBJECT Fdo)
 
VOID NTAPI ClasspFreeReleaseRequest (IN PDEVICE_OBJECT Fdo)
 
VOID NTAPI ClasspReleaseQueue (IN PDEVICE_OBJECT DeviceObject, IN PIRP ReleaseQueueIrp)
 
VOID NTAPI ClasspDisablePowerNotification (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
NTSTATUS NTAPI ClassMinimalPowerHandler (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI ClassAddChild (IN PFUNCTIONAL_DEVICE_EXTENSION Parent, IN PPHYSICAL_DEVICE_EXTENSION Child, IN BOOLEAN AcquireLock)
 
PPHYSICAL_DEVICE_EXTENSION NTAPI ClassRemoveChild (IN PFUNCTIONAL_DEVICE_EXTENSION Parent, IN PPHYSICAL_DEVICE_EXTENSION Child, IN BOOLEAN AcquireLock)
 
VOID NTAPI ClasspRetryDpcTimer (IN PCLASS_PRIVATE_FDO_DATA FdoData)
 
VOID NTAPI ClassFreeOrReuseSrb (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PSCSI_REQUEST_BLOCK Srb)
 
VOID NTAPI ClassRetryRequest (IN PDEVICE_OBJECT SelfDeviceObject, IN PIRP Irp, IN LARGE_INTEGER TimeDelta100ns)
 
VOID NTAPI ClasspBuildRequestEx (IN PFUNCTIONAL_DEVICE_EXTENSION Fdo, IN PIRP Irp, IN PSCSI_REQUEST_BLOCK Srb)
 
NTSTATUS NTAPI ClasspAllocateReleaseQueueIrp (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
NTSTATUS NTAPI ClasspInitializeGesn (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMEDIA_CHANGE_DETECTION_INFO Info)
 
VOID NTAPI ClasspSendNotification (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN const GUID *Guid, IN ULONG ExtraDataSize, IN PVOID ExtraData)
 
VOID NTAPI ClassSendEjectionNotification (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID NTAPI ClasspScanForSpecialInRegistry (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID NTAPI ClasspScanForClassHacks (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN ULONG_PTR Data)
 
NTSTATUS NTAPI ClasspInitializeHotplugInfo (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID NTAPI ClasspPerfIncrementErrorCount (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
VOID NTAPI ClasspPerfIncrementSuccessfulIo (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
 
PTRANSFER_PACKET NTAPI NewTransferPacket (PDEVICE_OBJECT Fdo)
 
VOID NTAPI DestroyTransferPacket (PTRANSFER_PACKET Pkt)
 
VOID NTAPI EnqueueFreeTransferPacket (PDEVICE_OBJECT Fdo, PTRANSFER_PACKET Pkt)
 
PTRANSFER_PACKET NTAPI DequeueFreeTransferPacket (PDEVICE_OBJECT Fdo, BOOLEAN AllocIfNeeded)
 
VOID NTAPI SetupReadWriteTransferPacket (PTRANSFER_PACKET pkt, PVOID Buf, ULONG Len, LARGE_INTEGER DiskLocation, PIRP OriginalIrp)
 
VOID NTAPI SubmitTransferPacket (PTRANSFER_PACKET Pkt)
 
NTSTATUS NTAPI TransferPktComplete (IN PDEVICE_OBJECT NullFdo, IN PIRP Irp, IN PVOID Context)
 
VOID NTAPI ServiceTransferRequest (PDEVICE_OBJECT Fdo, PIRP Irp)
 
VOID NTAPI TransferPacketRetryTimerDpc (IN PKDPC Dpc, IN PVOID DeferredContext, IN PVOID SystemArgument1, IN PVOID SystemArgument2)
 
BOOLEAN NTAPI InterpretTransferPacketError (PTRANSFER_PACKET Pkt)
 
BOOLEAN NTAPI RetryTransferPacket (PTRANSFER_PACKET Pkt)
 
VOID NTAPI EnqueueDeferredClientIrp (PCLASS_PRIVATE_FDO_DATA FdoData, PIRP Irp)
 
PIRP NTAPI DequeueDeferredClientIrp (PCLASS_PRIVATE_FDO_DATA FdoData)
 
VOID NTAPI InitLowMemRetry (PTRANSFER_PACKET Pkt, PVOID BufPtr, ULONG Len, LARGE_INTEGER TargetLocation)
 
BOOLEAN NTAPI StepLowMemRetry (PTRANSFER_PACKET Pkt)
 
VOID NTAPI SetupEjectionTransferPacket (TRANSFER_PACKET *Pkt, BOOLEAN PreventMediaRemoval, PKEVENT SyncEventPtr, PIRP OriginalIrp)
 
VOID NTAPI SetupModeSenseTransferPacket (TRANSFER_PACKET *Pkt, PKEVENT SyncEventPtr, PVOID ModeSenseBuffer, UCHAR ModeSenseBufferLen, UCHAR PageMode, PIRP OriginalIrp)
 
VOID NTAPI SetupDriveCapacityTransferPacket (TRANSFER_PACKET *Pkt, PVOID ReadCapacityBuffer, ULONG ReadCapacityBufferLen, PKEVENT SyncEventPtr, PIRP OriginalIrp)
 
PMDL NTAPI BuildDeviceInputMdl (PVOID Buffer, ULONG BufferLen)
 
VOID NTAPI FreeDeviceInputMdl (PMDL Mdl)
 
NTSTATUS NTAPI InitializeTransferPackets (PDEVICE_OBJECT Fdo)
 
VOID NTAPI DestroyAllTransferPackets (PDEVICE_OBJECT Fdo)
 

Variables

CLASSPNP_SCAN_FOR_SPECIAL_INFO ClassBadItems []
 
GUID ClassGuidQueryRegInfoEx
 
DRIVER_INITIALIZE DriverEntry
 
DRIVER_UNLOAD ClassUnload
 
DRIVER_DISPATCH ClassCreateClose
 
DRIVER_DISPATCH ClassReadWrite
 
DRIVER_DISPATCH ClassDeviceControlDispatch
 
DRIVER_DISPATCH ClassDispatchPnp
 
DRIVER_DISPATCH ClassSystemControl
 
DRIVER_ADD_DEVICE ClassAddDevice
 
IO_COMPLETION_ROUTINE ClasspSendSynchronousCompletion
 
DRIVER_STARTIO ClasspStartIo
 
IO_COMPLETION_ROUTINE ClassReleaseQueueCompletion
 
DRIVER_DISPATCH ClassDispatchPower
 
KDEFERRED_ROUTINE ClasspRetryRequestDpc
 

Macro Definition Documentation

◆ CLASS_ERROR_LEVEL_1

#define CLASS_ERROR_LEVEL_1   (0x4)

Definition at line 50 of file classp.h.

◆ CLASS_ERROR_LEVEL_2

#define CLASS_ERROR_LEVEL_2   (0x8)

Definition at line 51 of file classp.h.

◆ CLASS_FILE_OBJECT_EXTENSION_KEY

#define CLASS_FILE_OBJECT_EXTENSION_KEY   'eteP'

Definition at line 79 of file classp.h.

◆ CLASS_PERF_RESTORE_MINIMUM

#define CLASS_PERF_RESTORE_MINIMUM   (0x10)

Definition at line 49 of file classp.h.

◆ CLASS_TAG_PRIVATE_DATA

#define CLASS_TAG_PRIVATE_DATA   'CPcS'

Definition at line 82 of file classp.h.

◆ CLASS_TAG_PRIVATE_DATA_FDO

#define CLASS_TAG_PRIVATE_DATA_FDO   'FPcS'

Definition at line 83 of file classp.h.

◆ CLASS_TAG_PRIVATE_DATA_PDO

#define CLASS_TAG_PRIVATE_DATA_PDO   'PPcS'

Definition at line 84 of file classp.h.

◆ CLASSP_REG_HACK_VALUE_NAME

#define CLASSP_REG_HACK_VALUE_NAME   (L"HackMask")

Definition at line 43 of file classp.h.

◆ CLASSP_REG_MMC_DETECTION_VALUE_NAME

#define CLASSP_REG_MMC_DETECTION_VALUE_NAME   (L"MMCDetectionState")

Definition at line 44 of file classp.h.

◆ CLASSP_REG_PERF_RESTORE_VALUE_NAME

#define CLASSP_REG_PERF_RESTORE_VALUE_NAME   (L"RestorePerfAtCount")

Definition at line 46 of file classp.h.

◆ CLASSP_REG_REMOVAL_POLICY_VALUE_NAME

#define CLASSP_REG_REMOVAL_POLICY_VALUE_NAME   (L"UserRemovalPolicy")

Definition at line 47 of file classp.h.

◆ CLASSP_REG_SUBKEY_NAME

#define CLASSP_REG_SUBKEY_NAME   (L"Classpnp")

Definition at line 41 of file classp.h.

◆ CLASSP_REG_WRITE_CACHE_VALUE_NAME

#define CLASSP_REG_WRITE_CACHE_VALUE_NAME   (L"WriteCacheEnableOverride")

Definition at line 45 of file classp.h.

◆ CLASSP_VOLUME_VERIFY_CHECKED

#define CLASSP_VOLUME_VERIFY_CHECKED   0x34

Definition at line 80 of file classp.h.

◆ FDO_HACK_CANNOT_LOCK_MEDIA

#define FDO_HACK_CANNOT_LOCK_MEDIA   (0x00000001)

Definition at line 53 of file classp.h.

◆ FDO_HACK_GESN_IS_BAD

#define FDO_HACK_GESN_IS_BAD   (0x00000002)

Definition at line 54 of file classp.h.

◆ FDO_HACK_INVALID_FLAGS

#define FDO_HACK_INVALID_FLAGS   (~FDO_HACK_VALID_FLAGS)

Definition at line 58 of file classp.h.

◆ FDO_HACK_NO_SYNC_CACHE

#define FDO_HACK_NO_SYNC_CACHE   (0x00000004)

Definition at line 55 of file classp.h.

◆ FDO_HACK_VALID_FLAGS

#define FDO_HACK_VALID_FLAGS   (0x00000007)

Definition at line 57 of file classp.h.

◆ MAX

#define MAX (   a,
  b 
)    ((a) > (b) ? (a) : (b))

Definition at line 468 of file classp.h.

◆ MAX_WORKINGSET_TRANSFER_PACKETS_Consumer

#define MAX_WORKINGSET_TRANSFER_PACKETS_Consumer   64

Definition at line 376 of file classp.h.

◆ MAX_WORKINGSET_TRANSFER_PACKETS_Enterprise

#define MAX_WORKINGSET_TRANSFER_PACKETS_Enterprise   2048

Definition at line 380 of file classp.h.

◆ MAX_WORKINGSET_TRANSFER_PACKETS_Server

#define MAX_WORKINGSET_TRANSFER_PACKETS_Server   1024

Definition at line 378 of file classp.h.

◆ MIN

#define MIN (   a,
  b 
)    ((a) < (b) ? (a) : (b))

Definition at line 467 of file classp.h.

◆ MIN_INITIAL_TRANSFER_PACKETS

#define MIN_INITIAL_TRANSFER_PACKETS   1

Definition at line 374 of file classp.h.

◆ MIN_WORKINGSET_TRANSFER_PACKETS_Consumer

#define MIN_WORKINGSET_TRANSFER_PACKETS_Consumer   4

Definition at line 375 of file classp.h.

◆ MIN_WORKINGSET_TRANSFER_PACKETS_Enterprise

#define MIN_WORKINGSET_TRANSFER_PACKETS_Enterprise   256

Definition at line 379 of file classp.h.

◆ MIN_WORKINGSET_TRANSFER_PACKETS_Server

#define MIN_WORKINGSET_TRANSFER_PACKETS_Server   64

Definition at line 377 of file classp.h.

◆ MINIMUM_RETRY_UNITS

#define MINIMUM_RETRY_UNITS   ((LONGLONG)32)

Definition at line 472 of file classp.h.

◆ NOT_READY_RETRY_INTERVAL

#define NOT_READY_RETRY_INTERVAL   10

Definition at line 471 of file classp.h.

◆ NUM_DRIVECAPACITY_RETRIES

#define NUM_DRIVECAPACITY_RETRIES   1

Definition at line 76 of file classp.h.

◆ NUM_ERROR_LOG_ENTRIES

#define NUM_ERROR_LOG_ENTRIES   16

Definition at line 280 of file classp.h.

◆ NUM_LOCKMEDIAREMOVAL_RETRIES

#define NUM_LOCKMEDIAREMOVAL_RETRIES   1

Definition at line 74 of file classp.h.

◆ NUM_MODESENSE_RETRIES

#define NUM_MODESENSE_RETRIES   1

Definition at line 75 of file classp.h.

Typedef Documentation

◆ CLASS_DETECTION_STATE

◆ CLASS_ERROR_LOG_DATA

◆ CLASS_RETRY_INFO

◆ CSCAN_LIST

◆ FAILURE_PREDICTION_INFO

◆ PCLASS_DETECTION_STATE

◆ PCLASS_ERROR_LOG_DATA

◆ PCLASS_RETRY_INFO

◆ PCSCAN_LIST

◆ PFAILURE_PREDICTION_INFO

◆ PMEDIA_LOCK_TYPE

◆ PTRANSFER_PACKET

◆ TRANSFER_PACKET

Enumeration Type Documentation

◆ _CLASS_DETECTION_STATE

Enumerator
ClassDetectionUnknown 
ClassDetectionUnsupported 
ClassDetectionSupported 

Definition at line 251 of file classp.h.

251  {
enum _CLASS_DETECTION_STATE * PCLASS_DETECTION_STATE
enum _CLASS_DETECTION_STATE CLASS_DETECTION_STATE

◆ MEDIA_LOCK_TYPE

Enumerator
SimpleMediaLock 
SecureMediaLock 
InternalMediaLock 

Definition at line 189 of file classp.h.

189  {
MEDIA_LOCK_TYPE
Definition: classp.h:189
enum MEDIA_LOCK_TYPE * PMEDIA_LOCK_TYPE

Function Documentation

◆ AllocateDictionaryEntry()

NTSTATUS NTAPI AllocateDictionaryEntry ( IN PDICTIONARY  Dictionary,
IN ULONGLONG  Key,
IN ULONG  Size,
IN ULONG  Tag,
OUT PVOID Entry 
)

Definition at line 60 of file dictlib.c.

67 {
69  KIRQL oldIrql;
71 
73 
74  *Entry = NULL;
75 
77  Size + sizeof(DICTIONARY_HEADER),
78  Tag);
79 
80  if(header == NULL) {
82  }
83 
85  header->Key = Key;
86 
87  //
88  // Find the correct location for this entry in the dictionary.
89  //
90 
91  KeAcquireSpinLock(&(Dictionary->SpinLock), &oldIrql);
92 
93  TRY {
94 
95  entry = &(Dictionary->List);
96 
97  while(*entry != NULL) {
98  if((*entry)->Key == Key) {
99 
100  //
101  // Dictionary must have unique keys.
102  //
103 
105  LEAVE;
106 
107  } else if ((*entry)->Key < Key) {
108 
109  //
110  // We will go ahead and insert the key in here.
111  //
112  break;
113  } else {
114  entry = &((*entry)->Next);
115  }
116  }
117 
118  //
119  // If we make it here then we will go ahead and do the insertion.
120  //
121 
122  header->Next = *entry;
123  *entry = header;
124 
125  } FINALLY {
126  KeReleaseSpinLock(&(Dictionary->SpinLock), oldIrql);
127 
128  if(!NT_SUCCESS(status)) {
130  } else {
131  *Entry = (PVOID) header->Data;
132  }
133  }
134  return status;
135 }
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define FINALLY
Definition: classpnp.h:113
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
IN PLARGE_INTEGER IN PLARGE_INTEGER PEPROCESS ULONG Key
Definition: fatprocs.h:2697
LONG NTSTATUS
Definition: precomp.h:26
#define LEAVE
Definition: classpnp.h:112
#define TRY(sps, bps)
UCHAR KIRQL
Definition: env_spec_w32.h:591
smooth NULL
Definition: ftsmooth.c:416
void * PVOID
Definition: retypes.h:9
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
uint32_t entry
Definition: isohybrid.c:63
IN PVOID IN PVOID IN USHORT IN USHORT Size
Definition: pci.h:359
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
IN ULONG IN ULONG Tag
Definition: evtlib.h:159
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
struct CFHEADER header
Definition: fdi.c:101
base of all file and directory entries
Definition: entries.h:82
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
Definition: ps.c:97

Referenced by ClasspCreateClose().

◆ BuildDeviceInputMdl()

PMDL NTAPI BuildDeviceInputMdl ( PVOID  Buffer,
ULONG  BufferLen 
)

Definition at line 480 of file utils.c.

481 {
482  PMDL mdl;
483 
484  mdl = IoAllocateMdl(Buffer, BufferLen, FALSE, FALSE, NULL);
485  if (mdl){
486  _SEH2_TRY {
487  /*
488  * We are reading from the device.
489  * Therefore, the device is WRITING to the locked memory.
490  * So we request IoWriteAccess.
491  */
493 
496 
497  DBGWARN(("BuildReadMdl: MmProbeAndLockPages failed with %xh.", status));
498  IoFreeMdl(mdl);
499  mdl = NULL;
500  } _SEH2_END;
501  }
502  else {
503  DBGWARN(("BuildReadMdl: IoAllocateMdl failed"));
504  }
505 
506  return mdl;
507 }
LONG NTSTATUS
Definition: precomp.h:26
_SEH2_TRY
Definition: create.c:4250
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
_SEH2_END
Definition: create.c:4424
VOID NTAPI MmProbeAndLockPages(IN PMDL Mdl, IN KPROCESSOR_MODE AccessMode, IN LOCK_OPERATION Operation)
Definition: mdlsup.c:935
#define DBGWARN(args_in_parens)
Definition: debug.h:134
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
Definition: ps.c:97

Referenced by ClassModeSense(), and ClassReadDriveCapacity().

◆ ClassAddChild()

VOID NTAPI ClassAddChild ( IN PFUNCTIONAL_DEVICE_EXTENSION  Parent,
IN PPHYSICAL_DEVICE_EXTENSION  Child,
IN BOOLEAN  AcquireLock 
)

Definition at line 8566 of file class.c.

8571 {
8572  if(AcquireLock) {
8574  }
8575 
8576  #if DBG
8577  //
8578  // Make sure this child's not already in the list.
8579  //
8580  {
8581  PPHYSICAL_DEVICE_EXTENSION testChild;
8582 
8583  for (testChild = Parent->CommonExtension.ChildList;
8584  testChild != NULL;
8585  testChild = testChild->CommonExtension.ChildList) {
8586 
8587  ASSERT(testChild != Child);
8588  }
8589  }
8590  #endif
8591 
8592  Child->CommonExtension.ChildList = Parent->CommonExtension.ChildList;
8593  Parent->CommonExtension.ChildList = Child;
8594 
8595  if(AcquireLock) {
8597  }
8598  return;
8599 } // end ClassAddChild()
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:628
VOID NTAPI ClassAcquireChildLock(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:8483
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
VOID NTAPI ClassReleaseChildLock(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:8526
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE Child
Definition: acpixf.h:728

Referenced by ClassCreateDeviceObject().

◆ ClassFreeOrReuseSrb()

VOID NTAPI ClassFreeOrReuseSrb ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
IN PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 824 of file obsolete.c.

847 {
848  PCOMMON_DEVICE_EXTENSION commonExt = &FdoExtension->CommonExtension;
849  //KIRQL oldIrql;
850  //PIRP blockedIrp;
851 
852  // This function is obsolete, but still called by DISK.SYS .
853  // DBGWARN(("ClassFreeOrReuseSrb is OBSOLETE !"));
854 
855  //
856  // safety net. this should never occur. if it does, it's a potential
857  // memory leak.
858  //
860 
861  if (commonExt->IsSrbLookasideListInitialized){
862  /*
863  * Put the SRB back in our lookaside list.
864  *
865  * BUGBUG - Some class drivers use ClassIoComplete
866  * to complete SRBs that they themselves allocated.
867  * So we may be putting a "foreign" SRB
868  * (e.g. with a different pool tag) into our lookaside list.
869  */
871  }
872  else {
873  DBGERR(("ClassFreeOrReuseSrb: someone is trying to use an uninitialized SrbLookasideList !!!"));
874  ExFreePool(Srb);
875  }
876 }
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
#define SRB_FLAGS_FREE_SENSE_BUFFER
Definition: srb.h:398
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
BOOLEAN IsSrbLookasideListInitialized
Definition: classpnp.h:586
#define ClasspFreeSrb(ext, srb)
Definition: classpnp.h:147
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
#define DBGERR(args_in_parens)
Definition: debug.h:135
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by ClassIoComplete(), ClassIoCompleteAssociated(), ClasspEjectionControl(), and ClassSendSrbAsynchronous().

◆ ClassGetPdoId()

NTSTATUS NTAPI ClassGetPdoId ( IN PDEVICE_OBJECT  Pdo,
IN BUS_QUERY_ID_TYPE  IdType,
IN PUNICODE_STRING  IdString 
)

Definition at line 6824 of file class.c.

6829 {
6831  driverExtension = IoGetDriverObjectExtension(Pdo->DriverObject,
6833 
6834  ASSERT_PDO(Pdo);
6835  ASSERT(driverExtension->InitData.ClassQueryId);
6836 
6837  PAGED_CODE();
6838 
6839  return driverExtension->InitData.ClassQueryId( Pdo, IdType, IdString);
6840 } // end ClassGetPdoId()
#define CLASS_DRIVER_EXTENSION_KEY
Definition: classpnp.h:91
_In_ PDEVICE_OBJECT Pdo
Definition: classpnp.h:301
PCLASS_QUERY_ID ClassQueryId
Definition: classpnp.h:525
_In_ BUS_QUERY_ID_TYPE _In_ PUNICODE_STRING IdString
Definition: classpnp.h:357
#define PAGED_CODE()
Definition: video.h:57
#define ASSERT_PDO(x)
Definition: pci.h:36
_In_ BUS_QUERY_ID_TYPE IdType
Definition: classpnp.h:357
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
CLASS_INIT_DATA InitData
Definition: classpnp.h:556

Referenced by ClassDispatchPnp().

◆ ClassIoCompletion()

NTSTATUS NTAPI ClassIoCompletion ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PVOID  Context 
)

Definition at line 4730 of file class2.c.

4758 {
4761 
4762  //
4763  // If pending is returned for this Irp then mark current stack
4764  // as pending
4765  //
4766 
4767  if (Irp->PendingReturned) {
4768 
4769  IoMarkIrpPending( Irp );
4770  }
4771 
4772  return Irp->IoStatus.Status;
4773 }
_In_ PIRP Irp
Definition: csq.h:116
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:323
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
IoMarkIrpPending(Irp)

Referenced by ScsiClassInternalIoControl().

◆ ClassMinimalPowerHandler()

NTSTATUS NTAPI ClassMinimalPowerHandler ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 1302 of file power.c.

1306 {
1309  NTSTATUS status;
1310 
1313 
1314  if(commonExtension->IsFdo) {
1315 
1316  if (DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA) {
1317 
1318  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension =
1320 
1321  //
1322  // Check if the system is going to hibernate or standby.
1323  //
1324  if (irpStack->MinorFunction == IRP_MN_SET_POWER){
1325  PVPB vpb;
1326 
1327  switch (irpStack->Parameters.Power.ShutdownType){
1328 
1329  case PowerActionSleep:
1330  case PowerActionHibernate:
1331  //
1332  // If the volume is mounted, set the verify bit so that
1333  // the filesystem will be forced re-read the media
1334  // after coming out of hibernation or standby.
1335  //
1336  vpb = ClassGetVpb(fdoExtension->DeviceObject);
1337  if (vpb && (vpb->Flags & VPB_MOUNTED)){
1338  SET_FLAG(fdoExtension->DeviceObject->Flags, DO_VERIFY_VOLUME);
1339  }
1340  break;
1341  default:
1342  break;
1343  }
1344  }
1345  }
1346 
1348  return PoCallDriver(commonExtension->LowerDeviceObject, Irp);
1349 
1350  } else {
1351 
1352  if (irpStack->MinorFunction != IRP_MN_SET_POWER &&
1353  irpStack->MinorFunction != IRP_MN_QUERY_POWER) {
1354 
1355  NOTHING;
1356 
1357  } else {
1358 
1359  Irp->IoStatus.Status = STATUS_SUCCESS;
1360  Irp->IoStatus.Information = 0;
1361 
1362  }
1363  status = Irp->IoStatus.Status;
1364 
1366  return status;
1367  }
1368 } // end ClassMinimalPowerHandler()
PVPB NTAPI ClassGetVpb(IN PDEVICE_OBJECT DeviceObject)
Definition: class.c:8048
USHORT Flags
Definition: iotypes.h:169
#define IRP_MN_QUERY_POWER
NTSTATUS NTAPI PoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
Definition: power.c:485
_In_ PIRP Irp
Definition: csq.h:116
LONG NTSTATUS
Definition: precomp.h:26
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
PVOID DeviceExtension
Definition: env_spec_w32.h:418
PDEVICE_OBJECT DeviceObject
Definition: classpnp.h:693
#define IRP_MN_SET_POWER
#define NOTHING
Definition: env_spec_w32.h:461
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
VOID NTAPI PoStartNextPowerIrp(IN PIRP Irp)
Definition: power.c:626
VOID NTAPI ClassCompleteRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN CCHAR PriorityBoost)
Definition: lock.c:376
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:574
Definition: iotypes.h:166
#define IO_NO_INCREMENT
Definition: iotypes.h:566
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
#define VPB_MOUNTED
Definition: iotypes.h:1764
static SERVICE_STATUS status
Definition: service.c:31
VOID NTAPI ClassReleaseRemoveLock(IN PDEVICE_OBJECT DeviceObject, IN OPTIONAL PIRP Tag)
Definition: lock.c:212
Definition: ps.c:97

Referenced by ClassInitialize().

◆ ClasspAllocateReleaseQueueIrp()

NTSTATUS NTAPI ClasspAllocateReleaseQueueIrp ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

◆ ClasspAllocateReleaseRequest()

NTSTATUS NTAPI ClasspAllocateReleaseRequest ( IN PDEVICE_OBJECT  Fdo)

Definition at line 8062 of file class.c.

8065 {
8066  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
8067  //PIO_STACK_LOCATION irpStack;
8068 
8069  KeInitializeSpinLock(&(fdoExtension->ReleaseQueueSpinLock));
8070 
8071  fdoExtension->ReleaseQueueNeeded = FALSE;
8072  fdoExtension->ReleaseQueueInProgress = FALSE;
8073  fdoExtension->ReleaseQueueIrpFromPool = FALSE;
8074 
8075  //
8076  // The class driver is responsible for allocating a properly sized irp,
8077  // or ClassReleaseQueue will attempt to do it on the first error.
8078  //
8079 
8080  fdoExtension->ReleaseQueueIrp = NULL;
8081 
8082  //
8083  // Write length to SRB.
8084  //
8085 
8086  fdoExtension->ReleaseQueueSrb.Length = sizeof(SCSI_REQUEST_BLOCK);
8087 
8088  return STATUS_SUCCESS;
8089 } // end ClasspAllocateReleaseRequest()
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
KSPIN_LOCK ReleaseQueueSpinLock
Definition: classpnp.h:727
smooth NULL
Definition: ftsmooth.c:416
USHORT Length
Definition: srb.h:241
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
return STATUS_SUCCESS
Definition: btrfs.c:2938
SCSI_REQUEST_BLOCK ReleaseQueueSrb
Definition: classpnp.h:729

Referenced by ClassCreateDeviceObject().

◆ ClasspBuildRequestEx()

VOID NTAPI ClasspBuildRequestEx ( IN PFUNCTIONAL_DEVICE_EXTENSION  Fdo,
IN PIRP  Irp,
IN PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 503 of file obsolete.c.

541 {
544 
545  LARGE_INTEGER startingOffset = currentIrpStack->Parameters.Read.ByteOffset;
546 
547  PCDB cdb;
548  ULONG logicalBlockAddress;
549  USHORT transferBlocks;
550 
551  // This function is obsolete, but still called by CDROM.SYS .
552  // DBGWARN(("ClasspBuildRequestEx is OBSOLETE !"));
553 
554  //
555  // Prepare the SRB.
556  //
557 
559 
560  //
561  // Calculate relative sector address.
562  //
563 
564  logicalBlockAddress =
565  (ULONG)(Int64ShrlMod32(startingOffset.QuadPart,
566  FdoExtension->SectorShift));
567 
568  //
569  // Write length to SRB.
570  //
571 
572  Srb->Length = sizeof(SCSI_REQUEST_BLOCK);
573 
574  //
575  // Set up IRP Address.
576  //
577 
578  Srb->OriginalRequest = Irp;
579 
580  //
581  // Set up target ID and logical unit number.
582  //
583 
584  Srb->Function = SRB_FUNCTION_EXECUTE_SCSI;
585  Srb->DataBuffer = MmGetMdlVirtualAddress(Irp->MdlAddress);
586 
587  //
588  // Save byte count of transfer in SRB Extension.
589  //
590 
591  Srb->DataTransferLength = currentIrpStack->Parameters.Read.Length;
592 
593  //
594  // Initialize the queue actions field.
595  //
596 
597  Srb->QueueAction = SRB_SIMPLE_TAG_REQUEST;
598 
599  //
600  // Queue sort key is Relative Block Address.
601  //
602 
603  Srb->QueueSortKey = logicalBlockAddress;
604 
605  //
606  // Indicate auto request sense by specifying buffer and size.
607  //
608 
609  Srb->SenseInfoBuffer = FdoExtension->SenseData;
610  Srb->SenseInfoBufferLength = SENSE_BUFFER_SIZE;
611 
612  //
613  // Set timeout value of one unit per 64k bytes of data.
614  //
615 
616  Srb->TimeOutValue = ((Srb->DataTransferLength + 0xFFFF) >> 16) *
617  FdoExtension->TimeOutValue;
618 
619  //
620  // Zero statuses.
621  //
622 
623  Srb->SrbStatus = Srb->ScsiStatus = 0;
624  Srb->NextSrb = 0;
625 
626  //
627  // Indicate that 10-byte CDB's will be used.
628  //
629 
630  Srb->CdbLength = 10;
631 
632  //
633  // Fill in CDB fields.
634  //
635 
636  cdb = (PCDB)Srb->Cdb;
637 
638  transferBlocks = (USHORT)(currentIrpStack->Parameters.Read.Length >>
639  FdoExtension->SectorShift);
640 
641  //
642  // Move little endian values into CDB in big endian format.
643  //
644 
645  cdb->CDB10.LogicalBlockByte0 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte3;
646  cdb->CDB10.LogicalBlockByte1 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte2;
647  cdb->CDB10.LogicalBlockByte2 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte1;
648  cdb->CDB10.LogicalBlockByte3 = ((PFOUR_BYTE)&logicalBlockAddress)->Byte0;
649 
650  cdb->CDB10.TransferBlocksMsb = ((PFOUR_BYTE)&transferBlocks)->Byte1;
651  cdb->CDB10.TransferBlocksLsb = ((PFOUR_BYTE)&transferBlocks)->Byte0;
652 
653  //
654  // Set transfer direction flag and Cdb command.
655  //
656 
657  if (currentIrpStack->MajorFunction == IRP_MJ_READ) {
658 
659  DebugPrint((3, "ClassBuildRequest: Read Command\n"));
660 
661  SET_FLAG(Srb->SrbFlags, SRB_FLAGS_DATA_IN);
662  cdb->CDB10.OperationCode = SCSIOP_READ;
663 
664  } else {
665 
666  DebugPrint((3, "ClassBuildRequest: Write Command\n"));
667 
668  SET_FLAG(Srb->SrbFlags, SRB_FLAGS_DATA_OUT);
669  cdb->CDB10.OperationCode = SCSIOP_WRITE;
670  }
671 
672  //
673  // If this is not a write-through request, then allow caching.
674  //
675 
676  if (!(currentIrpStack->Flags & SL_WRITE_THROUGH)) {
677 
679 
680  } else {
681 
682  //
683  // If write caching is enable then force media access in the
684  // cdb.
685  //
686 
687  if (FdoExtension->DeviceFlags & DEV_WRITE_CACHE) {
688  cdb->CDB10.ForceUnitAccess = TRUE;
689  }
690  }
691 
693  SET_FLAG(Srb->SrbFlags, SRB_CLASS_FLAGS_PAGING);
694  }
695 
696  //
697  // OR in the default flags from the device object.
698  //
699 
700  SET_FLAG(Srb->SrbFlags, FdoExtension->SrbFlags);
701 
702  //
703  // Set up major SCSI function.
704  //
705 
706  nextIrpStack->MajorFunction = IRP_MJ_SCSI;
707 
708  //
709  // Save SRB address in next stack for port driver.
710  //
711 
712  nextIrpStack->Parameters.Scsi.Srb = Srb;
713 
714  //
715  // Save retry count in current IRP stack.
716  //
717 
718  currentIrpStack->Parameters.Others.Argument4 = (PVOID)MAXIMUM_RETRIES;
719 
720  //
721  // Set up IoCompletion routine address.
722  //
723 
725 
726 }
struct _FOUR_BYTE * PFOUR_BYTE
#define TRUE
Definition: types.h:120
#define MmGetMdlVirtualAddress(_Mdl)
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
_In_ PIRP Irp
Definition: csq.h:116
Definition: cdrw_hw.h:28
struct _CDB::_CDB10 CDB10
#define SRB_FLAGS_DATA_IN
Definition: srb.h:392
#define SENSE_BUFFER_SIZE
Definition: cdrw_hw.h:1183
#define DEV_WRITE_CACHE
Definition: class2.h:21
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
#define IRP_MJ_SCSI
#define SCSIOP_READ
Definition: cdrw_hw.h:905
#define SCSIOP_WRITE
Definition: cdrw_hw.h:906
union _CDB * PCDB
void * PVOID
Definition: retypes.h:9
NTSTATUS NTAPI ClassIoComplete(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN PVOID Context)
Definition: class.c:2432
#define MAXIMUM_RETRIES
Definition: class2.h:14
struct _SCSI_REQUEST_BLOCK SCSI_REQUEST_BLOCK
#define SRB_CLASS_FLAGS_PAGING
Definition: classpnp.h:21
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
#define Int64ShrlMod32(a, b)
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
unsigned short USHORT
Definition: pedump.c:61
#define SRB_SIMPLE_TAG_REQUEST
Definition: srb.h:415
#define SRB_FLAGS_DATA_OUT
Definition: srb.h:393
#define SRB_FLAGS_ADAPTER_CACHE_ENABLE
Definition: srb.h:397
#define IRP_PAGING_IO
#define SL_WRITE_THROUGH
Definition: iotypes.h:1781
#define IRP_MJ_READ
Definition: rdpdr.c:46
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
#define IRP_SYNCHRONOUS_PAGING_IO
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by ClassBuildRequest().

◆ ClasspCleanupProtectedLocks()

VOID NTAPI ClasspCleanupProtectedLocks ( IN PFILE_OBJECT_EXTENSION  FsContext)

Definition at line 298 of file create.c.

301 {
302  PCOMMON_DEVICE_EXTENSION commonExtension =
303  FsContext->DeviceObject->DeviceExtension;
304 
305  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension =
306  commonExtension->PartitionZeroExtension;
307 
308  ULONG newDeviceLockCount = 1;
309 
310  PAGED_CODE();
311 
312  DebugPrint((2,
313  "ClasspCleanupProtectedLocks called for %p\n",
314  FsContext->DeviceObject));
315  DebugPrint((2,
316  "ClasspCleanupProtectedLocks - FsContext %p is locked "
317  "%d times\n", FsContext, FsContext->LockCount));
318 
320 
321  //
322  // Synchronize with ejection and ejection control requests.
323  //
324 
327  UserRequest,
328  UserMode,
329  FALSE,
330  NULL);
331 
332  //
333  // For each secure lock on this handle decrement the secured lock count
334  // for the FDO. Keep track of the new value.
335  //
336 
337  if(FsContext->LockCount != 0) {
338 
339  do {
340 
341  InterlockedDecrement((PLONG)&FsContext->LockCount);
342 
343  newDeviceLockCount =
345 
346  } while(FsContext->LockCount != 0);
347 
348  //
349  // If the new lock count has been dropped to zero then issue a lock
350  // command to the device.
351  //
352 
353  DebugPrint((2,
354  "ClasspCleanupProtectedLocks: FDO secured lock count = %d "
355  "lock count = %d\n",
356  fdoExtension->ProtectedLockCount,
357  fdoExtension->LockCount));
358 
359  if((newDeviceLockCount == 0) && (fdoExtension->LockCount == 0)) {
360 
361  SCSI_REQUEST_BLOCK srb;
362  PCDB cdb;
364 
365  DebugPrint((2,
366  "ClasspCleanupProtectedLocks: FDO lock count dropped "
367  "to zero\n"));
368 
369  RtlZeroMemory(&srb, sizeof(SCSI_REQUEST_BLOCK));
370  cdb = (PCDB) &(srb.Cdb);
371 
372  srb.CdbLength = 6;
373 
374  cdb->MEDIA_REMOVAL.OperationCode = SCSIOP_MEDIUM_REMOVAL;
375 
376  //
377  // TRUE - prevent media removal.
378  // FALSE - allow media removal.
379  //
380 
381  cdb->MEDIA_REMOVAL.Prevent = FALSE;
382 
383  //
384  // Set timeout value.
385  //
386 
387  srb.TimeOutValue = fdoExtension->TimeOutValue;
389  &srb,
390  NULL,
391  0,
392  FALSE);
393 
394  DebugPrint((2,
395  "ClasspCleanupProtectedLocks: unlock request to drive "
396  "returned status %lx\n", status));
397  }
398  }
399 
400  KeSetEvent(&fdoExtension->EjectSynchronizationEvent,
402  FALSE);
404  return;
405 }
_Inout_ PLIST_ENTRY _In_ PVOID FsContext
Definition: fltkernel.h:2239
UCHAR Cdb[16]
Definition: srb.h:271
struct _CDB::_MEDIA_REMOVAL MEDIA_REMOVAL
struct _FUNCTIONAL_DEVICE_EXTENSION * PartitionZeroExtension
Definition: classpnp.h:575
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
UCHAR CdbLength
Definition: srb.h:250
ULONG TimeOutValue
Definition: srb.h:254
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
smooth NULL
Definition: ftsmooth.c:416
union _CDB * PCDB
PAGED_CODE()
NTSTATUS NTAPI ClassSendSrbSynchronous(PDEVICE_OBJECT Fdo, PSCSI_REQUEST_BLOCK Srb, PVOID BufferAddress, ULONG BufferLength, BOOLEAN WriteToDevice)
Definition: class.c:2648
ULONG BreakOnClose
Definition: create.c:26
PDEVICE_OBJECT DeviceObject
Definition: classpnp.h:693
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define InterlockedDecrement
Definition: armddk.h:52
#define SCSIOP_MEDIUM_REMOVAL
Definition: cdrw_hw.h:902
#define KeEnterCriticalRegion()
Definition: ke_x.h:83
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
#define KeLeaveCriticalRegion()
Definition: ke_x.h:114
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
signed int * PLONG
Definition: retypes.h:5
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by ClasspCreateClose().

◆ ClasspCreateClose()

NTSTATUS NTAPI ClasspCreateClose ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp 
)

Definition at line 125 of file create.c.

150 {
153 
154  PFILE_OBJECT fileObject = irpStack->FileObject;
155 
157 
158  PAGED_CODE();
159 
160 
161  //
162  // ISSUE-2000/3/28-henrygab - if lower stack fails create/close, we end up
163  // in an inconsistent state. re-write to verify all args and allocate all
164  // required resources, then pass the irp down, then complete the
165  // transaction. this is because we also cannot forward the irp, then fail
166  // it after it has succeeded a lower-level driver.
167  //
168 
169  if(irpStack->MajorFunction == IRP_MJ_CREATE) {
170 
171  PIO_SECURITY_CONTEXT securityContext =
172  irpStack->Parameters.Create.SecurityContext;
173  DebugPrint((2,
174  "ClasspCREATEClose: create received for device %p\n",
175  DeviceObject));
176  DebugPrint((2,
177  "ClasspCREATEClose: desired access %lx\n",
178  securityContext->DesiredAccess));
179  DebugPrint((2,
180  "ClasspCREATEClose: file object %lx\n",
181  irpStack->FileObject));
182 
184 
185  if(irpStack->FileObject != NULL) {
186 
187  PFILE_OBJECT_EXTENSION fsContext;
188 
189  //
190  // Allocate our own file object extension for this device object.
191  //
192 
194  &commonExtension->FileObjectDictionary,
195  (ULONG_PTR)irpStack->FileObject,
196  sizeof(FILE_OBJECT_EXTENSION),
198  (PVOID *)&fsContext);
199 
200  if(NT_SUCCESS(status)) {
201 
202  RtlZeroMemory(fsContext,
203  sizeof(FILE_OBJECT_EXTENSION));
204 
205  fsContext->FileObject = irpStack->FileObject;
206  fsContext->DeviceObject = DeviceObject;
207  } else if (status == STATUS_OBJECT_NAME_COLLISION) {
209  }
210  }
211 
212  } else {
213 
214  DebugPrint((2,
215  "ClasspCreateCLOSE: close received for device %p\n",
216  DeviceObject));
217  DebugPrint((2,
218  "ClasspCreateCLOSE: file object %p\n",
219  fileObject));
220 
221  if(irpStack->FileObject != NULL) {
222 
223  PFILE_OBJECT_EXTENSION fsContext =
224  ClasspGetFsContext(commonExtension, irpStack->FileObject);
225 
226  DebugPrint((2,
227  "ClasspCreateCLOSE: file extension %p\n",
228  fsContext));
229 
230  if(fsContext != NULL) {
231 
232  DebugPrint((2,
233  "ClasspCreateCLOSE: extension is ours - "
234  "freeing\n"));
236 
237  ClasspCleanupProtectedLocks(fsContext);
238 
239  ClasspCleanupDisableMcn(fsContext);
240 
241  FreeDictionaryEntry(&(commonExtension->FileObjectDictionary),
242  fsContext);
243  }
244  }
245  }
246 
247  //
248  // Notify the lower levels about the create or close operation - give them
249  // a chance to cleanup too.
250  //
251 
252  DebugPrint((2,
253  "ClasspCreateClose: %s for devobj %p\n",
254  (NT_SUCCESS(status) ? "Success" : "FAILED"),
255  DeviceObject));
256 
257 
258  if(NT_SUCCESS(status)) {
259 
260  KEVENT event;
261 
262  //
263  // Set up the event to wait on
264  //
265 
267 
270  TRUE, TRUE, TRUE);
271 
272  status = IoCallDriver(commonExtension->LowerDeviceObject, Irp);
273 
274  if(status == STATUS_PENDING) {
276  Executive,
277  KernelMode,
278  FALSE,
279  NULL);
280  status = Irp->IoStatus.Status;
281  }
282 
283  if (!NT_SUCCESS(status)) {
285  "ClasspCreateClose: Lower driver failed, but we "
286  "succeeded. This is a problem, lock counts will be "
287  "out of sync between levels.\n"));
288  }
289 
290  }
291 
292 
293  return status;
294 }
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define TRUE
Definition: types.h:120
#define IRP_MJ_CREATE
Definition: rdpdr.c:44
VOID NTAPI ClasspCleanupProtectedLocks(IN PFILE_OBJECT_EXTENSION FsContext)
Definition: create.c:298
_In_ PIRP Irp
Definition: csq.h:116
ACCESS_MASK DesiredAccess
Definition: iotypes.h:2513
IO_COMPLETION_ROUTINE ClassSignalCompletion
Definition: classpnp.h:1137
LONG NTSTATUS
Definition: precomp.h:26
PDEVICE_OBJECT DeviceObject
Definition: classpnp.h:533
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
PFILE_OBJECT_EXTENSION NTAPI ClasspGetFsContext(IN PCOMMON_DEVICE_EXTENSION CommonExtension, IN PFILE_OBJECT FileObject)
Definition: create.c:969
NTSTATUS NTAPI AllocateDictionaryEntry(IN PDICTIONARY Dictionary, IN ULONGLONG Key, IN ULONG Size, IN ULONG Tag, OUT PVOID *Entry)
Definition: dictlib.c:60
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
uint32_t ULONG_PTR
Definition: typedefs.h:63
FORCEINLINE VOID IoCopyCurrentIrpStackLocationToNext(_Inout_ PIRP Irp)
Definition: iofuncs.h:2820
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
PAGED_CODE()
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
ULONG BreakOnClose
Definition: create.c:26
* PFILE_OBJECT
Definition: iotypes.h:1955
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define CLASS_TAG_FILE_OBJECT_EXTENSION
Definition: classpnp.h:78
VOID NTAPI ClasspCleanupDisableMcn(IN PFILE_OBJECT_EXTENSION FsContext)
Definition: create.c:409
struct _cl_event * event
Definition: glext.h:7739
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:574
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
DICTIONARY FileObjectDictionary
Definition: classpnp.h:607
VOID NTAPI FreeDictionaryEntry(IN PDICTIONARY Dictionary, IN PVOID Entry)
Definition: dictlib.c:171
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
return STATUS_SUCCESS
Definition: btrfs.c:2938
PFILE_OBJECT FileObject
Definition: classpnp.h:532
static SERVICE_STATUS status
Definition: service.c:31
HRESULT Create([out]ITransactionReceiver **ppReceiver)
Definition: ps.c:97

Referenced by ClassCreateClose().

◆ ClasspDisablePowerNotification()

VOID NTAPI ClasspDisablePowerNotification ( PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

◆ ClasspDisableTimer()

NTSTATUS NTAPI ClasspDisableTimer ( PDEVICE_OBJECT  DeviceObject)

Definition at line 3285 of file autorun.c.

3288 {
3289  //PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
3290  //PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
3291  //PMEDIA_CHANGE_DETECTION_INFO mCDInfo = fdoExtension->MediaChangeDetectionInfo;
3292  //PFAILURE_PREDICTION_INFO fPInfo = fdoExtension->FailurePredictionInfo;
3293  //NTSTATUS status;
3294 
3295  PAGED_CODE();
3296 
3297  if (DeviceObject->Timer != NULL) {
3298 
3299  //
3300  // we are only going to stop the actual timer in remove device routine.
3301  // it is the responsibility of the code within the timer routine to
3302  // check if the device is removed and not processing io for the final
3303  // call.
3304  // this keeps the code clean and prevents lots of bugs.
3305  //
3306 
3307 
3309  DebugPrint((3, "ClasspDisableTimer: Once a second timer disabled "
3310  "for device %p\n", DeviceObject));
3311 
3312  } else {
3313 
3314  DebugPrint((1, "ClasspDisableTimer: Timer never enabled\n"));
3315 
3316  }
3317 
3318  return STATUS_SUCCESS;
3319 } // end ClasspDisableTimer()
#define PAGED_CODE()
Definition: video.h:57
VOID NTAPI IoStopTimer(PDEVICE_OBJECT DeviceObject)
Definition: iotimer.c:166
smooth NULL
Definition: ftsmooth.c:416
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
return STATUS_SUCCESS
Definition: btrfs.c:2938

Referenced by ClassPnpStartDevice(), ClassRemoveDevice(), and ClassSetFailurePredictionPoll().

◆ ClasspEjectionControl()

NTSTATUS NTAPI ClasspEjectionControl ( IN PDEVICE_OBJECT  Fdo,
IN PIRP  Irp,
IN MEDIA_LOCK_TYPE  LockType,
IN BOOLEAN  Lock 
)

Definition at line 449 of file create.c.

455 {
456  PFUNCTIONAL_DEVICE_EXTENSION FdoExtension = Fdo->DeviceExtension;
457  PCOMMON_DEVICE_EXTENSION commonExtension =
459 
460  PFILE_OBJECT_EXTENSION fsContext = NULL;
462  volatile PSCSI_REQUEST_BLOCK srb = NULL;
463  BOOLEAN countChanged = FALSE;
464 
465  PAGED_CODE();
466 
467  //
468  // Interlock with ejection and secure lock cleanup code. This is a
469  // user request so we can allow the stack to get swapped out while we
470  // wait for synchronization.
471  //
472 
474  &(FdoExtension->EjectSynchronizationEvent),
475  UserRequest,
476  UserMode,
477  FALSE,
478  NULL);
479 
481 
482  DebugPrint((2,
483  "ClasspEjectionControl: "
484  "Received request for %s lock type\n",
485  LockTypeStrings[LockType]
486  ));
487 
488  _SEH2_TRY {
489  PCDB cdb;
490 
492 
493  if(srb == NULL) {
495  _SEH2_LEAVE;
496  }
497 
498  RtlZeroMemory(srb, sizeof(SCSI_REQUEST_BLOCK));
499 
500  cdb = (PCDB) srb->Cdb;
501 
502  //
503  // Determine if this is a "secured" request.
504  //
505 
506  if(LockType == SecureMediaLock) {
507 
509  PFILE_OBJECT fileObject = irpStack->FileObject;
510 
511  //
512  // Make sure that the file object we are supplied has a
513  // proper FsContext before we try doing a secured lock.
514  //
515 
516  if(fileObject != NULL) {
517  fsContext = ClasspGetFsContext(commonExtension, fileObject);
518  }
519 
520  if (fsContext == NULL) {
521 
522  //
523  // This handle isn't setup correctly. We can't let the
524  // operation go.
525  //
526 
528  _SEH2_LEAVE;
529  }
530  }
531 
532  if(Lock) {
533 
534  //
535  // This is a lock command. Reissue the command in case bus or
536  // device was reset and the lock was cleared.
537  // note: may need to decrement count if actual lock operation
538  // failed....
539  //
540 
541  switch(LockType) {
542 
543  case SimpleMediaLock: {
544  FdoExtension->LockCount++;
545  countChanged = TRUE;
546  break;
547  }
548 
549  case SecureMediaLock: {
550  fsContext->LockCount++;
551  FdoExtension->ProtectedLockCount++;
552  countChanged = TRUE;
553  break;
554  }
555 
556  case InternalMediaLock: {
557  FdoExtension->InternalLockCount++;
558  countChanged = TRUE;
559  break;
560  }
561  }
562 
563  } else {
564 
565  //
566  // This is an unlock command. If it's a secured one then make sure
567  // the caller has a lock outstanding or return an error.
568  // note: may need to re-increment the count if actual unlock
569  // operation fails....
570  //
571 
572  switch(LockType) {
573 
574  case SimpleMediaLock: {
575  if(FdoExtension->LockCount != 0) {
576  FdoExtension->LockCount--;
577  countChanged = TRUE;
578  }
579  break;
580  }
581 
582  case SecureMediaLock: {
583  if(fsContext->LockCount == 0) {
585  _SEH2_LEAVE;
586  }
587  fsContext->LockCount--;
588  FdoExtension->ProtectedLockCount--;
589  countChanged = TRUE;
590  break;
591  }
592 
593  case InternalMediaLock: {
594  ASSERT(FdoExtension->InternalLockCount != 0);
595  FdoExtension->InternalLockCount--;
596  countChanged = TRUE;
597  break;
598  }
599  }
600 
601  //
602  // We only send an unlock command to the drive if both the
603  // secured and unsecured lock counts have dropped to zero.
604  //
605 
606  if((FdoExtension->ProtectedLockCount != 0) ||
607  (FdoExtension->InternalLockCount != 0) ||
608  (FdoExtension->LockCount != 0)) {
609 
611  _SEH2_LEAVE;
612  }
613  }
614 
616  if (TEST_FLAG(Fdo->Characteristics, FILE_REMOVABLE_MEDIA)) {
617 
618  srb->CdbLength = 6;
619  cdb->MEDIA_REMOVAL.OperationCode = SCSIOP_MEDIUM_REMOVAL;
620 
621  //
622  // TRUE - prevent media removal.
623  // FALSE - allow media removal.
624  //
625 
626  cdb->MEDIA_REMOVAL.Prevent = Lock;
627 
628  //
629  // Set timeout value.
630  //
631 
632  srb->TimeOutValue = FdoExtension->TimeOutValue;
633 
634  //
635  // The actual lock operation on the device isn't so important
636  // as the internal lock counts. Ignore failures.
637  //
638 
640  srb,
641  NULL,
642  0,
643  FALSE);
644  }
645 
646  } _SEH2_FINALLY {
647 
648  if (!NT_SUCCESS(status)) {
649  DebugPrint((2,
650  "ClasspEjectionControl: FAILED status %x -- "
651  "reverting lock counts\n", status));
652 
653  if (countChanged) {
654 
655  //
656  // have to revert to previous counts if the
657  // lock/unlock operation actually failed.
658  //
659 
660  if(Lock) {
661 
662  switch(LockType) {
663 
664  case SimpleMediaLock: {
665  FdoExtension->LockCount--;
666  break;
667  }
668 
669  case SecureMediaLock: {
670  fsContext->LockCount--;
671  FdoExtension->ProtectedLockCount--;
672  break;
673  }
674 
675  case InternalMediaLock: {
676  FdoExtension->InternalLockCount--;
677  break;
678  }
679  }
680 
681  } else {
682 
683  switch(LockType) {
684 
685  case SimpleMediaLock: {
686  FdoExtension->LockCount++;
687  break;
688  }
689 
690  case SecureMediaLock: {
691  fsContext->LockCount++;
692  FdoExtension->ProtectedLockCount++;
693  break;
694  }
695 
696  case InternalMediaLock: {
697  FdoExtension->InternalLockCount++;
698  break;
699  }
700  }
701  }
702 
703  }
704 
705  } else {
706 
707  DebugPrint((2,
708  "ClasspEjectionControl: Succeeded\n"));
709 
710  }
711 
712  DebugPrint((2,
713  "ClasspEjectionControl: "
714  "Current Counts: Internal: %x Secure: %x Simple: %x\n",
715  FdoExtension->InternalLockCount,
716  FdoExtension->ProtectedLockCount,
717  FdoExtension->LockCount
718  ));
719 
720  KeSetEvent(&(FdoExtension->EjectSynchronizationEvent),
722  FALSE);
723  if (srb) {
725  }
726 
727  } _SEH2_END;
728  return status;
729 }
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
UCHAR Cdb[16]
Definition: srb.h:271
struct _CDB::_MEDIA_REMOVAL MEDIA_REMOVAL
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
Definition: cdrw_hw.h:28
LONG NTSTATUS
Definition: precomp.h:26
UCHAR CdbLength
Definition: srb.h:250
ULONG TimeOutValue
Definition: srb.h:254
LONG NTAPI KeSetEvent(IN PKEVENT Event, IN KPRIORITY Increment, IN BOOLEAN Wait)
Definition: eventobj.c:159
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
PFILE_OBJECT_EXTENSION NTAPI ClasspGetFsContext(IN PCOMMON_DEVICE_EXTENSION CommonExtension, IN PFILE_OBJECT FileObject)
Definition: create.c:969
_SEH2_TRY
Definition: create.c:4250
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
union _CDB * PCDB
PAGED_CODE()
#define ClasspAllocateSrb(ext)
Definition: classpnp.h:143
NTSTATUS NTAPI ClassSendSrbSynchronous(PDEVICE_OBJECT Fdo, PSCSI_REQUEST_BLOCK Srb, PVOID BufferAddress, ULONG BufferLength, BOOLEAN WriteToDevice)
Definition: class.c:2648
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PCSTR LockTypeStrings[]
Definition: create.c:28
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
* PFILE_OBJECT
Definition: iotypes.h:1955
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define SCSIOP_MEDIUM_REMOVAL
Definition: cdrw_hw.h:902
IN OUT PLONG IN OUT PLONG Addend IN OUT PLONG IN LONG IN OUT PLONG IN LONG Increment IN PNDIS_RW_LOCK Lock
Definition: CrNtStubs.h:75
VOID NTAPI ClassFreeOrReuseSrb(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PSCSI_REQUEST_BLOCK Srb)
Definition: obsolete.c:824
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
_SEH2_END
Definition: create.c:4424
_SEH2_FINALLY
Definition: create.c:4395
#define IO_NO_INCREMENT
Definition: iotypes.h:566
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define _SEH2_LEAVE
Definition: filesup.c:20
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by ClassDeviceControl(), and ClassDispatchPnp().

◆ ClasspEnableTimer()

NTSTATUS NTAPI ClasspEnableTimer ( PDEVICE_OBJECT  DeviceObject)

Definition at line 3234 of file autorun.c.

3237 {
3238  NTSTATUS status;
3239 
3240  PAGED_CODE();
3241 
3242  if (DeviceObject->Timer == NULL) {
3243 
3245 
3246  } else {
3247 
3249 
3250  }
3251 
3252  if (NT_SUCCESS(status)) {
3253 
3255  DebugPrint((1, "ClasspEnableTimer: Once a second timer enabled "
3256  "for device %p\n", DeviceObject));
3257 
3258  }
3259 
3260  DebugPrint((1, "ClasspEnableTimer: Device %p, Status %lx "
3261  "initializing timer\n", DeviceObject, status));
3262 
3263  return status;
3264 
3265 } // end ClasspEnableTimer()
VOID NTAPI IoStartTimer(IN PDEVICE_OBJECT DeviceObject)
Definition: iotimer.c:133
LONG NTSTATUS
Definition: precomp.h:26
#define PAGED_CODE()
Definition: video.h:57
VOID NTAPI ClasspTimerTick(PDEVICE_OBJECT DeviceObject, PVOID Context)
Definition: autorun.c:3086
smooth NULL
Definition: ftsmooth.c:416
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSTATUS NTAPI IoInitializeTimer(IN PDEVICE_OBJECT DeviceObject, IN PIO_TIMER_ROUTINE TimerRoutine, IN PVOID Context)
Definition: iotimer.c:92
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by ClassPnpStartDevice(), and ClassSetFailurePredictionPoll().

◆ ClasspFreeReleaseRequest()

VOID NTAPI ClasspFreeReleaseRequest ( IN PDEVICE_OBJECT  Fdo)

Definition at line 8098 of file class.c.

8101 {
8102  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
8103  //KIRQL oldIrql;
8104 
8105  ASSERT(fdoExtension->CommonExtension.IsRemoved != NO_REMOVE);
8106 
8107  //
8108  // free anything the driver allocated
8109  //
8110 
8111  if (fdoExtension->ReleaseQueueIrp) {
8112  if (fdoExtension->ReleaseQueueIrpFromPool) {
8113  ExFreePool(fdoExtension->ReleaseQueueIrp);
8114  } else {
8115  IoFreeIrp(fdoExtension->ReleaseQueueIrp);
8116  }
8117  fdoExtension->ReleaseQueueIrp = NULL;
8118  }
8119 
8120  //
8121  // free anything that we allocated
8122  //
8123 
8124  if ((fdoExtension->PrivateFdoData) &&
8125  (fdoExtension->PrivateFdoData->ReleaseQueueIrpAllocated)) {
8126 
8127  ExFreePool(fdoExtension->PrivateFdoData->ReleaseQueueIrp);
8128  fdoExtension->PrivateFdoData->ReleaseQueueIrpAllocated = FALSE;
8129  fdoExtension->PrivateFdoData->ReleaseQueueIrp = NULL;
8130  }
8131 
8132  return;
8133 } // end ClasspFreeReleaseRequest()
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:695
smooth NULL
Definition: ftsmooth.c:416
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define NO_REMOVE
Definition: classpnp.h:93
VOID NTAPI IoFreeIrp(IN PIRP Irp)
Definition: irp.c:1666
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by ClassRemoveDevice().

◆ ClasspGetFsContext()

PFILE_OBJECT_EXTENSION NTAPI ClasspGetFsContext ( IN PCOMMON_DEVICE_EXTENSION  CommonExtension,
IN PFILE_OBJECT  FileObject 
)

Definition at line 969 of file create.c.

973 {
974  PAGED_CODE();
975  return GetDictionaryEntry(&(CommonExtension->FileObjectDictionary),
977 }
uint32_t ULONG_PTR
Definition: typedefs.h:63
_In_ PIO_STACK_LOCATION _Inout_ PFILE_OBJECT FileObject
Definition: create.c:4157
PAGED_CODE()
PVOID NTAPI GetDictionaryEntry(IN PDICTIONARY Dictionary, IN ULONGLONG Key)
Definition: dictlib.c:139

Referenced by ClasspCreateClose(), ClasspEjectionControl(), and ClasspMcnControl().

◆ ClasspInitializeGesn()

NTSTATUS NTAPI ClasspInitializeGesn ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
IN PMEDIA_CHANGE_DETECTION_INFO  Info 
)

Definition at line 1668 of file autorun.c.

1672 {
1675  PSTORAGE_ADAPTER_DESCRIPTOR adapterDescriptor;
1677  PIRP irp;
1678  KEVENT event;
1679  BOOLEAN retryImmediately;
1680  ULONG i;
1681  ULONG atapiResets;
1682 
1683 
1684  PAGED_CODE();
1685  ASSERT(Info == FdoExtension->MediaChangeDetectionInfo);
1686 
1687  //
1688  // read if we already know the abilities of the device
1689  //
1690 
1694  (PULONG)&detectionState);
1695 
1696  if (detectionState == ClassDetectionUnsupported) {
1697  goto ExitWithError;
1698  }
1699 
1700  //
1701  // check if the device has a hack flag saying never to try this.
1702  //
1703 
1704  if (TEST_FLAG(FdoExtension->PrivateFdoData->HackFlags,
1706 
1707  detectionState = ClassDetectionUnsupported;
1712  goto ExitWithError;
1713 
1714  }
1715 
1716 
1717  //
1718  // else go through the process since we allocate buffers and
1719  // get all sorts of device settings.
1720  //
1721 
1722  if (Info->Gesn.Buffer == NULL) {
1725  '??cS');
1726  }
1727  if (Info->Gesn.Buffer == NULL) {
1729  goto ExitWithError;
1730  }
1731  if (Info->Gesn.Mdl != NULL) {
1732  IoFreeMdl(Info->Gesn.Mdl);
1733  }
1734  Info->Gesn.Mdl = IoAllocateMdl(Info->Gesn.Buffer,
1736  FALSE, FALSE, NULL);
1737  if (Info->Gesn.Mdl == NULL) {
1739  goto ExitWithError;
1740  }
1741 
1742  MmBuildMdlForNonPagedPool(Info->Gesn.Mdl);
1743  Info->Gesn.BufferSize = GESN_BUFFER_SIZE;
1744  Info->Gesn.EventMask = 0;
1745 
1746  //
1747  // all items are prepared to use GESN (except the event mask, so don't
1748  // optimize this part out!).
1749  //
1750  // now see if it really works. we have to loop through this because
1751  // many SAMSUNG (and one COMPAQ) drives timeout when requesting
1752  // NOT_READY events, even when the IMMEDIATE bit is set. :(
1753  //
1754  // using a drive list is cumbersome, so this might fix the problem.
1755  //
1756 
1757  adapterDescriptor = FdoExtension->AdapterDescriptor;
1758  atapiResets = 0;
1759  retryImmediately = TRUE;
1760  for (i = 0; (i < 16) && (retryImmediately != FALSE); i++) {
1761 
1763  if (irp == NULL) {
1765  goto ExitWithError;
1766  }
1767 
1768  ASSERT(TEST_FLAG(Info->MediaChangeSrb.SrbFlags, SRB_FLAGS_NO_QUEUE_FREEZE));
1769 
1770  //
1771  // replace the completion routine with a different one this time...
1772  //
1773 
1776  &event,
1777  TRUE, TRUE, TRUE);
1779 
1780  status = IoCallDriver(FdoExtension->CommonExtension.LowerDeviceObject, irp);
1781 
1782  if (status == STATUS_PENDING) {
1784  Executive,
1785  KernelMode,
1786  FALSE,
1787  NULL);
1789  }
1790  ClassReleaseRemoveLock(FdoExtension->DeviceObject, irp);
1791 
1792  if (SRB_STATUS(Info->MediaChangeSrb.SrbStatus) != SRB_STATUS_SUCCESS) {
1793  ClassInterpretSenseInfo(FdoExtension->DeviceObject,
1794  &(Info->MediaChangeSrb),
1795  IRP_MJ_SCSI,
1796  0,
1797  0,
1798  &status,
1799  NULL);
1800  }
1801 
1802  if ((adapterDescriptor->BusType == BusTypeAtapi) &&
1803  (Info->MediaChangeSrb.SrbStatus == SRB_STATUS_BUS_RESET)
1804  ) {
1805 
1806  //
1807  // ATAPI unfortunately returns SRB_STATUS_BUS_RESET instead
1808  // of SRB_STATUS_TIMEOUT, so we cannot differentiate between
1809  // the two. if we get this status four time consecutively,
1810  // stop trying this command. it is too late to change ATAPI
1811  // at this point, so special-case this here. (07/10/2001)
1812  // NOTE: any value more than 4 may cause the device to be
1813  // marked missing.
1814  //
1815 
1816  atapiResets++;
1817  if (atapiResets >= 4) {
1819  goto ExitWithError;
1820  }
1821  }
1822 
1823  if (status == STATUS_DATA_OVERRUN) {
1825  }
1826 
1828  (status == STATUS_TIMEOUT) ||
1831  ) {
1832 
1833  //
1834  // with these error codes, we don't ever want to try this command
1835  // again on this device, since it reacts poorly.
1836  //
1837 
1843  "Classpnp => GESN test failed %x for fdo %p\n",
1844  status, FdoExtension->DeviceObject));
1845  goto ExitWithError;
1846 
1847 
1848  }
1849 
1850  if (!NT_SUCCESS(status)) {
1851 
1852  //
1853  // this may be other errors that should not disable GESN
1854  // for all future start_device calls.
1855  //
1856 
1858  "Classpnp => GESN test failed %x for fdo %p\n",
1859  status, FdoExtension->DeviceObject));
1860  goto ExitWithError;
1861  }
1862 
1863  if (i == 0) {
1864 
1865  //
1866  // the first time, the request was just retrieving a mask of
1867  // available bits. use this to mask future requests.
1868  //
1869 
1870  header = (PNOTIFICATION_EVENT_STATUS_HEADER)(Info->Gesn.Buffer);
1871 
1873  "Classpnp => Fdo %p supports event mask %x\n",
1874  FdoExtension->DeviceObject, header->SupportedEventClasses));
1875 
1876 
1877  if (TEST_FLAG(header->SupportedEventClasses,
1880  "Classpnp => GESN supports MCN\n"));
1881  }
1882  if (TEST_FLAG(header->SupportedEventClasses,
1885  "Classpnp => GESN supports DeviceBusy\n"));
1886  }
1887  Info->Gesn.EventMask = header->SupportedEventClasses;
1888 
1889  //
1890  // realistically, we are only considering the following events:
1891  // EXTERNAL REQUEST - this is being tested for play/stop/etc.
1892  // MEDIA STATUS - autorun and ejection requests.
1893  // DEVICE BUSY - to allow us to predict when media will be ready.
1894  // therefore, we should not bother querying for the other,
1895  // unknown events. clear all but the above flags.
1896  //
1897 
1898  Info->Gesn.EventMask &=
1902 
1903 
1904  //
1905  // HACKHACK - REF #0001
1906  // Some devices will *never* report an event if we've also requested
1907  // that it report lower-priority events. this is due to a
1908  // misunderstanding in the specification wherein a "No Change" is
1909  // interpreted to be a real event. what should occur is that the
1910  // device should ignore "No Change" events when multiple event types
1911  // are requested unless there are no other events waiting. this
1912  // greatly reduces the number of requests that the host must send
1913  // to determine if an event has occurred. Since we must work on all
1914  // drives, default to enabling the hack until we find evidence of
1915  // proper firmware.
1916  //
1917 
1918  if (CountOfSetBitsUChar(Info->Gesn.EventMask) == 1) {
1920  "Classpnp => GESN hack %s for FDO %p\n",
1921  "not required", FdoExtension->DeviceObject));
1922  } else {
1924  "Classpnp => GESN hack %s for FDO %p\n",
1925  "enabled", FdoExtension->DeviceObject));
1926  Info->Gesn.HackEventMask = 1;
1927  }
1928 
1929  } else {
1930 
1931  //
1932  // not the first time looping through, so interpret the results.
1933  //
1934 
1936  (PVOID)Info->Gesn.Buffer,
1937  &retryImmediately);
1938 
1939  }
1940 
1941  } // end loop of GESN requests....
1942 
1943  //
1944  // we can only use this if it can be relied upon for media changes,
1945  // since we are (by definition) no longer going to be polling via
1946  // a TEST_UNIT_READY irp, and drives will not report UNIT ATTENTION
1947  // for this command (although a filter driver, such as one for burning
1948  // cd's, might still fake those errors).
1949  //
1950  // since we also rely upon NOT_READY events to change the cursor
1951  // into a "wait" cursor, we can't use GESN without NOT_READY support.
1952  //
1953 
1954  if (TEST_FLAG(Info->Gesn.EventMask,
1956  TEST_FLAG(Info->Gesn.EventMask,
1958  ) {
1959 
1961  "Classpnp => Enabling GESN support for fdo %p\n",
1962  FdoExtension->DeviceObject));
1963  Info->Gesn.Supported = TRUE;
1964 
1969 
1970  return STATUS_SUCCESS;
1971 
1972  }
1973 
1975  "Classpnp => GESN available but not enabled for fdo %p\n",
1976  FdoExtension->DeviceObject));
1977  goto ExitWithError;
1978 
1979  // fall through...
1980 
1981 ExitWithError:
1982  if (Info->Gesn.Mdl) {
1983  IoFreeMdl(Info->Gesn.Mdl);
1984  Info->Gesn.Mdl = NULL;
1985  }
1986  if (Info->Gesn.Buffer) {
1987  ExFreePool(Info->Gesn.Buffer);
1988  Info->Gesn.Buffer = NULL;
1989  }
1990  Info->Gesn.Supported = 0;
1991  Info->Gesn.EventMask = 0;
1992  Info->Gesn.BufferSize = 0;
1993  return STATUS_NOT_SUPPORTED;
1994 
1995 }
#define SRB_STATUS_BUS_RESET
Definition: srb.h:345
#define TRUE
Definition: types.h:120
* PSTORAGE_ADAPTER_DESCRIPTOR
Definition: ntddstor.h:476
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define STATUS_DATA_OVERRUN
Definition: udferr_usr.h:152
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
#define NOTIFICATION_MEDIA_STATUS_CLASS_MASK
Definition: scsi.h:37
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:396
#define NOTIFICATION_EXTERNAL_REQUEST_CLASS_MASK
Definition: scsi.h:36
VOID NTAPI MmBuildMdlForNonPagedPool(IN PMDL Mdl)
Definition: mdlsup.c:428
IO_COMPLETION_ROUTINE ClassSignalCompletion
Definition: classpnp.h:1137
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
#define NOTIFICATION_DEVICE_BUSY_CLASS_MASK
Definition: scsi.h:39
NTSTATUS NTAPI KeWaitForSingleObject(IN PVOID Object, IN KWAIT_REASON WaitReason, IN KPROCESSOR_MODE WaitMode, IN BOOLEAN Alertable, IN PLARGE_INTEGER Timeout OPTIONAL)
Definition: wait.c:416
#define SRB_STATUS(Status)
Definition: srb.h:381
struct TraceInfo Info
#define PAGED_CODE()
Definition: video.h:57
#define KdPrintEx(_x_)
Definition: kdfuncs.h:114
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
#define IRP_MJ_SCSI
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define STATUS_TIMEOUT
Definition: ntstatus.h:81
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
NTSTATUS NTAPI ClassSetDeviceParameter(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PWSTR SubkeyName OPTIONAL, IN PWSTR ParameterName, IN ULONG ParameterValue)
Definition: utils.c:136
__inline ULONG CountOfSetBitsUChar(UCHAR _X)
Definition: tools.h:150
BOOLEAN NTAPI ClassInterpretSenseInfo(IN PDEVICE_OBJECT Fdo, IN PSCSI_REQUEST_BLOCK Srb, IN UCHAR MajorFunctionCode, IN ULONG IoDeviceCode, IN ULONG RetryCount, OUT NTSTATUS *Status, OUT OPTIONAL ULONG *RetryInterval)
Definition: class.c:2994
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI ClassGetDeviceParameter(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PWSTR SubkeyName OPTIONAL, IN PWSTR ParameterName, IN OUT PULONG ParameterValue)
Definition: utils.c:52
PIRP NTAPI ClasspPrepareMcnIrp(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMEDIA_CHANGE_DETECTION_INFO Info, IN BOOLEAN UseGesn)
Definition: autorun.c:1036
enum _CLASS_DETECTION_STATE CLASS_DETECTION_STATE
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_PENDING
Definition: ntstatus.h:82
VOID NTAPI IoFreeMdl(PMDL Mdl)
Definition: iomdl.c:146
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define CLASSP_REG_SUBKEY_NAME
Definition: classp.h:41
struct _cl_event * event
Definition: glext.h:7739
PMDL NTAPI IoAllocateMdl(IN PVOID VirtualAddress, IN ULONG Length, IN BOOLEAN SecondaryBuffer, IN BOOLEAN ChargeQuota, IN PIRP Irp)
Definition: iomdl.c:22
#define FDO_HACK_GESN_IS_BAD
Definition: classp.h:54
VOID NTAPI ClasspInterpretGesnData(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PNOTIFICATION_EVENT_STATUS_HEADER Header, IN PBOOLEAN ResendImmediately)
Definition: autorun.c:286
#define CLASSP_REG_MMC_DETECTION_VALUE_NAME
Definition: classp.h:44
#define KeInitializeEvent(pEvt, foo, foo2)
Definition: env_spec_w32.h:477
struct _NOTIFICATION_EVENT_STATUS_HEADER * PNOTIFICATION_EVENT_STATUS_HEADER
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
#define GESN_BUFFER_SIZE
Definition: autorun.c:29
#define STATUS_IO_TIMEOUT
Definition: udferr_usr.h:163
#define STATUS_NOT_SUPPORTED
Definition: ntstatus.h:409
unsigned int ULONG
Definition: retypes.h:1
#define SRB_STATUS_SUCCESS
Definition: srb.h:333
return STATUS_SUCCESS
Definition: btrfs.c:2938
struct CFHEADER header
Definition: fdi.c:101
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
VOID NTAPI ClassReleaseRemoveLock(IN PDEVICE_OBJECT DeviceObject, IN OPTIONAL PIRP Tag)
Definition: lock.c:212
Definition: ps.c:97

Referenced by ClasspInitializePolling().

◆ ClasspInitializeHotplugInfo()

NTSTATUS NTAPI ClasspInitializeHotplugInfo ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

Definition at line 8964 of file class.c.

8967 {
8968  PCLASS_PRIVATE_FDO_DATA fdoData = FdoExtension->PrivateFdoData;
8969  DEVICE_REMOVAL_POLICY deviceRemovalPolicy;
8970  NTSTATUS status;
8971  ULONG resultLength = 0;
8972  ULONG writeCacheOverride;
8973 
8974  PAGED_CODE();
8975 
8976  //
8977  // start with some default settings
8978  //
8979  RtlZeroMemory(&(fdoData->HotplugInfo), sizeof(STORAGE_HOTPLUG_INFO));
8980 
8981  //
8982  // set the size (aka version)
8983  //
8984 
8985  fdoData->HotplugInfo.Size = sizeof(STORAGE_HOTPLUG_INFO);
8986 
8987  //
8988  // set if the device has removable media
8989  //
8990 
8991  if (FdoExtension->DeviceDescriptor->RemovableMedia) {
8992  fdoData->HotplugInfo.MediaRemovable = TRUE;
8993  } else {
8994  fdoData->HotplugInfo.MediaRemovable = FALSE;
8995  }
8996 
8997  //
8998  // this refers to devices which, for reasons not yet understood,
8999  // do not fail PREVENT_MEDIA_REMOVAL requests even though they
9000  // have no way to lock the media into the drive. this allows
9001  // the filesystems to turn off delayed-write caching for these
9002  // devices as well.
9003  //
9004 
9005  if (TEST_FLAG(FdoExtension->PrivateFdoData->HackFlags,
9007  fdoData->HotplugInfo.MediaHotplug = TRUE;
9008  } else {
9009  fdoData->HotplugInfo.MediaHotplug = FALSE;
9010  }
9011 
9012 
9013  //
9014  // Look into the registry to see if the user has chosen
9015  // to override the default setting for the removal policy
9016  //
9017 
9018  RtlZeroMemory(&deviceRemovalPolicy, sizeof(DEVICE_REMOVAL_POLICY));
9019 
9023  (PULONG)&deviceRemovalPolicy);
9024 
9025  if (deviceRemovalPolicy == 0)
9026  {
9027  //
9028  // Query the default removal policy from the kernel
9029  //
9030 
9033  sizeof(DEVICE_REMOVAL_POLICY),
9034  (PVOID)&deviceRemovalPolicy,
9035  &resultLength);
9036  if (!NT_SUCCESS(status))
9037  {
9038  return status;
9039  }
9040 
9041  if (resultLength != sizeof(DEVICE_REMOVAL_POLICY))
9042  {
9043  return STATUS_UNSUCCESSFUL;
9044  }
9045  }
9046 
9047  //
9048  // use this info to set the DeviceHotplug setting
9049  // don't rely on DeviceCapabilities, since it can't properly
9050  // determine device relations, etc. let the kernel figure this
9051  // stuff out instead.
9052  //
9053 
9054  if (deviceRemovalPolicy == RemovalPolicyExpectSurpriseRemoval) {
9055  fdoData->HotplugInfo.DeviceHotplug = TRUE;
9056  } else {
9057  fdoData->HotplugInfo.DeviceHotplug = FALSE;
9058  }
9059 
9060  //
9061  // this refers to the *filesystem* caching, but has to be included
9062  // here since it's a per-device setting. this may change to be
9063  // stored by the system in the future.
9064  //
9065 
9066  writeCacheOverride = FALSE;
9070  &writeCacheOverride);
9071 
9072  if (writeCacheOverride) {
9074  } else {
9076  }
9077 
9078  return STATUS_SUCCESS;
9079 }
#define TRUE
Definition: types.h:120
#define CLASSP_REG_REMOVAL_POLICY_VALUE_NAME
Definition: classp.h:47
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
BOOLEAN DeviceHotplug
Definition: imports.h:248
LONG NTSTATUS
Definition: precomp.h:26
STORAGE_HOTPLUG_INFO HotplugInfo
Definition: classp.h:403
#define PAGED_CODE()
Definition: video.h:57
BOOLEAN MediaHotplug
Definition: imports.h:247
NTSTATUS NTAPI IoGetDeviceProperty(IN PDEVICE_OBJECT DeviceObject, IN DEVICE_REGISTRY_PROPERTY DeviceProperty, IN ULONG BufferLength, OUT PVOID PropertyBuffer, OUT PULONG ResultLength)
Definition: pnpmgr.c:4228
VOID NTAPI ClassGetDeviceParameter(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PWSTR SubkeyName OPTIONAL, IN PWSTR ParameterName, IN OUT PULONG ParameterValue)
Definition: utils.c:52
BOOLEAN WriteCacheEnableOverride
Definition: imports.h:249
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
#define CLASSP_REG_SUBKEY_NAME
Definition: classp.h:41
enum _DEVICE_REMOVAL_POLICY DEVICE_REMOVAL_POLICY
unsigned int * PULONG
Definition: retypes.h:1
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
BOOLEAN MediaRemovable
Definition: imports.h:246
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
#define FDO_HACK_CANNOT_LOCK_MEDIA
Definition: classp.h:53
struct _STORAGE_HOTPLUG_INFO STORAGE_HOTPLUG_INFO
#define CLASSP_REG_WRITE_CACHE_VALUE_NAME
Definition: classp.h:45
Definition: ps.c:97

Referenced by ClassPnpStartDevice().

◆ ClasspMcnControl()

NTSTATUS NTAPI ClasspMcnControl ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
IN PIRP  Irp,
IN PSCSI_REQUEST_BLOCK  Srb 
)

Definition at line 2890 of file autorun.c.

2895 {
2896  PCOMMON_DEVICE_EXTENSION commonExtension =
2898 
2900  PPREVENT_MEDIA_REMOVAL request = Irp->AssociatedIrp.SystemBuffer;
2901 
2902  PFILE_OBJECT fileObject = irpStack->FileObject;
2903  PFILE_OBJECT_EXTENSION fsContext = NULL;
2904 
2906 
2907  PAGED_CODE();
2908 
2909  //
2910  // Check to make sure we have a file object extension to keep track of this
2911  // request. If not we'll fail it before synchronizing.
2912  //
2913 
2914  TRY {
2915 
2916  if(fileObject != NULL) {
2917  fsContext = ClasspGetFsContext(commonExtension, fileObject);
2918  }else if(Irp->RequestorMode == KernelMode) { // && fileObject == NULL
2919  fsContext = &FdoExtension->KernelModeMcnContext;
2920  }
2921 
2922  if (fsContext == NULL) {
2923 
2924  //
2925  // This handle isn't setup correctly. We can't let the
2926  // operation go.
2927  //
2928 
2930  LEAVE;
2931  }
2932 
2933  if(request->PreventMediaRemoval) {
2934 
2935  //
2936  // This is a lock command. Reissue the command in case bus or
2937  // device was reset and the lock was cleared.
2938  //
2939 
2942 
2943  } else {
2944 
2945  if(fsContext->McnDisableCount == 0) {
2947  LEAVE;
2948  }
2949 
2952  }
2953 
2954  } FINALLY {
2955 
2956  Irp->IoStatus.Status = status;
2957 
2958  if(Srb) {
2959  ExFreePool(Srb);
2960  }
2961 
2962  ClassReleaseRemoveLock(FdoExtension->DeviceObject, Irp);
2963  ClassCompleteRequest(FdoExtension->DeviceObject,
2964  Irp,
2965  IO_NO_INCREMENT);
2966  }
2967  return status;
2968 } // end ClasspMcnControl(
PFILE_OBJECT_EXTENSION NTAPI ClasspGetFsContext(IN PCOMMON_DEVICE_EXTENSION CommonExtension, IN PFILE_OBJECT FileObject)
Definition: create.c:969
#define FINALLY
Definition: classpnp.h:113
VOID NTAPI ClassDisableMediaChangeDetection(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: autorun.c:2803
_In_ PIRP Irp
Definition: csq.h:116
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define LEAVE
Definition: classpnp.h:112
#define TRY(sps, bps)
#define PAGED_CODE()
Definition: video.h:57
#define STATUS_INVALID_DEVICE_STATE
Definition: udferr_usr.h:178
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI ClassEnableMediaChangeDetection(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: autorun.c:2718
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
* PFILE_OBJECT
Definition: iotypes.h:1955
#define InterlockedDecrement
Definition: armddk.h:52
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2745
PFILE_OBJECT FileObject
Definition: iotypes.h:2813
#define InterlockedIncrement
Definition: armddk.h:53
VOID NTAPI ClassCompleteRequest(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN CCHAR PriorityBoost)
Definition: lock.c:376
Definition: tftpd.h:85
#define IO_NO_INCREMENT
Definition: iotypes.h:566
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
return STATUS_SUCCESS
Definition: btrfs.c:2938
signed int * PLONG
Definition: retypes.h:5
static SERVICE_STATUS status
Definition: service.c:31
#define ExFreePool(addr)
Definition: env_spec_w32.h:352
VOID NTAPI ClassReleaseRemoveLock(IN PDEVICE_OBJECT DeviceObject, IN OPTIONAL PIRP Tag)
Definition: lock.c:212
Definition: ps.c:97

Referenced by ClassDeviceControl().

◆ ClasspMediaChangeCompletion()

NTSTATUS NTAPI ClasspMediaChangeCompletion ( PDEVICE_OBJECT  DeviceObject,
PIRP  Irp,
PVOID  Context 
)

◆ ClassPnpQueryFdoRelations()

NTSTATUS NTAPI ClassPnpQueryFdoRelations ( IN PDEVICE_OBJECT  Fdo,
IN PIRP  Irp 
)

Definition at line 6551 of file class.c.

6555 {
6556  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
6558  driverExtension = IoGetDriverObjectExtension(Fdo->DriverObject,
6560 
6561  PAGED_CODE();
6562 
6563  //
6564  // If there's already an enumeration in progress then don't start another
6565  // one.
6566  //
6567 
6568  if(InterlockedIncrement((PLONG)&fdoExtension->EnumerationInterlock) == 1) {
6569  driverExtension->InitData.ClassEnumerateDevice(Fdo);
6570  }
6571 
6572  Irp->IoStatus.Information = (ULONG_PTR) NULL;
6573 
6574  Irp->IoStatus.Status = ClassRetrieveDeviceRelations(
6575  Fdo,
6576  BusRelations,
6577  (PDEVICE_RELATIONS*)&Irp->IoStatus.Information);
6579 
6580  return Irp->IoStatus.Status;
6581 } // end ClassPnpQueryFdoRelations()
#define CLASS_DRIVER_EXTENSION_KEY
Definition: classpnp.h:91
_In_ PIRP Irp
Definition: csq.h:116
#define PAGED_CODE()
Definition: video.h:57
smooth NULL
Definition: ftsmooth.c:416
#define InterlockedDecrement
Definition: armddk.h:52
PCLASS_ENUM_DEVICE ClassEnumerateDevice
Definition: classpnp.h:524
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
#define InterlockedIncrement
Definition: armddk.h:53
NTSTATUS NTAPI ClassRetrieveDeviceRelations(IN PDEVICE_OBJECT Fdo, IN DEVICE_RELATION_TYPE RelationType, OUT PDEVICE_RELATIONS *DeviceRelations)
Definition: class.c:6709
CLASS_INIT_DATA InitData
Definition: classpnp.h:556
#define ULONG_PTR
Definition: config.h:101
signed int * PLONG
Definition: retypes.h:5

Referenced by ClassDispatchPnp().

◆ ClassPnpStartDevice()

NTSTATUS NTAPI ClassPnpStartDevice ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 1265 of file class.c.

1266 {
1267  PCLASS_DRIVER_EXTENSION driverExtension;
1268  PCLASS_INIT_DATA initData;
1269 
1270  PCLASS_DEV_INFO devInfo;
1271 
1274  BOOLEAN isFdo = commonExtension->IsFdo;
1275 
1276  BOOLEAN isMountedDevice = TRUE;
1277  //UNICODE_STRING interfaceName;
1278 
1279  BOOLEAN timerStarted;
1280 
1282 
1283  PAGED_CODE();
1284 
1285  driverExtension = IoGetDriverObjectExtension(DeviceObject->DriverObject,
1287 
1288  initData = &(driverExtension->InitData);
1289  if(isFdo) {
1290  devInfo = &(initData->FdoData);
1291  } else {
1292  devInfo = &(initData->PdoData);
1293  }
1294 
1295  ASSERT(devInfo->ClassInitDevice != NULL);
1296  ASSERT(devInfo->ClassStartDevice != NULL);
1297 
1298  if (!commonExtension->IsInitialized){
1299 
1300  //
1301  // perform FDO/PDO specific initialization
1302  //
1303 
1304  if (isFdo){
1305  STORAGE_PROPERTY_ID propertyId;
1306 
1307  //
1308  // allocate a private extension for class data
1309  //
1310 
1311  if (fdoExtension->PrivateFdoData == NULL) {
1312  fdoExtension->PrivateFdoData =
1314  sizeof(CLASS_PRIVATE_FDO_DATA),
1316  );
1317  }
1318 
1319  if (fdoExtension->PrivateFdoData == NULL) {
1320  DebugPrint((0, "ClassPnpStartDevice: Cannot allocate for "
1321  "private fdo data\n"));
1323  }
1324 
1325  //
1326  // initialize the struct's various fields.
1327  //
1328 
1329  RtlZeroMemory(fdoExtension->PrivateFdoData,
1330  sizeof(CLASS_PRIVATE_FDO_DATA)
1331  );
1332  KeInitializeTimer(&fdoExtension->PrivateFdoData->Retry.Timer);
1333  KeInitializeDpc(&fdoExtension->PrivateFdoData->Retry.Dpc,
1335  DeviceObject);
1336  KeInitializeSpinLock(&fdoExtension->PrivateFdoData->Retry.Lock);
1337  fdoExtension->PrivateFdoData->Retry.Granularity =
1339  commonExtension->Reserved4 = (ULONG_PTR)(' GPH'); // debug aid
1340 
1341  //
1342  // NOTE: the old interface allowed the class driver to allocate
1343  // this. this was unsafe for low-memory conditions. allocate one
1344  // unconditionally now, and modify our internal functions to use
1345  // our own exclusively as it is the only safe way to do this.
1346  //
1347 
1348  status = ClasspAllocateReleaseQueueIrp(fdoExtension);
1349  if (!NT_SUCCESS(status)) {
1350  DebugPrint((0, "ClassPnpStartDevice: Cannot allocate the "
1351  "private release queue irp\n"));
1352  return status;
1353  }
1354 
1355  //
1356  // Call port driver to get adapter capabilities.
1357  //
1358 
1359  propertyId = StorageAdapterProperty;
1360 
1362  commonExtension->LowerDeviceObject,
1363  &propertyId,
1364  (PSTORAGE_DESCRIPTOR_HEADER *)&fdoExtension->AdapterDescriptor);
1365 
1366  if(!NT_SUCCESS(status)) {
1367 
1368  //
1369  // This DebugPrint is to help third-party driver writers
1370  //
1371 
1372  DebugPrint((0, "ClassPnpStartDevice: ClassGetDescriptor "
1373  "[ADAPTER] failed %lx\n", status));
1374  return status;
1375  }
1376 
1377  //
1378  // Call port driver to get device descriptor.
1379  //
1380 
1381  propertyId = StorageDeviceProperty;
1382 
1384  commonExtension->LowerDeviceObject,
1385  &propertyId,
1386  (PSTORAGE_DESCRIPTOR_HEADER *)&fdoExtension->DeviceDescriptor);
1387 
1388  if(!NT_SUCCESS(status)) {
1389 
1390  //
1391  // This DebugPrint is to help third-party driver writers
1392  //
1393 
1394  DebugPrint((0, "ClassPnpStartDevice: ClassGetDescriptor "
1395  "[DEVICE] failed %lx\n", status));
1396  return status;
1397  }
1398 
1399  ClasspScanForSpecialInRegistry(fdoExtension);
1400  ClassScanForSpecial(fdoExtension,
1401  ClassBadItems,
1403 
1404  //
1405  // allow perf to be re-enabled after a given number of failed IOs
1406  // require this number to be at least CLASS_PERF_RESTORE_MINIMUM
1407  //
1408 
1409  {
1410  ULONG t = 0;
1411  ClassGetDeviceParameter(fdoExtension,
1414  &t);
1415  if (t >= CLASS_PERF_RESTORE_MINIMUM) {
1416  fdoExtension->PrivateFdoData->Perf.ReEnableThreshold = t;
1417  }
1418  }
1419 
1420 
1421  //
1422  // compatibility comes first. writable cd media will not
1423  // get a SYNCH_CACHE on power down.
1424  //
1425 
1426  if (fdoExtension->DeviceObject->DeviceType != FILE_DEVICE_DISK) {
1427  SET_FLAG(fdoExtension->PrivateFdoData->HackFlags,
1429  }
1430 
1431  //
1432  // initialize the hotplug information only after the ScanForSpecial
1433  // routines, as it relies upon the hack flags.
1434  //
1435 
1436  status = ClasspInitializeHotplugInfo(fdoExtension);
1437 
1438  if (!NT_SUCCESS(status)) {
1439  DebugPrint((1, "ClassPnpStartDevice: Could not initialize "
1440  "hotplug information %lx\n", status));
1441  return status;
1442  }
1443 
1444  /*
1445  * Allocate/initialize TRANSFER_PACKETs and related resources.
1446  */
1448  }
1449 
1450  //
1451  // ISSUE - drivers need to disable write caching on the media
1452  // if hotplug and !useroverride. perhaps we should
1453  // allow registration of a callback to enable/disable
1454  // write cache instead.
1455  //
1456 
1457  if (NT_SUCCESS(status)){
1458  status = devInfo->ClassInitDevice(DeviceObject);
1459  }
1460 
1461  }
1462 
1463  if (!NT_SUCCESS(status)){
1464 
1465  //
1466  // Just bail out - the remove that comes down will clean up the
1467  // initialized scraps.
1468  //
1469 
1470  return status;
1471  } else {
1472  commonExtension->IsInitialized = TRUE;
1473 
1474  if (commonExtension->IsFdo) {
1475  fdoExtension->PrivateFdoData->Perf.OriginalSrbFlags = fdoExtension->SrbFlags;
1476  }
1477 
1478  }
1479 
1480  //
1481  // If device requests autorun functionality or a once a second callback
1482  // then enable the once per second timer.
1483  //
1484  // NOTE: This assumes that ClassInitializeMediaChangeDetection is always
1485  // called in the context of the ClassInitDevice callback. If called
1486  // after then this check will have already been made and the
1487  // once a second timer will not have been enabled.
1488  //
1489  if ((isFdo) &&
1490  ((initData->ClassTick != NULL) ||
1491  (fdoExtension->MediaChangeDetectionInfo != NULL) ||
1492  ((fdoExtension->FailurePredictionInfo != NULL) &&
1493  (fdoExtension->FailurePredictionInfo->Method != FailurePredictionNone))))
1494  {
1496  timerStarted = TRUE;
1497  } else {
1498  timerStarted = FALSE;
1499  }
1500 
1501  //
1502  // NOTE: the timer looks at commonExtension->CurrentState now
1503  // to prevent Media Change Notification code from running
1504  // until the device is started, but allows the device
1505  // specific tick handler to run. therefore it is imperative
1506  // that commonExtension->CurrentState not be updated until
1507  // the device specific startdevice handler has finished.
1508  //
1509 
1510  status = devInfo->ClassStartDevice(DeviceObject);
1511 
1512  if(NT_SUCCESS(status)) {
1513  commonExtension->CurrentState = IRP_MN_START_DEVICE;
1514 
1515  if((isFdo) && (initData->ClassEnumerateDevice != NULL)) {
1516  isMountedDevice = FALSE;
1517  }
1518 
1519  if((DeviceObject->DeviceType != FILE_DEVICE_DISK) &&
1520  (DeviceObject->DeviceType != FILE_DEVICE_CD_ROM)) {
1521 
1522  isMountedDevice = FALSE;
1523  }
1524 
1525 
1526  if(isMountedDevice) {
1528  }
1529 
1530  if((commonExtension->IsFdo) &&
1531  (devInfo->ClassWmiInfo.GuidRegInfo != NULL)) {
1532 
1534  }
1535  } else {
1536 
1537  if (timerStarted) {
1539  }
1540  }
1541 
1542  return status;
1543 }
#define CLASS_DRIVER_EXTENSION_KEY
Definition: classpnp.h:91
#define FILE_DEVICE_DISK
Definition: winioctl.h:112
NTSTATUS NTAPI ClasspEnableTimer(PDEVICE_OBJECT DeviceObject)
Definition: autorun.c:3234
VOID NTAPI ClasspScanForClassHacks(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN ULONG_PTR Data)
Definition: class.c:9083
enum _STORAGE_PROPERTY_ID STORAGE_PROPERTY_ID
PGUIDREGINFO GuidRegInfo
Definition: classpnp.h:491
#define TRUE
Definition: types.h:120
* PSTORAGE_DESCRIPTOR_HEADER
Definition: ntddstor.h:441
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
PMEDIA_CHANGE_DETECTION_INFO MediaChangeDetectionInfo
Definition: classpnp.h:721
NTSTATUS NTAPI ClasspAllocateReleaseQueueIrp(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:8193
CLASS_DEV_INFO FdoData
Definition: classpnp.h:521
LONG NTSTATUS
Definition: precomp.h:26
ULONG NTAPI KeQueryTimeIncrement(VOID)
Definition: clock.c:153
VOID NTAPI ClasspScanForSpecialInRegistry(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:9101
GLdouble GLdouble t
Definition: gl.h:2047
VOID NTAPI ClasspRegisterMountedDeviceInterface(IN PDEVICE_OBJECT DeviceObject)
Definition: class.c:7569
#define PAGED_CODE()
Definition: video.h:57
PCLASS_TICK ClassTick
Definition: classpnp.h:528
#define FILE_DEVICE_CD_ROM
Definition: winioctl.h:107
VOID NTAPI ClassScanForSpecial(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN CLASSPNP_SCAN_FOR_SPECIAL_INFO DeviceList[], IN PCLASS_SCAN_FOR_SPECIAL_HANDLER Function)
Definition: utils.c:213
PCLASS_INIT_DEVICE ClassInitDevice
Definition: classpnp.h:510
FORCEINLINE VOID KeInitializeSpinLock(_Out_ PKSPIN_LOCK SpinLock)
Definition: kefuncs.h:251
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeInitializeTimer(OUT PKTIMER Timer)
Definition: timerobj.c:233
NTSTATUS NTAPI ClasspInitializeHotplugInfo(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:8964
VOID NTAPI ClassGetDeviceParameter(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PWSTR SubkeyName OPTIONAL, IN PWSTR ParameterName, IN OUT PULONG ParameterValue)
Definition: utils.c:52
NTSTATUS NTAPI InitializeTransferPackets(PDEVICE_OBJECT Fdo)
Definition: xferpkt.c:43
NTSTATUS NTAPI IoWMIRegistrationControl(IN PDEVICE_OBJECT DeviceObject, IN ULONG Action)
Definition: wmi.c:68
#define WMIREG_ACTION_REGISTER
#define FDO_HACK_NO_SYNC_CACHE
Definition: classp.h:55
CLASS_WMI_INFO ClassWmiInfo
Definition: classpnp.h:516
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
PCLASS_START_DEVICE ClassStartDevice
Definition: classpnp.h:511
PSTORAGE_ADAPTER_DESCRIPTOR AdapterDescriptor
Definition: classpnp.h:699
#define IRP_MN_START_DEVICE
PSTORAGE_DEVICE_DESCRIPTOR DeviceDescriptor
Definition: classpnp.h:698
NTSTATUS NTAPI ClassGetDescriptor(IN PDEVICE_OBJECT DeviceObject, IN PSTORAGE_PROPERTY_ID PropertyId, OUT PSTORAGE_DESCRIPTOR_HEADER *Descriptor)
Definition: class.c:6364
PDEVICE_OBJECT DeviceObject
Definition: classpnp.h:693
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define CLASSP_REG_SUBKEY_NAME
Definition: classp.h:41
#define CLASS_TAG_PRIVATE_DATA
Definition: classp.h:82
PCLASS_ENUM_DEVICE ClassEnumerateDevice
Definition: classpnp.h:524
PVOID NTAPI IoGetDriverObjectExtension(IN PDRIVER_OBJECT DriverObject, IN PVOID ClientIdentificationAddress)
Definition: driver.c:1842
VOID NTAPI ClasspRetryRequestDpc(IN PKDPC Dpc, IN PVOID Context, IN PVOID Arg1, IN PVOID Arg2)
Definition: class.c:8702
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
CLASSPNP_SCAN_FOR_SPECIAL_INFO ClassBadItems[]
Definition: data.c:34
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
struct _FAILURE_PREDICTION_INFO * FailurePredictionInfo
Definition: classpnp.h:735
PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:574
CLASS_DEV_INFO PdoData
Definition: classpnp.h:522
NTSTATUS NTAPI ClasspDisableTimer(PDEVICE_OBJECT DeviceObject)
Definition: autorun.c:3285
CLASS_INIT_DATA InitData
Definition: classpnp.h:556
unsigned int ULONG
Definition: retypes.h:1
#define CLASSP_REG_PERF_RESTORE_VALUE_NAME
Definition: classp.h:46
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ULONG_PTR
Definition: config.h:101
#define CLASS_PERF_RESTORE_MINIMUM
Definition: classp.h:49
VOID NTAPI KeInitializeDpc(IN PKDPC Dpc, IN PKDEFERRED_ROUTINE DeferredRoutine, IN PVOID DeferredContext)
Definition: dpc.c:711
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by ClassDispatchPnp().

◆ ClasspPagingNotificationCompletion()

NTSTATUS NTAPI ClasspPagingNotificationCompletion ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN PDEVICE_OBJECT  RealDeviceObject 
)

◆ ClasspPerfIncrementErrorCount()

VOID NTAPI ClasspPerfIncrementErrorCount ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

Definition at line 333 of file utils.c.

336 {
337  PCLASS_PRIVATE_FDO_DATA fdoData = FdoExtension->PrivateFdoData;
338  KIRQL oldIrql;
339  ULONG errors;
340 
341  KeAcquireSpinLock(&fdoData->SpinLock, &oldIrql);
342 
343  fdoData->Perf.SuccessfulIO = 0; // implicit interlock
344  errors = InterlockedIncrement((PLONG)&FdoExtension->ErrorCount);
345 
346  if (errors >= CLASS_ERROR_LEVEL_1) {
347 
348  //
349  // If the error count has exceeded the error limit, then disable
350  // any tagged queuing, multiple requests per lu queueing
351  // and synchronous data transfers.
352  //
353  // Clearing the no queue freeze flag prevents the port driver
354  // from sending multiple requests per logical unit.
355  //
356 
359 
361 
362  DebugPrint((ClassDebugError, "ClasspPerfIncrementErrorCount: "
363  "Too many errors; disabling tagged queuing and "
364  "synchronous data tranfers.\n"));
365 
366  }
367 
368  if (errors >= CLASS_ERROR_LEVEL_2) {
369 
370  //
371  // If a second threshold is reached, disable disconnects.
372  //
373 
375  DebugPrint((ClassDebugError, "ClasspPerfIncrementErrorCount: "
376  "Too many errors; disabling disconnects.\n"));
377  }
378 
379  KeReleaseSpinLock(&fdoData->SpinLock, oldIrql);
380  return;
381 }
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:396
KSPIN_LOCK SpinLock
Definition: classp.h:456
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define CLEAR_FLAG(Flags, Bit)
Definition: classpnp.h:155
#define CLASS_ERROR_LEVEL_2
Definition: classp.h:51
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:389
#define CLASS_ERROR_LEVEL_1
Definition: classp.h:50
#define SRB_FLAGS_DISABLE_DISCONNECT
Definition: srb.h:388
struct _CLASS_PRIVATE_FDO_DATA::@1014 Perf
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
#define InterlockedIncrement
Definition: armddk.h:53
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
unsigned int ULONG
Definition: retypes.h:1
signed int * PLONG
Definition: retypes.h:5
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
Definition: srb.h:387

Referenced by ClassInterpretSenseInfo().

◆ ClasspPerfIncrementSuccessfulIo()

VOID NTAPI ClasspPerfIncrementSuccessfulIo ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

Definition at line 385 of file utils.c.

388 {
389  PCLASS_PRIVATE_FDO_DATA fdoData = FdoExtension->PrivateFdoData;
390  KIRQL oldIrql;
391  ULONG errors;
392  ULONG succeeded = 0;
393 
394  //
395  // don't take a hit from the interlocked op unless we're in
396  // a degraded state and we've got a threshold to hit.
397  //
398 
399  if (FdoExtension->ErrorCount == 0) {
400  return;
401  }
402 
403  if (fdoData->Perf.ReEnableThreshold == 0) {
404  return;
405  }
406 
407  succeeded = InterlockedIncrement((PLONG)&fdoData->Perf.SuccessfulIO);
408  if (succeeded < fdoData->Perf.ReEnableThreshold) {
409  return;
410  }
411 
412  //
413  // if we hit the threshold, grab the spinlock and verify we've
414  // actually done so. this allows us to ignore the spinlock 99%
415  // of the time.
416  //
417 
418  KeAcquireSpinLock(&fdoData->SpinLock, &oldIrql);
419 
420  //
421  // re-read the value, so we don't run this multiple times
422  // for a single threshold being hit. this keeps errorcount
423  // somewhat useful.
424  //
425 
426  succeeded = fdoData->Perf.SuccessfulIO;
427 
428  if ((FdoExtension->ErrorCount != 0) &&
429  (fdoData->Perf.ReEnableThreshold <= succeeded)
430  ) {
431 
432  fdoData->Perf.SuccessfulIO = 0; // implicit interlock
433 
434  ASSERT(FdoExtension->ErrorCount > 0);
435  errors = InterlockedDecrement((PLONG)&FdoExtension->ErrorCount);
436 
437  //
438  // note: do in reverse order of the sets "just in case"
439  //
440 
441  if (errors < CLASS_ERROR_LEVEL_2) {
442  if (errors == CLASS_ERROR_LEVEL_2 - 1) {
443  DebugPrint((ClassDebugError, "ClasspPerfIncrementSuccessfulIo: "
444  "Error level 2 no longer required.\n"));
445  }
446  if (!TEST_FLAG(fdoData->Perf.OriginalSrbFlags,
448  CLEAR_FLAG(FdoExtension->SrbFlags,
450  }
451  }
452 
453  if (errors < CLASS_ERROR_LEVEL_1) {
454  if (errors == CLASS_ERROR_LEVEL_1 - 1) {
455  DebugPrint((ClassDebugError, "ClasspPerfIncrementSuccessfulIo: "
456  "Error level 1 no longer required.\n"));
457  }
458  if (!TEST_FLAG(fdoData->Perf.OriginalSrbFlags,
460  CLEAR_FLAG(FdoExtension->SrbFlags,
462  }
463  if (TEST_FLAG(fdoData->Perf.OriginalSrbFlags,
465  SET_FLAG(FdoExtension->SrbFlags,
467  }
468  if (TEST_FLAG(fdoData->Perf.OriginalSrbFlags,
470  SET_FLAG(FdoExtension->SrbFlags,
472  }
473  }
474  } // end of threshold definitely being hit for first time
475 
476  KeReleaseSpinLock(&fdoData->SpinLock, oldIrql);
477  return;
478 }
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
#define SRB_FLAGS_NO_QUEUE_FREEZE
Definition: srb.h:396
KSPIN_LOCK SpinLock
Definition: classp.h:456
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define CLEAR_FLAG(Flags, Bit)
Definition: classpnp.h:155
#define CLASS_ERROR_LEVEL_2
Definition: classp.h:51
#define KeAcquireSpinLock(sl, irql)
Definition: env_spec_w32.h:609
#define SRB_FLAGS_DISABLE_SYNCH_TRANSFER
Definition: srb.h:389
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define CLASS_ERROR_LEVEL_1
Definition: classp.h:50
#define SRB_FLAGS_DISABLE_DISCONNECT
Definition: srb.h:388
struct _CLASS_PRIVATE_FDO_DATA::@1014 Perf
#define InterlockedDecrement
Definition: armddk.h:52
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
#define InterlockedIncrement
Definition: armddk.h:53
#define KeReleaseSpinLock(sl, irql)
Definition: env_spec_w32.h:627
unsigned int ULONG
Definition: retypes.h:1
signed int * PLONG
Definition: retypes.h:5
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
Definition: srb.h:387

Referenced by ClassIoComplete(), and TransferPktComplete().

◆ ClasspRegisterMountedDeviceInterface()

VOID NTAPI ClasspRegisterMountedDeviceInterface ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 7569 of file class.c.

7572 {
7573 
7575  BOOLEAN isFdo = commonExtension->IsFdo;
7576 
7577  PDEVICE_OBJECT pdo;
7578  UNICODE_STRING interfaceName;
7579 
7580  NTSTATUS status;
7581 
7582  if(isFdo) {
7583 
7584  PFUNCTIONAL_DEVICE_EXTENSION functionalExtension;
7585 
7586  functionalExtension =
7587  (PFUNCTIONAL_DEVICE_EXTENSION) commonExtension;
7588  pdo = functionalExtension->LowerPdo;
7589  } else {
7590  pdo = DeviceObject;
7591  }
7592 
7594  pdo,
7595  &MOUNTDEV_MOUNTED_DEVICE_GUID,
7596  NULL,
7597  &interfaceName
7598  );
7599 
7600  if(NT_SUCCESS(status)) {
7601 
7602  //
7603  // Copy the interface name before setting the interface state - the
7604  // name is needed by the components we notify.
7605  //
7606 
7607  commonExtension->MountedDeviceInterfaceName = interfaceName;
7608  status = IoSetDeviceInterfaceState(&interfaceName, TRUE);
7609 
7610  if(!NT_SUCCESS(status)) {
7611  RtlFreeUnicodeString(&interfaceName);
7612  }
7613  }
7614 
7615  if(!NT_SUCCESS(status)) {
7617  NULL);
7618  }
7619  return;
7620 } // end ClasspRegisterMountedDeviceInterface()
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
struct _FUNCTIONAL_DEVICE_EXTENSION * PFUNCTIONAL_DEVICE_EXTENSION
PVOID DeviceExtension
Definition: env_spec_w32.h:418
unsigned char BOOLEAN
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI IoSetDeviceInterfaceState(IN PUNICODE_STRING SymbolicLinkName, IN BOOLEAN Enable)
Definition: deviface.c:1311
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
UNICODE_STRING MountedDeviceInterfaceName
Definition: classpnp.h:604
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
PDEVICE_OBJECT LowerPdo
Definition: classpnp.h:697
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
NTSTATUS NTAPI IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject, IN CONST GUID *InterfaceClassGuid, IN PUNICODE_STRING ReferenceString OPTIONAL, OUT PUNICODE_STRING SymbolicLinkName)
Definition: deviface.c:955
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by ClassPnpStartDevice().

◆ ClasspReleaseQueue()

VOID NTAPI ClasspReleaseQueue ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  ReleaseQueueIrp 
)

Definition at line 8269 of file class.c.

8273 {
8274  PIO_STACK_LOCATION irpStack;
8275  PIRP irp;
8276  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
8277  PDEVICE_OBJECT lowerDevice;
8278  PSCSI_REQUEST_BLOCK srb;
8279  KIRQL currentIrql;
8280 
8281  lowerDevice = fdoExtension->CommonExtension.LowerDeviceObject;
8282 
8283  //
8284  // we raise irql separately so we're not swapped out or suspended
8285  // while holding the release queue irp in this routine. this lets
8286  // us release the spin lock before lowering irql.
8287  //
8288 
8289  KeRaiseIrql(DISPATCH_LEVEL, &currentIrql);
8290 
8292 
8293  //
8294  // make sure that if they passed us an irp, it matches our allocated irp.
8295  //
8296 
8297  ASSERT((ReleaseQueueIrp == NULL) ||
8298  (ReleaseQueueIrp == fdoExtension->PrivateFdoData->ReleaseQueueIrp));
8299 
8300  //
8301  // ASSERT that we've already allocated this. (should not occur)
8302  // try to allocate it anyways, then finally bugcheck if
8303  // there's still no memory...
8304  //
8305 
8306  ASSERT(fdoExtension->PrivateFdoData->ReleaseQueueIrpAllocated);
8307  if (!fdoExtension->PrivateFdoData->ReleaseQueueIrpAllocated) {
8308  ClasspAllocateReleaseQueueIrp(fdoExtension);
8309  }
8310  if (!fdoExtension->PrivateFdoData->ReleaseQueueIrpAllocated) {
8311  KeBugCheckEx(SCSI_DISK_DRIVER_INTERNAL, 0x12, (ULONG_PTR)Fdo, 0x0, 0x0);
8312  }
8313 
8314  if ((fdoExtension->ReleaseQueueInProgress) && (ReleaseQueueIrp == NULL)) {
8315 
8316  //
8317  // Someone is already using the irp - just set the flag to indicate that
8318  // we need to release the queue again.
8319  //
8320 
8321  fdoExtension->ReleaseQueueNeeded = TRUE;
8323  KeLowerIrql(currentIrql);
8324  return;
8325 
8326  }
8327 
8328  //
8329  // Mark that there is a release queue in progress and drop the spinlock.
8330  //
8331 
8332  fdoExtension->ReleaseQueueInProgress = TRUE;
8333  if (ReleaseQueueIrp) {
8334  irp = ReleaseQueueIrp;
8335  } else {
8336  irp = fdoExtension->PrivateFdoData->ReleaseQueueIrp;
8337  }
8338  srb = &(fdoExtension->ReleaseQueueSrb);
8339 
8341 
8342  ASSERT(irp != NULL);
8343 
8344  irpStack = IoGetNextIrpStackLocation(irp);
8345 
8346  irpStack->MajorFunction = IRP_MJ_SCSI;
8347 
8348  srb->OriginalRequest = irp;
8349 
8350  //
8351  // Store the SRB address in next stack for port driver.
8352  //
8353 
8354  irpStack->Parameters.Scsi.Srb = srb;
8355 
8356  //
8357  // If this device is removable then flush the queue. This will also
8358  // release it.
8359  //
8360 
8361  if (TEST_FLAG(Fdo->Characteristics, FILE_REMOVABLE_MEDIA)){
8363  }
8364  else {
8366  }
8367 
8368  ClassAcquireRemoveLock(Fdo, irp);
8369 
8372  Fdo,
8373  TRUE,
8374  TRUE,
8375  TRUE);
8376 
8377  IoCallDriver(lowerDevice, irp);
8378 
8379  KeLowerIrql(currentIrql);
8380 
8381  return;
8382 
8383 } // end ClassReleaseQueue()
#define KeRaiseIrql(irql, oldIrql)
Definition: env_spec_w32.h:597
#define TRUE
Definition: types.h:120
#define KeLowerIrql(oldIrql)
Definition: env_spec_w32.h:602
#define ClassAcquireRemoveLock(devobj, tag)
Definition: classpnp.h:97
PVOID OriginalRequest
Definition: srb.h:258
GLint x0
Definition: linetemp.h:95
NTSTATUS NTAPI ClasspAllocateReleaseQueueIrp(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:8193
#define TEST_FLAG(Flags, Bit)
Definition: classpnp.h:156
VOID NTAPI KeAcquireSpinLockAtDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:192
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:695
#define SRB_FUNCTION_FLUSH_QUEUE
Definition: srb.h:321
#define SRB_FUNCTION_RELEASE_QUEUE
Definition: srb.h:311
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:515
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define IRP_MJ_SCSI
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
KSPIN_LOCK ReleaseQueueSpinLock
Definition: classpnp.h:727
smooth NULL
Definition: ftsmooth.c:416
UCHAR Function
Definition: srb.h:242
VOID NTAPI KeReleaseSpinLockFromDpcLevel(IN PKSPIN_LOCK SpinLock)
Definition: spinlock.c:215
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
NTSTATUS NTAPI ClassReleaseQueueCompletion(PDEVICE_OBJECT DeviceObject, PIRP Irp, PVOID Context)
Definition: class.c:8412
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2647
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:2772
SCSI_REQUEST_BLOCK ReleaseQueueSrb
Definition: classpnp.h:729
VOID NTAPI KeBugCheckEx(_In_ ULONG BugCheckCode, _In_ ULONG_PTR BugCheckParameter1, _In_ ULONG_PTR BugCheckParameter2, _In_ ULONG_PTR BugCheckParameter3, _In_ ULONG_PTR BugCheckParameter4)
Definition: rtlcompat.c:107

Referenced by ClassReleaseQueue(), and ClassReleaseQueueCompletion().

◆ ClasspRetryDpcTimer()

VOID NTAPI ClasspRetryDpcTimer ( IN PCLASS_PRIVATE_FDO_DATA  FdoData)

Definition at line 8913 of file class.c.

8916 {
8917  LARGE_INTEGER fire;
8918 
8919  ASSERT(FdoData->Retry.Tick.QuadPart != (LONGLONG)0);
8920  ASSERT(FdoData->Retry.ListHead != NULL); // never fire an empty list
8921 
8922  //
8923  // fire == (CurrentTick - now) * (100ns per tick)
8924  //
8925  // NOTE: Overflow is nearly impossible and is ignored here
8926  //
8927 
8928  KeQueryTickCount(&fire);
8929  fire.QuadPart = FdoData->Retry.Tick.QuadPart - fire.QuadPart;
8930  fire.QuadPart *= FdoData->Retry.Granularity;
8931 
8932  //
8933  // fire is now multiples of 100ns until should fire the timer.
8934  // if timer should already have expired, or would fire too quickly,
8935  // fire it in some arbitrary number of ticks to prevent infinitely
8936  // recursing.
8937  //
8938 
8939  if (fire.QuadPart < MINIMUM_RETRY_UNITS) {
8941  }
8942 
8944  "ClassRetry: ======= %I64x ticks\n",
8945  fire.QuadPart));
8946 
8947  //
8948  // must use negative to specify relative time to fire
8949  //
8950 
8951  fire.QuadPart = fire.QuadPart * ((LONGLONG)-1);
8952 
8953  //
8954  // set the timer, since this is the first addition
8955  //
8956 
8957  KeSetTimerEx(&FdoData->Retry.Timer, fire, 0, &FdoData->Retry.Dpc);
8958 
8959  return;
8960 } // end ClasspRetryDpcTimer()
BOOLEAN NTAPI KeSetTimerEx(IN OUT PKTIMER Timer, IN LARGE_INTEGER DueTime, IN LONG Period, IN PKDPC Dpc OPTIONAL)
Definition: timerobj.c:294
smooth NULL
Definition: ftsmooth.c:416
VOID NTAPI KeQueryTickCount(IN PLARGE_INTEGER TickCount)
Definition: clock.c:165
int64_t LONGLONG
Definition: typedefs.h:66
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
#define MINIMUM_RETRY_UNITS
Definition: classp.h:472
LONGLONG QuadPart
Definition: typedefs.h:112

Referenced by ClasspRetryRequestDpc(), and ClassRetryRequest().

◆ ClasspScanForClassHacks()

VOID NTAPI ClasspScanForClassHacks ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
IN ULONG_PTR  Data 
)

Definition at line 9083 of file class.c.

9087 {
9088  PAGED_CODE();
9089 
9090  //
9091  // remove invalid flags and save
9092  //
9093 
9095  SET_FLAG(FdoExtension->PrivateFdoData->HackFlags, Data);
9096  return;
9097 }
#define FDO_HACK_INVALID_FLAGS
Definition: classp.h:58
#define PAGED_CODE()
Definition: video.h:57
#define CLEAR_FLAG(Flags, Bit)
Definition: classpnp.h:155
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154

Referenced by ClassPnpStartDevice().

◆ ClasspScanForSpecialInRegistry()

VOID NTAPI ClasspScanForSpecialInRegistry ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension)

Definition at line 9101 of file class.c.

9104 {
9105  HANDLE deviceParameterHandle; // device instance key
9106  HANDLE classParameterHandle; // classpnp subkey
9107  OBJECT_ATTRIBUTES objectAttributes;
9108  UNICODE_STRING subkeyName;
9109  NTSTATUS status;
9110 
9111  //
9112  // seeded in the ENUM tree by ClassInstaller
9113  //
9114  ULONG deviceHacks;
9115  RTL_QUERY_REGISTRY_TABLE queryTable[2]; // null terminated array
9116 
9117  PAGED_CODE();
9118 
9119  deviceParameterHandle = NULL;
9120  classParameterHandle = NULL;
9121  deviceHacks = 0;
9122 
9125  KEY_WRITE,
9126  &deviceParameterHandle
9127  );
9128 
9129  if (!NT_SUCCESS(status)) {
9130  goto cleanupScanForSpecial;
9131  }
9132 
9134  InitializeObjectAttributes(&objectAttributes,
9135  &subkeyName,
9137  deviceParameterHandle,
9138  NULL
9139  );
9140 
9141  status = ZwOpenKey( &classParameterHandle,
9142  KEY_READ,
9143  &objectAttributes
9144  );
9145 
9146  if (!NT_SUCCESS(status)) {
9147  goto cleanupScanForSpecial;
9148  }
9149 
9150  //
9151  // Zero out the memory
9152  //
9153 
9154  RtlZeroMemory(&queryTable[0], 2*sizeof(RTL_QUERY_REGISTRY_TABLE));
9155 
9156  //
9157  // Setup the structure to read
9158  //
9159 
9160  queryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
9161  queryTable[0].Name = CLASSP_REG_HACK_VALUE_NAME;
9162  queryTable[0].EntryContext = &deviceHacks;
9163  queryTable[0].DefaultType = REG_DWORD;
9164  queryTable[0].DefaultData = &deviceHacks;
9165  queryTable[0].DefaultLength = 0;
9166 
9167  //
9168  // read values
9169  //
9170 
9172  (PWSTR)classParameterHandle,
9173  &queryTable[0],
9174  NULL,
9175  NULL
9176  );
9177  if (!NT_SUCCESS(status)) {
9178  goto cleanupScanForSpecial;
9179  }
9180 
9181  //
9182  // remove unknown values and save...
9183  //
9184 
9186  "Classpnp => ScanForSpecial: HackFlags %#08x\n",
9187  deviceHacks));
9188 
9189  CLEAR_FLAG(deviceHacks, FDO_HACK_INVALID_FLAGS);
9190  SET_FLAG(FdoExtension->PrivateFdoData->HackFlags, deviceHacks);
9191 
9192 
9193 cleanupScanForSpecial:
9194 
9195  if (deviceParameterHandle) {
9196  ZwClose(deviceParameterHandle);
9197  }
9198 
9199  if (classParameterHandle) {
9200  ZwClose(classParameterHandle);
9201  }
9202 
9203  //
9204  // we should modify the system hive to include another key for us to grab
9205  // settings from. in this case: Classpnp\HackFlags
9206  //
9207  // the use of a DWORD value for the HackFlags allows 32 hacks w/o
9208  // significant use of the registry, and also reduces OEM exposure.
9209  //
9210  // definition of bit flags:
9211  // 0x00000001 -- Device succeeds PREVENT_MEDIUM_REMOVAL, but
9212  // cannot actually prevent removal.
9213  // 0x00000002 -- Device hard-hangs or times out for GESN requests.
9214  // 0xfffffffc -- Currently reserved, may be used later.
9215  //
9216 
9217  return;
9218 }
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2738
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
uint16_t * PWSTR
Definition: typedefs.h:54
LONG NTSTATUS
Definition: precomp.h:26
#define FDO_HACK_INVALID_FLAGS
Definition: classp.h:58
#define PAGED_CODE()
Definition: video.h:57
#define KdPrintEx(_x_)
Definition: kdfuncs.h:114
#define CLEAR_FLAG(Flags, Bit)
Definition: classpnp.h:155
smooth NULL
Definition: ftsmooth.c:416
#define KEY_WRITE
Definition: nt_native.h:1031
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define CLASSP_REG_SUBKEY_NAME
Definition: classp.h:41
#define RTL_REGISTRY_HANDLE
Definition: nt_native.h:168
#define SET_FLAG(Flags, Bit)
Definition: classpnp.h:154
#define DPFLTR_ERROR_LEVEL
Definition: main.cpp:32
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:4586
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_DWORD
Definition: sdbapi.c:596
static SERVICE_STATUS status
Definition: service.c:31
#define CLASSP_REG_HACK_VALUE_NAME
Definition: classp.h:43
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
Definition: ps.c:97

Referenced by ClassPnpStartDevice().

◆ ClasspSendNotification()

VOID NTAPI ClasspSendNotification ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
IN const GUID Guid,
IN ULONG  ExtraDataSize,
IN PVOID  ExtraData 
)

Definition at line 173 of file autorun.c.

179 {
181  ULONG requiredSize;
182 
183  requiredSize =
184  (sizeof(TARGET_DEVICE_CUSTOM_NOTIFICATION) - sizeof(UCHAR)) +
186 
187  if (requiredSize > 0x0000ffff) {
188  // MAX_USHORT, max total size for these events!
190  "Error sending event: size too large! (%x)\n",
191  requiredSize));
192  return;
193  }
194 
196  requiredSize,
197  'oNcS');
198 
199  //
200  // if none allocated, exit
201  //
202 
203  if (notification == NULL) {
204  return;
205  }
206 
207  //
208  // Prepare and send the request!
209  //
210 
211  RtlZeroMemory(notification, requiredSize);
212  notification->Version = 1;
213  notification->Size = (USHORT)(requiredSize);
214  notification->FileObject = NULL;
215  notification->NameBufferOffset = -1;
216  notification->Event = *Guid;
217  RtlCopyMemory(notification->CustomDataBuffer, ExtraData, ExtraDataSize);
218 
220  notification,
221  NULL, NULL);
222 
224  notification = NULL;
225  return;
226 }
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
struct _TARGET_DEVICE_CUSTOM_NOTIFICATION TARGET_DEVICE_CUSTOM_NOTIFICATION
_In_ const GUID _In_ ULONG ExtraDataSize
Definition: classpnp.h:1236
#define KdPrintEx(_x_)
Definition: kdfuncs.h:114
static GUID * Guid
Definition: apphelp.c:93
smooth NULL
Definition: ftsmooth.c:416
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
unsigned char UCHAR
Definition: xmlstorage.h:181
unsigned short USHORT
Definition: pedump.c:61
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
NTSTATUS NTAPI IoReportTargetDeviceChangeAsynchronous(IN PDEVICE_OBJECT PhysicalDeviceObject, IN PVOID NotificationStructure, IN PDEVICE_CHANGE_COMPLETE_CALLBACK Callback OPTIONAL, IN PVOID Context OPTIONAL)
Definition: pnpreport.c:519
#define ExFreePool(addr)
Definition: env_spec_w32.h:352

Referenced by ClassInterpretSenseInfo(), ClasspInternalSetMediaChangeState(), ClasspInterpretGesnData(), and ClassSendEjectionNotification().

◆ ClassQueryPnpCapabilities()

NTSTATUS NTAPI ClassQueryPnpCapabilities ( IN PDEVICE_OBJECT  PhysicalDeviceObject,
IN PDEVICE_CAPABILITIES  Capabilities 
)

Definition at line 6863 of file class.c.

6867 {
6868  PCLASS_DRIVER_EXTENSION driverExtension =
6869  ClassGetDriverExtension(DeviceObject->DriverObject);
6871 
6872  PCLASS_QUERY_PNP_CAPABILITIES queryRoutine = NULL;
6873 
6874  PAGED_CODE();
6875 
6878 
6879  if(commonExtension->IsFdo) {
6880  queryRoutine = driverExtension->InitData.FdoData.ClassQueryPnpCapabilities;
6881  } else {
6882  queryRoutine = driverExtension->InitData.PdoData.ClassQueryPnpCapabilities;
6883  }
6884 
6885  if(queryRoutine) {
6886  return queryRoutine(DeviceObject,
6887  Capabilities);
6888  } else {
6889  return STATUS_NOT_IMPLEMENTED;
6890  }
6891 } // end ClassQueryPnpCapabilities()
#define STATUS_NOT_IMPLEMENTED
Definition: ntstatus.h:225
CLASS_DEV_INFO FdoData
Definition: classpnp.h:521
#define PAGED_CODE()
Definition: video.h:57
_Must_inspect_result_ typedef _Out_ PHIDP_CAPS Capabilities
Definition: hidclass.h:103
PVOID DeviceExtension
Definition: env_spec_w32.h:418
smooth NULL
Definition: ftsmooth.c:416
PCLASS_DRIVER_EXTENSION NTAPI ClassGetDriverExtension(IN PDRIVER_OBJECT DriverObject)
Definition: class.c:7236
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
IN PDEVICE_OBJECT DeviceObject
Definition: fatprocs.h:1560
CLASS_DEV_INFO PdoData
Definition: classpnp.h:522
CLASS_INIT_DATA InitData
Definition: classpnp.h:556
PCLASS_QUERY_PNP_CAPABILITIES ClassQueryPnpCapabilities
Definition: classpnp.h:515

Referenced by ClassDispatchPnp().

◆ ClassRemoveChild()

Definition at line 8628 of file class.c.

8633 {
8634  if(AcquireLock) {
8636  }
8637 
8638  TRY {
8639  PCOMMON_DEVICE_EXTENSION previousChild = &Parent->CommonExtension;
8640 
8641  //
8642  // If the list is empty then bail out now.
8643  //
8644 
8645  if(Parent->CommonExtension.ChildList == NULL) {
8646  Child = NULL;
8647  LEAVE;
8648  }
8649 
8650  //
8651  // If the caller specified a child then find the child object before
8652  // it. If none was specified then the FDO is the child object before
8653  // the one we want to remove.
8654  //
8655 
8656  if(Child != NULL) {
8657 
8658  //
8659  // Scan through the child list to find the entry which points to
8660  // this one.
8661  //
8662 
8663  do {
8664  ASSERT(previousChild != &Child->CommonExtension);
8665 
8666  if(previousChild->ChildList == Child) {
8667  break;
8668  }
8669 
8670  previousChild = &previousChild->ChildList->CommonExtension;
8671  } while(previousChild != NULL);
8672 
8673  if(previousChild == NULL) {
8674  Child = NULL;
8675  LEAVE;
8676  }
8677  }
8678 
8679  //
8680  // Save the next child away then unlink it from the list.
8681  //
8682 
8683  Child = previousChild->ChildList;
8684  previousChild->ChildList = Child->CommonExtension.ChildList;
8685  Child->CommonExtension.ChildList = NULL;
8686 
8687  } FINALLY {
8688  if(AcquireLock) {
8690  }
8691  }
8692  return Child;
8693 } // end ClassRemoveChild()
#define FINALLY
Definition: classpnp.h:113
VOID NTAPI ClassAcquireChildLock(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:8483
#define LEAVE
Definition: classpnp.h:112
#define TRY(sps, bps)
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE Parent
Definition: acpixf.h:728
VOID NTAPI ClassReleaseChildLock(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:8526
smooth NULL
Definition: ftsmooth.c:416
struct _PHYSICAL_DEVICE_EXTENSION * ChildList
Definition: classpnp.h:592
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
ACPI_PHYSICAL_ADDRESS ACPI_SIZE BOOLEAN Warn BOOLEAN Physical UINT32 ACPI_TABLE_HEADER *OutTableHeader ACPI_TABLE_HEADER **OutTable ACPI_HANDLE UINT32 ACPI_WALK_CALLBACK ACPI_WALK_CALLBACK void void **ReturnValue UINT32 ACPI_BUFFER *RetPathPtr ACPI_OBJECT_HANDLER void *Data ACPI_OBJECT_HANDLER void **Data ACPI_STRING ACPI_OBJECT_LIST ACPI_BUFFER *ReturnObjectBuffer ACPI_DEVICE_INFO **ReturnBuffer ACPI_HANDLE ACPI_HANDLE Child
Definition: acpixf.h:728

Referenced by ClassMarkChildMissing(), and ClassRemoveDevice().

◆ ClassRetrieveDeviceRelations()

NTSTATUS NTAPI ClassRetrieveDeviceRelations ( IN PDEVICE_OBJECT  Fdo,
IN DEVICE_RELATION_TYPE  RelationType,
OUT PDEVICE_RELATIONS DeviceRelations 
)

Definition at line 6709 of file class.c.

6714 {
6715  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
6716 
6717  ULONG count = 0;
6718  ULONG i;
6719 
6720  PPHYSICAL_DEVICE_EXTENSION nextChild;
6721 
6722  ULONG relationsSize;
6723  PDEVICE_RELATIONS deviceRelations = NULL;
6724 
6725  NTSTATUS status;
6726 
6727  PAGED_CODE();
6728 
6729  ClassAcquireChildLock(fdoExtension);
6730 
6731  nextChild = fdoExtension->CommonExtension.ChildList;
6732 
6733  //
6734  // Count the number of PDO's attached to this disk
6735  //
6736 
6737  while(nextChild != NULL) {
6738  PCOMMON_DEVICE_EXTENSION commonExtension;
6739 
6740  commonExtension = &(nextChild->CommonExtension);
6741 
6742  ASSERTMSG("ClassPnp internal error: missing child on active list\n",
6743  (nextChild->IsMissing == FALSE));
6744 
6745  nextChild = commonExtension->ChildList;
6746 
6747  count++;
6748  };
6749 
6750  relationsSize = (sizeof(DEVICE_RELATIONS) +
6751  (count * sizeof(PDEVICE_OBJECT)));
6752 
6753  deviceRelations = ExAllocatePoolWithTag(PagedPool, relationsSize, '5BcS');
6754 
6755  if(deviceRelations == NULL) {
6756 
6757  DebugPrint((1, "ClassRetrieveDeviceRelations: unable to allocate "
6758  "%d bytes for device relations\n", relationsSize));
6759 
6760  ClassReleaseChildLock(fdoExtension);
6761 
6763  }
6764 
6765  RtlZeroMemory(deviceRelations, relationsSize);
6766 
6767  nextChild = fdoExtension->CommonExtension.ChildList;
6768  i = count - 1;
6769 
6770  while(nextChild != NULL) {
6771  PCOMMON_DEVICE_EXTENSION commonExtension;
6772 
6773  commonExtension = &(nextChild->CommonExtension);
6774 
6775  ASSERTMSG("ClassPnp internal error: missing child on active list\n",
6776  (nextChild->IsMissing == FALSE));
6777 
6778  deviceRelations->Objects[i--] = nextChild->DeviceObject;
6779 
6781  nextChild->DeviceObject,
6782  0,
6783  NULL,
6784  KernelMode);
6786 
6787  nextChild->IsEnumerated = TRUE;
6788  nextChild = commonExtension->ChildList;
6789  }
6790 
6791  ASSERTMSG("Child list has changed: ", i == -1);
6792 
6793  deviceRelations->Count = count;
6794  *DeviceRelations = deviceRelations;
6795  ClassReleaseChildLock(fdoExtension);
6796  return STATUS_SUCCESS;
6797 } // end ClassRetrieveDeviceRelations()
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:628
#define TRUE
Definition: types.h:120
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
VOID NTAPI ClassAcquireChildLock(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:8483
GLuint GLuint GLsizei count
Definition: gl.h:1545
PDEVICE_OBJECT Objects[1]
Definition: iotypes.h:2055
LONG NTSTATUS
Definition: precomp.h:26
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:695
#define PAGED_CODE()
Definition: video.h:57
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
VOID NTAPI ClassReleaseChildLock(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: class.c:8526
#define ASSERTMSG(msg, exp)
Definition: nt_native.h:431
smooth NULL
Definition: ftsmooth.c:416
NTSTATUS NTAPI ObReferenceObjectByPointer(IN PVOID Object, IN ACCESS_MASK DesiredAccess, IN POBJECT_TYPE ObjectType, IN KPROCESSOR_MODE AccessMode)
Definition: obref.c:383
PDEVICE_OBJECT DeviceObject
Definition: classpnp.h:626
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _PHYSICAL_DEVICE_EXTENSION * ChildList
Definition: classpnp.h:592
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel) ?(CompletionRoutine !=NULL) :TRUE)
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG NTAPI DebugPrint(IN PSTRING DebugString, IN ULONG ComponentId, IN ULONG Level)
Definition: debug.c:23
struct _DEVICE_RELATIONS DEVICE_RELATIONS
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
return STATUS_SUCCESS
Definition: btrfs.c:2938
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by ClassPnpQueryFdoRelations().

◆ ClassRetryRequest()

VOID NTAPI ClassRetryRequest ( IN PDEVICE_OBJECT  SelfDeviceObject,
IN PIRP  Irp,
IN LARGE_INTEGER  TimeDelta100ns 
)

Definition at line 8780 of file class.c.

8785 {
8786  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension;
8787  PCLASS_PRIVATE_FDO_DATA fdoData;
8788  PCLASS_RETRY_INFO retryInfo;
8789  //PCLASS_RETRY_INFO *previousNext;
8790  LARGE_INTEGER delta;
8791  KIRQL irql;
8792 
8793  //
8794  // this checks we aren't destroying irps
8795  //
8796  ASSERT(sizeof(CLASS_RETRY_INFO) <= (4*sizeof(PVOID)));
8797 
8798  fdoExtension = SelfDeviceObject->DeviceExtension;
8799  fdoData = fdoExtension->PrivateFdoData;