ReactOS  0.4.15-dev-2965-g9a42267
disk.h File Reference
#include "ntddk.h"
#include "scsi.h"
#include <wmidata.h>
#include "classpnp.h"
#include <wmistr.h>
#include "ntstrsafe.h"
#include <storswtr.h>
Include dependency graph for disk.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  _DISK_GROUP_CONTEXT
 
struct  _DISK_DATA
 
struct  _DISK_MEDIA_TYPES_LIST
 
struct  DISKREREGREQUEST
 
struct  _DISK_VERIFY_WORKITEM_CONTEXT
 

Macros

#define DEBUG_COMP_ID   DPFLTR_DISK_ID
 
#define WPP_GUID_DISK   (945186BF, 3DD6, 4f3f, 9C8E, 9EDD3FC9D558)
 
#define WPP_CONTROL_GUIDS   WPP_CONTROL_GUIDS_NORMAL_FLAGS(WPP_GUID_DISK)
 
#define DISK_TAG_GENERAL   ' DcS'
 
#define DISK_TAG_SMART   'aDcS'
 
#define DISK_TAG_INFO_EXCEPTION   'ADcS'
 
#define DISK_TAG_DISABLE_CACHE   'CDcS'
 
#define DISK_TAG_CCONTEXT   'cDcS'
 
#define DISK_TAG_DISK_GEOM   'GDcS'
 
#define DISK_TAG_UPDATE_GEOM   'gDcS'
 
#define DISK_TAG_SENSE_INFO   'IDcS'
 
#define DISK_TAG_PNP_ID   'iDcS'
 
#define DISK_TAG_MODE_DATA   'MDcS'
 
#define DISK_CACHE_MBR_CHECK   'mDcS'
 
#define DISK_TAG_NAME   'NDcS'
 
#define DISK_TAG_READ_CAP   'PDcS'
 
#define DISK_TAG_PART_LIST   'pDcS'
 
#define DISK_TAG_SRB   'SDcS'
 
#define DISK_TAG_START   'sDcS'
 
#define DISK_TAG_UPDATE_CAP   'UDcS'
 
#define DISK_TAG_WI_CONTEXT   'WDcS'
 
#define HackDisableTaggedQueuing   (0x01)
 
#define HackDisableSynchronousTransfers   (0x02)
 
#define HackDisableSpinDown   (0x04)
 
#define HackDisableWriteCache   (0x08)
 
#define HackCauseNotReportableHack   (0x10)
 
#define HackRequiresStartUnitCommand   (0x20)
 
#define DiskDeviceParameterSubkey   L"Disk"
 
#define DiskDeviceUserWriteCacheSetting   L"UserWriteCacheSetting"
 
#define DiskDeviceCacheIsPowerProtected   L"CacheIsPowerProtected"
 
#define FUNCTIONAL_EXTENSION_SIZE   sizeof(FUNCTIONAL_DEVICE_EXTENSION) + sizeof(DISK_DATA)
 
#define MODE_DATA_SIZE   192
 
#define VALUE_BUFFER_SIZE   2048
 
#define SCSI_DISK_TIMEOUT   10
 
#define PARTITION0_LIST_SIZE   4
 
#define MAX_MEDIA_TYPES   4
 
#define MAX_SECTORS_PER_VERIFY   0x100
 
#define ONE_MILLI_SECOND   ((ULONGLONG)10 * 1000)
 
#define DISK_DEFAULT_FAILURE_POLLING_PERIOD   1 * 60 * 60
 
#define CHECK_IRQL()
 
#define DiskIsValidSmartSelfTest(Subcommand)
 
#define DiskReadDriveCapacity(Fdo)   ClassReadDriveCapacity(Fdo)
 
#define DiskGetDetectInfo(FdoExtension, DetectInfo)   (STATUS_UNSUCCESSFUL)
 
#define DiskHashGuid(Guid)   (((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0])
 

Typedefs

typedef struct _DISK_GROUP_CONTEXT DISK_GROUP_CONTEXT
 
typedef struct _DISK_GROUP_CONTEXTPDISK_GROUP_CONTEXT
 
typedef enum _DISK_USER_WRITE_CACHE_SETTING DISK_USER_WRITE_CACHE_SETTING
 
typedef enum _DISK_USER_WRITE_CACHE_SETTINGPDISK_USER_WRITE_CACHE_SETTING
 
typedef struct _DISK_DATA DISK_DATA
 
typedef struct _DISK_DATAPDISK_DATA
 
typedef struct _DISK_MEDIA_TYPES_LIST DISK_MEDIA_TYPES_LIST
 
typedef struct _DISK_MEDIA_TYPES_LISTPDISK_MEDIA_TYPES_LIST
 
typedef struct DISKREREGREQUESTPDISKREREGREQUEST
 
typedef struct _DISK_VERIFY_WORKITEM_CONTEXT DISK_VERIFY_WORKITEM_CONTEXT
 
typedef struct _DISK_VERIFY_WORKITEM_CONTEXTPDISK_VERIFY_WORKITEM_CONTEXT
 

Enumerations

enum  _DISK_USER_WRITE_CACHE_SETTING { DiskWriteCacheDisable = 0, DiskWriteCacheEnable = 1, DiskWriteCacheDefault = -1 }
 

Functions

VOID NTAPI DiskUnload (IN PDRIVER_OBJECT DriverObject)
 
NTSTATUS NTAPI DiskAddDevice (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT Pdo)
 
NTSTATUS NTAPI DiskInitFdo (IN PDEVICE_OBJECT Fdo)
 
NTSTATUS NTAPI DiskStartFdo (IN PDEVICE_OBJECT Fdo)
 
NTSTATUS NTAPI DiskStopDevice (IN PDEVICE_OBJECT DeviceObject, IN UCHAR Type)
 
NTSTATUS NTAPI DiskRemoveDevice (IN PDEVICE_OBJECT DeviceObject, IN UCHAR Type)
 
