[ISAPNP] Implement querying bus information

This commit is contained in:
Dmitry Borisov 2021-03-04 18:47:34 +06:00
parent 8f36dee6ff
commit e19595572a
3 changed files with 35 additions and 1 deletions

View file

@ -683,6 +683,7 @@ IsaAddDevice(
PDEVICE_OBJECT Fdo;
PISAPNP_FDO_EXTENSION FdoExt;
NTSTATUS Status;
static ULONG BusNumber = 0;
PAGED_CODE();
@ -708,6 +709,7 @@ IsaAddDevice(
FdoExt->Common.IsFdo = TRUE;
FdoExt->Common.State = dsStopped;
FdoExt->DriverObject = DriverObject;
FdoExt->BusNumber = BusNumber++;
FdoExt->Pdo = PhysicalDeviceObject;
FdoExt->Ldo = IoAttachDeviceToDeviceStack(Fdo,
PhysicalDeviceObject);

View file

@ -14,6 +14,9 @@
#include <section_attribs.h>
#include "isapnphw.h"
#include <initguid.h>
#include <wdmguid.h>
#ifdef __cplusplus
extern "C" {
#endif
@ -73,6 +76,7 @@ typedef struct _ISAPNP_FDO_EXTENSION
PDEVICE_OBJECT Ldo;
PDEVICE_OBJECT Pdo;
PDEVICE_OBJECT ReadPortPdo;
ULONG BusNumber;
KEVENT DeviceSyncEvent;
LIST_ENTRY DeviceListHead;
ULONG DeviceCount;

View file

@ -483,6 +483,31 @@ IsaPdoRepeatRequest(
return STATUS_PENDING;
}
static
CODE_SEG("PAGE")
NTSTATUS
IsaPdoQueryBusInformation(
_In_ PISAPNP_PDO_EXTENSION PdoExt,
_Inout_ PIRP Irp)
{
PPNP_BUS_INFORMATION BusInformation;
PAGED_CODE();
BusInformation = ExAllocatePoolWithTag(PagedPool,
sizeof(PNP_BUS_INFORMATION),
TAG_ISAPNP);
if (!BusInformation)
return STATUS_INSUFFICIENT_RESOURCES;
BusInformation->BusTypeGuid = GUID_BUS_TYPE_ISAPNP;
BusInformation->LegacyBusType = Isa;
BusInformation->BusNumber = PdoExt->FdoExt->BusNumber;
Irp->IoStatus.Information = (ULONG_PTR)BusInformation;
return STATUS_SUCCESS;
}
CODE_SEG("PAGE")
NTSTATUS
IsaPdoPnp(
@ -544,6 +569,10 @@ IsaPdoPnp(
Status = IsaReadPortQueryId(Irp, IrpSp);
break;
case IRP_MN_QUERY_BUS_INFORMATION:
Status = IsaPdoQueryBusInformation(PdoExt, Irp);
break;
case IRP_MN_QUERY_REMOVE_DEVICE:
case IRP_MN_REMOVE_DEVICE:
case IRP_MN_CANCEL_REMOVE_DEVICE:
@ -559,7 +588,6 @@ IsaPdoPnp(
case IRP_MN_WRITE_CONFIG:
case IRP_MN_EJECT:
case IRP_MN_SET_LOCK:
case IRP_MN_QUERY_BUS_INFORMATION:
case IRP_MN_DEVICE_USAGE_NOTIFICATION:
return IsaPdoRepeatRequest(PdoExt, Irp, TRUE);