StorPortGetLogicalUnit routine

The StorPortGetLogicalUnit routine returns a pointer to the miniport driver's per-logical-unit storage area.


STORPORT_API PVOID StorPortGetLogicalUnit(
  _In_ PVOID HwDeviceExtension,
  _In_ UCHAR PathId,
  _In_ UCHAR TargetId,
  _In_ UCHAR Lun


HwDeviceExtension [in]

A pointer to the hardware device extension. This is a per HBA storage area that the port driver allocates and initializes on behalf of the miniport driver. Miniport drivers usually store HBA-specific information in this extension, such as the state of the HBA and the mapped access ranges for the HBA. This area is available to the miniport driver as soon as the miniport driver's HwStorFindAdapter routine is called. The port driver frees this memory when it removes the device.

PathId [in]

Identifies the SCSI bus.

TargetId [in]

Identifies the target controller or device on the bus.

Lun [in]

Identifies the logical unit (LU) number of the target device.

Return value

StorPortGetLogicalUnit returns a pointer to the miniport driver's storage area for the requested logical unit. If the logical unit does not exist, it returns NULL.


StorPortGetLogicalUnit is irrelevant if the miniport driver's DriverEntry routine specified zero for the LuExtensionSize in the HW_INITIALIZATION_DATA when it called StorPortInitialize. Otherwise, the operating system-specific port driver allocates and initializes with zeros a set of LU extensions of the specified size for the miniport driver to use.

Per-LU storage can be used to store data relevant to a particular peripheral, such as saved data pointers. To access this area, the miniport driver calls StorPortGetLogicalUnit when the driver is maintaining information about the state of or current operation for any particular peripheral.

The operating system-specific port driver can consider a logical unit to be nonexistent if there is no active request for that logical unit and the device has never been successfully selected.

Note  When the miniport driver calls StorPortGetLogicalUnit at IRQL = DISPATCH_LEVEL, the function acquires the interrupt lock. Calling StorPortGetLogicalUnit too often at this IRQL level impacts the performance and scalability of the miniport driver.


Target platform



Available in Windows XP and later versions of the Windows operating systems.


Storport.h (include Storport.h)



See also




Send comments about this topic to Microsoft