NTSTATUS NTAPI DiskReadWriteVerification (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI DiskDeviceControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID NTAPI DiskFdoProcessError (PDEVICE_OBJECT DeviceObject, PSCSI_REQUEST_BLOCK Srb, NTSTATUS *Status, BOOLEAN *Retry)
 
NTSTATUS NTAPI DiskShutdownFlush (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS NTAPI DiskGetCacheInformation (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PDISK_CACHE_INFORMATION CacheInfo)
 
NTSTATUS NTAPI DiskSetCacheInformation (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PDISK_CACHE_INFORMATION CacheInfo)
 
VOID DiskLogCacheInformation (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PDISK_CACHE_INFORMATION CacheInfo, IN NTSTATUS Status)
 
NTSTATUS DiskIoctlGetCacheSetting (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS DiskIoctlSetCacheSetting (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
VOID DiskFlushDispatch (IN PDEVICE_OBJECT Fdo, IN PDISK_GROUP_CONTEXT FlushContext)
 
NTSTATUS DiskModeSelect (IN PDEVICE_OBJECT DeviceObject, _In_reads_bytes_(Length) PCHAR ModeSelectBuffer, IN ULONG Length, IN BOOLEAN SavePage)
 
NTSTATUS DiskPerformSmartCommand (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN ULONG SrbControlCode, IN UCHAR Command, IN UCHAR Feature, IN UCHAR SectorCount, IN UCHAR SectorNumber, IN OUT PSRB_IO_CONTROL SrbControl, OUT PULONG BufferSize)
 
NTSTATUS DiskGetInfoExceptionInformation (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, OUT PMODE_INFO_EXCEPTIONS ReturnPageData)
 
NTSTATUS DiskSetInfoExceptionInformation (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMODE_INFO_EXCEPTIONS PageData)
 
NTSTATUS DiskGetModePage (_In_ PDEVICE_OBJECT Fdo, _In_ UCHAR PageMode, _In_ UCHAR PageControl, _In_ PMODE_PARAMETER_HEADER ModeData, _Inout_ PULONG ModeDataSize, _Out_ PVOID *PageData)
 
NTSTATUS DiskEnableInfoExceptions (_In_ PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, _In_ BOOLEAN Enable)
 
NTSTATUS DiskDetectFailurePrediction (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PFAILURE_PREDICTION_METHOD FailurePredictCapability, BOOLEAN ScsiAddressAvailable)
 
NTSTATUS DiskCreateFdo (IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT LowerDeviceObject, IN PULONG DeviceCount, IN BOOLEAN DasdAccessOnly)
 
VOID NTAPI DiskSetSpecialHacks (IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN ULONG_PTR Data)
 
VOID ResetBus (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS DiskGenerateDeviceName (IN ULONG DeviceNumber, OUT PCCHAR *RawName)
 
VOID DiskCreateSymbolicLinks (IN PDEVICE_OBJECT DeviceObject)
 
VOID DiskDeleteSymbolicLinks (IN PDEVICE_OBJECT DeviceObject)
 
NTSTATUS NTAPI DiskFdoQueryWmiRegInfo (IN PDEVICE_OBJECT DeviceObject, OUT ULONG *RegFlags, OUT PUNICODE_STRING InstanceName)
 
NTSTATUS NTAPI DiskFdoQueryWmiRegInfoEx (IN PDEVICE_OBJECT DeviceObject, OUT ULONG *RegFlags, OUT PUNICODE_STRING InstanceName, OUT PUNICODE_STRING MofName)
 
NTSTATUS NTAPI DiskFdoQueryWmiDataBlock (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG BufferAvail, OUT PUCHAR Buffer)
 
NTSTATUS NTAPI DiskFdoSetWmiDataBlock (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG BufferSize, IN PUCHAR Buffer)
 
NTSTATUS NTAPI DiskFdoSetWmiDataItem (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG DataItemId, IN ULONG BufferSize, IN PUCHAR Buffer)
 
NTSTATUS NTAPI DiskFdoExecuteWmiMethod (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN ULONG MethodId, IN ULONG InBufferSize, IN ULONG OutBufferSize, IN PUCHAR Buffer)
 
NTSTATUS NTAPI DiskWmiFunctionControl (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN ULONG GuidIndex, IN CLASSENABLEDISABLEFUNCTION Function, IN BOOLEAN Enable)
 
NTSTATUS DiskReadFailurePredictStatus (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PSTORAGE_FAILURE_PREDICT_STATUS DiskSmartStatus)
 
NTSTATUS DiskReadFailurePredictData (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PSTORAGE_FAILURE_PREDICT_DATA DiskSmartData)
 
NTSTATUS DiskEnableDisableFailurePrediction (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN Enable)
 
NTSTATUS DiskEnableDisableFailurePredictPolling (PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN Enable, ULONG PollTimeInSeconds)
 
NTSTATUS DiskInitializeReregistration (VOID)
 
NTSTATUS DiskDetermineMediaTypes (IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN UCHAR MediumType, IN UCHAR DensityCode, IN BOOLEAN MediaPresent, IN BOOLEAN IsWritable)
 
NTSTATUS DiskIoctlGetLengthInfo (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS DiskIoctlGetDriveGeometry (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlGetDriveGeometryEx (IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
 
NTSTATUS DiskIoctlGetCacheInformation (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlSetCacheInformation (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlGetMediaTypesEx (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlPredictFailure (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlEnableFailurePrediction (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlVerify (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlReassignBlocks (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlReassignBlocksEx (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlIsWritable (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlSetVerify (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlClearVerify (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlUpdateDriveSize (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlGetVolumeDiskExtents (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlSmartGetVersion (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlSmartReceiveDriveData (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
NTSTATUS DiskIoctlSmartSendDriveCommand (IN PDEVICE_OBJECT DeviceObject, IN OUT PIRP Irp)
 
FORCEINLINE PCDB GetSrbScsiData (_In_ PSTORAGE_REQUEST_BLOCK SrbEx, _In_opt_ PUCHAR CdbLength8, _In_opt_ PULONG CdbLength32, _In_opt_ PUCHAR ScsiStatus, _In_opt_ PVOID *SenseInfoBuffer, _In_opt_ PUCHAR SenseInfoBufferLength)
 
FORCEINLINE VOID SetSrbScsiData (_In_ PSTORAGE_REQUEST_BLOCK SrbEx, _In_ UCHAR CdbLength8, _In_ ULONG CdbLength32, _In_ UCHAR ScsiStatus, _In_opt_ PVOID SenseInfoBuffer, _In_ UCHAR SenseInfoBufferLength)
 

Variables

CLASSPNP_SCAN_FOR_SPECIAL_INFO DiskBadControllers []
 
const DISK_MEDIA_TYPES_LIST DiskMediaTypes []
 
const DISK_MEDIA_TYPES_LIST DiskMediaTypesExclude []
 
DRIVER_INITIALIZE DriverEntry
 
IO_WORKITEM_ROUTINE DisableWriteCache
 
IO_WORKITEM_ROUTINE DiskIoctlVerifyThread
 
IO_COMPLETION_ROUTINE DiskFlushComplete
 
GUIDREGINFO DiskWmiFdoGuidList []
 

Macro Definition Documentation

◆ CHECK_IRQL

#define CHECK_IRQL ( )
Value:
NT_ASSERT(KeGetCurrentIrql() < DISPATCH_LEVEL); \
}
#define KeGetCurrentIrql()
Definition: env_spec_w32.h:706
#define STATUS_INVALID_LEVEL
Definition: ntstatus.h:564
#define DISPATCH_LEVEL
Definition: env_spec_w32.h:696

Definition at line 458 of file disk.h.

◆ DEBUG_COMP_ID

#define DEBUG_COMP_ID   DPFLTR_DISK_ID

Definition at line 35 of file disk.h.

◆ DISK_CACHE_MBR_CHECK

#define DISK_CACHE_MBR_CHECK   'mDcS'

Definition at line 63 of file disk.h.

◆ DISK_DEFAULT_FAILURE_POLLING_PERIOD

#define DISK_DEFAULT_FAILURE_POLLING_PERIOD   1 * 60 * 60

Definition at line 456 of file disk.h.

◆ DISK_TAG_CCONTEXT

#define DISK_TAG_CCONTEXT   'cDcS'

Definition at line 57 of file disk.h.

◆ DISK_TAG_DISABLE_CACHE

#define DISK_TAG_DISABLE_CACHE   'CDcS'

Definition at line 56 of file disk.h.

◆ DISK_TAG_DISK_GEOM

#define DISK_TAG_DISK_GEOM   'GDcS'

Definition at line 58 of file disk.h.

◆ DISK_TAG_GENERAL

#define DISK_TAG_GENERAL   ' DcS'

Definition at line 53 of file disk.h.

◆ DISK_TAG_INFO_EXCEPTION

#define DISK_TAG_INFO_EXCEPTION   'ADcS'

Definition at line 55 of file disk.h.

◆ DISK_TAG_MODE_DATA

#define DISK_TAG_MODE_DATA   'MDcS'

Definition at line 62 of file disk.h.

◆ DISK_TAG_NAME

#define DISK_TAG_NAME   'NDcS'

Definition at line 64 of file disk.h.

◆ DISK_TAG_PART_LIST

#define DISK_TAG_PART_LIST   'pDcS'

Definition at line 66 of file disk.h.

◆ DISK_TAG_PNP_ID

#define DISK_TAG_PNP_ID   'iDcS'

Definition at line 61 of file disk.h.

◆ DISK_TAG_READ_CAP

#define DISK_TAG_READ_CAP   'PDcS'

Definition at line 65 of file disk.h.

◆ DISK_TAG_SENSE_INFO

#define DISK_TAG_SENSE_INFO   'IDcS'

Definition at line 60 of file disk.h.

◆ DISK_TAG_SMART

#define DISK_TAG_SMART   'aDcS'

Definition at line 54 of file disk.h.

◆ DISK_TAG_SRB

#define DISK_TAG_SRB   'SDcS'

Definition at line 67 of file disk.h.

◆ DISK_TAG_START

#define DISK_TAG_START   'sDcS'

Definition at line 68 of file disk.h.

◆ DISK_TAG_UPDATE_CAP

#define DISK_TAG_UPDATE_CAP   'UDcS'

Definition at line 69 of file disk.h.

◆ DISK_TAG_UPDATE_GEOM

#define DISK_TAG_UPDATE_GEOM   'gDcS'

Definition at line 59 of file disk.h.

◆ DISK_TAG_WI_CONTEXT

#define DISK_TAG_WI_CONTEXT   'WDcS'

Definition at line 70 of file disk.h.

◆ DiskDeviceCacheIsPowerProtected

#define DiskDeviceCacheIsPowerProtected   L"CacheIsPowerProtected"

Definition at line 405 of file disk.h.

◆ DiskDeviceParameterSubkey

#define DiskDeviceParameterSubkey   L"Disk"

Definition at line 403 of file disk.h.

◆ DiskDeviceUserWriteCacheSetting

#define DiskDeviceUserWriteCacheSetting   L"UserWriteCacheSetting"

Definition at line 404 of file disk.h.

◆ DiskGetDetectInfo

#define DiskGetDetectInfo (   FdoExtension,
  DetectInfo 
)    (STATUS_UNSUCCESSFUL)

Definition at line 861 of file disk.h.

◆ DiskHashGuid

#define DiskHashGuid (   Guid)    (((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0])

Definition at line 865 of file disk.h.

◆ DiskIsValidSmartSelfTest

#define DiskIsValidSmartSelfTest (   Subcommand)
Value:
( ((Subcommand) == SMART_OFFLINE_ROUTINE_OFFLINE) || \
((Subcommand) == SMART_SHORT_SELFTEST_OFFLINE) || \
((Subcommand) == SMART_EXTENDED_SELFTEST_OFFLINE) )
#define SMART_SHORT_SELFTEST_OFFLINE
Definition: ntdddisk.h:718
#define SMART_EXTENDED_SELFTEST_OFFLINE
Definition: ntdddisk.h:719
#define SMART_OFFLINE_ROUTINE_OFFLINE
Definition: ntdddisk.h:717

Definition at line 619 of file disk.h.

◆ DiskReadDriveCapacity

#define DiskReadDriveCapacity (   Fdo)    ClassReadDriveCapacity(Fdo)

Definition at line 818 of file disk.h.

◆ FUNCTIONAL_EXTENSION_SIZE

#define FUNCTIONAL_EXTENSION_SIZE   sizeof(FUNCTIONAL_DEVICE_EXTENSION) + sizeof(DISK_DATA)

Definition at line 408 of file disk.h.

◆ HackCauseNotReportableHack

#define HackCauseNotReportableHack   (0x10)

Definition at line 399 of file disk.h.

◆ HackDisableSpinDown

#define HackDisableSpinDown   (0x04)

Definition at line 397 of file disk.h.

◆ HackDisableSynchronousTransfers

#define HackDisableSynchronousTransfers   (0x02)

Definition at line 396 of file disk.h.

◆ HackDisableTaggedQueuing

#define HackDisableTaggedQueuing   (0x01)

Definition at line 395 of file disk.h.

◆ HackDisableWriteCache

#define HackDisableWriteCache   (0x08)

Definition at line 398 of file disk.h.

◆ HackRequiresStartUnitCommand

#define HackRequiresStartUnitCommand   (0x20)

Definition at line 400 of file disk.h.

◆ MAX_MEDIA_TYPES

#define MAX_MEDIA_TYPES   4

Definition at line 415 of file disk.h.

◆ MAX_SECTORS_PER_VERIFY

#define MAX_SECTORS_PER_VERIFY   0x100

Definition at line 435 of file disk.h.

◆ MODE_DATA_SIZE

#define MODE_DATA_SIZE   192

Definition at line 410 of file disk.h.

◆ ONE_MILLI_SECOND

#define ONE_MILLI_SECOND   ((ULONGLONG)10 * 1000)

Definition at line 440 of file disk.h.

◆ PARTITION0_LIST_SIZE

#define PARTITION0_LIST_SIZE   4

Definition at line 413 of file disk.h.

◆ SCSI_DISK_TIMEOUT

#define SCSI_DISK_TIMEOUT   10

Definition at line 412 of file disk.h.

◆ VALUE_BUFFER_SIZE

#define VALUE_BUFFER_SIZE   2048

Definition at line 411 of file disk.h.

◆ WPP_CONTROL_GUIDS

Definition at line 44 of file disk.h.

◆ WPP_GUID_DISK

#define WPP_GUID_DISK   (945186BF, 3DD6, 4f3f, 9C8E, 9EDD3FC9D558)

Definition at line 42 of file disk.h.

Typedef Documentation

◆ DISK_DATA

◆ DISK_GROUP_CONTEXT

◆ DISK_MEDIA_TYPES_LIST

◆ DISK_USER_WRITE_CACHE_SETTING

◆ DISK_VERIFY_WORKITEM_CONTEXT

◆ PDISK_DATA

◆ PDISK_GROUP_CONTEXT

◆ PDISK_MEDIA_TYPES_LIST

◆ PDISK_USER_WRITE_CACHE_SETTING

◆ PDISK_VERIFY_WORKITEM_CONTEXT

◆ PDISKREREGREQUEST

Enumeration Type Documentation

◆ _DISK_USER_WRITE_CACHE_SETTING

Enumerator
DiskWriteCacheDisable 
DiskWriteCacheEnable 
DiskWriteCacheDefault 

Definition at line 177 of file disk.h.

178 {
182 
enum _DISK_USER_WRITE_CACHE_SETTING * PDISK_USER_WRITE_CACHE_SETTING
enum _DISK_USER_WRITE_CACHE_SETTING DISK_USER_WRITE_CACHE_SETTING

Function Documentation

◆ DiskAddDevice()

NTSTATUS NTAPI DiskAddDevice ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  Pdo 
)

Definition at line 53 of file pnp.c.

78 {
79  ULONG rootPartitionMountable = FALSE;
80 
81  PCONFIGURATION_INFORMATION configurationInformation;
82  ULONG diskCount;
83 
85 
86  PAGED_CODE();
87 
88  //
89  // See if we should be allowing file systems to mount on partition zero.
90  //
91 
92  TRY {
93  HANDLE deviceKey = NULL;
94 
95  UNICODE_STRING diskKeyName;
96  OBJECT_ATTRIBUTES objectAttributes = {0};
97  HANDLE diskKey;
98 
99  RTL_QUERY_REGISTRY_TABLE queryTable[2] = { 0 };
100 
103  KEY_READ,
104  &deviceKey);
105 
106  if(!NT_SUCCESS(status)) {
107  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_PNP, "DiskAddDevice: Error %#08lx opening device key "
108  "for pdo %p\n",
110  LEAVE;
111  }
112 
113  RtlInitUnicodeString(&diskKeyName, L"Disk");
114  InitializeObjectAttributes(&objectAttributes,
115  &diskKeyName,
117  deviceKey,
118  NULL);
119 
120  status = ZwOpenKey(&diskKey, KEY_READ, &objectAttributes);
121  ZwClose(deviceKey);
122 
123  if(!NT_SUCCESS(status)) {
124  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_PNP, "DiskAddDevice: Error %#08lx opening disk key "
125  "for pdo %p device key %p\n",
126  status, PhysicalDeviceObject, deviceKey));
127  LEAVE;
128  }
129 
131  queryTable[0].Name = L"RootPartitionMountable";
132  queryTable[0].EntryContext = &(rootPartitionMountable);
134 
135 #ifdef _MSC_VER
136 #pragma prefast(suppress:6309, "We don't have QueryRoutine so Context doesn't make any sense")
137 #endif
139  diskKey,
140  queryTable,
141  NULL,
142  NULL);
143 
144  if(!NT_SUCCESS(status)) {
145  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_PNP, "DiskAddDevice: Error %#08lx reading value from "
146  "disk key %p for pdo %p\n",
147  status, diskKey, PhysicalDeviceObject));
148  }
149 
150  ZwClose(diskKey);
151 
152  } FINALLY {
153 
154  //
155  // Do nothing.
156  //
157 
158  if(!NT_SUCCESS(status)) {
159  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_PNP, "DiskAddDevice: Will %sallow file system to mount on "
160  "partition zero of disk %p\n",
161  (rootPartitionMountable ? "" : "not "),
163  }
164  }
165 
166  //
167  // Create device objects for disk
168  //
169 
170  diskCount = 0;
171 
173  DriverObject,
175  &diskCount,
176  (BOOLEAN) !rootPartitionMountable
177  );
178 
179  //
180  // Get the number of disks already initialized.
181  //
182 
183  configurationInformation = IoGetConfigurationInformation();
184 
185  if (NT_SUCCESS(status)) {
186 
187  //
188  // Increment system disk device count.
189  //
190 
191  configurationInformation->DiskCount++;
192 
193  }
194 
195  return status;
196 
197 } // end DiskAddDevice()
#define FINALLY
Definition: classpnp.h:116
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
PCONFIGURATION_INFORMATION NTAPI IoGetConfigurationInformation(VOID)
Definition: iorsrce.c:830
#define PLUGPLAY_REGKEY_DEVICE
Definition: iofuncs.h:2786
#define KEY_READ
Definition: nt_native.h:1023
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
LONG NTSTATUS
Definition: precomp.h:26
#define LEAVE
Definition: classpnp.h:115
#define TRY(sps, bps)
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define FALSE
Definition: types.h:117
unsigned char BOOLEAN
#define RTL_QUERY_REGISTRY_TYPECHECK
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
NTSTATUS DiskCreateFdo(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PULONG DeviceCount, IN BOOLEAN DasdAccessOnly)
Definition: disk.c:307
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
#define RTL_REGISTRY_HANDLE
Definition: nt_native.h:168
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
#define RTL_QUERY_REGISTRY_TYPECHECK_SHIFT
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
Definition: pnpmgr.c:2191
unsigned int ULONG
Definition: retypes.h:1
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define REG_NONE
Definition: nt_native.h:1492
#define REG_DWORD
Definition: sdbapi.c:596
static SERVICE_STATUS status
Definition: service.c:31
#define RTL_QUERY_REGISTRY_DIRECT
Definition: nt_native.h:144
#define PAGED_CODE()
Definition: ps.c:97

Referenced by DriverEntry().

◆ DiskCreateFdo()

NTSTATUS DiskCreateFdo ( IN PDRIVER_OBJECT  DriverObject,
IN PDEVICE_OBJECT  LowerDeviceObject,
IN PULONG  DeviceCount,
IN BOOLEAN  DasdAccessOnly 
)

Definition at line 307 of file disk.c.

340 {
341  PCCHAR deviceName = NULL;
342  HANDLE handle = NULL;
343  PDEVICE_OBJECT lowerDevice = NULL;
345  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension;
347 
348  PAGED_CODE();
349 
350  *DeviceCount = 0;
351 
352  //
353  // Set up an object directory to contain the objects for this
354  // device and all its partitions.
355  //
356 
357  do {
358 
359  WCHAR dirBuffer[64] = { 0 };
360  UNICODE_STRING dirName;
361  OBJECT_ATTRIBUTES objectAttribs;
362 
363  status = RtlStringCchPrintfW(dirBuffer, sizeof(dirBuffer) / sizeof(dirBuffer[0]) - 1, L"\\Device\\Harddisk%d", *DeviceCount);
364  if (!NT_SUCCESS(status)) {
365  TracePrint((TRACE_LEVEL_FATAL, TRACE_FLAG_PNP, "DiskCreateFdo: Format symbolic link failed with error: 0x%X\n", status));
366  return status;
367  }
368 
369  RtlInitUnicodeString(&dirName, dirBuffer);
370 
371  InitializeObjectAttributes(&objectAttribs,
372  &dirName,
374  NULL,
375  NULL);
376 
379  &objectAttribs);
380 
381  (*DeviceCount)++;
382 
383  } while((status == STATUS_OBJECT_NAME_COLLISION) ||
385 
386  if (!NT_SUCCESS(status)) {
387 
388  TracePrint((TRACE_LEVEL_FATAL, TRACE_FLAG_PNP, "DiskCreateFdo: Could not create directory - %lx\n", status));
389 
390  return(status);
391  }
392 
393  //
394  // When this loop exits the count is inflated by one - fix that.
395  //
396 
397  (*DeviceCount)--;
398 
399  //
400  // Claim the device.
401  //
402 
404 
405  status = ClassClaimDevice(lowerDevice, FALSE);
406 
407  if (!NT_SUCCESS(status)) {
409  ZwClose(handle);
410  ObDereferenceObject(lowerDevice);
411  return status;
412  }
413 
414  //
415  // Create a device object for this device. Each physical disk will
416  // have at least one device object. The required device object
417  // describes the entire device. Its directory path is
418  // \Device\HarddiskN\Partition0, where N = device number.
419  //
420 
421  status = DiskGenerateDeviceName(*DeviceCount, &deviceName);
422 
423  if(!NT_SUCCESS(status)) {
424  TracePrint((TRACE_LEVEL_FATAL, TRACE_FLAG_PNP, "DiskCreateFdo - couldn't create name %lx\n", status));
425 
426  goto DiskCreateFdoExit;
427 
428  }
429 
430  status = ClassCreateDeviceObject(DriverObject,
431  deviceName,
433  TRUE,
434  &deviceObject);
435 
436  if (!NT_SUCCESS(status)) {
437  TracePrint((TRACE_LEVEL_FATAL, TRACE_FLAG_PNP, "DiskCreateFdo: Can not create device object %s\n", deviceName));
438  goto DiskCreateFdoExit;
439  }
440 
441  FREE_POOL(deviceName);
442 
443  //
444  // Indicate that IRPs should include MDLs for data transfers.
445  //
446 
448 
449  fdoExtension = deviceObject->DeviceExtension;
450 
451  if(DasdAccessOnly) {
452 
453  //
454  // Inidicate that only RAW should be allowed to mount on the root
455  // partition object. This ensures that a file system can't doubly
456  // mount on a super-floppy by mounting once on P0 and once on P1.
457  //
458 
459 #ifdef _MSC_VER
460 #pragma prefast(suppress:28175);
461 #endif
462  SET_FLAG(deviceObject->Vpb->Flags, VPB_RAW_MOUNT);
463  }
464 
465  //
466  // Initialize lock count to zero. The lock count is used to
467  // disable the ejection mechanism on devices that support
468  // removable media. Only the lock count in the physical
469  // device extension is used.
470  //
471 
472  fdoExtension->LockCount = 0;
473 
474  //
475  // Save system disk number.
476  //
477 
478  fdoExtension->DeviceNumber = *DeviceCount;
479 
480  //
481  // Set the alignment requirements for the device based on the
482  // host adapter requirements
483  //
484 
485  if (lowerDevice->AlignmentRequirement > deviceObject->AlignmentRequirement) {
486  deviceObject->AlignmentRequirement = lowerDevice->AlignmentRequirement;
487  }
488 
489  //
490  // Finally, attach to the pdo
491  //
492 
493  fdoExtension->LowerPdo = PhysicalDeviceObject;
494 
495  fdoExtension->CommonExtension.LowerDeviceObject =
497 
498 
499  if(fdoExtension->CommonExtension.LowerDeviceObject == NULL) {
500 
501  //
502  // Uh - oh, we couldn't attach
503  // cleanup and return
504  //
505 
507  goto DiskCreateFdoExit;
508  }
509 
510  //
511  // Clear the init flag.
512  //
513 
515 
516  //
517  // Store a handle to the device object directory for this disk
518  //
519 
520  fdoExtension->DeviceDirectory = handle;
521 
522  ObDereferenceObject(lowerDevice);
523 
524  return STATUS_SUCCESS;
525 
526 DiskCreateFdoExit:
527 
528  if (deviceObject != NULL)
529  {
531  }
532 
533  FREE_POOL(deviceName);
534 
535  ObDereferenceObject(lowerDevice);
536 
538  ZwClose(handle);
539 
540  return status;
541 }
#define DO_DEVICE_INITIALIZING
Definition: env_spec_w32.h:399
#define STATUS_OBJECT_NAME_COLLISION
Definition: udferr_usr.h:150
#define OBJ_CASE_INSENSITIVE
Definition: winternl.h:228
#define TRUE
Definition: types.h:120
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
#define STATUS_OBJECT_NAME_EXISTS
Definition: ntstatus.h:114
LONG NTSTATUS
Definition: precomp.h:26
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:873
PDEVICE_OBJECT PhysicalDeviceObject
Definition: btrfs_drv.h:1155
#define OBJ_KERNEL_HANDLE
Definition: winternl.h:231
#define DO_DIRECT_IO
Definition: env_spec_w32.h:396
namespace GUID const ADDRINFOEXW ADDRINFOEXW struct timeval OVERLAPPED LPLOOKUPSERVICE_COMPLETION_ROUTINE HANDLE * handle
Definition: sock.c:82
#define FALSE
Definition: types.h:117
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
ULONG DeviceCount
Definition: mpu401.c:26
PDEVICE_OBJECT NTAPI IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice, IN PDEVICE_OBJECT TargetDevice)
Definition: device.c:966
NTSYSAPI NTSTATUS NTAPI ZwCreateDirectoryObject(_Out_ PHANDLE DirectoryHandle, _In_ ACCESS_MASK DesiredAccess, _In_ POBJECT_ATTRIBUTES ObjectAttributes)
NTSTATUS DiskGenerateDeviceName(IN ULONG DeviceNumber, OUT PCCHAR *RawName)
Definition: pnp.c:612
#define CLEAR_FLAG(Flags, Bit)
Definition: cdrom.h:1494
PDEVICE_OBJECT NTAPI IoGetAttachedDeviceReference(PDEVICE_OBJECT DeviceObject)
Definition: device.c:1406
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
Definition: wdfdriver.h:213
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ObDereferenceObject
Definition: obfuncs.h:203
#define STATUS_UNSUCCESSFUL
Definition: udferr_usr.h:132
static const WCHAR L[]
Definition: oid.c:1250
PDEVICE_OBJECT LowerPdo
Definition: classpnp.h:875
#define OBJ_PERMANENT
Definition: winternl.h:226
ULONG AlignmentRequirement
Definition: env_spec_w32.h:420
MxDeviceObject deviceObject
#define VPB_RAW_MOUNT
Definition: iotypes.h:1811
VOID NTAPI IoDeleteDevice(IN PDEVICE_OBJECT DeviceObject)
Definition: device.c:1251
#define DIRECTORY_ALL_ACCESS
Definition: nt_native.h:1259
#define NULL
Definition: types.h:112
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define InitializeObjectAttributes(p, n, a, r, s)
Definition: reg.c:106
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
NTSYSAPI NTSTATUS NTAPI ZwMakeTemporaryObject(_In_ HANDLE Handle)
#define SET_FLAG(Flags, Bit)
Definition: cdrom.h:1493
#define PAGED_CODE()
Definition: ps.c:97

Referenced by DiskAddDevice().

◆ DiskCreateSymbolicLinks()

VOID DiskCreateSymbolicLinks ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 676 of file pnp.c.

702 {
703  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
704  PDISK_DATA diskData = commonExtension->DriverData;
705 
706  WCHAR wideSourceName[64] = { 0 };
707  UNICODE_STRING unicodeSourceName;
708 
710 
711  PAGED_CODE();
712 
713  //
714  // Build the destination for the link first using the device name
715  // stored in the device object
716  //
717 
718  NT_ASSERT(commonExtension->DeviceName.Buffer);
719 
720  if(!diskData->LinkStatus.WellKnownNameCreated) {
721  //
722  // Put together the source name using the partition and device number
723  // in the device extension and disk data segment
724  //
725 
726  status = RtlStringCchPrintfW(wideSourceName, sizeof(wideSourceName) / sizeof(wideSourceName[0]) - 1,
727  L"\\Device\\Harddisk%d\\Partition0",
728  commonExtension->PartitionZeroExtension->DeviceNumber);
729 
730  if (NT_SUCCESS(status)) {
731 
732  RtlInitUnicodeString(&unicodeSourceName, wideSourceName);
733 
734  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_PNP, "DiskCreateSymbolicLink: Linking %wZ to %wZ\n",
735  &unicodeSourceName,
736  &commonExtension->DeviceName));
737 
738  status = IoCreateSymbolicLink(&unicodeSourceName,
739  &commonExtension->DeviceName);
740 
741  if(NT_SUCCESS(status)){
742  diskData->LinkStatus.WellKnownNameCreated = TRUE;
743  }
744  }
745  }
746 
747  if (!diskData->LinkStatus.PhysicalDriveLinkCreated) {
748 
749  //
750  // Create a physical drive N link using the device number we saved
751  // away during AddDevice.
752  //
753 
754  status = RtlStringCchPrintfW(wideSourceName, sizeof(wideSourceName) / sizeof(wideSourceName[0]) - 1,
755  L"\\DosDevices\\PhysicalDrive%d",
756  commonExtension->PartitionZeroExtension->DeviceNumber);
757  if (NT_SUCCESS(status)) {
758 
759  RtlInitUnicodeString(&unicodeSourceName, wideSourceName);
760 
761  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_PNP, "DiskCreateSymbolicLink: Linking %wZ to %wZ\n",
762  &unicodeSourceName,
763  &(commonExtension->DeviceName)));
764 
765  status = IoCreateSymbolicLink(&unicodeSourceName,
766  &(commonExtension->DeviceName));
767 
768  if(NT_SUCCESS(status)) {
769  diskData->LinkStatus.PhysicalDriveLinkCreated = TRUE;
770  }
771  }
772  }
773 
774 
775  return;
776 }
#define TRUE
Definition: types.h:120
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
struct _FUNCTIONAL_DEVICE_EXTENSION * PartitionZeroExtension
Definition: classpnp.h:599
LONG NTSTATUS
Definition: precomp.h:26
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
UNICODE_STRING DeviceName
Definition: classpnp.h:615
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _DISK_DATA::@1030 LinkStatus
static SERVICE_STATUS status
Definition: service.c:31
#define PAGED_CODE()
#define NT_ASSERT
Definition: rtlfuncs.h:3310
Definition: ps.c:97

Referenced by DiskInitFdo().

◆ DiskDeleteSymbolicLinks()

VOID DiskDeleteSymbolicLinks ( IN PDEVICE_OBJECT  DeviceObject)

Definition at line 780 of file pnp.c.

802 {
803  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
804  PDISK_DATA diskData = commonExtension->DriverData;
805 
806  WCHAR wideLinkName[64] = { 0 };
807  UNICODE_STRING unicodeLinkName;
809 
810  PAGED_CODE();
811 
812  if(diskData->LinkStatus.WellKnownNameCreated) {
813 
814  status = RtlStringCchPrintfW(wideLinkName, sizeof(wideLinkName) / sizeof(wideLinkName[0]) - 1,
815  L"\\Device\\Harddisk%d\\Partition0",
816  commonExtension->PartitionZeroExtension->DeviceNumber);
817  if (NT_SUCCESS(status)) {
818  RtlInitUnicodeString(&unicodeLinkName, wideLinkName);
819  IoDeleteSymbolicLink(&unicodeLinkName);
820  }
821  diskData->LinkStatus.WellKnownNameCreated = FALSE;
822  }
823 
824  if(diskData->LinkStatus.PhysicalDriveLinkCreated) {
825 
826  status = RtlStringCchPrintfW(wideLinkName, sizeof(wideLinkName) / sizeof(wideLinkName[0]) - 1,
827  L"\\DosDevices\\PhysicalDrive%d",
828  commonExtension->PartitionZeroExtension->DeviceNumber);
829  if (NT_SUCCESS(status)) {
830  RtlInitUnicodeString(&unicodeLinkName, wideLinkName);
831  IoDeleteSymbolicLink(&unicodeLinkName);
832  }
833  diskData->LinkStatus.PhysicalDriveLinkCreated = FALSE;
834  }
835 
836 
837  return;
838 }
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
Definition: ntstrsafe.h:1110
struct _FUNCTIONAL_DEVICE_EXTENSION * PartitionZeroExtension
Definition: classpnp.h:599
LONG NTSTATUS
Definition: precomp.h:26
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define FALSE
Definition: types.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
static const WCHAR L[]
Definition: oid.c:1250
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
struct _DISK_DATA::@1030 LinkStatus
static SERVICE_STATUS status
Definition: service.c:31
#define PAGED_CODE()
Definition: ps.c:97

Referenced by DiskRemoveDevice().

◆ DiskDetectFailurePrediction()

NTSTATUS DiskDetectFailurePrediction ( PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
PFAILURE_PREDICTION_METHOD  FailurePredictCapability,
BOOLEAN  ScsiAddressAvailable 
)

Definition at line 2230 of file diskwmi.c.

2270 {
2272  PDISK_DATA diskData = (PDISK_DATA)(commonExtension->DriverData);
2273  BOOLEAN supportFP;
2274  NTSTATUS status;
2275  STORAGE_PREDICT_FAILURE checkFailure;
2276  STORAGE_FAILURE_PREDICT_STATUS diskSmartStatus;
2277 
2278  PAGED_CODE();
2279 
2280  //
2281  // Assume no failure predict mechanisms
2282  //
2283  *FailurePredictCapability = FailurePredictionNone;
2284 
2285  //
2286  // See if this is an IDE drive that supports SMART. If so enable SMART
2287  // and then ensure that it suports the SMART READ STATUS command
2288  //
2289 
2290  if (ScsiAddressAvailable)
2291  {
2292  DiskGetIdentifyInfo(FdoExtension, &supportFP);
2293 
2294  if (supportFP)
2295  {
2297  if (NT_SUCCESS(status))
2298  {
2299  *FailurePredictCapability = FailurePredictionSmart;
2300  diskData->FailurePredictionEnabled = TRUE;
2301 
2303  &diskSmartStatus);
2304 
2305  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "Disk: Device %p %s IDE SMART\n",
2306  FdoExtension->DeviceObject,
2307  NT_SUCCESS(status) ? "does" : "does not"));
2308 
2309  if (!NT_SUCCESS(status))
2310  {
2311  *FailurePredictCapability = FailurePredictionNone;
2312  diskData->FailurePredictionEnabled = FALSE;
2313  }
2314  }
2315  return(status);
2316  }
2317  }
2318  //
2319  // See if there is a a filter driver to intercept
2320  // IOCTL_STORAGE_PREDICT_FAILURE
2321  //
2323  &checkFailure);
2324 
2325  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "Disk: Device %p %s IOCTL_STORAGE_FAILURE_PREDICT\n",
2326  FdoExtension->DeviceObject,
2327  NT_SUCCESS(status) ? "does" : "does not"));
2328 
2329  if (NT_SUCCESS(status))
2330  {
2331  *FailurePredictCapability = FailurePredictionIoctl;
2332  diskData->FailurePredictionEnabled = TRUE;
2333  if (checkFailure.PredictFailure)
2334  {
2335  checkFailure.PredictFailure = 512;
2336  ClassNotifyFailurePredicted(FdoExtension,
2337  (PUCHAR)&checkFailure,
2338  sizeof(checkFailure),
2339  (BOOLEAN)(FdoExtension->FailurePredicted == FALSE),
2340  0x11,
2341  diskData->ScsiAddress.PathId,
2342  diskData->ScsiAddress.TargetId,
2343  diskData->ScsiAddress.Lun);
2344 
2345  FdoExtension->FailurePredicted = TRUE;
2346  }
2347  return(status);
2348  }
2349 
2350  //
2351  // Finally we assume it will not be a scsi smart drive. but
2352  // we'll also send off an asynchronous mode sense so that if
2353  // it is SMART we'll reregister the device object
2354  //
2355 
2356  *FailurePredictCapability = FailurePredictionNone;
2357 
2359 
2360  return(STATUS_SUCCESS);
2361 }
UCHAR PathId
Definition: scsi_port.h:149
struct _DISK_DATA * PDISK_DATA
NTSTATUS DiskReadFailurePredictStatus(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PSTORAGE_FAILURE_PREDICT_STATUS DiskSmartStatus)
Definition: diskwmi.c:1251
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
SCSI_ADDRESS ScsiAddress
Definition: disk.h:325
NTSTATUS DiskInfoExceptionCheck(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: diskwmi.c:1922
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
UCHAR TargetId
Definition: scsi_port.h:150
#define FALSE
Definition: types.h:117
BOOLEAN FailurePredictionEnabled
Definition: disk.h:346
unsigned char BOOLEAN
static NTSTATUS DiskEnableSmart(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: diskwmi.c:271
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
NTSTATUS DiskGetIdentifyInfo(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PBOOLEAN SupportSmart)
Definition: diskwmi.c:813
NTSTATUS DiskSendFailurePredictIoctl(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PSTORAGE_PREDICT_FAILURE checkFailure)
Definition: diskwmi.c:854
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
#define PAGED_CODE()
Definition: ps.c:97

Referenced by DiskInitFdo().

◆ DiskDetermineMediaTypes()

NTSTATUS DiskDetermineMediaTypes ( IN PDEVICE_OBJECT  Fdo,
IN PIRP  Irp,
IN UCHAR  MediumType,
IN UCHAR  DensityCode,
IN BOOLEAN  MediaPresent,
IN BOOLEAN  IsWritable 
)

Definition at line 655 of file disk.c.

685 {
686  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
688 
689  PGET_MEDIA_TYPES mediaTypes = Irp->AssociatedIrp.SystemBuffer;
690  PDEVICE_MEDIA_INFO mediaInfo = &mediaTypes->MediaInfo[0];
691  BOOLEAN deviceMatched = FALSE;
692 
693  PAGED_CODE();
694 
695  //
696  // this should be checked prior to calling into this routine
697  // as we use the buffer as mediaTypes
698  //
699 
700  NT_ASSERT(irpStack->Parameters.DeviceIoControl.OutputBufferLength >=
701  sizeof(GET_MEDIA_TYPES));
702 
703  //
704  // Determine if this device is removable or fixed.
705  //
706 
707  if (!TEST_FLAG(Fdo->Characteristics, FILE_REMOVABLE_MEDIA)) {
708 
709  //
710  // Fixed disk.
711  //
712 
713  mediaTypes->DeviceType = FILE_DEVICE_DISK;
714  mediaTypes->MediaInfoCount = 1;
715 
716  mediaInfo->DeviceSpecific.DiskInfo.Cylinders.QuadPart = fdoExtension->DiskGeometry.Cylinders.QuadPart;
717  mediaInfo->DeviceSpecific.DiskInfo.MediaType = FixedMedia;
718  mediaInfo->DeviceSpecific.DiskInfo.TracksPerCylinder = fdoExtension->DiskGeometry.TracksPerCylinder;
719  mediaInfo->DeviceSpecific.DiskInfo.SectorsPerTrack = fdoExtension->DiskGeometry.SectorsPerTrack;
720  mediaInfo->DeviceSpecific.DiskInfo.BytesPerSector = fdoExtension->DiskGeometry.BytesPerSector;
721  mediaInfo->DeviceSpecific.DiskInfo.NumberMediaSides = 1;
722  mediaInfo->DeviceSpecific.DiskInfo.MediaCharacteristics = (MEDIA_CURRENTLY_MOUNTED | MEDIA_READ_WRITE);
723 
724  if (!IsWritable) {
725 
726  SET_FLAG(mediaInfo->DeviceSpecific.DiskInfo.MediaCharacteristics,
728  }
729 
730  } else {
731 
732  PCCHAR vendorId = (PCCHAR) fdoExtension->DeviceDescriptor + fdoExtension->DeviceDescriptor->VendorIdOffset;
733  PCCHAR productId = (PCCHAR) fdoExtension->DeviceDescriptor + fdoExtension->DeviceDescriptor->ProductIdOffset;
734  PCCHAR productRevision = (PCCHAR) fdoExtension->DeviceDescriptor + fdoExtension->DeviceDescriptor->ProductRevisionOffset;
735  DISK_MEDIA_TYPES_LIST const *mediaListEntry;
736  ULONG currentMedia;
737  ULONG i;
738  ULONG j;
739  ULONG sizeNeeded;
740 
741  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_IOCTL,
742  "DiskDetermineMediaTypes: Vendor %s, Product %s\n",
743  vendorId,
744  productId));
745 
746 
747  //
748  // If there's an entry with such vendorId & ProductId in the DiskMediaTypesExclude list,
749  // this device shouldn't be looked up in the DiskMediaTypes list to determine a medium type.
750  // The exclude table allows to narrow down the set of devices described by the DiskMediaTypes
751  // list (e.g.: DiskMediaTypes says "all HP devices" and DiskMediaTypesExlclude says
752  // "except for HP RDX")
753  //
754 
755  for (i = 0; DiskMediaTypesExclude[i].VendorId != NULL; i++) {
756  mediaListEntry = &DiskMediaTypesExclude[i];
757 
758  if (strncmp(mediaListEntry->VendorId,vendorId,strlen(mediaListEntry->VendorId))) {
759  continue;
760  }
761 
762  if ((mediaListEntry->ProductId != NULL) &&
763  strncmp(mediaListEntry->ProductId, productId, strlen(mediaListEntry->ProductId))) {
764  continue;
765  }
766 
767  goto SkipTable;
768  }
769 
770  //
771  // Run through the list until we find the entry with a NULL Vendor Id.
772  //
773 
774  for (i = 0; DiskMediaTypes[i].VendorId != NULL; i++) {
775 
776  mediaListEntry = &DiskMediaTypes[i];
777 
778  if (strncmp(mediaListEntry->VendorId,vendorId,strlen(mediaListEntry->VendorId))) {
779  continue;
780  }
781 
782  if ((mediaListEntry->ProductId != NULL) &&
783  strncmp(mediaListEntry->ProductId, productId, strlen(mediaListEntry->ProductId))) {
784  continue;
785  }
786 
787  if ((mediaListEntry->Revision != NULL) &&
788  strncmp(mediaListEntry->Revision, productRevision, strlen(mediaListEntry->Revision))) {
789  continue;
790  }
791 
792  deviceMatched = TRUE;
793 
794  mediaTypes->DeviceType = FILE_DEVICE_DISK;
795  mediaTypes->MediaInfoCount = mediaListEntry->NumberOfTypes;
796 
797  //
798  // Ensure that buffer is large enough.
799  //
800 
801  sizeNeeded = FIELD_OFFSET(GET_MEDIA_TYPES, MediaInfo[0]) +
802  (mediaListEntry->NumberOfTypes *
803  sizeof(DEVICE_MEDIA_INFO)
804  );
805 
806  if (irpStack->Parameters.DeviceIoControl.OutputBufferLength <
807  sizeNeeded) {
808 
809  //
810  // Buffer too small
811  //
812 
813  Irp->IoStatus.Status = STATUS_BUFFER_TOO_SMALL;
815  }
816 
817  for (j = 0; j < mediaListEntry->NumberOfTypes; j++) {
818 
819  mediaInfo->DeviceSpecific.RemovableDiskInfo.Cylinders.QuadPart = fdoExtension->DiskGeometry.Cylinders.QuadPart;
820  mediaInfo->DeviceSpecific.RemovableDiskInfo.TracksPerCylinder = fdoExtension->DiskGeometry.TracksPerCylinder;
821  mediaInfo->DeviceSpecific.RemovableDiskInfo.SectorsPerTrack = fdoExtension->DiskGeometry.SectorsPerTrack;
822  mediaInfo->DeviceSpecific.RemovableDiskInfo.BytesPerSector = fdoExtension->DiskGeometry.BytesPerSector;
823  mediaInfo->DeviceSpecific.RemovableDiskInfo.NumberMediaSides = mediaListEntry->NumberOfSides;
824 
825  //
826  // Set the type.
827  //
828 
829  mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaType = mediaListEntry->MediaTypes[j];
830 
831  if (mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaType == MO_5_WO) {
832  mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics = MEDIA_WRITE_ONCE;
833  } else {
834  mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics = MEDIA_READ_WRITE;
835  }
836 
837  //
838  // Status will either be success, if media is present, or no media.
839  // It would be optimal to base from density code and medium type, but not all devices
840  // have values for these fields.
841  //
842 
843  if (MediaPresent) {
844 
845  //
846  // The usage of MediumType and DensityCode is device specific, so this may need
847  // to be extended to further key off of product/vendor ids.
848  // Currently, the MO units are the only devices that return this information.
849  //
850 
851  if (MediumType == 2) {
852  currentMedia = MO_5_WO;
853  } else if (MediumType == 3) {
854  currentMedia = MO_5_RW;
855 
856  if (DensityCode == 0x87) {
857 
858  //
859  // Indicate that the pinnacle 4.6 G media
860  // is present. Other density codes will default to normal
861  // RW MO media.
862  //
863 
864  currentMedia = PINNACLE_APEX_5_RW;
865  }
866  } else {
867  currentMedia = 0;
868  }
869 
870  if (currentMedia) {
871  if (mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaType == (STORAGE_MEDIA_TYPE)currentMedia) {
872  SET_FLAG(mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics, MEDIA_CURRENTLY_MOUNTED);
873  }
874 
875  } else {
876  SET_FLAG(mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics, MEDIA_CURRENTLY_MOUNTED);
877  }
878  }
879 
880  if (!IsWritable) {
881  SET_FLAG(mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics, MEDIA_WRITE_PROTECTED);
882  }
883 
884  //
885  // Advance to next entry.
886  //
887 
888  mediaInfo++;
889  }
890  }
891 
892 SkipTable:
893 
894  if (!deviceMatched) {
895 
896  TracePrint((TRACE_LEVEL_WARNING, TRACE_FLAG_IOCTL,
897  "DiskDetermineMediaTypes: Unknown device. Vendor: %s Product: %s Revision: %s\n",
898  vendorId,
899  productId,
900  productRevision));
901  //
902  // Build an entry for unknown.
903  //
904 
905  mediaTypes->DeviceType = FILE_DEVICE_DISK;
906  mediaTypes->MediaInfoCount = 1;
907 
908  mediaInfo->DeviceSpecific.RemovableDiskInfo.Cylinders.QuadPart = fdoExtension->DiskGeometry.Cylinders.QuadPart;
909  mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaType = RemovableMedia;
910  mediaInfo->DeviceSpecific.RemovableDiskInfo.TracksPerCylinder = fdoExtension->DiskGeometry.TracksPerCylinder;
911  mediaInfo->DeviceSpecific.RemovableDiskInfo.SectorsPerTrack = fdoExtension->DiskGeometry.SectorsPerTrack;
912  mediaInfo->DeviceSpecific.RemovableDiskInfo.BytesPerSector = fdoExtension->DiskGeometry.BytesPerSector;
913  mediaInfo->DeviceSpecific.RemovableDiskInfo.NumberMediaSides = 1;
914  mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics = MEDIA_READ_WRITE;
915 
916  if (MediaPresent) {
917 
918  SET_FLAG(mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics, MEDIA_CURRENTLY_MOUNTED);
919  }
920 
921  if (!IsWritable) {
922 
923  SET_FLAG(mediaInfo->DeviceSpecific.RemovableDiskInfo.MediaCharacteristics, MEDIA_WRITE_PROTECTED);
924  }
925  }
926  }
927 
928  Irp->IoStatus.Information =
929  FIELD_OFFSET(GET_MEDIA_TYPES, MediaInfo[0]) +
930  (mediaTypes->MediaInfoCount * sizeof(DEVICE_MEDIA_INFO));
931 
932  return STATUS_SUCCESS;
933 }
#define FILE_DEVICE_DISK
Definition: winioctl.h:113
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
DISK_GEOMETRY DiskGeometry
Definition: classpnp.h:888
#define TRUE
Definition: types.h:120
struct _DEVICE_MEDIA_INFO::@3114::@3116 RemovableDiskInfo
DISK_MEDIA_TYPES_LIST const DiskMediaTypesExclude[]
Definition: data.c:74
ULONG BytesPerSector
Definition: ntdddisk.h:409
ULONG TracksPerCylinder
Definition: ntdddisk.h:407
struct _DEVICE_MEDIA_INFO::@3114::@3115 DiskInfo
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define MEDIA_WRITE_PROTECTED
Definition: minitape.h:35
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
enum _STORAGE_MEDIA_TYPE STORAGE_MEDIA_TYPE
union _DEVICE_MEDIA_INFO::@3114 DeviceSpecific
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define MEDIA_WRITE_ONCE
Definition: minitape.h:32
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
unsigned char BOOLEAN
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
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 GLint GLint j
Definition: glfuncs.h:250
LARGE_INTEGER Cylinders
Definition: ntdddisk.h:405
ULONG SectorsPerTrack
Definition: ntdddisk.h:408
PSTORAGE_DEVICE_DESCRIPTOR DeviceDescriptor
Definition: classpnp.h:876
int strncmp(const char *String1, const char *String2, ACPI_SIZE Count)
Definition: utclib.c:534
#define MEDIA_READ_WRITE
Definition: minitape.h:34
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
ULONG DeviceType
Definition: ntddstor.h:494
DISK_MEDIA_TYPES_LIST const DiskMediaTypes[]
Definition: data.c:82
ULONG MediaInfoCount
Definition: ntddstor.h:495
#define TRACE_LEVEL_WARNING
Definition: storswtr.h:28
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
#define MEDIA_CURRENTLY_MOUNTED
Definition: minitape.h:36
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
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define NULL
Definition: types.h:112
_Must_inspect_result_ _Out_ PBOOLEAN IsWritable
Definition: fltkernel.h:1743
struct _DEVICE_MEDIA_INFO DEVICE_MEDIA_INFO
unsigned int ULONG
Definition: retypes.h:1
#define STATUS_SUCCESS
Definition: shellext.h:65
struct _NAMED_PIPE_CREATE_PARAMETERS * Parameters
Definition: iotypes.h:3128
#define SET_FLAG(Flags, Bit)
Definition: cdrom.h:1493
LONGLONG QuadPart
Definition: typedefs.h:114
DEVICE_MEDIA_INFO MediaInfo[1]
Definition: ntddstor.h:496
#define PAGED_CODE()
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by DiskIoctlGetMediaTypesEx().

◆ DiskDeviceControl()

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

◆ DiskEnableDisableFailurePrediction()

NTSTATUS DiskEnableDisableFailurePrediction ( PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
BOOLEAN  Enable 
)

Definition at line 1126 of file diskwmi.c.

1147 {
1148  NTSTATUS status;
1149  PCOMMON_DEVICE_EXTENSION commonExtension = &(FdoExtension->CommonExtension);
1150  PDISK_DATA diskData = (PDISK_DATA)(commonExtension->DriverData);
1151 
1152  PAGED_CODE();
1153 
1154  switch(diskData->FailurePredictionCapability)
1155  {
1157  {
1158  if (Enable)
1159  {
1161  } else {
1163  }
1164 
1165  if (NT_SUCCESS(status)) {
1166  diskData->FailurePredictionEnabled = Enable;
1167  }
1168 
1169  break;
1170  }
1171 
1174  {
1175  //
1176  // We assume that the drive is already setup properly for
1177  // failure prediction
1178  //
1180  break;
1181  }
1182 
1183  default:
1184  {
1186  }
1187  }
1188  return status;
1189 }
struct _DISK_DATA * PDISK_DATA
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
BOOLEAN FailurePredictionEnabled
Definition: disk.h:346
static NTSTATUS DiskEnableSmart(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: diskwmi.c:271
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
FAILURE_PREDICTION_METHOD FailurePredictionCapability
Definition: disk.h:331
static NTSTATUS DiskDisableSmart(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension)
Definition: diskwmi.c:293
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
#define PAGED_CODE()
Definition: ps.c:97

Referenced by DiskEnableDisableFailurePredictPolling(), DiskFdoExecuteWmiMethod(), DiskIoctlEnableFailurePrediction(), and DiskWmiFunctionControl().

◆ DiskEnableDisableFailurePredictPolling()

NTSTATUS DiskEnableDisableFailurePredictPolling ( PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
BOOLEAN  Enable,
ULONG  PollTimeInSeconds 
)

Definition at line 1193 of file diskwmi.c.

1217 {
1218  NTSTATUS status;
1220  PDISK_DATA diskData = (PDISK_DATA)(commonExtension->DriverData);
1221 
1222  PAGED_CODE();
1223 
1224  if (Enable)
1225  {
1227  Enable);
1228  } else {
1230  }
1231 
1232  if (NT_SUCCESS(status))
1233  {
1234  status = ClassSetFailurePredictionPoll(FdoExtension,
1235  Enable ? diskData->FailurePredictionCapability :
1237  PollTimeInSeconds);
1238 
1239  //
1240  // Even if this failed we do not want to disable FP on the
1241  // hardware. FP is only ever disabled on the hardware by
1242  // specific command of the user.
1243  //
1244  }
1245 
1246  return status;
1247 }
struct _DISK_DATA * PDISK_DATA
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
struct _COMMON_DEVICE_EXTENSION * PCOMMON_DEVICE_EXTENSION
FAILURE_PREDICTION_METHOD FailurePredictionCapability
Definition: disk.h:331
NTSTATUS DiskEnableDisableFailurePrediction(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN Enable)
Definition: diskwmi.c:1126
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
#define PAGED_CODE()
Definition: ps.c:97

Referenced by DiskFdoExecuteWmiMethod(), DiskInitFdo(), and DiskWmiFunctionControl().

◆ DiskEnableInfoExceptions()

NTSTATUS DiskEnableInfoExceptions ( _In_ PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
_In_ BOOLEAN  Enable 
)

Definition at line 979 of file diskwmi.c.

983 {
984  PDISK_DATA diskData = (PDISK_DATA)(FdoExtension->CommonExtension.DriverData);
986  PMODE_PARAMETER_HEADER modeData;
987  PMODE_INFO_EXCEPTIONS pageData;
988  MODE_INFO_EXCEPTIONS changeablePageData;
989  ULONG modeDataSize;
990 
991  PAGED_CODE();
992 
993  modeDataSize = MODE_DATA_SIZE;
994 
995  modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned,
996  modeDataSize,
998 
999  if (modeData == NULL) {
1000 
1001  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_WMI, "DiskEnableInfoExceptions: Unable to allocate mode "
1002  "data buffer\n"));
1004  }
1005 
1006  //
1007  // First see which data is actually changeable.
1008  //
1009  status = DiskGetModePage(FdoExtension->DeviceObject,
1011  1, // Page Control = 1 indicates we want changeable values.
1012  modeData,
1013  &modeDataSize,
1014  (PVOID*)&pageData);
1015 
1016  if (!NT_SUCCESS(status) || pageData == NULL) {
1017  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "DiskEnableInfoExceptions: does NOT support SMART for device %p\n",
1018  FdoExtension->DeviceObject));
1019  FREE_POOL(modeData);
1020  return STATUS_NOT_SUPPORTED;
1021  }
1022 
1023  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "DiskEnableInfoExceptions: DOES support SMART for device %p\n",
1024  FdoExtension->DeviceObject));
1025 
1026  //
1027  // At the very least, the DEXCPT bit must be changeable.
1028  // If it's not, bail out now.
1029  //
1030  if (pageData->Dexcpt == 0) {
1031  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "DiskEnableInfoExceptions: does NOT support DEXCPT bit for device %p\n",
1032  FdoExtension->DeviceObject));
1033  FREE_POOL(modeData);
1034  return STATUS_NOT_SUPPORTED;
1035  }
1036 
1037  //
1038  // Cache away which values are changeable.
1039  //
1040  RtlCopyMemory(&changeablePageData, pageData, sizeof(MODE_INFO_EXCEPTIONS));
1041 
1042  //
1043  // Now get the current values.
1044  //
1045  status = DiskGetModePage(FdoExtension->DeviceObject,
1047  0, // Page Control = 0 indicates we want current values.
1048  modeData,
1049  &modeDataSize,
1050  (PVOID*)&pageData);
1051 
1052  if (!NT_SUCCESS(status) || pageData == NULL) {
1053  //
1054  // At this point we know the device supports this mode page so
1055  // assert if something goes wrong here.
1056  //
1057  NT_ASSERT(NT_SUCCESS(status) && pageData);
1058  FREE_POOL(modeData);
1059  return STATUS_NOT_SUPPORTED;
1060  }
1061 
1062  //
1063  // If the device is currently configured to not report any informational
1064  // exceptions and we cannot change the value of that field, there's
1065  // nothing to be done.
1066  //
1067  if (pageData->ReportMethod == 0 && changeablePageData.ReportMethod == 0) {
1068  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "DiskEnableInfoExceptions: MRIE field is 0 and is not changeable for device %p\n",
1069  FdoExtension->DeviceObject));
1070  FREE_POOL(modeData);
1071  return STATUS_NOT_SUPPORTED;
1072  }
1073 
1074  //
1075  // If the PERF bit is changeable, set it now.
1076  //
1077  if (changeablePageData.Perf) {
1078  pageData->Perf = diskData->AllowFPPerfHit ? 0 : 1;
1079  }
1080 
1081  //
1082  // If the MRIE field is changeable, set it to 4 so that informational
1083  // exceptions get reported with the "Recovered Error" sense key.
1084  //
1085  if (changeablePageData.ReportMethod) {
1086  pageData->ReportMethod = 4;
1087  }
1088 
1089  //
1090  // Finally, set the DEXCPT bit appropriately to enable/disable
1091  // informational exception reporting and send the Mode Select.
1092  //
1093  pageData->Dexcpt = !Enable;
1094 
1095  status = ClassModeSelect(FdoExtension->DeviceObject,
1096  (PCHAR)modeData,
1097  modeDataSize,
1098  pageData->PSBit);
1099 
1100  //
1101  // Update the failure prediction state. Note that for this particular
1102  // mode FailurePredictionNone is used when it's not enabled.
1103  //
1104  if (NT_SUCCESS(status)) {
1105  if (Enable) {
1107  diskData->FailurePredictionEnabled = TRUE;
1108  } else {
1110  diskData->FailurePredictionEnabled = FALSE;
1111  }
1112  }
1113 
1114  FREE_POOL(modeData);
1115 
1116  return status;
1117 }
signed char * PCHAR
Definition: retypes.h:7
#define MODE_PAGE_FAULT_REPORTING
Definition: scsi.h:218
struct _DISK_DATA * PDISK_DATA
return STATUS_NOT_SUPPORTED
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
#define TRUE
Definition: types.h:120
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONGLONG _In_ ULONGLONG _In_ BOOLEAN Enable
Definition: ntddpcm.h:140
NTSTATUS NTAPI ClassModeSelect(_In_ PDEVICE_OBJECT Fdo, _In_reads_bytes_(Length) PCHAR ModeSelectBuffer, _In_ ULONG Length, _In_ BOOLEAN SavePages)
Definition: class.c:6873
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
BOOLEAN AllowFPPerfHit
Definition: disk.h:332
#define DISK_TAG_INFO_EXCEPTION
Definition: disk.h:55
#define FALSE
Definition: types.h:117
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
BOOLEAN FailurePredictionEnabled
Definition: disk.h:346
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
FAILURE_PREDICTION_METHOD FailurePredictionCapability
Definition: disk.h:331
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define NULL
Definition: types.h:112
NTSTATUS DiskGetModePage(_In_ PDEVICE_OBJECT Fdo, _In_ UCHAR PageMode, _In_ UCHAR PageControl, _In_ PMODE_PARAMETER_HEADER ModeData, _Inout_ PULONG ModeDataSize, _Out_ PVOID *PageData)
Definition: diskwmi.c:903
#define MODE_DATA_SIZE
Definition: cdrom.c:173
unsigned int ULONG
Definition: retypes.h:1
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
static SERVICE_STATUS status
Definition: service.c:31
#define PAGED_CODE()
#define NT_ASSERT
Definition: rtlfuncs.h:3310
Definition: ps.c:97

Referenced by DiskIoctlEnableFailurePrediction().

◆ DiskFdoExecuteWmiMethod()

NTSTATUS NTAPI DiskFdoExecuteWmiMethod ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN ULONG  GuidIndex,
IN ULONG  MethodId,
IN ULONG  InBufferSize,
IN ULONG  OutBufferSize,
IN PUCHAR  Buffer 
)

Definition at line 3045 of file diskwmi.c.

3088 {
3089  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
3090  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
3091  PDISK_DATA diskData = (PDISK_DATA)(commonExtension->DriverData);
3092  ULONG sizeNeeded = 0;
3093  NTSTATUS status;
3094 
3095  PAGED_CODE();
3096 
3097  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "Disk: DiskExecuteWmiMethod, DeviceObject %p, Irp %p, Guid Id %d, MethodId %d\n"
3098  " InBufferSize %#x, OutBufferSize %#x, Buffer %p\n",
3099  DeviceObject, Irp,
3101 
3102  switch(GuidIndex)
3103  {
3104  case SmartPerformFunction:
3105  {
3106 
3109  (diskData->FailurePredictionCapability ==
3111  (diskData->FailurePredictionCapability ==
3113 
3114 
3115  switch(MethodId)
3116  {
3117  //
3118  // void AllowPerformanceHit([in] boolean Allow)
3119  //
3121  {
3122  BOOLEAN allowPerfHit;
3123 
3124  sizeNeeded = 0;
3125  if (InBufferSize >= sizeof(BOOLEAN))
3126  {
3128 
3129  allowPerfHit = *((PBOOLEAN)Buffer);
3130  if (diskData->AllowFPPerfHit != allowPerfHit)
3131  {
3132  diskData->AllowFPPerfHit = allowPerfHit;
3133  if (diskData->FailurePredictionCapability ==
3135  {
3136  MODE_INFO_EXCEPTIONS modeInfo;
3137 
3138  status = DiskGetInfoExceptionInformation(fdoExtension,
3139  &modeInfo);
3140  if (NT_SUCCESS(status))
3141  {
3142  modeInfo.Perf = allowPerfHit ? 0 : 1;
3143  status = DiskSetInfoExceptionInformation(fdoExtension,
3144  &modeInfo);
3145  }
3146  }
3147  else
3148  {
3150  }
3151  }
3152 
3153  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "DiskFdoWmiExecuteMethod: AllowPerformanceHit %x for device %p --> %lx\n",
3154  allowPerfHit,
3155  fdoExtension->DeviceObject,
3156  status));
3157  } else {
3159  }
3160  break;
3161  }
3162 
3163  //
3164  // void EnableDisableHardwareFailurePrediction([in] boolean Enable)
3165  //
3167  {
3168  BOOLEAN enable;
3169 
3170  sizeNeeded = 0;
3171  if (InBufferSize >= sizeof(BOOLEAN))
3172  {
3174  enable = *((PBOOLEAN)Buffer);
3175  if (!enable)
3176  {
3177  //
3178  // If we are disabling we need to also disable
3179  // polling
3180  //
3182  fdoExtension,
3183  enable,
3184  0);
3185  }
3186 
3188  fdoExtension,
3189  enable);
3190 
3191  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "DiskFdoWmiExecuteMethod: EnableDisableHardwareFailurePrediction: %x for device %p --> %lx\n",
3192  enable,
3193  fdoExtension->DeviceObject,
3194  status));
3195  } else {
3197  }
3198  break;
3199  }
3200 
3201  //
3202  // void EnableDisableFailurePredictionPolling(
3203  // [in] uint32 Period,
3204  // [in] boolean Enable)
3205  //
3207  {
3208  BOOLEAN enable;
3209  ULONG period;
3210 
3211  sizeNeeded = 0;
3212  if (InBufferSize >= (sizeof(ULONG) + sizeof(BOOLEAN)))
3213  {
3214  period = *((PULONG)Buffer);
3215  Buffer += sizeof(ULONG);
3216  enable = *((PBOOLEAN)Buffer);
3217 
3219  fdoExtension,
3220  enable,
3221  period);
3222 
3223  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "DiskFdoWmiExecuteMethod: EnableDisableFailurePredictionPolling: %x %x for device %p --> %lx\n",
3224  enable,
3225  period,
3226  fdoExtension->DeviceObject,
3227  status));
3228  } else {
3230  }
3231  break;
3232  }
3233 
3234  //
3235  // void GetFailurePredictionCapability([out] uint32 Capability)
3236  //
3238  {
3239  sizeNeeded = sizeof(ULONG);
3240  if (OutBufferSize >= sizeNeeded)
3241  {
3244  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "DiskFdoWmiExecuteMethod: GetFailurePredictionCapability: %x for device %p --> %lx\n",
3246  fdoExtension->DeviceObject,
3247  status));
3248  } else {
3250  }
3251  break;
3252  }
3253 
3254  //
3255  // void EnableOfflineDiags([out] boolean Success);
3256  //
3257  case EnableOfflineDiags:
3258  {
3259  sizeNeeded = sizeof(BOOLEAN);
3260  if (OutBufferSize >= sizeNeeded)
3261  {
3262  if (diskData->FailurePredictionCapability ==
3264  {
3265  //
3266  // Initiate or resume offline diagnostics.
3267  // This may cause a loss of performance
3268  // to the disk, but mayincrease the amount
3269  // of disk checking.
3270  //
3271  status = DiskExecuteSmartDiagnostics(fdoExtension,
3272  0);
3273 
3274  } else {
3276  }
3277 
3279 
3280  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "DiskFdoWmiExecuteMethod: EnableOfflineDiags for device %p --> %lx\n",
3281  fdoExtension->DeviceObject,
3282  status));
3283  } else {
3285  }
3286  break;
3287  }
3288 
3289  //
3290  // void ReadLogSectors([in] uint8 LogAddress,
3291  // [in] uint8 SectorCount,
3292  // [out] uint32 Length,
3293  // [out, WmiSizeIs("Length")] uint8 LogSectors[]
3294  // );
3295  //
3296  case ReadLogSectors:
3297  {
3298  if (diskData->FailurePredictionCapability ==
3300  {
3301  if (InBufferSize >= sizeof(READ_LOG_SECTORS_IN))
3302  {
3303  PREAD_LOG_SECTORS_IN inParams;
3304  PREAD_LOG_SECTORS_OUT outParams;
3305  ULONG readSize;
3306 
3307  inParams = (PREAD_LOG_SECTORS_IN)Buffer;
3308  readSize = inParams->SectorCount * SMART_LOG_SECTOR_SIZE;
3309  sizeNeeded = FIELD_OFFSET(READ_LOG_SECTORS_OUT,
3310  LogSectors) + readSize;
3311 
3312  if (OutBufferSize >= sizeNeeded)
3313  {
3314  outParams = (PREAD_LOG_SECTORS_OUT)Buffer;
3315  status = DiskReadSmartLog(fdoExtension,
3316  inParams->SectorCount,
3317  inParams->LogAddress,
3318  outParams->LogSectors);
3319 
3320  if (NT_SUCCESS(status))
3321  {
3322  outParams->Length = readSize;
3323  } else {
3324  //
3325  // SMART command failure is
3326  // indicated by successful
3327  // execution, but no data returned
3328  //
3329  outParams->Length = 0;
3331  }
3332  } else {
3334  }
3335 
3336  } else {
3338  }
3339  } else {
3341  }
3342  break;
3343  }
3344 
3345  // void WriteLogSectors([in] uint8 LogAddress,
3346  // [in] uint8 SectorCount,
3347  // [in] uint32 Length,
3348  // [in, WmiSizeIs("Length")] uint8 LogSectors[],
3349  // [out] boolean Success
3350  // );
3351  case WriteLogSectors:
3352  {
3353  if (diskData->FailurePredictionCapability ==
3355  {
3357  LogSectors))
3358  {
3359  PWRITE_LOG_SECTORS_IN inParams;
3360  PWRITE_LOG_SECTORS_OUT outParams;
3361  ULONG writeSize;
3362 
3363  inParams = (PWRITE_LOG_SECTORS_IN)Buffer;
3364  writeSize = inParams->SectorCount * SMART_LOG_SECTOR_SIZE;
3366  LogSectors) +
3367  writeSize))
3368  {
3369  sizeNeeded = sizeof(WRITE_LOG_SECTORS_OUT);
3370 
3371  if (OutBufferSize >= sizeNeeded)
3372  {
3373  outParams = (PWRITE_LOG_SECTORS_OUT)Buffer;
3374  status = DiskWriteSmartLog(fdoExtension,
3375  inParams->SectorCount,
3376  inParams->LogAddress,
3377  inParams->LogSectors);
3378 
3379  if (NT_SUCCESS(status))
3380  {
3381  outParams->Success = TRUE;
3382  } else {
3383  outParams->Success = FALSE;
3385  }
3386  } else {
3388  }
3389  } else {
3391  }
3392  } else {
3394  }
3395  } else {
3397  }
3398  break;
3399  }
3400 
3401  // void ExecuteSelfTest([in] uint8 Subcommand,
3402  // [out,
3403  // Values{"0", "1", "2"},
3404  // ValueMap{"Successful Completion",
3405  // "Captive Mode Required",
3406  // "Unsuccessful Completion"}
3407  // ]
3408  // uint32 ReturnCode);
3409  case ExecuteSelfTest:
3410  {
3411  if (diskData->FailurePredictionCapability ==
3413  {
3414  if (InBufferSize >= sizeof(EXECUTE_SELF_TEST_IN))
3415  {
3416  sizeNeeded = sizeof(EXECUTE_SELF_TEST_OUT);
3417  if (OutBufferSize >= sizeNeeded)
3418  {
3419  PEXECUTE_SELF_TEST_IN inParam;
3420  PEXECUTE_SELF_TEST_OUT outParam;
3421 
3422  inParam = (PEXECUTE_SELF_TEST_IN)Buffer;
3423  outParam = (PEXECUTE_SELF_TEST_OUT)Buffer;
3424 
3425  if (DiskIsValidSmartSelfTest(inParam->Subcommand))
3426  {
3427  status = DiskExecuteSmartDiagnostics(fdoExtension,
3428  inParam->Subcommand);
3429  if (NT_SUCCESS(status))
3430  {
3431  //
3432  // Return self test executed
3433  // without a problem
3434  //
3435  outParam->ReturnCode = 0;
3436  } else {
3437  //
3438  // Return Self test execution
3439  // failed status
3440  //
3441  outParam->ReturnCode = 2;
3443  }
3444  } else {
3445  //
3446  // If self test subcommand requires
3447  // captive mode then return that
3448  // status
3449  //
3450  outParam->ReturnCode = 1;
3452  }
3453 
3454  } else {
3456  }
3457 
3458  } else {
3460  }
3461  } else {
3463  }
3464 
3465  break;
3466  }
3467 
3468  default :
3469  {
3470  sizeNeeded = 0;
3472  break;
3473  }
3474  }
3475 
3476  break;
3477  }
3478 
3479  case DiskGeometryGuid:
3480  case SmartStatusGuid:
3481  case SmartDataGuid:
3482  case SmartEventGuid:
3483  case SmartThresholdsGuid:
3485  {
3486  sizeNeeded = 0;
3488  break;
3489  }
3490 
3491  default:
3492  {
3493  sizeNeeded = 0;
3495  }
3496  }
3497 
3498  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "Disk: DiskExecuteMethod Device %p, Irp %p returns %lx\n",
3499  DeviceObject, Irp, status));
3500 
3502  Irp,
3503  status,
3504  sizeNeeded,
3505  IO_NO_INCREMENT);
3506 
3507  return status;
3508 }
#define SMART_LOG_SECTOR_SIZE
Definition: ntdddisk.h:734
struct _DISK_DATA * PDISK_DATA
#define WriteLogSectors
Definition: wmidata.h:3387
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:776
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define SmartEventGuid
Definition: diskwmi.c:150
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_INVALID_DEVICE_REQUEST
Definition: udferr_usr.h:138
struct _WRITE_LOG_SECTORS_OUT * PWRITE_LOG_SECTORS_OUT
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define DiskGeometryGuid
Definition: diskwmi.c:140
BOOLEAN AllowFPPerfHit
Definition: disk.h:332
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
NTSTATUS DiskSetInfoExceptionInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMODE_INFO_EXCEPTIONS PageData)
Definition: disk.c:2985
struct _EXECUTE_SELF_TEST_OUT * PEXECUTE_SELF_TEST_OUT
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
long LONG
Definition: pedump.c:60
#define ScsiInfoExceptionsGuid
Definition: diskwmi.c:152
unsigned char BOOLEAN
NTSTATUS DiskGetInfoExceptionInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMODE_INFO_EXCEPTIONS ReturnPageData)
Definition: disk.c:2896
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:418
Definition: bufpool.h:45
#define ReadLogSectors
Definition: wmidata.h:3374
#define ExecuteSelfTest
Definition: wmidata.h:3407
struct _EXECUTE_SELF_TEST_IN * PEXECUTE_SELF_TEST_IN
NTSTATUS DiskWriteSmartLog(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN UCHAR SectorCount, IN UCHAR LogAddress, IN PUCHAR Buffer)
Definition: diskwmi.c:429
_In_ ULONG InBufferSize
Definition: wdfwmi.h:106
_In_ ULONG OutBufferSize
Definition: wdfwmi.h:87
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DiskIsValidSmartSelfTest(Subcommand)
Definition: disk.h:619
struct _EXECUTE_SELF_TEST_OUT EXECUTE_SELF_TEST_OUT
enum FAILURE_PREDICTION_METHOD * PFAILURE_PREDICTION_METHOD
#define SmartStatusGuid
Definition: diskwmi.c:141
_In_ ULONG MethodId
Definition: wdfwmi.h:142
NTSTATUS DiskEnableDisableFailurePredictPolling(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN Enable, ULONG PollTimeInSeconds)
Definition: diskwmi.c:1193
PDEVICE_OBJECT DeviceObject
Definition: classpnp.h:871
char * PBOOLEAN
Definition: retypes.h:11
#define EnableDisableFailurePredictionPolling
Definition: diskwmi.c:146
#define EnableDisableHardwareFailurePrediction
Definition: diskwmi.c:145
#define SmartThresholdsGuid
Definition: diskwmi.c:151
FAILURE_PREDICTION_METHOD FailurePredictionCapability
Definition: disk.h:331
NTSTATUS DiskEnableDisableFailurePrediction(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN Enable)
Definition: diskwmi.c:1126
#define AllowDisallowPerformanceHit
Definition: diskwmi.c:144
struct _READ_LOG_SECTORS_IN * PREAD_LOG_SECTORS_IN
GLboolean enable
Definition: glext.h:11120
NTSTATUS DiskReadSmartLog(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN UCHAR SectorCount, IN UCHAR LogAddress, OUT PUCHAR Buffer)
Definition: diskwmi.c:379
SCSIPORT_API NTSTATUS NTAPI ClassWmiCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ NTSTATUS Status, _In_ ULONG BufferUsed, _In_ CCHAR PriorityBoost)
Definition: classwmi.c:1009
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
struct _WRITE_LOG_SECTORS_IN * PWRITE_LOG_SECTORS_IN
unsigned int * PULONG
Definition: retypes.h:1
struct _READ_LOG_SECTORS_OUT * PREAD_LOG_SECTORS_OUT
#define BOOLEAN
Definition: pedump.c:73
#define SmartPerformFunction
Definition: diskwmi.c:143
#define SmartDataGuid
Definition: diskwmi.c:142
#define STATUS_WMI_ITEMID_NOT_FOUND
Definition: ntstatus.h:778
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65
#define EnableOfflineDiags
Definition: diskwmi.c:148
#define GetFailurePredictionCapability
Definition: diskwmi.c:147
static SERVICE_STATUS status
Definition: service.c:31
static NTSTATUS DiskExecuteSmartDiagnostics(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, UCHAR Subcommand)
Definition: diskwmi.c:359
struct _WRITE_LOG_SECTORS_OUT WRITE_LOG_SECTORS_OUT
#define PAGED_CODE()
#define NT_ASSERT
Definition: rtlfuncs.h:3310
Definition: ps.c:97

