mirror of
https://github.com/reactos/reactos.git
synced 2025-05-20 09:36:16 +00:00
- Import disk.sys from Windows XP DDK
- Does not yet build svn path=/branches/usb-bringup-trunk/; revision=55211
This commit is contained in:
parent
2d7c9100e1
commit
c30c0341fd
11 changed files with 15644 additions and 0 deletions
13
drivers/storage/class/disk_new/CMakeLists.txt
Normal file
13
drivers/storage/class/disk_new/CMakeLists.txt
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
|
||||||
|
include_directories(..)
|
||||||
|
|
||||||
|
add_library(disk SHARED data.c disk.c diskwmi.c enum.c geometry.c part.c pnp.c disk.rc)
|
||||||
|
|
||||||
|
set_module_type(disk kernelmodedriver)
|
||||||
|
add_importlibs(disk
|
||||||
|
class2
|
||||||
|
scsiport
|
||||||
|
ntoskrnl
|
||||||
|
hal)
|
||||||
|
|
||||||
|
add_cd_file(TARGET disk DESTINATION reactos/system32/drivers NO_CAB FOR all)
|
77
drivers/storage/class/disk_new/data.c
Normal file
77
drivers/storage/class/disk_new/data.c
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (C) Microsoft Corporation, 1991 - 1999
|
||||||
|
|
||||||
|
Module Name:
|
||||||
|
|
||||||
|
disk.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
SCSI disk class driver
|
||||||
|
|
||||||
|
Environment:
|
||||||
|
|
||||||
|
kernel mode only
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
#include "disk.h"
|
||||||
|
|
||||||
|
#ifdef ALLOC_DATA_PRAGMA
|
||||||
|
#pragma data_seg("PAGE")
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/*
|
||||||
|
#define HackDisableTaggedQueuing (0x01)
|
||||||
|
#define HackDisableSynchronousTransfers (0x02)
|
||||||
|
#define HackDisableSpinDown (0x04)
|
||||||
|
#define HackDisableWriteCache (0x08)
|
||||||
|
#define HackCauseNotReportableHack (0x10)
|
||||||
|
#define HackRequiresStartUnitCommand (0x20)
|
||||||
|
*/
|
||||||
|
|
||||||
|
CLASSPNP_SCAN_FOR_SPECIAL_INFO DiskBadControllers[] = {
|
||||||
|
{ "COMPAQ" , "PD-1" , NULL, 0x02 },
|
||||||
|
{ "CONNER" , "CP3500" , NULL, 0x02 },
|
||||||
|
{ "FUJITSU" , "M2652S-512" , NULL, 0x01 },
|
||||||
|
{ "HP ", "C1113F " , NULL, 0x20 },
|
||||||
|
// iomegas require START_UNIT commands so be sure to match all of them.
|
||||||
|
{ "iomega" , "jaz" , NULL, 0x30 },
|
||||||
|
{ "iomega" , NULL , NULL, 0x20 },
|
||||||
|
{ "IOMEGA" , "ZIP" , NULL, 0x27 },
|
||||||
|
{ "IOMEGA" , NULL , NULL, 0x20 },
|
||||||
|
{ "MAXTOR" , "MXT-540SL" , "I1.2", 0x01 },
|
||||||
|
{ "MICROP" , "1936-21MW1002002" , NULL, 0x03 },
|
||||||
|
{ "OLIVETTI", "CP3500" , NULL, 0x02 },
|
||||||
|
{ "SEAGATE" , "ST41601N" , "0102", 0x02 },
|
||||||
|
{ "SEAGATE" , "ST3655N" , NULL, 0x08 },
|
||||||
|
{ "SEAGATE" , "ST3390N" , NULL, 0x08 },
|
||||||
|
{ "SEAGATE" , "ST12550N" , NULL, 0x08 },
|
||||||
|
{ "SEAGATE" , "ST32430N" , NULL, 0x08 },
|
||||||
|
{ "SEAGATE" , "ST31230N" , NULL, 0x08 },
|
||||||
|
{ "SEAGATE" , "ST15230N" , NULL, 0x08 },
|
||||||
|
{ "SyQuest" , "SQ5110" , "CHC", 0x03 },
|
||||||
|
{ "TOSHIBA" , "MK538FB" , "60", 0x01 },
|
||||||
|
{ NULL , NULL , NULL, 0x0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
DISK_MEDIA_TYPES_LIST const DiskMediaTypes[] = {
|
||||||
|
{ "COMPAQ" , "PD-1 LF-1094" , NULL, 1, 1, PC_5_RW , 0 , 0 , 0 },
|
||||||
|
{ "HP" , NULL , NULL, 2, 2, MO_5_WO , MO_5_RW, 0 , 0 },
|
||||||
|
{ "iomega" , "jaz" , NULL, 1, 1, IOMEGA_JAZ , 0 , 0 , 0 },
|
||||||
|
{ "IOMEGA" , "ZIP" , NULL, 1, 1, IOMEGA_ZIP , 0 , 0 , 0 },
|
||||||
|
{ "PINNACLE", "Apex 4.6GB" , NULL, 3, 2, PINNACLE_APEX_5_RW, MO_5_RW, MO_5_WO, 0 },
|
||||||
|
{ "SONY" , "SMO-F541" , NULL, 2, 2, MO_5_WO , MO_5_RW, 0 , 0 },
|
||||||
|
{ "SONY" , "SMO-F551" , NULL, 2, 2, MO_5_WO , MO_5_RW, 0 , 0 },
|
||||||
|
{ NULL , NULL , NULL, 0, 0, 0 , 0 , 0 , 0 }
|
||||||
|
};
|
||||||
|
|
||||||
|
#ifdef ALLOC_DATA_PRAGMA
|
||||||
|
#pragma data_seg()
|
||||||
|
#endif
|
||||||
|
|
6581
drivers/storage/class/disk_new/disk.c
Normal file
6581
drivers/storage/class/disk_new/disk.c
Normal file
File diff suppressed because it is too large
Load diff
977
drivers/storage/class/disk_new/disk.h
Normal file
977
drivers/storage/class/disk_new/disk.h
Normal file
|
@ -0,0 +1,977 @@
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (C) Microsoft Corporation, 1991 - 1999
|
||||||
|
|
||||||
|
Module Name:
|
||||||
|
|
||||||
|
disk.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
SCSI disk class driver
|
||||||
|
|
||||||
|
Environment:
|
||||||
|
|
||||||
|
kernel mode only
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
#include "ntddk.h"
|
||||||
|
#include "scsi.h"
|
||||||
|
#include <wmidata.h>
|
||||||
|
#include "classpnp.h"
|
||||||
|
#if defined(JAPAN) && defined(_X86_)
|
||||||
|
#include "machine.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#include <wmistr.h>
|
||||||
|
|
||||||
|
#if defined(_X86_)
|
||||||
|
#include "mountdev.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef ExAllocatePool
|
||||||
|
#undef ExAllocatePool
|
||||||
|
#define ExAllocatePool #assert(FALSE)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#define DISK_TAG_GENERAL ' DcS' // "ScD " - generic tag
|
||||||
|
#define DISK_TAG_SMART 'aDcS' // "ScDa" - SMART allocations
|
||||||
|
#define DISK_TAG_INFO_EXCEPTION 'ADcS' // "ScDA" - Info Exceptions
|
||||||
|
#define DISK_TAG_DISABLE_CACHE 'CDcS' // "ScDC" - disable cache paths
|
||||||
|
#define DISK_TAG_CCONTEXT 'cDcS' // "ScDc" - disk allocated completion context
|
||||||
|
#define DISK_TAG_DISK_GEOM 'GDcS' // "ScDG" - disk geometry buffer
|
||||||
|
#define DISK_TAG_UPDATE_GEOM 'gDcS' // "ScDg" - update disk geometry paths
|
||||||
|
#define DISK_TAG_SENSE_INFO 'IDcS' // "ScDI" - sense info buffers
|
||||||
|
#define DISK_TAG_PNP_ID 'iDcS' // "ScDp" - pnp ids
|
||||||
|
#define DISK_TAG_MODE_DATA 'MDcS' // "ScDM" - mode data buffer
|
||||||
|
#define DISK_CACHE_MBR_CHECK 'mDcS' // "ScDM" - mbr checksum code
|
||||||
|
#define DISK_TAG_NAME 'NDcS' // "ScDN" - disk name code
|
||||||
|
#define DISK_TAG_READ_CAP 'PDcS' // "ScDP" - read capacity buffer
|
||||||
|
#define DISK_TAG_PART_LIST 'pDcS' // "ScDp" - disk partition lists
|
||||||
|
#define DISK_TAG_SRB 'SDcS' // "ScDS" - srb allocation
|
||||||
|
#define DISK_TAG_START 'sDcS' // "ScDs" - start device paths
|
||||||
|
#define DISK_TAG_UPDATE_CAP 'UDcS' // "ScDU" - update capacity path
|
||||||
|
#define DISK_TAG_WI_CONTEXT 'WDcS' // "ScDW" - work-item context
|
||||||
|
|
||||||
|
typedef
|
||||||
|
VOID
|
||||||
|
(*PDISK_UPDATE_PARTITIONS) (
|
||||||
|
IN PDEVICE_OBJECT Fdo,
|
||||||
|
IN OUT PDRIVE_LAYOUT_INFORMATION_EX PartitionList
|
||||||
|
);
|
||||||
|
|
||||||
|
#if defined(_X86_)
|
||||||
|
|
||||||
|
//
|
||||||
|
// Disk device data
|
||||||
|
//
|
||||||
|
|
||||||
|
typedef enum _DISK_GEOMETRY_SOURCE {
|
||||||
|
DiskGeometryUnknown,
|
||||||
|
DiskGeometryFromBios,
|
||||||
|
DiskGeometryFromPort,
|
||||||
|
DiskGeometryFromNec98,
|
||||||
|
DiskGeometryGuessedFromBios,
|
||||||
|
DiskGeometryFromDefault
|
||||||
|
} DISK_GEOMETRY_SOURCE, *PDISK_GEOMETRY_SOURCE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
|
||||||
|
typedef struct _DISK_DATA {
|
||||||
|
|
||||||
|
//
|
||||||
|
// This field is the ordinal of a partition as it appears on a disk.
|
||||||
|
//
|
||||||
|
|
||||||
|
ULONG PartitionOrdinal;
|
||||||
|
|
||||||
|
//
|
||||||
|
// How has this disk been partitioned? Either EFI or MBR.
|
||||||
|
//
|
||||||
|
|
||||||
|
PARTITION_STYLE PartitionStyle;
|
||||||
|
|
||||||
|
union {
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
//
|
||||||
|
// Disk signature (from MBR)
|
||||||
|
//
|
||||||
|
|
||||||
|
ULONG Signature;
|
||||||
|
|
||||||
|
//
|
||||||
|
// MBR checksum
|
||||||
|
//
|
||||||
|
|
||||||
|
ULONG MbrCheckSum;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Number of hidden sectors for BPB.
|
||||||
|
//
|
||||||
|
|
||||||
|
ULONG HiddenSectors;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Partition type of this device object
|
||||||
|
//
|
||||||
|
// This field is set by:
|
||||||
|
//
|
||||||
|
// 1. Initially set according to the partition list entry
|
||||||
|
// partition type returned by IoReadPartitionTable.
|
||||||
|
//
|
||||||
|
// 2. Subsequently set by the
|
||||||
|
// IOCTL_DISK_SET_PARTITION_INFORMATION I/O control
|
||||||
|
// function when IoSetPartitionInformation function
|
||||||
|
// successfully updates the partition type on the disk.
|
||||||
|
//
|
||||||
|
|
||||||
|
UCHAR PartitionType;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Boot indicator - indicates whether this partition is a
|
||||||
|
// bootable (active) partition for this device
|
||||||
|
//
|
||||||
|
// This field is set according to the partition list entry boot
|
||||||
|
// indicator returned by IoReadPartitionTable.
|
||||||
|
//
|
||||||
|
|
||||||
|
BOOLEAN BootIndicator;
|
||||||
|
|
||||||
|
} Mbr;
|
||||||
|
|
||||||
|
struct {
|
||||||
|
|
||||||
|
//
|
||||||
|
// The DiskGUID field from the EFI partition header.
|
||||||
|
//
|
||||||
|
|
||||||
|
GUID DiskId;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Partition type of this device object.
|
||||||
|
//
|
||||||
|
|
||||||
|
GUID PartitionType;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Unique partition identifier for this partition.
|
||||||
|
//
|
||||||
|
|
||||||
|
GUID PartitionId;
|
||||||
|
|
||||||
|
//
|
||||||
|
// EFI partition attributes for this partition.
|
||||||
|
//
|
||||||
|
|
||||||
|
ULONG64 Attributes;
|
||||||
|
|
||||||
|
//
|
||||||
|
// EFI partition name of this partition.
|
||||||
|
//
|
||||||
|
|
||||||
|
WCHAR PartitionName[36];
|
||||||
|
|
||||||
|
} Efi;
|
||||||
|
|
||||||
|
}; // unnamed union
|
||||||
|
|
||||||
|
struct {
|
||||||
|
//
|
||||||
|
// This flag is set when the well known name is created (through
|
||||||
|
// DiskCreateSymbolicLinks) and cleared when destroying it
|
||||||
|
// (by calling DiskDeleteSymbolicLinks).
|
||||||
|
//
|
||||||
|
|
||||||
|
BOOLEAN WellKnownNameCreated : 1;
|
||||||
|
|
||||||
|
//
|
||||||
|
// This flag is set when the PhysicalDriveN link is created (through
|
||||||
|
// DiskCreateSymbolicLinks) and is cleared when destroying it (through
|
||||||
|
// DiskDeleteSymbolicLinks)
|
||||||
|
//
|
||||||
|
|
||||||
|
BOOLEAN PhysicalDriveLinkCreated : 1;
|
||||||
|
|
||||||
|
} LinkStatus;
|
||||||
|
|
||||||
|
//
|
||||||
|
// ReadyStatus - STATUS_SUCCESS indicates that the drive is ready for
|
||||||
|
// use. Any error status is to be returned as an explaination for why
|
||||||
|
// a request is failed.
|
||||||
|
//
|
||||||
|
// This was done solely for the zero-length partition case of having no
|
||||||
|
// media in a removable disk drive. When that occurs, and a read is sent
|
||||||
|
// to the zero-length non-partition-zero PDO that was created, we had to
|
||||||
|
// be able to fail the request with a reasonable value. This may not have
|
||||||
|
// been the best way to do this, but it works.
|
||||||
|
//
|
||||||
|
|
||||||
|
NTSTATUS ReadyStatus;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Routine to be called when updating the disk partitions. This routine
|
||||||
|
// is different for removable and non-removable media and is called by
|
||||||
|
// (among other things) DiskEnumerateDevice
|
||||||
|
//
|
||||||
|
|
||||||
|
PDISK_UPDATE_PARTITIONS UpdatePartitionRoutine;
|
||||||
|
|
||||||
|
//
|
||||||
|
// SCSI address used for SMART operations.
|
||||||
|
//
|
||||||
|
|
||||||
|
SCSI_ADDRESS ScsiAddress;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Event used to synchronize partitioning operations and enumerations.
|
||||||
|
//
|
||||||
|
|
||||||
|
KEVENT PartitioningEvent;
|
||||||
|
|
||||||
|
//
|
||||||
|
// These unicode strings hold the disk and volume interface strings. If
|
||||||
|
// the interfaces were not registered or could not be set then the string
|
||||||
|
// buffer will be NULL.
|
||||||
|
//
|
||||||
|
|
||||||
|
UNICODE_STRING DiskInterfaceString;
|
||||||
|
UNICODE_STRING PartitionInterfaceString;
|
||||||
|
|
||||||
|
//
|
||||||
|
// What type of failure prediction mechanism is available
|
||||||
|
//
|
||||||
|
|
||||||
|
FAILURE_PREDICTION_METHOD FailurePredictionCapability;
|
||||||
|
BOOLEAN AllowFPPerfHit;
|
||||||
|
|
||||||
|
#if defined(_X86_)
|
||||||
|
//
|
||||||
|
// This flag indiciates that a non-default geometry for this drive has
|
||||||
|
// already been determined by the disk driver. This field is ignored
|
||||||
|
// for removable media drives.
|
||||||
|
//
|
||||||
|
|
||||||
|
DISK_GEOMETRY_SOURCE GeometrySource;
|
||||||
|
|
||||||
|
//
|
||||||
|
// If GeometryDetermined is TRUE this will contain the geometry which was
|
||||||
|
// reported by the firmware or by the BIOS. For removable media drives
|
||||||
|
// this will contain the last geometry used when media was present.
|
||||||
|
//
|
||||||
|
|
||||||
|
DISK_GEOMETRY RealGeometry;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
//
|
||||||
|
// Indicates that the cached partition table is valid when set.
|
||||||
|
//
|
||||||
|
|
||||||
|
ULONG CachedPartitionTableValid;
|
||||||
|
|
||||||
|
//
|
||||||
|
// The cached partition table - this is only valid if the previous
|
||||||
|
// flag is set. When invalidated the cached partition table will be
|
||||||
|
// freed and replaced the next time one of the partitioning functions is
|
||||||
|
// called. This allows the error handling routines to invalidate it by
|
||||||
|
// setting the flag and doesn't require that they obtain a lock.
|
||||||
|
//
|
||||||
|
|
||||||
|
PDRIVE_LAYOUT_INFORMATION_EX CachedPartitionTable;
|
||||||
|
|
||||||
|
//
|
||||||
|
// This mutex prevents more than one IOCTL_DISK_VERIFY from being
|
||||||
|
// sent down to the disk. This greatly reduces the possibility of
|
||||||
|
// a Denial-of-Service attack
|
||||||
|
//
|
||||||
|
|
||||||
|
KMUTEX VerifyMutex;
|
||||||
|
|
||||||
|
} DISK_DATA, *PDISK_DATA;
|
||||||
|
|
||||||
|
// Define a general structure of identfing disk controllers with bad
|
||||||
|
// hardware.
|
||||||
|
//
|
||||||
|
|
||||||
|
#define HackDisableTaggedQueuing (0x01)
|
||||||
|
#define HackDisableSynchronousTransfers (0x02)
|
||||||
|
#define HackDisableSpinDown (0x04)
|
||||||
|
#define HackDisableWriteCache (0x08)
|
||||||
|
#define HackCauseNotReportableHack (0x10)
|
||||||
|
#define HackRequiresStartUnitCommand (0x20)
|
||||||
|
#define HackDisableWriteCacheNotSupported (0x40)
|
||||||
|
|
||||||
|
|
||||||
|
#define DiskDeviceParameterSubkey L"Disk"
|
||||||
|
#define DiskDeviceSpecialFlags L"SpecialFlags"
|
||||||
|
#define DiskDeviceUserWriteCacheSetting L"UserWriteCacheSetting"
|
||||||
|
|
||||||
|
|
||||||
|
#define FUNCTIONAL_EXTENSION_SIZE sizeof(FUNCTIONAL_DEVICE_EXTENSION) + sizeof(DISK_DATA)
|
||||||
|
#define PHYSICAL_EXTENSION_SIZE sizeof(PHYSICAL_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
|
||||||
|
typedef struct _DISK_MEDIA_TYPES_LIST {
|
||||||
|
PCHAR VendorId;
|
||||||
|
PCHAR ProductId;
|
||||||
|
PCHAR Revision;
|
||||||
|
const ULONG NumberOfTypes;
|
||||||
|
const ULONG NumberOfSides;
|
||||||
|
const STORAGE_MEDIA_TYPE MediaTypes[MAX_MEDIA_TYPES];
|
||||||
|
} DISK_MEDIA_TYPES_LIST, *PDISK_MEDIA_TYPES_LIST;
|
||||||
|
|
||||||
|
//
|
||||||
|
// WMI reregistration structures used for reregister work item
|
||||||
|
//
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
SINGLE_LIST_ENTRY Next;
|
||||||
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
PIRP Irp;
|
||||||
|
} DISKREREGREQUEST, *PDISKREREGREQUEST;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Write cache setting as defined by the user
|
||||||
|
//
|
||||||
|
typedef enum _DISK_USER_WRITE_CACHE_SETTING
|
||||||
|
{
|
||||||
|
DiskWriteCacheDisable = 0,
|
||||||
|
DiskWriteCacheEnable = 1,
|
||||||
|
DiskWriteCacheDefault = -1
|
||||||
|
|
||||||
|
} DISK_USER_WRITE_CACHE_SETTING, *PDISK_USER_WRITE_CACHE_SETTING;
|
||||||
|
|
||||||
|
#define MAX_SECTORS_PER_VERIFY 0x200
|
||||||
|
|
||||||
|
//
|
||||||
|
// This is based off 100ns units
|
||||||
|
//
|
||||||
|
#define ONE_MILLI_SECOND ((ULONGLONG)10 * 1000)
|
||||||
|
|
||||||
|
//
|
||||||
|
// Context for the work-item
|
||||||
|
//
|
||||||
|
typedef struct _DISK_VERIFY_WORKITEM_CONTEXT
|
||||||
|
{
|
||||||
|
PIRP Irp;
|
||||||
|
PSCSI_REQUEST_BLOCK Srb;
|
||||||
|
PIO_WORKITEM WorkItem;
|
||||||
|
|
||||||
|
} DISK_VERIFY_WORKITEM_CONTEXT, *PDISK_VERIFY_WORKITEM_CONTEXT;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Poll for Failure Prediction every hour
|
||||||
|
//
|
||||||
|
#define DISK_DEFAULT_FAILURE_POLLING_PERIOD 1 * 60 * 60
|
||||||
|
|
||||||
|
//
|
||||||
|
// Static global lookup tables.
|
||||||
|
//
|
||||||
|
|
||||||
|
extern CLASSPNP_SCAN_FOR_SPECIAL_INFO DiskBadControllers[];
|
||||||
|
extern const DISK_MEDIA_TYPES_LIST DiskMediaTypes[];
|
||||||
|
|
||||||
|
//
|
||||||
|
// Macros
|
||||||
|
//
|
||||||
|
|
||||||
|
//
|
||||||
|
// Routine prototypes.
|
||||||
|
//
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DriverEntry(
|
||||||
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
|
IN PUNICODE_STRING RegistryPath
|
||||||
|
);
|
||||||
|
|
||||||
|
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
|
||||||
|
DiskInitPdo(
|
||||||
|
IN PDEVICE_OBJECT Pdo
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskStartFdo(
|
||||||
|
IN PDEVICE_OBJECT Fdo
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskStartPdo(
|
||||||
|
IN PDEVICE_OBJECT Pdo
|
||||||
|
);
|
||||||
|
|
||||||
|
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
|
||||||
|
NTAPI
|
||||||
|
DisableWriteCache(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIO_WORKITEM WorkItem
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskIoctlVerify(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PDISK_VERIFY_WORKITEM_CONTEXT Context
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskModeSelect(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PCHAR ModeSelectBuffer,
|
||||||
|
IN ULONG Length,
|
||||||
|
IN BOOLEAN SavePage
|
||||||
|
);
|
||||||
|
|
||||||
|
//
|
||||||
|
// We need to validate that the self test subcommand is valid and
|
||||||
|
// appropriate. Right now we allow subcommands 0, 1 and 2 which are non
|
||||||
|
// captive mode tests. Once we figure out a way to know if it is safe to
|
||||||
|
// run a captive test then we can allow captive mode tests. Also if the
|
||||||
|
// atapi 5 spec is ever updated to denote that bit 7 is the captive
|
||||||
|
// mode bit, we can allow any request that does not have bit 7 set. Until
|
||||||
|
// that is done we want to be sure
|
||||||
|
//
|
||||||
|
#define DiskIsValidSmartSelfTest(Subcommand) \
|
||||||
|
( ((Subcommand) == SMART_OFFLINE_ROUTINE_OFFLINE) || \
|
||||||
|
((Subcommand) == SMART_SHORT_SELFTEST_OFFLINE) || \
|
||||||
|
((Subcommand) == SMART_EXTENDED_SELFTEST_OFFLINE) )
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
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
|
||||||
|
NTAPI
|
||||||
|
DiskGetInfoExceptionInformation(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
|
||||||
|
OUT PMODE_INFO_EXCEPTIONS ReturnPageData
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskSetInfoExceptionInformation(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
|
||||||
|
IN PMODE_INFO_EXCEPTIONS PageData
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskDetectFailurePrediction(
|
||||||
|
PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
|
||||||
|
PFAILURE_PREDICTION_METHOD FailurePredictCapability
|
||||||
|
);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
EnumerateBusKey(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION DeviceExtension,
|
||||||
|
HANDLE BusKey,
|
||||||
|
PULONG DiskNumber
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskCreateFdo(
|
||||||
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
|
IN PDEVICE_OBJECT LowerDeviceObject,
|
||||||
|
IN PULONG DeviceCount,
|
||||||
|
IN BOOLEAN DasdAccessOnly
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
UpdateDeviceObjects(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIRP Irp
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskSetSpecialHacks(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
|
||||||
|
IN ULONG_PTR Data
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskScanRegistryForSpecial(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
ResetBus(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskEnumerateDevice(
|
||||||
|
IN PDEVICE_OBJECT Fdo
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskQueryId(
|
||||||
|
IN PDEVICE_OBJECT Pdo,
|
||||||
|
IN BUS_QUERY_ID_TYPE IdType,
|
||||||
|
IN PUNICODE_STRING UnicodeIdString
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskQueryPnpCapabilities(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PDEVICE_CAPABILITIES Capabilities
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskGenerateDeviceName(
|
||||||
|
IN BOOLEAN IsFdo,
|
||||||
|
IN ULONG DeviceNumber,
|
||||||
|
IN OPTIONAL ULONG PartitionNumber,
|
||||||
|
IN OPTIONAL PLARGE_INTEGER StartingOffset,
|
||||||
|
IN OPTIONAL PLARGE_INTEGER PartitionLength,
|
||||||
|
OUT PUCHAR *RawName
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskCreateSymbolicLinks(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskUpdatePartitions(
|
||||||
|
IN PDEVICE_OBJECT Fdo,
|
||||||
|
IN OUT PDRIVE_LAYOUT_INFORMATION_EX PartitionList
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskUpdateRemovablePartitions(
|
||||||
|
IN PDEVICE_OBJECT Fdo,
|
||||||
|
IN OUT PDRIVE_LAYOUT_INFORMATION_EX PartitionList
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskCreatePdo(
|
||||||
|
IN PDEVICE_OBJECT Fdo,
|
||||||
|
IN ULONG PartitionOrdinal,
|
||||||
|
IN PPARTITION_INFORMATION_EX PartitionEntry,
|
||||||
|
IN PARTITION_STYLE PartitionStyle,
|
||||||
|
OUT PDEVICE_OBJECT *Pdo
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskDeleteSymbolicLinks(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskPdoQueryWmiRegInfo(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
OUT ULONG *RegFlags,
|
||||||
|
OUT PUNICODE_STRING InstanceName
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskPdoQueryWmiDataBlock(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIRP Irp,
|
||||||
|
IN ULONG GuidIndex,
|
||||||
|
IN ULONG BufferAvail,
|
||||||
|
OUT PUCHAR Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskPdoSetWmiDataBlock(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIRP Irp,
|
||||||
|
IN ULONG GuidIndex,
|
||||||
|
IN ULONG BufferSize,
|
||||||
|
IN PUCHAR Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskPdoSetWmiDataItem(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIRP Irp,
|
||||||
|
IN ULONG GuidIndex,
|
||||||
|
IN ULONG DataItemId,
|
||||||
|
IN ULONG BufferSize,
|
||||||
|
IN PUCHAR Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskPdoExecuteWmiMethod(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIRP Irp,
|
||||||
|
IN ULONG GuidIndex,
|
||||||
|
IN ULONG MethodId,
|
||||||
|
IN ULONG InBufferSize,
|
||||||
|
IN ULONG OutBufferSize,
|
||||||
|
IN PUCHAR Buffer
|
||||||
|
);
|
||||||
|
|
||||||
|
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
|
||||||
|
NTAPI
|
||||||
|
DiskReadFailurePredictStatus(
|
||||||
|
PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
|
||||||
|
PSTORAGE_FAILURE_PREDICT_STATUS DiskSmartStatus
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskReadFailurePredictData(
|
||||||
|
PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
|
||||||
|
PSTORAGE_FAILURE_PREDICT_DATA DiskSmartData
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskEnableDisableFailurePrediction(
|
||||||
|
PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
|
||||||
|
BOOLEAN Enable
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskEnableDisableFailurePredictPolling(
|
||||||
|
PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
|
||||||
|
BOOLEAN Enable,
|
||||||
|
ULONG PollTimeInSeconds
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskAcquirePartitioningLock(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskReleasePartitioningLock(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS NTAPI DiskInitializeReregistration(
|
||||||
|
void
|
||||||
|
);
|
||||||
|
|
||||||
|
extern GUIDREGINFO DiskWmiFdoGuidList[];
|
||||||
|
extern GUIDREGINFO DiskWmiPdoGuidList[];
|
||||||
|
|
||||||
|
#if defined(_X86_)
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskReadDriveCapacity(
|
||||||
|
IN PDEVICE_OBJECT Fdo
|
||||||
|
);
|
||||||
|
#else
|
||||||
|
#define DiskReadDriveCapacity(Fdo) ClassReadDriveCapacity(Fdo)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#if defined(_X86_)
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
NTSTATUS
|
||||||
|
DiskQuerySuggestedLinkName(
|
||||||
|
IN PDEVICE_OBJECT DeviceObject,
|
||||||
|
IN PIRP Irp
|
||||||
|
);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskSaveDetectInfo(
|
||||||
|
PDRIVER_OBJECT DriverObject
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskCleanupDetectInfo(
|
||||||
|
IN PDRIVER_OBJECT DriverObject
|
||||||
|
);
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskDriverReinitialization (
|
||||||
|
IN PDRIVER_OBJECT DriverObject,
|
||||||
|
IN PVOID Nothing,
|
||||||
|
IN ULONG Count
|
||||||
|
);
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
|
VOID
|
||||||
|
NTAPI
|
||||||
|
DiskConvertPartitionToExtended(
|
||||||
|
IN PPARTITION_INFORMATION Partition,
|
||||||
|
OUT PPARTITION_INFORMATION_EX PartitionEx
|
||||||
|
);
|
||||||
|
|
||||||
|
PDRIVE_LAYOUT_INFORMATION_EX
|
||||||
|
NTAPI
|
||||||
|
DiskConvertLayoutToExtended(
|
||||||
|
IN CONST PDRIVE_LAYOUT_INFORMATION Layout
|
||||||
|
);
|
||||||
|
|
||||||
|
PDRIVE_LAYOUT_INFORMATION
|
||||||
|
NTAPI
|
||||||
|
DiskConvertExtendedToLayout(
|
||||||
|
IN CONST PDRIVE_LAYOUT_INFORMATION_EX LayoutEx
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskReadPartitionTableEx(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN BOOLEAN BypassCache,
|
||||||
|
OUT PDRIVE_LAYOUT_INFORMATION_EX* DriveLayout
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskWritePartitionTableEx(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskSetPartitionInformationEx(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN ULONG PartitionNumber,
|
||||||
|
IN struct _SET_PARTITION_INFORMATION_EX* PartitionInfo
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskSetPartitionInformation(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN ULONG SectorSize,
|
||||||
|
IN ULONG PartitionNumber,
|
||||||
|
IN ULONG PartitionType
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskVerifyPartitionTable(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN BOOLEAN FixErrors
|
||||||
|
);
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
NTAPI
|
||||||
|
DiskInvalidatePartitionTable(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN BOOLEAN PartitionLockHeld
|
||||||
|
);
|
||||||
|
|
||||||
|
#if defined (_X86_)
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskGetDetectInfo(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION FdoExtension,
|
||||||
|
OUT PDISK_DETECTION_INFO DetectInfo
|
||||||
|
);
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
NTAPI
|
||||||
|
DiskReadSignature(
|
||||||
|
IN PDEVICE_OBJECT Fdo
|
||||||
|
);
|
||||||
|
|
||||||
|
#else
|
||||||
|
#define DiskGetDetectInfo(FdoExtension, DetectInfo) (STATUS_UNSUCCESSFUL)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
#define DiskHashGuid(Guid) (((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0] ^ ((PULONG) &Guid)[0])
|
||||||
|
|
23
drivers/storage/class/disk_new/disk.rc
Normal file
23
drivers/storage/class/disk_new/disk.rc
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
//+-------------------------------------------------------------------------
|
||||||
|
//
|
||||||
|
// Microsoft Windows
|
||||||
|
//
|
||||||
|
// Copyright (C) Microsoft Corporation, 1996 - 1999
|
||||||
|
//
|
||||||
|
// File: disk.rc
|
||||||
|
//
|
||||||
|
//--------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
#include <ntverp.h>
|
||||||
|
|
||||||
|
#define VER_FILETYPE VFT_DRV
|
||||||
|
#define VER_FILESUBTYPE VFT2_DRV_SYSTEM
|
||||||
|
#define VER_FILEDESCRIPTION_STR "PnP Disk Driver"
|
||||||
|
#define VER_INTERNALNAME_STR "scsidisk.sys"
|
||||||
|
#define VER_ORIGINALFILENAME_STR "scsidisk.sys"
|
||||||
|
#define VER_LANGNEUTRAL
|
||||||
|
|
||||||
|
#include "common.ver"
|
||||||
|
|
96
drivers/storage/class/disk_new/diskdev.inf
Normal file
96
drivers/storage/class/disk_new/diskdev.inf
Normal file
|
@ -0,0 +1,96 @@
|
||||||
|
; disk.inf
|
||||||
|
;
|
||||||
|
; Installation inf for the Disk drive adapter.
|
||||||
|
;
|
||||||
|
; SAMPLE INF File for Class Driver
|
||||||
|
; FOR DDK - Driver Development Kit
|
||||||
|
;
|
||||||
|
; (c) Copyright 1999 Microsoft Corp.
|
||||||
|
;
|
||||||
|
|
||||||
|
[Version]
|
||||||
|
Signature="$Windows NT$"
|
||||||
|
Provider=%MS%
|
||||||
|
ClassGUID={4d36e967-e325-11ce-bfc1-08002be10318}
|
||||||
|
Class=DiskDrive
|
||||||
|
; CatalogFile=disk.cat ; Supply your own catalog file
|
||||||
|
; see DDK Doc.
|
||||||
|
DriverVer=08/27/1999
|
||||||
|
|
||||||
|
[DestinationDirs]
|
||||||
|
DefaultDestDir = 12
|
||||||
|
|
||||||
|
;
|
||||||
|
; Driver information
|
||||||
|
;
|
||||||
|
|
||||||
|
[Manufacturer]
|
||||||
|
%MS% = MS.Mfg
|
||||||
|
|
||||||
|
[MS.Mfg]
|
||||||
|
%MS.DeviceDesc0% = disk, GenDisk
|
||||||
|
%MS.DeviceDesc1% = disk, GenOptical
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
; General installation section
|
||||||
|
;
|
||||||
|
|
||||||
|
[disk]
|
||||||
|
|
||||||
|
;
|
||||||
|
; File sections
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
; Service Installation
|
||||||
|
;
|
||||||
|
|
||||||
|
[disk.Services]
|
||||||
|
AddService = disk, 0x00000002 , disk_Service_Inst
|
||||||
|
|
||||||
|
[disk_Service_Inst]
|
||||||
|
DisplayName = %disk.SvcDesc%
|
||||||
|
ServiceType = 1 ; SERVICE_KERNEL_DRIVER
|
||||||
|
StartType = 1 ; SERVICE_SYSTEM_START
|
||||||
|
ErrorControl = 0x1 ; SERVICE_ERROR_NORMAL
|
||||||
|
LoadOrderGroup = Pointer Port
|
||||||
|
ServiceBinary = %12%\disk.sys
|
||||||
|
|
||||||
|
|
||||||
|
;
|
||||||
|
; Source file information
|
||||||
|
;
|
||||||
|
|
||||||
|
[SourceDisksNames.x86]
|
||||||
|
1 = %DiskId1%,,,""
|
||||||
|
|
||||||
|
[SourceDisksFiles]
|
||||||
|
; Files for disk Microsoft Corp. Installation Disk #1 (DiskDrive)
|
||||||
|
disk.sys = 1,,
|
||||||
|
|
||||||
|
|
||||||
|
[Strings]
|
||||||
|
|
||||||
|
;
|
||||||
|
; Non-Localizable Strings
|
||||||
|
;
|
||||||
|
|
||||||
|
REG_SZ = 0x00000000
|
||||||
|
REG_MULTI_SZ = 0x00010000
|
||||||
|
REG_EXPAND_SZ = 0x00020000
|
||||||
|
REG_BINARY = 0x00000001
|
||||||
|
REG_DWORD = 0x00010001
|
||||||
|
SERVICEROOT = "System\CurrentControlSet\Services"
|
||||||
|
|
||||||
|
;
|
||||||
|
; Localizable Strings
|
||||||
|
;
|
||||||
|
|
||||||
|
MS.DeviceDesc0 = "Disk drive"
|
||||||
|
MS.DeviceDesc1 = "Optical disk drive"
|
||||||
|
DiskId1 = "Microsoft Corp. Installation Disk #1 (DiskDrive)"
|
||||||
|
MS = "Microsoft Corp."
|
||||||
|
disk.SvcDesc="Disk Drive"
|
||||||
|
|
3424
drivers/storage/class/disk_new/diskwmi.c
Normal file
3424
drivers/storage/class/disk_new/diskwmi.c
Normal file
File diff suppressed because it is too large
Load diff
1250
drivers/storage/class/disk_new/enum.c
Normal file
1250
drivers/storage/class/disk_new/enum.c
Normal file
File diff suppressed because it is too large
Load diff
1470
drivers/storage/class/disk_new/geometry.c
Normal file
1470
drivers/storage/class/disk_new/geometry.c
Normal file
File diff suppressed because it is too large
Load diff
327
drivers/storage/class/disk_new/part.c
Normal file
327
drivers/storage/class/disk_new/part.c
Normal file
|
@ -0,0 +1,327 @@
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Copyright (C) Microsoft Corporation, 1991 - 1999
|
||||||
|
|
||||||
|
Module Name:
|
||||||
|
|
||||||
|
disk.c
|
||||||
|
|
||||||
|
Abstract:
|
||||||
|
|
||||||
|
SCSI disk class driver
|
||||||
|
|
||||||
|
Environment:
|
||||||
|
|
||||||
|
kernel mode only
|
||||||
|
|
||||||
|
Notes:
|
||||||
|
|
||||||
|
Revision History:
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
#include "disk.h"
|
||||||
|
|
||||||
|
#define PtCache ClassDebugExternal1
|
||||||
|
|
||||||
|
#ifdef ALLOC_PRAGMA
|
||||||
|
|
||||||
|
#pragma alloc_text(PAGE, DiskReadPartitionTableEx)
|
||||||
|
#pragma alloc_text(PAGE, DiskWritePartitionTableEx)
|
||||||
|
#pragma alloc_text(PAGE, DiskSetPartitionInformationEx)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
ULONG DiskBreakOnPtInval = FALSE;
|
||||||
|
|
||||||
|
//
|
||||||
|
// By default, 64-bit systems can see GPT disks and 32-bit systems
|
||||||
|
// cannot. This will likely change in the future.
|
||||||
|
//
|
||||||
|
|
||||||
|
#if defined(_WIN64)
|
||||||
|
ULONG DiskDisableGpt = FALSE;
|
||||||
|
#else
|
||||||
|
ULONG DiskDisableGpt = TRUE;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
DiskReadPartitionTableEx(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN BOOLEAN BypassCache,
|
||||||
|
OUT PDRIVE_LAYOUT_INFORMATION_EX* DriveLayout
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This routine will return the current layout information for the disk.
|
||||||
|
If the cached information is still valid then it will be returned,
|
||||||
|
otherwise the layout will be retreived from the kernel and cached for
|
||||||
|
future use.
|
||||||
|
|
||||||
|
This routine must be called with the partitioning lock held. The
|
||||||
|
partition list which is returned is not guaranteed to remain valid
|
||||||
|
once the lock has been released.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
Fdo - a pointer to the FDO for the disk.
|
||||||
|
|
||||||
|
DriveLayout - a location to store a pointer to the drive layout information.
|
||||||
|
|
||||||
|
Return Value:
|
||||||
|
|
||||||
|
STATUS_SUCCESS if successful or an error status indicating what failed.
|
||||||
|
|
||||||
|
--*/
|
||||||
|
|
||||||
|
{
|
||||||
|
PDISK_DATA diskData = Fdo->CommonExtension.DriverData;
|
||||||
|
NTSTATUS status;
|
||||||
|
PDRIVE_LAYOUT_INFORMATION_EX layoutEx;
|
||||||
|
|
||||||
|
layoutEx = NULL;
|
||||||
|
|
||||||
|
if(BypassCache) {
|
||||||
|
diskData->CachedPartitionTableValid = FALSE;
|
||||||
|
DebugPrint((PtCache, "DiskRPTEx: cache bypassed and invalidated for "
|
||||||
|
"FDO %#p\n", Fdo));
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// If the cached partition table is present then return a copy of it.
|
||||||
|
//
|
||||||
|
|
||||||
|
if(diskData->CachedPartitionTableValid == TRUE) {
|
||||||
|
|
||||||
|
ULONG partitionNumber;
|
||||||
|
PDRIVE_LAYOUT_INFORMATION_EX layout = diskData->CachedPartitionTable;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Clear the partition numbers from the list entries
|
||||||
|
//
|
||||||
|
|
||||||
|
for(partitionNumber = 0;
|
||||||
|
partitionNumber < layout->PartitionCount;
|
||||||
|
partitionNumber++) {
|
||||||
|
layout->PartitionEntry[partitionNumber].PartitionNumber = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
*DriveLayout = diskData->CachedPartitionTable;
|
||||||
|
|
||||||
|
DebugPrint((PtCache, "DiskRPTEx: cached PT returned (%#p) for "
|
||||||
|
"FDO %#p\n",
|
||||||
|
*DriveLayout, Fdo));
|
||||||
|
|
||||||
|
return STATUS_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
ASSERTMSG("DiskReadPartitionTableEx is not using cached partition table",
|
||||||
|
(DiskBreakOnPtInval == FALSE));
|
||||||
|
|
||||||
|
//
|
||||||
|
// If there's a cached partition table still around then free it.
|
||||||
|
//
|
||||||
|
|
||||||
|
if(diskData->CachedPartitionTable) {
|
||||||
|
DebugPrint((PtCache, "DiskRPTEx: cached PT (%#p) freed for FDO %#p\n",
|
||||||
|
diskData->CachedPartitionTable, Fdo));
|
||||||
|
|
||||||
|
ExFreePool(diskData->CachedPartitionTable);
|
||||||
|
diskData->CachedPartitionTable = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// By default, X86 disables recognition of GPT disks. Instead we
|
||||||
|
// return the protective MBR partition. Use IoReadPartitionTable
|
||||||
|
// to get this.
|
||||||
|
//
|
||||||
|
|
||||||
|
status = IoReadPartitionTableEx(Fdo->DeviceObject, &layoutEx);
|
||||||
|
|
||||||
|
if (DiskDisableGpt) {
|
||||||
|
PDRIVE_LAYOUT_INFORMATION layout;
|
||||||
|
|
||||||
|
if (NT_SUCCESS (status) &&
|
||||||
|
layoutEx->PartitionStyle == PARTITION_STYLE_GPT) {
|
||||||
|
|
||||||
|
//
|
||||||
|
// ISSUE - 2000/29/08 - math: Remove from final product.
|
||||||
|
// Leave this debug print in for a while until everybody
|
||||||
|
// has had a chance to convert their GPT disks to MBR.
|
||||||
|
//
|
||||||
|
|
||||||
|
DbgPrint ("DISK: Disk %p recognized as a GPT disk on a system without GPT support.\n"
|
||||||
|
" Disk will appear as RAW.\n",
|
||||||
|
Fdo->DeviceObject);
|
||||||
|
|
||||||
|
ExFreePool (layoutEx);
|
||||||
|
status = IoReadPartitionTable(Fdo->DeviceObject,
|
||||||
|
Fdo->DiskGeometry.BytesPerSector,
|
||||||
|
FALSE,
|
||||||
|
&layout);
|
||||||
|
if (NT_SUCCESS (status)) {
|
||||||
|
layoutEx = DiskConvertLayoutToExtended(layout);
|
||||||
|
ExFreePool (layout);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
diskData->CachedPartitionTable = layoutEx;
|
||||||
|
|
||||||
|
//
|
||||||
|
// If the routine fails make sure we don't have a stale partition table
|
||||||
|
// pointer. Otherwise indicate that the table is now valid.
|
||||||
|
//
|
||||||
|
|
||||||
|
if(!NT_SUCCESS(status)) {
|
||||||
|
diskData->CachedPartitionTable = NULL;
|
||||||
|
} else {
|
||||||
|
diskData->CachedPartitionTableValid = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*DriveLayout = diskData->CachedPartitionTable;
|
||||||
|
|
||||||
|
DebugPrint((PtCache, "DiskRPTEx: returning PT %#p for FDO %#p with status "
|
||||||
|
"%#08lx. PT is %scached\n",
|
||||||
|
*DriveLayout,
|
||||||
|
Fdo,
|
||||||
|
status,
|
||||||
|
(diskData->CachedPartitionTableValid ? "" : "not ")));
|
||||||
|
|
||||||
|
|
||||||
|
return status;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
DiskWritePartitionTableEx(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN PDRIVE_LAYOUT_INFORMATION_EX DriveLayout
|
||||||
|
)
|
||||||
|
/*++
|
||||||
|
|
||||||
|
Routine Description:
|
||||||
|
|
||||||
|
This routine will invalidate the cached partition table. It will then
|
||||||
|
write the new drive layout to disk.
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
|
||||||
|
Fdo - the FDO for the disk getting the new partition table.
|
||||||
|
|
||||||
|
DriveLayout - the new drive layout.
|
||||||
|
|
||||||
|
Return Value:
|
||||||
|
|
||||||
|
status
|
||||||
|
|
||||||
|
--*/
|
||||||
|
{
|
||||||
|
PDISK_DATA diskData = Fdo->CommonExtension.DriverData;
|
||||||
|
|
||||||
|
//
|
||||||
|
// Invalidate the cached partition table. Do not free it as it may be
|
||||||
|
// the very drive layout that was passed in to us.
|
||||||
|
//
|
||||||
|
|
||||||
|
diskData->CachedPartitionTableValid = FALSE;
|
||||||
|
|
||||||
|
DebugPrint((PtCache, "DiskWPTEx: Invalidating PT cache for FDO %#p\n",
|
||||||
|
Fdo));
|
||||||
|
|
||||||
|
if (DiskDisableGpt) {
|
||||||
|
if (DriveLayout->PartitionStyle == PARTITION_STYLE_GPT) {
|
||||||
|
return STATUS_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return IoWritePartitionTableEx(Fdo->DeviceObject, DriveLayout);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
DiskSetPartitionInformationEx(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN ULONG PartitionNumber,
|
||||||
|
IN struct _SET_PARTITION_INFORMATION_EX* PartitionInfo
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PDISK_DATA diskData = Fdo->CommonExtension.DriverData;
|
||||||
|
|
||||||
|
diskData->CachedPartitionTableValid = FALSE;
|
||||||
|
DebugPrint((PtCache, "DiskSPIEx: Invalidating PT cache for FDO %#p\n",
|
||||||
|
Fdo));
|
||||||
|
|
||||||
|
if (DiskDisableGpt) {
|
||||||
|
if (PartitionInfo->PartitionStyle == PARTITION_STYLE_GPT) {
|
||||||
|
return STATUS_NOT_SUPPORTED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return IoSetPartitionInformationEx(Fdo->DeviceObject,
|
||||||
|
PartitionNumber,
|
||||||
|
PartitionInfo);
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
DiskSetPartitionInformation(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN ULONG SectorSize,
|
||||||
|
IN ULONG PartitionNumber,
|
||||||
|
IN ULONG PartitionType
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PDISK_DATA diskData = Fdo->CommonExtension.DriverData;
|
||||||
|
|
||||||
|
diskData->CachedPartitionTableValid = FALSE;
|
||||||
|
DebugPrint((PtCache, "DiskSPI: Invalidating PT cache for FDO %#p\n",
|
||||||
|
Fdo));
|
||||||
|
|
||||||
|
return IoSetPartitionInformation(Fdo->DeviceObject,
|
||||||
|
SectorSize,
|
||||||
|
PartitionNumber,
|
||||||
|
PartitionType);
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOLEAN
|
||||||
|
DiskInvalidatePartitionTable(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN BOOLEAN PartitionLockHeld
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PDISK_DATA diskData = Fdo->CommonExtension.DriverData;
|
||||||
|
BOOLEAN wasValid;
|
||||||
|
|
||||||
|
wasValid = (BOOLEAN) (diskData->CachedPartitionTableValid ? TRUE : FALSE);
|
||||||
|
diskData->CachedPartitionTableValid = FALSE;
|
||||||
|
|
||||||
|
DebugPrint((PtCache, "DiskIPT: Invalidating PT cache for FDO %#p\n",
|
||||||
|
Fdo));
|
||||||
|
|
||||||
|
if((PartitionLockHeld) && (diskData->CachedPartitionTable != NULL)) {
|
||||||
|
DebugPrint((PtCache, "DiskIPT: Freeing PT cache (%#p) for FDO %#p\n",
|
||||||
|
diskData->CachedPartitionTable, Fdo));
|
||||||
|
ExFreePool(diskData->CachedPartitionTable);
|
||||||
|
diskData->CachedPartitionTable = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wasValid;
|
||||||
|
}
|
||||||
|
|
||||||
|
NTSTATUS
|
||||||
|
DiskVerifyPartitionTable(
|
||||||
|
IN PFUNCTIONAL_DEVICE_EXTENSION Fdo,
|
||||||
|
IN BOOLEAN FixErrors
|
||||||
|
)
|
||||||
|
{
|
||||||
|
PDISK_DATA diskData = Fdo->CommonExtension.DriverData;
|
||||||
|
|
||||||
|
if(FixErrors) {
|
||||||
|
diskData->CachedPartitionTableValid = FALSE;
|
||||||
|
DebugPrint((PtCache, "DiskWPTEx: Invalidating PT cache for FDO %#p\n",
|
||||||
|
Fdo));
|
||||||
|
}
|
||||||
|
|
||||||
|
return IoVerifyPartitionTable(Fdo->DeviceObject, FixErrors);
|
||||||
|
}
|
||||||
|
|
1406
drivers/storage/class/disk_new/pnp.c
Normal file
1406
drivers/storage/class/disk_new/pnp.c
Normal file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue