StorPortStateChangeDetected routine

Notifies the Storport port driver of a state change for a logical unit number (LUN), host bus adapter (HBA) port, or target device.


ULONG StorPortStateChangeDetected(
  _In_     PVOID            HwDeviceExtension,
  _In_     ULONG            ChangedEntity,
  _In_     PSTOR_ADDRESS    Address,
  _In_     ULONG            Attributes,
  _In_opt_ PHW_STATE_CHANGE HwStateChange,
  _In_opt_ ULONG            HwStateChangeContext


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 immediately after the miniport driver calls StorPortInitialize. The port driver frees this memory when it removes the device.

ChangedEntity [in]

Flags indicating the entities whose state has changed. This is a bitwise OR combination of these values:

1 (0x1)

LUN state has changed.

2 (0x2)

Target state has changed.

4 (0x4)

Bus or port state has changed.


Address [in]

The address of the entity with the state change. Address value cannot change until the callback at HwStateChange is invoked. If Address is allocated in memory, the memory should be freed by the callback routine.

Attributes [in]

Attributes associated with the entity. These are a bitwise OR combination of the following:


LUNs are reserved for virtual machine use.


HwStateChange [in, optional]

A pointer to a callback routine supplied by the miniport. If present, the Storport driver will call this routine when the driver is finished processing this state change notification.

HwStateChangeContext [in, optional]

A miniport-supplied context value that is included when the routine set in HwStateChange is called.

Return value

A status value indicating the result of the notification. This can be one of these values:

Return codeDescription

The state change notification is scheduled for processing.


The address type or the entity type is invalid.


A prior notification is in process and this one cannot be scheduled.



A successful call to StorPortStateChangeDetected results in re-enumeration of the changed entity.

Only one state change request can be active at any time. If a miniport needs to make another StorPortStateChangeDetected call, it should provide a HwStateChange callback and make another call to StorPortStateChangeDetected after the callback to HwStateChange occurs. If a miniport wants to indicate multiple state changes at the same time, the miniport can call StorPortStateChangeDetected once, with changed entities set in ChangedEntity that includes all of the current state changes.

If multiple flags are specified in ChangedEntity, the flag with greater value will have precedence over lesser ones.


Target platform



Available in Windows 8 and later versions of Windows.


Storport.h (include Storport.h)



See also




Send comments about this topic to Microsoft