IOCTL_MOUNTDEV_QUERY_UNIQUE_ID control code
Support for this IOCTL by mount manager clients is mandatory. Upon receiving this IOCTL, the mount manager client must provide a counted byte string identifier that is unique to the client (that is, the device or the volume). The client cannot change this unique ID without alerting the mount manager (see IOCTL_MOUNTDEV_UNIQUE_ID_CHANGE_NOTIFY).
Parameters.DeviceIoControl.OutputBufferLength in the I/O stack location of the IRP indicates the size, in bytes, of the output buffer, which must be greater than or equal to sizeof(MOUNTDEV_UNIQUE_ID).
The device class or volume driver returns the MOUNTDEV_UNIQUE_ID structure in the buffer at Irp->AssociatedIrp.SystemBuffer.
The Information field is set to FIELD_OFFSET(MOUNTDEV_UNIQUE_ID, UniqueId) + output->UniqueIdLength; or alternatively to sizeof(USHORT) + output->UniqueIdLength, where output points to the buffer at Irp->AssociatedIrp.SystemBuffer.