[SCSIPORT] Append GEN_SCSIADAPTER compatible ID for legacy adapters (#3441)

Fixes UniATA root SCSI devices detection in the Device Manager.

Based on the description of GEN_SCSIADAPTER from Windows pnpscsi.inf:
- https://community.osr.com/discussion/41967/installing-isa-scsi-miniport-driver-through-f6-on-fresh-install-of-windows-2000-problem
- https://chat.reactos.org/reactos/pl/qii1w36wu7yrxyukh9b5dzwnje
- https://chat.reactos.org/reactos/pl/f5tanc9nfjdb5m17nhrq33994a

CORE-17398
This commit is contained in:
Stanislav Motylkov 2021-02-02 01:38:06 +03:00 committed by GitHub
parent e4dd39f1a9
commit df0261e799
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 66 additions and 0 deletions

View file

@ -705,6 +705,51 @@ FdoHandleDeviceRelations(
return IoCallDriver(PortExtension->Common.LowerDevice, Irp);
}
static
NTSTATUS
FdoHandleQueryCompatibleId(
_Inout_ PZZWSTR* PwIds)
{
static WCHAR GenScsiAdapterId[] = L"GEN_SCSIADAPTER";
PWCHAR Ids = *PwIds, NewIds;
ULONG Length = 0;
if (Ids)
{
/* Calculate the length of existing MULTI_SZ value line by line */
while (*Ids)
{
Ids += wcslen(Ids) + 1;
}
Length = Ids - *PwIds;
Ids = *PwIds;
}
/* New MULTI_SZ with added identifier and finalizing zeros */
NewIds = ExAllocatePoolZero(PagedPool,
Length * sizeof(WCHAR) + sizeof(GenScsiAdapterId) + sizeof(UNICODE_NULL),
TAG_SCSIPORT);
if (!NewIds)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
if (Length)
{
RtlCopyMemory(NewIds, Ids, Length * sizeof(WCHAR));
}
RtlCopyMemory(&NewIds[Length], GenScsiAdapterId, sizeof(GenScsiAdapterId));
/* Finally replace identifiers */
if (Ids)
{
ExFreePool(Ids);
}
*PwIds = NewIds;
return STATUS_SUCCESS;
}
NTSTATUS
FdoDispatchPnp(
_In_ PDEVICE_OBJECT DeviceObject,
@ -732,6 +777,17 @@ FdoDispatchPnp(
{
return FdoHandleDeviceRelations(portExt, Irp);
}
case IRP_MN_QUERY_ID:
{
if (ioStack->Parameters.QueryId.IdType == BusQueryCompatibleIDs)
{
Irp->IoStatus.Information = 0;
IoForwardIrpSynchronously(portExt->Common.LowerDevice, Irp);
status = FdoHandleQueryCompatibleId((PZZWSTR*)&Irp->IoStatus.Information);
break;
}
// otherwise fall through the default case
}
default:
{
// forward irp to next device object

View file

@ -26,6 +26,7 @@ DefaultDestDir = 12
%GenericMfg% = GenericMfg
[GenericMfg]
%GEN_SCSIADAPTER.DeviceDesc% = NO_DRV,,GEN_SCSIADAPTER
%PCI\VEN_104B&CC_0100.DeviceDesc% = BusLogic_Inst,PCI\VEN_104B&CC_0100
;----------------------------- ScsiPort Driver ----------------------------
@ -40,6 +41,13 @@ ErrorControl = 0
ServiceBinary = %12%\scsiport.sys
LoadOrderGroup = SCSI Port
;---------------------------- NO DRIVER REQ -----------------------------
[NO_DRV]
[NO_DRV.Services]
AddService = , 0x00000002
;----------------------------- BusLogic Driver ----------------------------
[BusLogic_Inst.NT]
@ -66,6 +74,7 @@ ReactOS = "ReactOS Team"
SCSIClassName = "SCSI and RAID Controllers"
GenericMfg = "(Standard SCSI and RAID controllers)"
GEN_SCSIADAPTER.DeviceDesc = "SCSI/RAID Host Controller"
PCI\VEN_104B&CC_0100.DeviceDesc = "BusLogic SCSI Controller"
[Strings.0405]
@ -120,6 +129,7 @@ ReactOS = "Команда ReactOS"
SCSIClassName = "SCSI и RAID контроллеры"
GenericMfg = "(Стандартные SCSI и RAID контроллеры)"
GEN_SCSIADAPTER.DeviceDesc = "SCSI/RAID хост-контроллер"
PCI\VEN_104B&CC_0100.DeviceDesc = "Контроллер BusLogic SCSI"
[Strings.041B]