BazisLib::DDK::BasicStorageVolume Class Reference

#include <volume.h>

Inherits BazisLib::DDK::StorageDevice.

Inherited by BazisLib::DDK::BasicCDVolume, and BazisLib::DDK::UniversalVolume.

Collaboration diagram for BazisLib::DDK::BasicStorageVolume:

Collaboration graph
[legend]

List of all members.

Public Member Functions

 BasicStorageVolume (LPCWSTR pwszDevicePrefix=L"BazisVolume", bool bDeleteThisAfterRemoveRequest=false, ULONG DeviceType=FILE_DEVICE_DISK, ULONG DeviceCharacteristics=FILE_DEVICE_SECURE_OPEN, bool bExclusive=FALSE, ULONG AdditionalDeviceFlags=DO_POWER_PAGABLE)
 ~BasicStorageVolume ()
bool Valid ()
NTSTATUS AddDevice (Driver *pDriver, PDEVICE_OBJECT PhysicalDeviceObject)

Protected Member Functions

bool EnableWindowsCacheBugWorkaround (size_t IntermediateBufferSize=1024 *1024)
 Allocates a shadow buffer for read operations preventing to prevent Windows read cache bug.
bool UpdateVolumeSize ()
 Updates stored volume size.
virtual NTSTATUS DispatchRoutine (IN IncomingIrp *Irp, IO_STACK_LOCATION *IrpSp) override
virtual NTSTATUS OnRead (PMDL pMdl, ULONG Length, ULONG Key, ULONGLONG ByteOffset, PULONG pBytesDone) override
virtual NTSTATUS OnWrite (PMDL pMdl, ULONG Length, ULONG Key, ULONGLONG ByteOffset, PULONG pBytesDone) override
virtual NTSTATUS OnCreate (PIO_SECURITY_CONTEXT SecurityContext, ULONG Options, USHORT FileAttributes, USHORT ShareAccess, PFILE_OBJECT pFileObj) override
virtual NTSTATUS OnClose () override
virtual NTSTATUS OnCheckVerify (ULONG OriginalControlCode, ULONG *pChangeCount) override
virtual NTSTATUS OnGetPartitionInfo (PPARTITION_INFORMATION pInfo, ULONG BufferLength, PULONG pBytesDone) override
virtual NTSTATUS OnGetPartitionInfoEx (PPARTITION_INFORMATION_EX pInfo, ULONG BufferLength, PULONG pBytesDone) override
virtual NTSTATUS OnVolumeOnline () override
virtual NTSTATUS OnVolumeOffline () override
virtual NTSTATUS OnGetDeviceNumber (PSTORAGE_DEVICE_NUMBER pNumber) override
virtual NTSTATUS OnGetDriveGeometry (PDISK_GEOMETRY pGeo) override
virtual NTSTATUS OnGetLengthInfo (PGET_LENGTH_INFORMATION pLength) override
virtual NTSTATUS OnDiskIsWritable () override
virtual NTSTATUS OnMediaRemoval (bool bLock) override
virtual NTSTATUS OnGetHotplugInfo (PSTORAGE_HOTPLUG_INFO pHotplugInfo) override
virtual NTSTATUS OnDiskVerify (PVERIFY_INFORMATION pVerifyInfo) override
virtual NTSTATUS OnSetPartitionInfo (PPARTITION_INFORMATION pInfo, ULONG InputLength) override
virtual NTSTATUS OnSetPartitionInfoEx (PPARTITION_INFORMATION_EX pInfo, ULONG InputLength) override
virtual unsigned GetSectorSize ()
virtual ULONGLONG GetTotalSize ()=0
virtual char GetPartitionType ()
virtual NTSTATUS Read (ULONGLONG ByteOffset, PVOID pBuffer, ULONG Length, PULONG pBytesDone)=0
virtual NTSTATUS Write (ULONGLONG ByteOffset, PVOID pBuffer, ULONG Length, PULONG pBytesDone)=0
ULONGLONG GetSectorCount ()

Private Attributes

unsigned m_SectorSize
ULONGLONG m_SectorCount
ULONGLONG m_SizeInBytes
DEVICE_TYPE m_ReportedDeviceType
void * m_pWinCacheBugWorkaroundBuffer
size_t m_WinCacheBugWorkaroundBufferSize


Detailed Description

This class provides a very easy way to maintain a volume recognizable by Windows Device Manager. Please do not override methods other than listed after "Overridables" comment to avoid incompatibility with future versions.

If you requre any additional functionality, please create another universal library class providing that functionality and having the corresponding abstract methods, and contact me via SourceForge.net


Constructor & Destructor Documentation

BazisLib::DDK::BasicStorageVolume::BasicStorageVolume ( LPCWSTR  pwszDevicePrefix = L"BazisVolume",
bool  bDeleteThisAfterRemoveRequest = false,
ULONG  DeviceType = FILE_DEVICE_DISK,
ULONG  DeviceCharacteristics = FILE_DEVICE_SECURE_OPEN,
bool  bExclusive = FALSE,
ULONG  AdditionalDeviceFlags = DO_POWER_PAGABLE 
)

BazisLib::DDK::BasicStorageVolume::~BasicStorageVolume (  ) 


Member Function Documentation

NTSTATUS BazisLib::DDK::BasicStorageVolume::AddDevice ( Driver pDriver,
PDEVICE_OBJECT  PhysicalDeviceObject 
)

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::DispatchRoutine ( IN IncomingIrp Irp,
IO_STACK_LOCATION *  IrpSp 
) [override, protected, virtual]

