https://git.reactos.org/?p=reactos.git;a=commitdiff;h=df0261e799ebdebbc91b4d02149eea6713371ad1

commit df0261e799ebdebbc91b4d02149eea6713371ad1
Author:     Stanislav Motylkov <[email protected]>
AuthorDate: Tue Feb 2 01:38:06 2021 +0300
Commit:     GitHub <[email protected]>
CommitDate: Tue Feb 2 01:38:06 2021 +0300

    [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
---
 drivers/storage/port/scsiport/fdo.c | 56 +++++++++++++++++++++++++++++++++++++
 media/inf/scsi.inf                  | 10 +++++++
 2 files changed, 66 insertions(+)

diff --git a/drivers/storage/port/scsiport/fdo.c 
b/drivers/storage/port/scsiport/fdo.c
index 052d5f62fa5..bdb6bf32b38 100644
--- a/drivers/storage/port/scsiport/fdo.c
+++ b/drivers/storage/port/scsiport/fdo.c
@@ -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
diff --git a/media/inf/scsi.inf b/media/inf/scsi.inf
index 315fe4a34da..e8aedc59160 100644
--- a/media/inf/scsi.inf
+++ b/media/inf/scsi.inf
@@ -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]

Reply via email to