BytesPerSector greater than PAGE_SIZE

I’m learning and experimenting with WDF KMDF10 on WXP-SP2+all updates. I
have modified toaster example from WDK, so that I can plug-in “generic disk”
PDOs on toaster bus. Disk is detected and after handling some IOCTLs and
SRBs, the “toaster disk” is shown in “Disk Management” as other regular
disks (handled by standard disk class driver).

At the moment my code doesn’t handle all SRBs yet, only until SCSI READ
(returning RtlZeroMemory).

One of initial IOCTLs I get and handle, is IOCTL_DISK_GET_DRIVE_GEOMETRY and
here is where I ran in some kind of trouble.

If (and only if) I set ULONG BytesPerSector; member of DISK_GEOMETRY
structure to value greater than 4096 (PAGE_SIZE), I always hit some random
BSOD’s (0xC5 or oxC2 or 0x0A) in disk.sys class driver. BSODs are very
likely caused by memory corruption (accessing free or garbage address).

BSOD is hit after I get and complete some (four to five) SCSI READ (not the
first one!) that are received after disk plug-in event. They are mixed with
SCSI READ CAPACITY that I also handle. I have checked with breakpoint in
WinDbg that memory described by SRB for SCSI READ is always OK, also during
PAGING IO. For sector size 8196 two pages are allocated and I can read/write
on them until the last byte. I don’t get any complains from Verifier,
running for classpnp.sys, disk.sys and my driver.

For other values of ULONG BytesPerSector, that are less or equal to 4096
(e.g. 512, 1024, 2048, .), it works. No BSODs at all, trying several
“toaster disk” plug-in and plug-out and Disk Manager disk initializations.

I would like to exclude this very obvious question:

Are devices (e.g. non standard disks) with BytesPerSector greater than 4096
(PAGE_SIZE) bytes, supported by standard CLASSPNP, disk class driver and OS?

Anybody already made such experiment?

I did not found any documented limitations, checking also classpnp and disk
sample source files in DDK.

WBR Primoz

> If (and only if) I set ULONG BytesPerSector; member of DISK_GEOMETRY

structure to value greater than 4096 (PAGE_SIZE), I always hit some random
BSOD’s (0xC5 or oxC2 or 0x0A) in disk.sys class driver. BSODs are very
likely caused by memory corruption (accessing free or garbage address).

Windows does not support disks with sectors > PAGE_SIZE.

This is the architectural limitation - “page-aligned” in Windows is
automatically “sector-aligned”, and such a disk will break this.

Emulate the smaller sectors on your device if you can.

Maxim Shatskih, Windows DDK MVP
StorageCraft Corporation
xxxxx@storagecraft.com
http://www.storagecraft.com