Referenced by DriverEntry().

◆ DiskFdoProcessError()

VOID NTAPI DiskFdoProcessError ( PDEVICE_OBJECT  DeviceObject,
PSCSI_REQUEST_BLOCK  Srb,
NTSTATUS Status,
BOOLEAN Retry 
)

Definition at line 2276 of file disk.c.

2306 {
2307  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
2308  PSTORAGE_REQUEST_BLOCK srbEx;
2309  PCDB cdb = NULL;
2310  UCHAR scsiStatus = 0;
2311  UCHAR senseBufferLength = 0;
2312  PVOID senseBuffer = NULL;
2313  CDB noOp = {0};
2314 
2315  //
2316  // Get relevant fields from SRB
2317  //
2318  if (Srb->Function == SRB_FUNCTION_STORAGE_REQUEST_BLOCK) {
2319 
2320  srbEx = (PSTORAGE_REQUEST_BLOCK)Srb;
2321 
2322  //
2323  // Look for SCSI SRB specific fields
2324  //
2325  if ((srbEx->SrbFunction == SRB_FUNCTION_EXECUTE_SCSI) &&
2326  (srbEx->NumSrbExData > 0)) {
2327  cdb = GetSrbScsiData(srbEx, NULL, NULL, &scsiStatus, &senseBuffer, &senseBufferLength);
2328 
2329  //
2330  // cdb and sense buffer should not be NULL
2331  //
2332  NT_ASSERT(cdb != NULL);
2333  NT_ASSERT(senseBuffer != NULL);
2334 
2335  }
2336 
2337  if (cdb == NULL) {
2338 
2339  //
2340  // Use a cdb that is all 0s
2341  //
2342  cdb = &noOp;
2343  }
2344 
2345  } else {
2346 
2347  cdb = (PCDB)(Srb->Cdb);
2348  scsiStatus = Srb->ScsiStatus;
2349  senseBufferLength = Srb->SenseInfoBufferLength;
2350  senseBuffer = Srb->SenseInfoBuffer;
2351  }
2352 
2353  if (*Status == STATUS_DATA_OVERRUN &&
2354  (cdb != NULL) &&
2355  (IS_SCSIOP_READWRITE(cdb->CDB10.OperationCode))) {
2356 
2357  *Retry = TRUE;
2358 
2359  //
2360  // Update the error count for the device.
2361  //
2362 
2363  fdoExtension->ErrorCount++;
2364 
2365  } else if (SRB_STATUS(Srb->SrbStatus) == SRB_STATUS_ERROR &&
2366  scsiStatus == SCSISTAT_BUSY) {
2367 
2368  //
2369  // a disk drive should never be busy this long. Reset the scsi bus
2370  // maybe this will clear the condition.
2371  //
2372 
2373  ResetBus(Fdo);
2374 
2375  //
2376  // Update the error count for the device.
2377  //
2378 
2379  fdoExtension->ErrorCount++;
2380 
2381  } else {
2382 
2383  BOOLEAN invalidatePartitionTable = FALSE;
2384 
2385  //
2386  // See if this might indicate that something on the drive has changed.
2387  //
2388 
2389  if ((Srb->SrbStatus & SRB_STATUS_AUTOSENSE_VALID) &&
2390  (senseBuffer != NULL) && (cdb != NULL)) {
2391 
2393  UCHAR senseKey = 0;
2394  UCHAR asc = 0;
2395  UCHAR ascq = 0;
2396 
2397  validSense = ScsiGetSenseKeyAndCodes(senseBuffer,
2398  senseBufferLength,
2400  &senseKey,
2401  &asc,
2402  &ascq);
2403 
2404  if (validSense) {
2405 
2406  switch (senseKey) {
2407 
2409 
2410  switch (asc) {
2411 
2413  {
2414  //
2415  // Look to see if this is an Io request with the ForceUnitAccess flag set
2416  //
2417  if (((cdb->CDB10.OperationCode == SCSIOP_WRITE) ||
2418  (cdb->CDB10.OperationCode == SCSIOP_WRITE16)) &&
2419  (cdb->CDB10.ForceUnitAccess))
2420  {
2421  PDISK_DATA diskData = (PDISK_DATA)fdoExtension->CommonExtension.DriverData;
2422 
2424  {
2425  PIO_ERROR_LOG_PACKET logEntry = NULL;
2426 
2427  //
2428  // The user has explicitly requested that write caching be turned on.
2429  // Warn the user that writes with FUA enabled are not working and that
2430  // they should disable write cache.
2431  //
2432 
2433  logEntry = IoAllocateErrorLogEntry(fdoExtension->DeviceObject,
2434  sizeof(IO_ERROR_LOG_PACKET) + (4 * sizeof(ULONG)));
2435 
2436  if (logEntry != NULL)
2437  {
2438  logEntry->FinalStatus = *Status;
2440  logEntry->SequenceNumber = 0;
2441  logEntry->MajorFunctionCode = IRP_MJ_SCSI;
2442  logEntry->IoControlCode = 0;
2443  logEntry->RetryCount = 0;
2444  logEntry->UniqueErrorValue = 0;
2445  logEntry->DumpDataSize = 4 * sizeof(ULONG);
2446 
2447  logEntry->DumpData[0] = diskData->ScsiAddress.PortNumber;
2448  logEntry->DumpData[1] = diskData->ScsiAddress.PathId;
2449  logEntry->DumpData[2] = diskData->ScsiAddress.TargetId;
2450  logEntry->DumpData[3] = diskData->ScsiAddress.Lun;
2451 
2452  //
2453  // Write the error log packet.
2454  //
2455 
2456  IoWriteErrorLogEntry(logEntry);
2457  }
2458  }
2459  else
2460  {
2461  //
2462  // Turn off write caching on this device. This is so that future
2463  // critical requests need not be sent down with ForceUnitAccess
2464  //
2465  PIO_WORKITEM workItem = IoAllocateWorkItem(Fdo);
2466 
2467  if (workItem)
2468  {
2469  IoQueueWorkItem(workItem, DisableWriteCache, CriticalWorkQueue, workItem);
2470  }
2471  }
2472 
2474  ADJUST_FUA_FLAG(fdoExtension);
2475 
2476 
2477  cdb->CDB10.ForceUnitAccess = FALSE;
2478  *Retry = TRUE;
2479 
2480  } else if ((cdb->CDB6FORMAT.OperationCode == SCSIOP_MODE_SENSE) &&
2481  (cdb->MODE_SENSE.PageCode == MODE_SENSE_RETURN_ALL)) {
2482 
2483  //
2484  // Mode sense for all pages failed. This command could fail with
2485  // SCSI_SENSE_ILLEGAL_REQUEST / SCSI_ADSENSE_INVALID_CDB if the data
2486  // to be returned is more than 256 bytes. In which case, try to get
2487  // only MODE_PAGE_CACHING since we only need the block descriptor.
2488  //
2489  // Simply change the page code and retry the request
2490  //
2491 
2492  cdb->MODE_SENSE.PageCode = MODE_PAGE_CACHING;
2493  *Retry = TRUE;
2494  }
2495 
2496  break;
2497  }
2498  } // end switch(asc)
2499  break;
2500  }
2501 
2502  case SCSI_SENSE_NOT_READY: {
2503 
2504  switch (asc) {
2506  switch (ascq) {
2510  invalidatePartitionTable = TRUE;
2511  break;
2512  }
2513  } // end switch(ascq)
2514  break;
2515  }
2516 
2518  invalidatePartitionTable = TRUE;
2519  break;
2520  }
2521  } // end switch(asc)
2522  break;
2523  }
2524 
2525  case SCSI_SENSE_MEDIUM_ERROR: {
2526  invalidatePartitionTable = TRUE;
2527  break;
2528  }
2529 
2531  invalidatePartitionTable = TRUE;
2532  break;
2533  }
2534 
2536  {
2537  invalidatePartitionTable = TRUE;
2538  break;
2539  }
2540 
2542  invalidatePartitionTable = TRUE;
2543  break;
2544  }
2545 
2546  } // end switch(senseKey)
2547  } // end if (validSense)
2548  } else {
2549 
2550  //
2551  // On any exceptional scsi condition which might indicate that the
2552  // device was changed we will flush out the state of the partition
2553  // table.
2554  //
2555 
2556  switch (SRB_STATUS(Srb->SrbStatus)) {
2559  case SRB_STATUS_NO_DEVICE:
2560  case SRB_STATUS_NO_HBA:
2563  case SRB_STATUS_TIMEOUT:
2568  {
2569  invalidatePartitionTable = TRUE;
2570  break;
2571  }
2572 
2573  case SRB_STATUS_ERROR:
2574  {
2575  if (scsiStatus == SCSISTAT_RESERVATION_CONFLICT)
2576  {
2577  invalidatePartitionTable = TRUE;
2578  }
2579 
2580  break;
2581  }
2582  } // end switch(Srb->SrbStatus)
2583  }
2584 
2585  if (invalidatePartitionTable && TEST_FLAG(Fdo->Characteristics, FILE_REMOVABLE_MEDIA)) {
2586 
2587  //
2588  // Inform the upper layers that the volume
2589  // on this disk is in need of verification
2590  //
2591 
2592  SET_FLAG(Fdo->Flags, DO_VERIFY_VOLUME);
2593  }
2594  }
2595 
2596  return;
2597 }
UCHAR PathId
Definition: scsi_port.h:149
UCHAR PortNumber
Definition: scsi_port.h:148
#define SCSISTAT_BUSY
Definition: cdrw_hw.h:1081
struct _DISK_DATA * PDISK_DATA
#define CLASS_SPECIAL_FUA_NOT_SUPPORTED
Definition: classpnp.h:174
UCHAR senseKey
Definition: scsi.h:4019
#define STATUS_DATA_OVERRUN
Definition: udferr_usr.h:152
#define MODE_PAGE_CACHING
Definition: cdrw_hw.h:846
#define SRB_STATUS_AUTOSENSE_VALID
Definition: srb.h:379
NTSTATUS FinalStatus
Definition: iotypes.h:2009
#define TRUE
Definition: types.h:120
#define SCSIOP_MODE_SENSE
Definition: cdrw_hw.h:896
Definition: cdrw_hw.h:28
#define IO_WARNING_WRITE_FUA_PROBLEM
Definition: ntiologc.h:93
#define SRB_STATUS_REQUEST_FLUSHED
Definition: srb.h:353
COMMON_DEVICE_EXTENSION CommonExtension
Definition: classpnp.h:873
struct _CDB::_CDB6FORMAT CDB6FORMAT
SCSI_ADDRESS ScsiAddress
Definition: disk.h:325
#define DO_VERIFY_VOLUME
Definition: env_spec_w32.h:393
#define SRB_STATUS_COMMAND_TIMEOUT
Definition: srb.h:343
#define MODE_SENSE_RETURN_ALL
Definition: cdrw_hw.h:857
#define SRB_STATUS_NO_DEVICE
Definition: srb.h:340
#define SCSI_SENSE_OPTIONS_FIXED_FORMAT_IF_UNKNOWN_FORMAT_INDICATED
Definition: scsi.h:3839
#define SCSI_ADSENSE_LUN_NOT_READY
Definition: cdrw_hw.h:1218
#define SCSIOP_WRITE16
Definition: scsi.h:915
struct _CDB::_CDB10 CDB10
if(dx==0 &&dy==0)
Definition: linetemp.h:174
PIO_WORKITEM NTAPI IoAllocateWorkItem(IN PDEVICE_OBJECT DeviceObject)
Definition: iowork.c:75
#define SCSI_SENSE_NOT_READY
Definition: cdrw_hw.h:1189
#define SRB_STATUS_INVALID_TARGET_ID
Definition: srb.h:355
UCHAR TargetId
Definition: scsi_port.h:150
#define SRB_STATUS(Status)
Definition: srb.h:381
VOID NTAPI IoWriteErrorLogEntry(IN PVOID ElEntry)
Definition: error.c:628
#define IRP_MJ_SCSI
#define SRB_STATUS_ERROR
Definition: srb.h:336
#define SCSI_SENSE_MEDIUM_ERROR
Definition: cdrw_hw.h:1190
NTSTATUS ErrorCode
Definition: iotypes.h:2007
#define SRB_STATUS_PARITY_ERROR
Definition: srb.h:346
#define SCSI_SENSEQ_MANUAL_INTERVENTION_REQUIRED
Definition: cdrw_hw.h:1315
#define FALSE
Definition: types.h:117
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
#define ADJUST_FUA_FLAG(fdoExt)
Definition: classpnp.h:53
#define SCSI_ADSENSE_NO_MEDIA_IN_DEVICE
Definition: cdrw_hw.h:1221
#define SCSIOP_WRITE
Definition: cdrw_hw.h:906
unsigned char BOOLEAN
#define SRB_STATUS_NO_HBA
Definition: srb.h:348
DISK_USER_WRITE_CACHE_SETTING WriteCacheOverride
Definition: disk.h:385
* PSTORAGE_REQUEST_BLOCK
Definition: srb.h:652
union _CDB * PCDB
IN PSCSI_REQUEST_BLOCK IN OUT NTSTATUS IN OUT BOOLEAN * Retry
Definition: class2.h:49
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
struct _CDB::_MODE_SENSE MODE_SENSE
PVOID NTAPI IoAllocateErrorLogEntry(IN PVOID IoObject, IN UCHAR EntrySize)
Definition: error.c:528
Status
Definition: gdiplustypes.h:24
VOID NTAPI DisableWriteCache(IN PDEVICE_OBJECT DeviceObject, IN PSCSI_INQUIRY_DATA LunInfo)
Definition: disk.c:3552
#define SCSI_SENSEQ_BECOMING_READY
Definition: cdrw_hw.h:1313
#define SCSISTAT_RESERVATION_CONFLICT
Definition: cdrw_hw.h:1084
PDEVICE_OBJECT DeviceObject
Definition: classpnp.h:871
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
#define SCSI_SENSE_HARDWARE_ERROR
Definition: cdrw_hw.h:1191
#define SRB_FUNCTION_STORAGE_REQUEST_BLOCK
Definition: srb.h:99
unsigned char UCHAR
Definition: xmlstorage.h:181
#define SRB_STATUS_SELECTION_TIMEOUT
Definition: srb.h:342
#define SCSI_SENSE_RECOVERED_ERROR
Definition: cdrw_hw.h:1188
#define SCSI_SENSEQ_CAUSE_NOT_REPORTABLE
Definition: cdrw_hw.h:1312
#define SRB_STATUS_INVALID_LUN
Definition: srb.h:354
VOID NTAPI IoQueueWorkItem(IN PIO_WORKITEM IoWorkItem, IN PIO_WORKITEM_ROUTINE WorkerRoutine, IN WORK_QUEUE_TYPE QueueType, IN PVOID Context)
Definition: iowork.c:40
#define IS_SCSIOP_READWRITE(opCode)
Definition: cdrom.h:803
#define SRB_STATUS_TIMEOUT
Definition: srb.h:341
#define NULL
Definition: types.h:112
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
unsigned int ULONG
Definition: retypes.h:1
#define SRB_STATUS_UNEXPECTED_BUS_FREE
Definition: srb.h:350
#define SRB_STATUS_INVALID_PATH_ID
Definition: srb.h:339
IN PSCSI_REQUEST_BLOCK Srb
Definition: class2.h:49
FORCEINLINE PCDB GetSrbScsiData(_In_ PSTORAGE_REQUEST_BLOCK SrbEx, _In_opt_ PUCHAR CdbLength8, _In_opt_ PULONG CdbLength32, _In_opt_ PUCHAR ScsiStatus, _In_opt_ PVOID *SenseInfoBuffer, _In_opt_ PUCHAR SenseInfoBufferLength)
Definition: disk.h:994
#define SCSI_SENSE_ILLEGAL_REQUEST
Definition: cdrw_hw.h:1192
VOID ResetBus(IN PDEVICE_OBJECT Fdo)
Definition: disk.c:2705
#define SET_FLAG(Flags, Bit)
Definition: cdrom.h:1493
#define SCSI_SENSE_UNIT_ATTENTION
Definition: cdrw_hw.h:1193
#define SCSI_ADSENSE_INVALID_CDB
Definition: cdrw_hw.h:1265
BOOLEAN validSense
Definition: scsi.h:4018
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by DriverEntry().

