41#pragma alloc_text(PAGE, DiskAddDevice)
42#pragma alloc_text(PAGE, DiskInitFdo)
43#pragma alloc_text(PAGE, DiskStartFdo)
44#pragma alloc_text(PAGE, DiskGenerateDeviceName)
45#pragma alloc_text(PAGE, DiskCreateSymbolicLinks)
46#pragma alloc_text(PAGE, DiskDeleteSymbolicLinks)
47#pragma alloc_text(PAGE, DiskRemoveDevice)
107 TracePrint((
TRACE_LEVEL_ERROR, TRACE_FLAG_PNP,
"DiskAddDevice: Error %#08lx opening device key "
124 TracePrint((
TRACE_LEVEL_ERROR, TRACE_FLAG_PNP,
"DiskAddDevice: Error %#08lx opening disk key "
125 "for pdo %p device key %p\n",
131 queryTable[0].
Name =
L"RootPartitionMountable";
136#pragma prefast(suppress:6309, "We don't have QueryRoutine so Context doesn't make any sense")
145 TracePrint((
TRACE_LEVEL_ERROR, TRACE_FLAG_PNP,
"DiskAddDevice: Error %#08lx reading value from "
146 "disk key %p for pdo %p\n",
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 "),
176 (
BOOLEAN) !rootPartitionMountable
229 ULONG bytesPerSector;
302 TracePrint((
TRACE_LEVEL_ERROR, TRACE_FLAG_PNP,
"DiskInitFdo: Can not allocate request sense buffer\n"));
324 if ( (fdoExtension->MiniportDescriptor !=
NULL) &&
325 (fdoExtension->MiniportDescriptor->IoTimeoutValue > 0) ) {
329 fdoExtension->
TimeOutValue = fdoExtension->MiniportDescriptor->IoTimeoutValue;
334 timeOut = ClassQueryTimeOutRegistryValue(
Fdo);
351 ClassUpdateInformationInRegistry(
Fdo,
359 ClassInitializeMediaChangeDetection(fdoExtension,
405 if (bytesPerSector == 0) {
434 fdoExtension->
DMSkew = *dmSkew;
441#if defined(_X86_) || defined(_AMD64_)
451 DiskReadSignature(
Fdo);
454 if (diskData->GeometrySource == DiskGeometryUnknown)
462 if (DiskIsNT4Geometry(fdoExtension))
465 diskData->RealGeometry.SectorsPerTrack = 0x20;
466 diskData->RealGeometry.TracksPerCylinder = 0x40;
469 diskData->GeometrySource = DiskGeometryFromNT4;
554 "%d for device %p, Status = %lx\n",
639#define FDO_NAME_FORMAT "\\Device\\Harddisk%d\\DR%d"
642 CHAR rawName[64] = { 0 };
650 TracePrint((
TRACE_LEVEL_ERROR, TRACE_FLAG_PNP,
"DiskGenerateDeviceName: Format FDO name failed with error: 0x%X\n",
status));
658 if(*RawName ==
NULL) {
664 TracePrint((
TRACE_LEVEL_ERROR, TRACE_FLAG_PNP,
"DiskGenerateDeviceName: Device name copy failed with error: 0x%X\n",
status));
706 WCHAR wideSourceName[64] = { 0 };
720 if(!diskData->
LinkStatus.WellKnownNameCreated) {
727 L"\\Device\\Harddisk%d\\Partition0",
747 if (!diskData->
LinkStatus.PhysicalDriveLinkCreated) {
755 L"\\DosDevices\\PhysicalDrive%d",
806 WCHAR wideLinkName[64] = { 0 };
812 if(diskData->
LinkStatus.WellKnownNameCreated) {
815 L"\\Device\\Harddisk%d\\Partition0",
824 if(diskData->
LinkStatus.PhysicalDriveLinkCreated) {
827 L"\\DosDevices\\PhysicalDrive%d",
902 ClassDeleteSrbLookasideList(commonExtension);
945 ULONG isPowerProtected = 0;
1005 ClassGetDeviceParameter(fdoExtension,
1021 TracePrint((
TRACE_LEVEL_WARNING, TRACE_FLAG_PNP,
"DiskStartFdo: Turning off write cache for %p due to a firmware issue\n",
Fdo));
1030 TracePrint((
TRACE_LEVEL_WARNING, TRACE_FLAG_PNP,
"DiskStartFdo: Turning off write cache for %p due to hotpluggable device\n",
Fdo));
1039 TracePrint((
TRACE_LEVEL_WARNING, TRACE_FLAG_PNP,
"DiskStartFdo: Turning off write cache for %p due to unlockable media\n",
Fdo));
1100 if (isPowerProtected == 1)
ACPI_SIZE strlen(const char *String)
PDEVICE_OBJECT PhysicalDeviceObject
#define DEV_SAFE_START_UNIT
#define FREE_POOL(_PoolPtr)
#define DEV_POWER_PROTECTED
#define TEST_FLAG(Flags, Bit)
#define CLEAR_FLAG(Flags, Bit)
#define SET_FLAG(Flags, Bit)
#define CLASS_SPECIAL_DISABLE_WRITE_CACHE
#define ADJUST_FUA_FLAG(fdoExt)
_In_ PCHAR _In_ ULONG DeviceNumber
#define NT_SUCCESS(StatCode)
_Must_inspect_result_ NTSTATUS NTAPI ClassReadDriveCapacity(_In_ PDEVICE_OBJECT Fdo)
CLASSPNP_SCAN_FOR_SPECIAL_INFO DiskBadControllers[]
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 NTAPI DiskSetSpecialHacks(IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, IN ULONG_PTR Data)
NTSTATUS DiskCreateFdo(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject, IN PULONG DeviceCount, IN BOOLEAN DasdAccessOnly)
NTSTATUS DiskDetectFailurePrediction(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, PFAILURE_PREDICTION_METHOD FailurePredictCapability, BOOLEAN ScsiAddressAvailable)
#define PARTITION0_LIST_SIZE
#define DISK_DEFAULT_FAILURE_POLLING_PERIOD
#define DiskDeviceParameterSubkey
#define DiskReadDriveCapacity(Fdo)
#define MAX_SECTORS_PER_VERIFY
#define DiskDeviceCacheIsPowerProtected
struct _DISK_DATA * PDISK_DATA
#define DiskDeviceUserWriteCacheSetting
#define SCSI_DISK_TIMEOUT
NTSTATUS DiskEnableDisableFailurePredictPolling(PFUNCTIONAL_DEVICE_EXTENSION FdoExtension, BOOLEAN Enable, ULONG PollTimeInSeconds)
NTSTATUS NTAPI DiskRemoveDevice(IN PDEVICE_OBJECT DeviceObject, IN UCHAR Type)
NTSTATUS DiskGenerateDeviceName(IN ULONG DeviceNumber, OUT PCCHAR *RawName)
NTSTATUS NTAPI DiskStartFdo(IN PDEVICE_OBJECT Fdo)
NTSTATUS NTAPI DiskInitFdo(IN PDEVICE_OBJECT Fdo)
VOID DiskCreateSymbolicLinks(IN PDEVICE_OBJECT DeviceObject)
ULONG diskDeviceSequenceNumber
NTSTATUS NTAPI DiskAddDevice(IN PDRIVER_OBJECT DriverObject, IN PDEVICE_OBJECT PhysicalDeviceObject)
NTSTATUS NTAPI DiskStopDevice(IN PDEVICE_OBJECT DeviceObject, IN UCHAR Type)
VOID DiskDeleteSymbolicLinks(IN PDEVICE_OBJECT DeviceObject)
#define SRB_FLAGS_QUEUE_ACTION_ENABLE
#define SRB_FLAGS_PORT_DRIVER_ALLOCSENSE
#define SRB_FLAGS_NO_QUEUE_FREEZE
#define ExAllocatePoolWithTag(hernya, size, tag)
#define KeWaitForSingleObject(pEvt, foo, a, b, c)
#define KeInitializeEvent(pEvt, foo, foo2)
#define InitializeListHead(ListHead)
#define KeInitializeSpinLock(sl)
#define OBJ_KERNEL_HANDLE
#define OBJ_CASE_INSENSITIVE
NTSYSAPI NTSTATUS WINAPI RtlQueryRegistryValues(ULONG, PCWSTR, PRTL_QUERY_REGISTRY_TABLE, PVOID, PVOID)
PCONFIGURATION_INFORMATION NTAPI IoGetConfigurationInformation(VOID)
Returns a pointer to the I/O manager's global configuration information structure.
#define IOCTL_STORAGE_GET_HOTPLUG_INFO
#define InitializeObjectAttributes(p, n, a, r, s)
NTSYSAPI NTSTATUS NTAPI ZwClose(_In_ HANDLE Handle)
NTSYSAPI NTSTATUS NTAPI ZwMakeTemporaryObject(_In_ HANDLE Handle)
NTSYSAPI VOID NTAPI RtlInitUnicodeString(PUNICODE_STRING DestinationString, PCWSTR SourceString)
#define RTL_QUERY_REGISTRY_DIRECT
#define RTL_REGISTRY_HANDLE
#define FILE_REMOVABLE_MEDIA
#define UNREFERENCED_PARAMETER(P)
PIRP NTAPI IoBuildDeviceIoControlRequest(IN ULONG IoControlCode, IN PDEVICE_OBJECT DeviceObject, IN PVOID InputBuffer, IN ULONG InputBufferLength, IN PVOID OutputBuffer, IN ULONG OutputBufferLength, IN BOOLEAN InternalDeviceIoControl, IN PKEVENT Event, IN PIO_STATUS_BLOCK IoStatusBlock)
NTSTATUS NTAPI IoCreateSymbolicLink(IN PUNICODE_STRING SymbolicLinkName, IN PUNICODE_STRING DeviceName)
NTSTATUS NTAPI IoDeleteSymbolicLink(IN PUNICODE_STRING SymbolicLinkName)
VOID NTAPI KeInitializeMutex(IN PKMUTEX Mutex, IN ULONG Level)
NTSTRSAFEAPI RtlStringCchCopyA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ NTSTRSAFE_PCSTR pszSrc)
NTSTRSAFEVAPI RtlStringCchPrintfA(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCSTR pszFormat,...)
NTSTRSAFEVAPI RtlStringCchPrintfW(_Out_writes_(cchDest) _Always_(_Post_z_) NTSTRSAFE_PWSTR pszDest, _In_ size_t cchDest, _In_ _Printf_format_string_ NTSTRSAFE_PCWSTR pszFormat,...)
NTSTATUS NTAPI IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject, IN ULONG DevInstKeyType, IN ACCESS_MASK DesiredAccess, OUT PHANDLE DevInstRegKey)
#define IOCTL_SCSI_GET_ADDRESS
#define SENSE_BUFFER_SIZE_EX
#define TRACE_LEVEL_WARNING
#define TRACE_LEVEL_ERROR
#define TRACE_LEVEL_INFORMATION
LARGE_INTEGER StartingOffset
PDEVICE_OBJECT DeviceObject
PDEVICE_OBJECT LowerDeviceObject
UNICODE_STRING DeviceName
struct _FUNCTIONAL_DEVICE_EXTENSION * PartitionZeroExtension
DISK_GROUP_CONTEXT FlushContext
DISK_USER_WRITE_CACHE_SETTING WriteCacheOverride
FAILURE_PREDICTION_METHOD FailurePredictionCapability
struct _DISK_DATA::@1066 LinkStatus
ULONG ScanForSpecialFlags
DISK_GEOMETRY DiskGeometry
COMMON_DEVICE_EXTENSION CommonExtension
PSTORAGE_ADAPTER_DESCRIPTOR AdapterDescriptor
PSTORAGE_DEVICE_DESCRIPTOR DeviceDescriptor
BOOLEAN WriteCacheEnableOverride
#define RtlZeroMemory(Destination, Length)
#define STATUS_UNSUCCESSFUL
#define STATUS_INSUFFICIENT_RESOURCES
_In_ PDEVICE_OBJECT DeviceObject
_Must_inspect_result_ _In_ PDRIVER_OBJECT DriverObject
_Must_inspect_result_ _In_ WDFDEVICE Fdo
#define PLUGPLAY_REGKEY_DEVICE
#define IRP_MN_REMOVE_DEVICE
#define IRP_MN_CANCEL_REMOVE_DEVICE
#define IRP_MN_QUERY_REMOVE_DEVICE
#define RTL_QUERY_REGISTRY_TYPECHECK
#define RTL_QUERY_REGISTRY_TYPECHECK_SHIFT