NT/W2K SCSI Port filter

I’m trying to write a simple SCSI port filter for NT/Win2k.
The sequence is:

  1. Get the pointer to the ScsiPort# device object
  2. Get the pointer to the miniport driver object
  3. Walk the list of all device objects and attach to each one of them

My question is: in case of a driver handling multiple ports (i.e. ATAPI.SYS)
how can I tell which device is on which port?
For example, assuming I have a hard disk on the primary ATAPI bus and a
CD-ROM on the secondary bus, when I scan the list of devices attached to the
ATAPI driver the following is the sequence:

FILE_DEVICE_MASS_STORAGE
FILE_DEVICE_DISK
FILE_DEVICE_CONTROLLER
FILE_DEVICE_CONTROLLER

How can I tell FILE_DEVICE_MASS_STORAGE is on ScsiPort1 and FILE_DEVICE_DISK
is on ScsiPort0?

TIA,

—Mirco.