◆ DiskFdoQueryWmiDataBlock()

NTSTATUS NTAPI DiskFdoQueryWmiDataBlock ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN ULONG  GuidIndex,
IN ULONG  BufferAvail,
OUT PUCHAR  Buffer 
)

Definition at line 2638 of file diskwmi.c.

2674 {
2675  NTSTATUS status;
2676  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
2677  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
2678  PDISK_DATA diskData = (PDISK_DATA)(commonExtension->DriverData);
2679  ULONG sizeNeeded;
2680 
2681  PAGED_CODE();
2682 
2683  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "Disk: DiskQueryWmiDataBlock, Device %p, Irp %p, GuiIndex %d\n"
2684  " BufferAvail %lx Buffer %p\n",
2685  DeviceObject, Irp,
2687 
2688  switch (GuidIndex)
2689  {
2690  case DiskGeometryGuid:
2691  {
2692  sizeNeeded = sizeof(DISK_GEOMETRY);
2693  if (BufferAvail >= sizeNeeded)
2694  {
2695  if (DeviceObject->Characteristics & FILE_REMOVABLE_MEDIA)
2696  {
2697  //
2698  // Issue ReadCapacity to update device extension
2699  // with information for current media.
2700  status = DiskReadDriveCapacity(commonExtension->PartitionZeroExtension->DeviceObject);
2701 
2702  //
2703  // Note whether the drive is ready.
2704  diskData->ReadyStatus = status;
2705 
2706  if (!NT_SUCCESS(status))
2707  {
2708  break;
2709  }
2710  }
2711 
2712  //
2713  // Copy drive geometry information from device extension.
2715  &(fdoExtension->DiskGeometry),
2716  sizeof(DISK_GEOMETRY));
2717 
2719  } else {
2721  }
2722  break;
2723  }
2724 
2725  case SmartStatusGuid:
2726  {
2727  PSTORAGE_FAILURE_PREDICT_STATUS diskSmartStatus;
2728 
2730 
2731  sizeNeeded = sizeof(STORAGE_FAILURE_PREDICT_STATUS);
2732  if (BufferAvail >= sizeNeeded)
2733  {
2734  STORAGE_PREDICT_FAILURE checkFailure;
2735 
2736  diskSmartStatus = (PSTORAGE_FAILURE_PREDICT_STATUS)Buffer;
2737 
2738  status = DiskSendFailurePredictIoctl(fdoExtension,
2739  &checkFailure);
2740 
2741  if (NT_SUCCESS(status))
2742  {
2743  if (diskData->FailurePredictionCapability ==
2745  {
2746  diskSmartStatus->Reason = *((PULONG)checkFailure.VendorSpecific);
2747  } else {
2748  diskSmartStatus->Reason = 0; // unknown
2749  }
2750 
2751  diskSmartStatus->PredictFailure = (checkFailure.PredictFailure != 0);
2752  }
2753  } else {
2755  }
2756  break;
2757  }
2758 
2759  case SmartDataGuid:
2760  {
2761  PSTORAGE_FAILURE_PREDICT_DATA diskSmartData;
2762 
2765  (diskData->FailurePredictionCapability ==
2767 
2768  sizeNeeded = sizeof(STORAGE_FAILURE_PREDICT_DATA);
2769  if (BufferAvail >= sizeNeeded)
2770  {
2772 
2773  diskSmartData = (PSTORAGE_FAILURE_PREDICT_DATA)Buffer;
2774 
2775  status = DiskSendFailurePredictIoctl(fdoExtension,
2776  checkFailure);
2777 
2778  if (NT_SUCCESS(status))
2779  {
2780  diskSmartData->Length = 512;
2781  }
2782  } else {
2784  }
2785 
2786  break;
2787  }
2788 
2789  case SmartThresholdsGuid:
2790  {
2791  PSTORAGE_FAILURE_PREDICT_THRESHOLDS diskSmartThresholds;
2792 
2795 
2796  sizeNeeded = sizeof(STORAGE_FAILURE_PREDICT_THRESHOLDS);
2797  if (BufferAvail >= sizeNeeded)
2798  {
2799  diskSmartThresholds = (PSTORAGE_FAILURE_PREDICT_THRESHOLDS)Buffer;
2801  diskSmartThresholds);
2802  } else {
2804  }
2805 
2806  break;
2807  }
2808 
2809  case SmartPerformFunction:
2810  {
2811  sizeNeeded = 0;
2813  break;
2814  }
2815 
2817  {
2818  PSTORAGE_SCSI_INFO_EXCEPTIONS infoExceptions;
2819  MODE_INFO_EXCEPTIONS modeInfo;
2820 
2823 
2824  sizeNeeded = sizeof(STORAGE_SCSI_INFO_EXCEPTIONS);
2825  if (BufferAvail >= sizeNeeded)
2826  {
2827  infoExceptions = (PSTORAGE_SCSI_INFO_EXCEPTIONS)Buffer;
2828  status = DiskGetInfoExceptionInformation(fdoExtension,
2829  &modeInfo);
2830  if (NT_SUCCESS(status))
2831  {
2832  infoExceptions->PageSavable = modeInfo.PSBit;
2833  infoExceptions->Flags = modeInfo.Flags;
2834  infoExceptions->MRIE = modeInfo.ReportMethod;
2835  infoExceptions->Padding = 0;
2836  REVERSE_BYTES(&infoExceptions->IntervalTimer,
2837  &modeInfo.IntervalTimer);
2838  REVERSE_BYTES(&infoExceptions->ReportCount,
2839  &modeInfo.ReportCount)
2840  }
2841  } else {
2843  }
2844 
2845  break;
2846  }
2847 
2848  default:
2849  {
2850  sizeNeeded = 0;
2852  }
2853  }
2854  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "Disk: DiskQueryWmiDataBlock Device %p, Irp %p returns %lx\n",
2855  DeviceObject, Irp, status));
2856 
2858  Irp,
2859  status,
2860  sizeNeeded,
2861  IO_NO_INCREMENT);
2862 
2863  return status;
2864 }
struct _STORAGE_FAILURE_PREDICT_THRESHOLDS STORAGE_FAILURE_PREDICT_THRESHOLDS
struct _DISK_DATA * PDISK_DATA
UCHAR IntervalTimer[4]
Definition: scsi.h:3028
struct _STORAGE_SCSI_INFO_EXCEPTIONS * PSTORAGE_SCSI_INFO_EXCEPTIONS
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:776
struct _STORAGE_FAILURE_PREDICT_DATA STORAGE_FAILURE_PREDICT_DATA
DISK_GEOMETRY DiskGeometry
Definition: classpnp.h:888
NTSTATUS ReadyStatus
Definition: disk.h:319
struct _FUNCTIONAL_DEVICE_EXTENSION * PartitionZeroExtension
Definition: classpnp.h:599
LONG NTSTATUS
Definition: precomp.h:26
#define REVERSE_BYTES(Destination, Source)
Definition: scsi.h:3465
struct _STORAGE_FAILURE_PREDICT_STATUS STORAGE_FAILURE_PREDICT_STATUS
struct _STORAGE_FAILURE_PREDICT_DATA * PSTORAGE_FAILURE_PREDICT_DATA
struct _STORAGE_FAILURE_PREDICT_THRESHOLDS * PSTORAGE_FAILURE_PREDICT_THRESHOLDS
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define DiskGeometryGuid
Definition: diskwmi.c:140
#define RtlMoveMemory(Destination, Source, Length)
Definition: typedefs.h:264
#define STATUS_BUFFER_TOO_SMALL
Definition: shellext.h:69
struct _STORAGE_FAILURE_PREDICT_STATUS * PSTORAGE_FAILURE_PREDICT_STATUS
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
NTSTATUS DiskReadFailurePredictThresholds(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PSTORAGE_FAILURE_PREDICT_THRESHOLDS DiskSmartThresholds)
Definition: diskwmi.c:1417
#define FILE_REMOVABLE_MEDIA
Definition: nt_native.h:807
#define ScsiInfoExceptionsGuid
Definition: diskwmi.c:152
NTSTATUS DiskGetInfoExceptionInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMODE_INFO_EXCEPTIONS ReturnPageData)
Definition: disk.c:2896
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:418
struct _STORAGE_PREDICT_FAILURE * PSTORAGE_PREDICT_FAILURE
Definition: bufpool.h:45
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define DiskReadDriveCapacity(Fdo)
Definition: disk.h:818
#define SmartStatusGuid
Definition: diskwmi.c:141
#define SmartThresholdsGuid
Definition: diskwmi.c:151
FAILURE_PREDICTION_METHOD FailurePredictionCapability
Definition: disk.h:331
struct _STORAGE_SCSI_INFO_EXCEPTIONS STORAGE_SCSI_INFO_EXCEPTIONS
_In_ PIRP _In_ ULONG _In_ ULONG BufferAvail
Definition: classpnp.h:418
UCHAR VendorSpecific[512]
Definition: ntddstor.h:501
struct _DISK_GEOMETRY DISK_GEOMETRY
SCSIPORT_API NTSTATUS NTAPI ClassWmiCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ NTSTATUS Status, _In_ ULONG BufferUsed, _In_ CCHAR PriorityBoost)
Definition: classwmi.c:1009
UCHAR ReportCount[4]
Definition: scsi.h:3029
unsigned int * PULONG
Definition: retypes.h:1
NTSTATUS DiskSendFailurePredictIoctl(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PSTORAGE_PREDICT_FAILURE checkFailure)
Definition: diskwmi.c:854
#define SmartPerformFunction
Definition: diskwmi.c:143
#define SmartDataGuid
Definition: diskwmi.c:142
unsigned int ULONG
Definition: retypes.h:1
#define IO_NO_INCREMENT
Definition: iotypes.h:598
#define STATUS_SUCCESS
Definition: shellext.h:65
static SERVICE_STATUS status
Definition: service.c:31
#define PAGED_CODE()
#define NT_ASSERT
Definition: rtlfuncs.h:3310
Definition: ps.c:97

Referenced by DriverEntry().

◆ DiskFdoQueryWmiRegInfo()

NTSTATUS NTAPI DiskFdoQueryWmiRegInfo ( IN PDEVICE_OBJECT  DeviceObject,
OUT ULONG RegFlags,
OUT PUNICODE_STRING  InstanceName 
)

Definition at line 2479 of file diskwmi.c.

2517 {
2518  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
2519  PDISK_DATA diskData = (PDISK_DATA)(commonExtension->DriverData);
2520 
2521  PAGED_CODE();
2523 
2526 
2527  switch (diskData->FailurePredictionCapability)
2528  {
2530  {
2532  //
2533  // Fall Through
2534  //
2535  }
2537  {
2542 
2543  break;
2544  }
2545 
2547  {
2553  break;
2554  }
2555 
2556 
2557  default:
2558  {
2563  break;
2564  }
2565  }
2566 
2567  //
2568  // Use devnode for FDOs
2570 
2571  return STATUS_SUCCESS;
2572 }
struct _DISK_DATA * PDISK_DATA
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define SmartEventGuid
Definition: diskwmi.c:150
GUIDREGINFO DiskWmiFdoGuidList[]
Definition: diskwmi.c:92
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
#define ScsiInfoExceptionsGuid
Definition: diskwmi.c:152
_Out_ ULONG * RegFlags
Definition: classpnp.h:403
#define WMIREG_FLAG_INSTANCE_PDO
Definition: wmistr.h:69
#define CLEAR_FLAG(Flags, Bit)
Definition: cdrom.h:1494
_Must_inspect_result_ _In_ ULONG Flags
Definition: wsk.h:170
#define WMIREG_FLAG_REMOVE_GUID
Definition: wmistr.h:70
#define SmartStatusGuid
Definition: diskwmi.c:141
#define SmartThresholdsGuid
Definition: diskwmi.c:151
FAILURE_PREDICTION_METHOD FailurePredictionCapability
Definition: disk.h:331
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING InstanceName
Definition: fltkernel.h:1162
#define SmartPerformFunction
Definition: diskwmi.c:143
#define SmartDataGuid
Definition: diskwmi.c:142
#define STATUS_SUCCESS
Definition: shellext.h:65
#define SET_FLAG(Flags, Bit)
Definition: cdrom.h:1493
#define PAGED_CODE()