This method is called every time a device receives an IRP. It Device class it handles the following codes by calling the corresponding virtual methods:

  • IRP_MJ_CREATE
  • IRP_MJ_CLOSE
    • IRP_MJ_READ
    • IRP_MJ_WRITE
    • IRP_MJ_DEVICE_CONTROL
    • IRP_MJ_INTERNAL_CONTROL If an IRP does not belong to the types listed above, it simply returns the IoStatus.Status value. A typical override should have the following structure: switch (IrpSp->MajorFunction) { case IRP_MJ_XXX: return DispatchXXX(...); case IRP_MJ_YYY: return DispatchYYY(...); default: return __super::DispatchRoutine(...); }
      Returns:
      If the return value is STATUS_PENDING, the packet is not touched after the method returns. In other case, the IoStatus.Status field is updated (if it was not set previously) and the packet is sent to the next driver (if one exists).
      Remarks:
      Note that if you inherit any child class of DDK::Driver, you should ensure that if you redefine the DispatchRoutine() in the way preventing some IRPs from being processed by the DispatchRoutine() of your base class, they will really NOT be processed by that class and some corresponding virtual methods will not be called. Please consider that if you want to redefine device behaviour for certain minor codes of a major code handled by parent class, and do not intend to alter other minors, you should call __super::DispatchRoutine() for these minors explicitly. Consider notes on DispatchRoutine() in other classes to see what major codes they handle.

Reimplemented from BazisLib::DDK::IODevice.

bool BazisLib::DDK::BasicStorageVolume::EnableWindowsCacheBugWorkaround ( size_t  IntermediateBufferSize = 1024 *1024  )  [protected]

Allocates a shadow buffer for read operations preventing to prevent Windows read cache bug.

This method should be called from the constructor of a child class to enable workaround for Windows read cache bug. The details on this bug can be found Windows Cache bug here.

virtual char BazisLib::DDK::BasicStorageVolume::GetPartitionType (  )  [inline, protected, virtual]

Reimplemented in BazisLib::DDK::UniversalVolume.

ULONGLONG BazisLib::DDK::BasicStorageVolume::GetSectorCount (  )  [inline, protected]

virtual unsigned BazisLib::DDK::BasicStorageVolume::GetSectorSize (  )  [inline, protected, virtual]

virtual ULONGLONG BazisLib::DDK::BasicStorageVolume::GetTotalSize (  )  [protected, pure virtual]

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnCheckVerify ( ULONG  OriginalControlCode,
ULONG *  pChangeCount 
) [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnClose (  )  [override, protected, virtual]

Reimplemented from BazisLib::DDK::IODevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnCreate ( PIO_SECURITY_CONTEXT  SecurityContext,
ULONG  Options,
USHORT  FileAttributes,
USHORT  ShareAccess,
PFILE_OBJECT  pFileObj 
) [override, protected, virtual]

Reimplemented from BazisLib::DDK::IODevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnDiskIsWritable (  )  [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnDiskVerify ( PVERIFY_INFORMATION  pVerifyInfo  )  [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnGetDeviceNumber ( PSTORAGE_DEVICE_NUMBER  pNumber  )  [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnGetDriveGeometry ( PDISK_GEOMETRY  pGeo  )  [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnGetHotplugInfo ( PSTORAGE_HOTPLUG_INFO  pHotplugInfo  )  [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnGetLengthInfo ( PGET_LENGTH_INFORMATION  pLength  )  [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnGetPartitionInfo ( PPARTITION_INFORMATION  pInfo,
ULONG  BufferLength,
PULONG  pBytesDone 
) [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnGetPartitionInfoEx ( PPARTITION_INFORMATION_EX  pInfo,
ULONG  BufferLength,
PULONG  pBytesDone 
) [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnMediaRemoval ( bool  bLock  )  [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnRead ( PMDL  pMdl,
ULONG  Length,
ULONG  Key,
ULONGLONG  ByteOffset,
PULONG  pBytesDone 
) [override, protected, virtual]

This method is called when the driver receives an IRP_MJ_READ packet. And the DO_DIRECT_IO flag is set in the DEVICE_OBJECT::Flags field.

Reimplemented from BazisLib::DDK::IODevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnSetPartitionInfo ( PPARTITION_INFORMATION  pInfo,
ULONG  InputLength 
) [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnSetPartitionInfoEx ( PPARTITION_INFORMATION_EX  pInfo,
ULONG  InputLength 
) [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnVolumeOffline (  )  [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnVolumeOnline (  )  [override, protected, virtual]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::OnWrite ( PMDL  pMdl,
ULONG  Length,
ULONG  Key,
ULONGLONG  ByteOffset,
PULONG  pBytesDone 
) [override, protected, virtual]

This method is called when the driver receives an IRP_MJ_WRITE packet. And the DO_DIRECT_IO flag is set in the DEVICE_OBJECT::Flags field.

Reimplemented from BazisLib::DDK::IODevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::Read ( ULONGLONG  ByteOffset,
PVOID  pBuffer,
ULONG  Length,
PULONG  pBytesDone 
) [protected, pure virtual]

bool BazisLib::DDK::BasicStorageVolume::UpdateVolumeSize (  )  [protected]

Updates stored volume size.

bool BazisLib::DDK::BasicStorageVolume::Valid (  )  [inline]

Reimplemented from BazisLib::DDK::StorageDevice.

virtual NTSTATUS BazisLib::DDK::BasicStorageVolume::Write ( ULONGLONG  ByteOffset,
PVOID  pBuffer,
ULONG  Length,
PULONG  pBytesDone 
) [protected, pure virtual]


Member Data Documentation

Reimplemented in BazisLib::DDK::BasicCDVolume.

Reimplemented in BazisLib::DDK::BasicCDVolume.

Reimplemented in BazisLib::DDK::BasicCDVolume.

Reimplemented in BazisLib::DDK::BasicCDVolume.


The documentation for this class was generated from the following file:
SourceForge.net Logo