Referenced by DiskFdoQueryWmiRegInfoEx(), and DriverEntry().

◆ DiskFdoQueryWmiRegInfoEx()

NTSTATUS NTAPI DiskFdoQueryWmiRegInfoEx ( IN PDEVICE_OBJECT  DeviceObject,
OUT ULONG RegFlags,
OUT PUNICODE_STRING  InstanceName,
OUT PUNICODE_STRING  MofName 
)

Definition at line 2577 of file diskwmi.c.

2620 {
2621  NTSTATUS status;
2622 
2623  UNREFERENCED_PARAMETER(MofName);
2624 
2626  RegFlags,
2627  InstanceName);
2628 
2629  //
2630  // Leave MofName alone since disk doesn't have one
2631  //
2632  return(status);
2633 }
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
LONG NTSTATUS
Definition: precomp.h:26
NTSTATUS NTAPI DiskFdoQueryWmiRegInfo(IN PDEVICE_OBJECT DeviceObject, OUT ULONG *RegFlags, OUT PUNICODE_STRING InstanceName)
Definition: diskwmi.c:2479
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_Out_ ULONG * RegFlags
Definition: classpnp.h:403
_Must_inspect_result_ _Inout_ PFLT_VOLUME _In_opt_ PCUNICODE_STRING InstanceName
Definition: fltkernel.h:1162
static SERVICE_STATUS status
Definition: service.c:31
Definition: ps.c:97

Referenced by DriverEntry().

◆ DiskFdoSetWmiDataBlock()

NTSTATUS NTAPI DiskFdoSetWmiDataBlock ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN ULONG  GuidIndex,
IN ULONG  BufferSize,
IN PUCHAR  Buffer 
)

Definition at line 2869 of file diskwmi.c.

2904 {
2905  NTSTATUS status;
2906  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = DeviceObject->DeviceExtension;
2907  PCOMMON_DEVICE_EXTENSION commonExtension = DeviceObject->DeviceExtension;
2908  PDISK_DATA diskData = (PDISK_DATA)(commonExtension->DriverData);
2909 
2910  PAGED_CODE();
2911 
2912  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "Disk: DiskSetWmiDataBlock, Device %p, Irp %p, GuiIndex %d\n"
2913  " BufferSize %#x Buffer %p\n",
2914  DeviceObject, Irp,
2916 
2918  {
2919  PSTORAGE_SCSI_INFO_EXCEPTIONS infoExceptions;
2920  MODE_INFO_EXCEPTIONS modeInfo = {0};
2921 
2923  {
2924  infoExceptions = (PSTORAGE_SCSI_INFO_EXCEPTIONS)Buffer;
2925 
2927  modeInfo.PageLength = sizeof(MODE_INFO_EXCEPTIONS) - 2;
2928 
2929  modeInfo.PSBit = 0;
2930  modeInfo.Flags = infoExceptions->Flags;
2931 
2932  modeInfo.ReportMethod = infoExceptions->MRIE;
2933 
2934  REVERSE_BYTES(&modeInfo.IntervalTimer[0],
2935  &infoExceptions->IntervalTimer);
2936 
2937  REVERSE_BYTES(&modeInfo.ReportCount[0],
2938  &infoExceptions->ReportCount);
2939 
2940  if (modeInfo.Perf == 1)
2941  {
2942  diskData->AllowFPPerfHit = FALSE;
2943  } else {
2944  diskData->AllowFPPerfHit = TRUE;
2945  }
2946 
2947  status = DiskSetInfoExceptionInformation(fdoExtension,
2948  &modeInfo);
2949  } else {
2951  }
2952 
2953  } else if (GuidIndex <= SmartThresholdsGuid)
2954  {
2956  } else {
2958  }
2959 
2960  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "Disk: DiskSetWmiDataBlock Device %p, Irp %p returns %lx\n",
2961  DeviceObject, Irp, status));
2962 
2964  Irp,
2965  status,
2966  0,
2967  IO_NO_INCREMENT);
2968 
2969  return status;
2970 }
#define MODE_PAGE_FAULT_REPORTING
Definition: scsi.h:218
struct _DISK_DATA * PDISK_DATA
UCHAR IntervalTimer[4]
Definition: scsi.h:3028
struct _STORAGE_SCSI_INFO_EXCEPTIONS * PSTORAGE_SCSI_INFO_EXCEPTIONS
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:776
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
LONG NTSTATUS
Definition: precomp.h:26
#define REVERSE_BYTES(Destination, Source)
Definition: scsi.h:3465
#define STATUS_WMI_READ_ONLY
Definition: ntstatus.h:818
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
BOOLEAN AllowFPPerfHit
Definition: disk.h:332
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
NTSTATUS DiskSetInfoExceptionInformation(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN PMODE_INFO_EXCEPTIONS PageData)
Definition: disk.c:2985
#define FALSE
Definition: types.h:117
_In_ PIRP Irp
Definition: csq.h:116
#define ScsiInfoExceptionsGuid
Definition: diskwmi.c:152
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:418
Definition: bufpool.h:45
#define SmartThresholdsGuid
Definition: diskwmi.c:151
SCSIPORT_API NTSTATUS NTAPI ClassWmiCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ NTSTATUS Status, _In_ ULONG BufferUsed, _In_ CCHAR PriorityBoost)
Definition: classwmi.c:1009
UCHAR ReportCount[4]
Definition: scsi.h:3029
struct _MODE_INFO_EXCEPTIONS MODE_INFO_EXCEPTIONS
#define IO_NO_INCREMENT
Definition: iotypes.h:598
static SERVICE_STATUS status
Definition: service.c:31
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
#define PAGED_CODE()
Definition: ps.c:97

Referenced by DriverEntry().

◆ DiskFdoSetWmiDataItem()

NTSTATUS NTAPI DiskFdoSetWmiDataItem ( IN PDEVICE_OBJECT  DeviceObject,
IN PIRP  Irp,
IN ULONG  GuidIndex,
IN ULONG  DataItemId,
IN ULONG  BufferSize,
IN PUCHAR  Buffer 
)

Definition at line 2975 of file diskwmi.c.

3013 {
3014  NTSTATUS status;
3015 
3016  PAGED_CODE();
3017 
3018  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "Disk: DiskSetWmiDataItem, Device %p, Irp %p, GuiIndex %d, DataId %d\n"
3019  " BufferSize %#x Buffer %p\n",
3020  DeviceObject, Irp,
3022 
3024  {
3026  } else {
3028  }
3029 
3030  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_WMI, "Disk: DiskSetWmiDataItem Device %p, Irp %p returns %lx\n",
3031  DeviceObject, Irp, status));
3032 
3034  Irp,
3035  status,
3036  0,
3037  IO_NO_INCREMENT);
3038 
3039  return status;
3040 }
#define STATUS_WMI_GUID_NOT_FOUND
Definition: ntstatus.h:776
LONG NTSTATUS
Definition: precomp.h:26
#define STATUS_WMI_READ_ONLY
Definition: ntstatus.h:818
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
_In_ PDEVICE_OBJECT DeviceObject
Definition: wdfdevice.h:2055
_In_ PIRP Irp
Definition: csq.h:116
_In_ PIRP _In_ ULONG GuidIndex
Definition: classpnp.h:418
Definition: bufpool.h:45
_In_ ULONG DataItemId
Definition: wdfwmi.h:123
#define SmartThresholdsGuid
Definition: diskwmi.c:151
SCSIPORT_API NTSTATUS NTAPI ClassWmiCompleteRequest(_In_ PDEVICE_OBJECT DeviceObject, _Inout_ PIRP Irp, _In_ NTSTATUS Status, _In_ ULONG BufferUsed, _In_ CCHAR PriorityBoost)
Definition: classwmi.c:1009
#define IO_NO_INCREMENT
Definition: iotypes.h:598
static SERVICE_STATUS status
Definition: service.c:31
_In_ WDFMEMORY _Out_opt_ size_t * BufferSize
Definition: wdfmemory.h:251
#define PAGED_CODE()
Definition: ps.c:97

Referenced by DriverEntry().

◆ DiskFlushDispatch()

VOID DiskFlushDispatch ( IN PDEVICE_OBJECT  Fdo,
IN PDISK_GROUP_CONTEXT  FlushContext 
)

Definition at line 1534 of file disk.c.

1558 {
1559  PFUNCTIONAL_DEVICE_EXTENSION fdoExt = Fdo->DeviceExtension;
1560  PSCSI_REQUEST_BLOCK srb = &FlushContext->Srb.Srb;
1561  PSTORAGE_REQUEST_BLOCK srbEx = &FlushContext->Srb.SrbEx;
1563  PSTOR_ADDR_BTL8 storAddrBtl8;
1564  PSRBEX_DATA_SCSI_CDB16 srbExDataCdb16;
1565  NTSTATUS SyncCacheStatus = STATUS_SUCCESS;
1566 
1567  //
1568  // Fill in the srb fields appropriately
1569  //
1570  if (fdoExt->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) {
1571  RtlZeroMemory(srbEx, sizeof(FlushContext->Srb.SrbExBuffer));
1572 
1573  srbEx->Length = FIELD_OFFSET(STORAGE_REQUEST_BLOCK, Signature);
1574  srbEx->Function = SRB_FUNCTION_STORAGE_REQUEST_BLOCK;
1575  srbEx->Signature = SRB_SIGNATURE;
1576  srbEx->Version = STORAGE_REQUEST_BLOCK_VERSION_1;
1577  srbEx->SrbLength = sizeof(FlushContext->Srb.SrbExBuffer);
1578  srbEx->RequestPriority = IoGetIoPriorityHint(FlushContext->CurrIrp);
1579  srbEx->AddressOffset = sizeof(STORAGE_REQUEST_BLOCK);
1580  srbEx->TimeOutValue = fdoExt->TimeOutValue * 4;
1581  srbEx->RequestTag = SP_UNTAGGED;
1582  srbEx->RequestAttribute = SRB_SIMPLE_TAG_REQUEST;
1583  srbEx->SrbFlags = fdoExt->SrbFlags;
1584 
1585  //
1586  // Set up address fields
1587  //
1588 
1589  storAddrBtl8 = (PSTOR_ADDR_BTL8) ((PUCHAR)srbEx + srbEx->AddressOffset);
1590  storAddrBtl8->Type = STOR_ADDRESS_TYPE_BTL8;
1591  storAddrBtl8->AddressLength = STOR_ADDR_BTL8_ADDRESS_LENGTH;
1592 
1593  } else {
1595 
1597  srb->TimeOutValue = fdoExt->TimeOutValue * 4;
1598  srb->QueueTag = SP_UNTAGGED;
1600  srb->SrbFlags = fdoExt->SrbFlags;
1601  }
1602 
1603  //
1604  // If write caching is enabled then send down a synchronize cache request
1605  //
1606  if (TEST_FLAG(fdoExt->DeviceFlags, DEV_WRITE_CACHE))
1607  {
1608 
1609  if (fdoExt->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) {
1610  srbEx->SrbFunction = SRB_FUNCTION_EXECUTE_SCSI;
1611  srbEx->NumSrbExData = 1;
1612 
1613  //
1614  // Set up SCSI SRB extended data fields
1615  //
1616 
1617  srbEx->SrbExDataOffset[0] = sizeof(STORAGE_REQUEST_BLOCK) +
1618  sizeof(STOR_ADDR_BTL8);
1619  if ((srbEx->SrbExDataOffset[0] + sizeof(SRBEX_DATA_SCSI_CDB16)) <= srbEx->SrbLength) {
1620  srbExDataCdb16 = (PSRBEX_DATA_SCSI_CDB16)((PUCHAR)srbEx + srbEx->SrbExDataOffset[0]);
1621  srbExDataCdb16->Type = SrbExDataTypeScsiCdb16;
1622  srbExDataCdb16->Length = SRBEX_DATA_SCSI_CDB16_LENGTH;
1623  srbExDataCdb16->CdbLength = 10;
1624  srbExDataCdb16->Cdb[0] = SCSIOP_SYNCHRONIZE_CACHE;
1625  } else {
1626  // Should not happen
1627  NT_ASSERT(FALSE);
1628  return;
1629  }
1630 
1631  } else {
1633  srb->CdbLength = 10;
1634  srb->Cdb[0] = SCSIOP_SYNCHRONIZE_CACHE;
1635  }
1636 
1637  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_SCSI, "DiskFlushDispatch: sending sync cache\n"));
1638 
1639  SyncCacheStatus = ClassSendSrbSynchronous(Fdo, srb, NULL, 0, TRUE);
1640  }
1641 
1642  //
1643  // Set up a FLUSH SRB
1644  //
1645  if (fdoExt->AdapterDescriptor->SrbType == SRB_TYPE_STORAGE_REQUEST_BLOCK) {
1646  srbEx->SrbFunction = SRB_FUNCTION_FLUSH;
1647  srbEx->NumSrbExData = 0;
1648  srbEx->SrbExDataOffset[0] = 0;
1649  srbEx->OriginalRequest = FlushContext->CurrIrp;
1650  srbEx->SrbStatus = 0;
1651 
1652  //
1653  // Make sure that this srb does not get freed
1654  //
1655  SET_FLAG(srbEx->SrbFlags, SRB_CLASS_FLAGS_PERSISTANT);
1656 
1657  } else {
1659  srb->CdbLength = 0;
1660  srb->OriginalRequest = FlushContext->CurrIrp;
1661  srb->SrbStatus = 0;
1662  srb->ScsiStatus = 0;
1663 
1664  //
1665  // Make sure that this srb does not get freed
1666  //
1668  }
1669 
1670  //
1671  // Make sure that this request does not get retried
1672  //
1673  irpSp = IoGetCurrentIrpStackLocation(FlushContext->CurrIrp);
1674 
1675  irpSp->Parameters.Others.Argument4 = (PVOID) 0;
1676 
1677  //
1678  // Fill in the irp fields appropriately
1679  //
1680  irpSp = IoGetNextIrpStackLocation(FlushContext->CurrIrp);
1681 
1682  irpSp->MajorFunction = IRP_MJ_SCSI;
1683  irpSp->Parameters.Scsi.Srb = srb;
1684 
1685  IoSetCompletionRoutine(FlushContext->CurrIrp, DiskFlushComplete, (PVOID)(ULONG_PTR)SyncCacheStatus, TRUE, TRUE, TRUE);
1686 
1687  TracePrint((TRACE_LEVEL_VERBOSE, TRACE_FLAG_SCSI, "DiskFlushDispatch: sending srb flush on irp %p\n", FlushContext->CurrIrp));
1688 
1689  //
1690  // Send down the flush request
1691  //
1692  IoCallDriver(((PCOMMON_DEVICE_EXTENSION)fdoExt)->LowerDeviceObject, FlushContext->CurrIrp);
1693 }
#define STOR_ADDRESS_TYPE_BTL8
Definition: scsi.h:3525
#define SRB_TYPE_STORAGE_REQUEST_BLOCK
Definition: srb.h:655
#define SCSIOP_SYNCHRONIZE_CACHE
Definition: cdrw_hw.h:918
ULONG SrbFlags
Definition: srb.h:252
PVOID OriginalRequest
Definition: srb.h:258
UCHAR Cdb[16]
Definition: srb.h:271
#define STORAGE_REQUEST_BLOCK_VERSION_1
Definition: srb.h:608
struct STOR_ADDRESS_ALIGN _STOR_ADDR_BTL8 * PSTOR_ADDR_BTL8
#define TRUE
Definition: types.h:120
unsigned char * PUCHAR
Definition: retypes.h:3
LONG NTSTATUS
Definition: precomp.h:26
UCHAR CdbLength
Definition: srb.h:250
UCHAR QueueAction
Definition: srb.h:249
ULONG TimeOutValue
Definition: srb.h:254
UCHAR SrbStatus
Definition: srb.h:243
#define DEV_WRITE_CACHE
Definition: class2.h:21
#define IoSetCompletionRoutine(_Irp, _CompletionRoutine, _Context, _InvokeOnSuccess, _InvokeOnError, _InvokeOnCancel)
Definition: irp.cpp:498
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define SP_UNTAGGED
Definition: srb.h:225
#define IRP_MJ_SCSI
struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB16 SRBEX_DATA_SCSI_CDB16
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_VERBOSE
Definition: storswtr.h:30
UCHAR ScsiStatus
Definition: srb.h:244
#define STOR_ADDR_BTL8_ADDRESS_LENGTH
Definition: scsi.h:3528
#define SRB_CLASS_FLAGS_PERSISTANT
Definition: classpnp.h:20
struct SRB_ALIGN _SRBEX_DATA_SCSI_CDB16 * PSRBEX_DATA_SCSI_CDB16
* PSTORAGE_REQUEST_BLOCK
Definition: srb.h:652
void * PVOID
Definition: retypes.h:9
UCHAR QueueTag
Definition: srb.h:248
#define TEST_FLAG(Flags, Bit)
Definition: cdrom.h:1495
#define SRB_FUNCTION_FLUSH
Definition: srb.h:315
NTSTATUS NTAPI ClassSendSrbSynchronous(_In_ PDEVICE_OBJECT Fdo, _Inout_ PSCSI_REQUEST_BLOCK _Srb, _In_reads_bytes_opt_(BufferLength) PVOID BufferAddress, _In_ ULONG BufferLength, _In_ BOOLEAN WriteToDevice)
Definition: class.c:4042
UCHAR Function
Definition: srb.h:242
PSTORAGE_ADAPTER_DESCRIPTOR AdapterDescriptor
Definition: classpnp.h:877
irpSp
Definition: iofuncs.h:2719
USHORT Length
Definition: srb.h:241
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
#define SRB_FUNCTION_STORAGE_REQUEST_BLOCK
Definition: srb.h:99
_In_z_ PCCHAR _In_ PDEVICE_OBJECT LowerDeviceObject
Definition: classpnp.h:982
#define SRB_SIGNATURE
Definition: srb.h:607
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetNextIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2695
__drv_aliasesMem FORCEINLINE PIO_STACK_LOCATION IoGetCurrentIrpStackLocation(_In_ PIRP Irp)
Definition: iofuncs.h:2793
STORAGE_REQUEST_BLOCK
Definition: srb.h:652
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:255
#define SRB_SIMPLE_TAG_REQUEST
Definition: srb.h:415
#define SCSI_REQUEST_BLOCK_SIZE
Definition: srb.h:274
#define NULL
Definition: types.h:112
NTSTATUS NTAPI IoCallDriver(IN PDEVICE_OBJECT DeviceObject, IN PIRP Irp)
Definition: irp.c:1218
NTKRNLVISTAAPI IO_PRIORITY_HINT NTAPI IoGetIoPriorityHint(_In_ PIRP Irp)
Definition: io.c:123
NTSTATUS NTAPI DiskFlushComplete(IN PDEVICE_OBJECT Fdo, IN PIRP Irp, IN PVOID Context)
Definition: disk.c:1699
struct STOR_ADDRESS_ALIGN _STOR_ADDR_BTL8 STOR_ADDR_BTL8
#define SRB_FUNCTION_EXECUTE_SCSI
Definition: srb.h:307
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
static const WCHAR Signature[]
Definition: parser.c:141
#define SRBEX_DATA_SCSI_CDB16_LENGTH
Definition: srb.h:480
#define SET_FLAG(Flags, Bit)
Definition: cdrom.h:1493
#define NT_ASSERT
Definition: rtlfuncs.h:3310

Referenced by DiskShutdownFlush().

◆ DiskGenerateDeviceName()

NTSTATUS DiskGenerateDeviceName ( IN ULONG  DeviceNumber,
OUT PCCHAR *  RawName 
)

Definition at line 612 of file pnp.c.

641 {
642  CHAR rawName[64] = { 0 };
644 
645  PAGED_CODE();
646 
647  status = RtlStringCchPrintfA(rawName, sizeof(rawName) - 1, FDO_NAME_FORMAT, DeviceNumber,
649  if (!NT_SUCCESS(status)) {
650  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_PNP, "DiskGenerateDeviceName: Format FDO name failed with error: 0x%X\n", status));
651  return status;
652  }
653 
654  *RawName = ExAllocatePoolWithTag(PagedPool,
655  strlen(rawName) + 1,
656  DISK_TAG_NAME);
657 
658  if(*RawName == NULL) {
660  }
661 
662  status = RtlStringCchCopyA(*RawName, strlen(rawName) + 1, rawName);
663  if (!NT_SUCCESS(status)) {
664  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_PNP, "DiskGenerateDeviceName: Device name copy failed with error: 0x%X\n", status));
665  FREE_POOL(*RawName);
666  return status;
667  }
668 
669  TracePrint((TRACE_LEVEL_INFORMATION, TRACE_FLAG_PNP, "DiskGenerateDeviceName: generated \"%s\"\n", rawName));
670 
671  return STATUS_SUCCESS;
672 }
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
char CHAR
Definition: xmlstorage.h:175
LONG NTSTATUS
Definition: precomp.h:26
#define TRACE_LEVEL_INFORMATION
Definition: storswtr.h:29
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
NTSTRSAFEVAPI RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
Definition: ntstrsafe.h:1085
#define FDO_NAME_FORMAT
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define DISK_TAG_NAME
Definition: disk.h:64
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define NULL
Definition: types.h:112
NTSTRSAFEAPI RtlStringCchCopyA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCSTR pszSrc)
Definition: ntstrsafe.h:110
#define STATUS_SUCCESS
Definition: shellext.h:65
_In_ PCHAR _In_ ULONG DeviceNumber
Definition: classpnp.h:1229
static SERVICE_STATUS status
Definition: service.c:31
ULONG diskDeviceSequenceNumber
Definition: pnp.c:35
#define PAGED_CODE()
Definition: ps.c:97

Referenced by DiskCreateFdo().

◆ DiskGetCacheInformation()

NTSTATUS NTAPI DiskGetCacheInformation ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
IN PDISK_CACHE_INFORMATION  CacheInfo 
)

Definition at line 3019 of file disk.c.

3044 {
3045  PMODE_PARAMETER_HEADER modeData;
3046  PMODE_CACHING_PAGE pageData;
3047 
3048  ULONG length;
3049 
3050  PAGED_CODE();
3051 
3052 
3053 
3054  modeData = ExAllocatePoolWithTag(NonPagedPoolNxCacheAligned,
3057 
3058  if (modeData == NULL) {
3059 
3060  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_IOCTL, "DiskGetSetCacheInformation: Unable to allocate mode "
3061  "data buffer\n"));
3063  }
3064 
3065  RtlZeroMemory(modeData, MODE_DATA_SIZE);
3066 
3067  length = ClassModeSense(FdoExtension->DeviceObject,
3068  (PCHAR) modeData,
3071 
3072  if (length < sizeof(MODE_PARAMETER_HEADER)) {
3073 
3074  //
3075  // Retry the request in case of a check condition.
3076  //
3077 
3078  length = ClassModeSense(FdoExtension->DeviceObject,
3079  (PCHAR) modeData,
3082 
3083  if (length < sizeof(MODE_PARAMETER_HEADER)) {
3084 
3085  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_IOCTL, "DiskGetCacheInformation: Mode Sense failed\n"));
3086 
3087  FREE_POOL(modeData);
3088  return STATUS_IO_DEVICE_ERROR;
3089  }
3090  }
3091 
3092  //
3093  // If the length is greater than length indicated by the mode data reset
3094  // the data to the mode data.
3095  //
3096 
3097  if (length > (ULONG) (modeData->ModeDataLength + 1)) {
3098  length = modeData->ModeDataLength + 1;
3099  }
3100 
3101  //
3102  // Check to see if the write cache is enabled.
3103  //
3104 
3105  pageData = ClassFindModePage((PCHAR) modeData,
3106  length,
3108  TRUE);
3109 
3110  //
3111  // Check if valid caching page exists.
3112  //
3113 
3114  if (pageData == NULL) {
3115  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_IOCTL, "DiskGetCacheInformation: Unable to find caching mode page.\n"));
3116  FREE_POOL(modeData);
3117  return STATUS_NOT_SUPPORTED;
3118  }
3119 
3120  //
3121  // Copy the parameters over.
3122  //
3123 
3124  RtlZeroMemory(CacheInfo, sizeof(DISK_CACHE_INFORMATION));
3125 
3126  CacheInfo->ParametersSavable = pageData->PageSavable;
3127 
3128  CacheInfo->ReadCacheEnabled = !(pageData->ReadDisableCache);
3129  CacheInfo->WriteCacheEnabled = pageData->WriteCacheEnable;
3130 
3131 
3132  //
3133  // Translate the values in the mode page into the ones defined in
3134  // ntdddisk.h.
3135  //
3136 
3137  CacheInfo->ReadRetentionPriority =
3139  CacheInfo->WriteRetentionPriority =
3141 
3142  CacheInfo->DisablePrefetchTransferLength =
3143  ((pageData->DisablePrefetchTransfer[0] << 8) +
3144  pageData->DisablePrefetchTransfer[1]);
3145 
3146  CacheInfo->ScalarPrefetch.Minimum =
3147  ((pageData->MinimumPrefetch[0] << 8) + pageData->MinimumPrefetch[1]);
3148 
3149  CacheInfo->ScalarPrefetch.Maximum =
3150  ((pageData->MaximumPrefetch[0] << 8) + pageData->MaximumPrefetch[1]);
3151 
3152  if(pageData->MultiplicationFactor) {
3153  CacheInfo->PrefetchScalar = TRUE;
3154  CacheInfo->ScalarPrefetch.MaximumBlocks =
3155  ((pageData->MaximumPrefetchCeiling[0] << 8) +
3156  pageData->MaximumPrefetchCeiling[1]);
3157  }
3158 
3159 
3160  FREE_POOL(modeData);
3161  return STATUS_SUCCESS;
3162 }
signed char * PCHAR
Definition: retypes.h:7
return STATUS_NOT_SUPPORTED
#define STATUS_INSUFFICIENT_RESOURCES
Definition: udferr_usr.h:158
UCHAR WriteCacheEnable
Definition: cdrw_hw.h:2779
#define MODE_PAGE_CACHING
Definition: cdrw_hw.h:846
#define TRUE
Definition: types.h:120
#define TRANSLATE_RETENTION_PRIORITY(_x)
Definition: disk.c:99
UCHAR ReadDisableCache
Definition: cdrw_hw.h:2777
UCHAR ReadRetensionPriority
Definition: cdrw_hw.h:2783
UCHAR MaximumPrefetch[2]
Definition: cdrw_hw.h:2787
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
#define FREE_POOL(_PoolPtr)
Definition: cdrom.h:782
#define MODE_DATA_SIZE
Definition: disk.c:164
UCHAR MultiplicationFactor
Definition: cdrw_hw.h:2778
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
#define DISK_TAG_DISABLE_CACHE
Definition: disk.h:56
PVOID NTAPI ClassFindModePage(_In_reads_bytes_(Length) PCHAR ModeSenseBuffer, _In_ ULONG Length, _In_ UCHAR PageMode, _In_ BOOLEAN Use6Byte)
Definition: class.c:6798
UCHAR MinimumPrefetch[2]
Definition: cdrw_hw.h:2786
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define NULL
Definition: types.h:112
ULONG NTAPI ClassModeSense(_In_ PDEVICE_OBJECT Fdo, _In_reads_bytes_(Length) PCHAR ModeSenseBuffer, _In_ ULONG Length, _In_ UCHAR PageMode)
Definition: class.c:6637
UCHAR DisablePrefetchTransfer[2]
Definition: cdrw_hw.h:2785
unsigned int ULONG
Definition: retypes.h:1
UCHAR MaximumPrefetchCeiling[2]
Definition: cdrw_hw.h:2788
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
UCHAR WriteRetensionPriority
Definition: cdrw_hw.h:2782
#define STATUS_SUCCESS
Definition: shellext.h:65
#define PAGED_CODE()

Referenced by DiskIoctlGetCacheInformation(), and DiskStartFdo().

◆ DiskGetInfoExceptionInformation()

NTSTATUS DiskGetInfoExceptionInformation ( IN PFUNCTIONAL_DEVICE_EXTENSION  FdoExtension,
OUT PMODE_INFO_EXCEPTIONS  ReturnPageData 
)

◆ DiskGetModePage()

NTSTATUS DiskGetModePage ( _In_ PDEVICE_OBJECT  Fdo,
_In_ UCHAR  PageMode,
_In_ UCHAR  PageControl,
_In_ PMODE_PARAMETER_HEADER  ModeData,
_Inout_ PULONG  ModeDataSize,
_Out_ PVOID PageData 
)

Definition at line 903 of file diskwmi.c.

911 {
912  ULONG size = 0;
913  PVOID pageData = NULL;
914 
915  PAGED_CODE();
916 
917  if (ModeData == NULL ||
918  ModeDataSize == NULL ||
919  *ModeDataSize < sizeof(MODE_PARAMETER_HEADER) ||
920  PageData == NULL) {
922  }
923 
924  RtlZeroMemory (ModeData, *ModeDataSize);
925 
927  (PCHAR) ModeData,
928  *ModeDataSize,
929  PageMode,
930  PageControl);
931 
932  if (size < sizeof(MODE_PARAMETER_HEADER)) {
933 
934  //
935  // Retry the request in case of a check condition.
936  //
938  (PCHAR) ModeData,
939  *ModeDataSize,
940  PageMode,
941  PageControl);
942 
943  if (size < sizeof(MODE_PARAMETER_HEADER)) {
944  TracePrint((TRACE_LEVEL_ERROR, TRACE_FLAG_WMI, "DiskGetModePage: Mode Sense for Page Mode %d with Page Control %d failed\n",
946  *ModeDataSize = 0;
947  return STATUS_IO_DEVICE_ERROR;
948  }
949  }
950 
951  //
952  // If the length is greater than length indicated by the mode data reset
953  // the data to the mode data.
954  //
955  if (size > (ULONG) (ModeData->ModeDataLength + 1)) {
956  size = ModeData->ModeDataLength + 1;
957  }
958 
959  *ModeDataSize = size;
960 
961  //
962  // Find the mode page
963  //
964  pageData = ClassFindModePage((PCHAR) ModeData,
965  size,
966  PageMode,
967  TRUE);
968 
969  if (pageData) {
970  *PageData = pageData;
971  return STATUS_SUCCESS;
972  } else {
973  *PageData = NULL;
974  return STATUS_NOT_SUPPORTED;
975  }
976 }
signed char * PCHAR
Definition: retypes.h:7
return STATUS_NOT_SUPPORTED
_In_ size_t _In_ UCHAR PageMode
Definition: cdrom.h:1325
#define TRUE
Definition: types.h:120
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
#define STATUS_IO_DEVICE_ERROR
Definition: udferr_usr.h:179
_In_ ULONG _In_ UCHAR _In_ UCHAR PageControl
Definition: cdrom.h:1316
GLsizeiptr size
Definition: glext.h:5919
PVOID NTAPI ClassFindModePage(_In_reads_bytes_(Length) PCHAR ModeSenseBuffer, _In_ ULONG Length, _In_ UCHAR PageMode, _In_ BOOLEAN Use6Byte)
Definition: class.c:6798
_Must_inspect_result_ _In_ WDFDEVICE Fdo
Definition: wdffdo.h:461
#define TRACE_LEVEL_ERROR
Definition: storswtr.h:27
#define NULL
Definition: types.h:112
unsigned int ULONG
Definition: retypes.h:1
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
#define STATUS_SUCCESS
Definition: shellext.h:65
ULONG NTAPI ClassModeSenseEx(_In_ PDEVICE_OBJECT Fdo, _In_reads_bytes_(Length) PCHAR ModeSenseBuffer, _In_ ULONG Length, _In_ UCHAR PageMode, _In_ UCHAR PageControl)
Definition: class.c:6656
#define PAGED_CODE()

Referenced by DiskEnableInfoExceptions().

◆ DiskInitFdo()

NTSTATUS NTAPI DiskInitFdo ( IN PDEVICE_OBJECT  Fdo)

Definition at line 202 of file pnp.c.

223 {
224  PFUNCTIONAL_DEVICE_EXTENSION fdoExtension = Fdo->DeviceExtension;
225  PDISK_DATA diskData = (PDISK_DATA) fdoExtension->CommonExtension.DriverData;
226 
227  ULONG srbFlags = 0;
228  ULONG timeOut = 0;
229  ULONG bytesPerSector;
230 
231  PULONG dmSkew;
232 
234 
235  PAGED_CODE();
236 
237  //
238  // Build the lookaside list for srb's for the physical disk. Should only
239  // need a couple. If this fails then we don't have an emergency SRB so
240  // fail the call to initialize.
241  //
242 
243  ClassInitializeSrbLookasideList((PCOMMON_DEVICE_EXTENSION) fdoExtension,
245 
246  if (fdoExtension->DeviceDescriptor->RemovableMedia)
247  {
248  SET_FLAG(Fdo->Characteristics, FILE_REMOVABLE_MEDIA);
249  }
250 
251  //
252  // Initialize the srb flags.
253  //
254 
255  //
256  // Because all requests share a common sense buffer, it is possible
257  // for the buffer to be overwritten if the port driver completes
258  // multiple failed requests that require a request sense before the
259  // class driver's completion routine can consume the data in the buffer.
260  // To prevent this, we allow the port driver to allocate a unique sense
261  // buffer each time it needs one. We are responsible for freeing this
262  // buffer. This also allows the adapter to be configured to support
263  // additional sense data beyond the minimum 18 bytes.
264  //
265 
267 
268  if (fdoExtension->DeviceDescriptor->CommandQueueing &&
269  fdoExtension->AdapterDescriptor->CommandQueueing) {
270 
272 
273  }
274 
275  //
276  // Look for controllers that require special flags.
277  //
278 
279  ClassScanForSpecial(fdoExtension, DiskBadControllers, DiskSetSpecialHacks);
280 
281  //
282  // Clear buffer for drive geometry.
283  //
284 
285  RtlZeroMemory(&(fdoExtension->DiskGeometry),
286  sizeof(