2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Kernel Streaming
4 * FILE: drivers/ksfilter/swenum/swenum.c
5 * PURPOSE: KS Allocator functions
6 * PROGRAMMER: Johannes Anderwald
12 const GUID KSMEDIUMSETID_Standard
= {0x4747B320L
, 0x62CE, 0x11CF, {0xA5, 0xD6, 0x28, 0xDB, 0x04, 0xC1, 0x00, 0x00}};
18 IN PDEVICE_OBJECT DeviceObject
,
24 /* just complete the irp */
25 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
27 /* complete the irp */
28 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
31 return STATUS_SUCCESS
;
38 IN PDEVICE_OBJECT DeviceObject
,
43 PIO_STACK_LOCATION IoStack
;
44 PDEVICE_OBJECT PnpDeviceObject
= NULL
;
46 /* check if the device object is a child device */
47 Status
= KsIsBusEnumChildDevice(DeviceObject
, &ChildDevice
);
49 /* check for success */
50 if (!NT_SUCCESS(Status
))
53 Irp
->IoStatus
.Status
= Status
;
54 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
58 /* let ks handle it */
59 Status
= KsServiceBusEnumPnpRequest(DeviceObject
, Irp
);
61 if (!NT_SUCCESS(Status
))
63 /* invalid request or not supported */
64 Irp
->IoStatus
.Status
= Status
;
65 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
69 /* get bus enum pnp object */
70 Status
= KsGetBusEnumPnpDeviceObject(DeviceObject
, &PnpDeviceObject
);
72 /* check for success */
73 if (!NT_SUCCESS(Status
))
75 /* failed to get pnp object */
76 Irp
->IoStatus
.Status
= Status
;
77 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
82 ASSERT(PnpDeviceObject
);
84 /* get current stack location */
85 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
87 if (IoStack
->MinorFunction
== IRP_MN_REMOVE_DEVICE
)
89 /* delete the device */
90 IoDeleteDevice(DeviceObject
);
93 /* skip current location */
94 IoSkipCurrentIrpStackLocation(Irp
);
95 /* call the pnp device object */
96 return IoCallDriver(PnpDeviceObject
, Irp
);
101 SwDispatchSystemControl(
102 IN PDEVICE_OBJECT DeviceObject
,
107 PDEVICE_OBJECT PnpDeviceObject
;
109 /* check if the device object is a child device */
110 Status
= KsIsBusEnumChildDevice(DeviceObject
, &ChildDevice
);
112 /* check for success */
113 if (NT_SUCCESS(Status
))
117 /* bus devices dont support internal requests */
118 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
119 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
120 return STATUS_SUCCESS
;
123 /* get bus enum pnp object */
124 Status
= KsGetBusEnumPnpDeviceObject(DeviceObject
, &PnpDeviceObject
);
126 /* check for success */
127 if (NT_SUCCESS(Status
))
129 /* skip current location */
130 IoSkipCurrentIrpStackLocation(Irp
);
131 /* call the pnp device object */
132 return IoCallDriver(PnpDeviceObject
, Irp
);
137 /* complete the request */
138 Irp
->IoStatus
.Status
= Status
;
139 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
147 SwDispatchDeviceControl(
148 IN PDEVICE_OBJECT DeviceObject
,
151 PIO_STACK_LOCATION IoStack
;
152 NTSTATUS Status
= STATUS_SUCCESS
;
154 /* get current stack location */
155 IoStack
= IoGetCurrentIrpStackLocation(Irp
);
157 if (IoStack
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_SWENUM_INSTALL_INTERFACE
)
159 /* install interface */
160 Status
= KsInstallBusEnumInterface(Irp
);
162 else if (IoStack
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_SWENUM_REMOVE_INTERFACE
)
164 /* remove interface */
165 Status
= KsRemoveBusEnumInterface(Irp
);
167 else if (IoStack
->Parameters
.DeviceIoControl
.IoControlCode
== IOCTL_SWENUM_GET_BUS_ID
)
170 return KsGetBusEnumIdentifier(Irp
);
174 Irp
->IoStatus
.Status
= Status
;
177 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
187 IN PDEVICE_OBJECT DeviceObject
,
193 /* check if the device object is a child device */
194 Status
= KsIsBusEnumChildDevice(DeviceObject
, &ChildDevice
);
196 /* check for success */
197 if (NT_SUCCESS(Status
))
201 /* child devices cant create devices */
202 Irp
->IoStatus
.Status
= STATUS_OBJECT_NAME_NOT_FOUND
;
203 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
204 return STATUS_OBJECT_NAME_NOT_FOUND
;
206 /* perform the create request */
207 Status
= KsServiceBusEnumCreateRequest(DeviceObject
, Irp
);
210 /* check the irp is pending */
211 if (Status
!= STATUS_PENDING
)
213 /* irp is ok to complete */
214 Irp
->IoStatus
.Status
= Status
;
215 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
225 IN PDEVICE_OBJECT DeviceObject
,
228 /* just complete the irp */
229 Irp
->IoStatus
.Status
= STATUS_SUCCESS
;
231 /* complete the irp */
232 IoCompleteRequest(Irp
, IO_NO_INCREMENT
);
235 return STATUS_SUCCESS
;
242 IN PDRIVER_OBJECT DriverObject
,
243 IN PDEVICE_OBJECT PhysicalDeviceObject
)
246 PDEVICE_OBJECT FunctionalDeviceObject
;
248 /* create the device */
249 Status
= IoCreateDevice(DriverObject
, sizeof(KSDEVICE_HEADER
), NULL
, FILE_DEVICE_BUS_EXTENDER
, 0, FALSE
, &FunctionalDeviceObject
);
251 if (!NT_SUCCESS(Status
))
257 /* create the bus enum object */
258 Status
= KsCreateBusEnumObject(L
"SW", FunctionalDeviceObject
, PhysicalDeviceObject
, NULL
, &KSMEDIUMSETID_Standard
, L
"Devices");
260 /* check for success */
261 if (NT_SUCCESS(Status
))
263 /* set device flags */
264 FunctionalDeviceObject
->Flags
|= DO_POWER_PAGABLE
;
265 FunctionalDeviceObject
->Flags
&= ~ DO_DEVICE_INITIALIZING
;
269 /* failed to create bus enum object */
270 IoDeleteDevice(FunctionalDeviceObject
);
280 IN PDRIVER_OBJECT DriverObject
)
288 IN PDRIVER_OBJECT DriverObject
,
289 IN PUNICODE_STRING RegistryPathName
)
292 /* setup add device routine */
293 DriverObject
->DriverExtension
->AddDevice
= SwAddDevice
;
295 /* setup unload routine */
296 DriverObject
->DriverUnload
= SwUnload
;
298 /* misc irp handling routines */
299 DriverObject
->MajorFunction
[IRP_MJ_CREATE
] = SwDispatchCreate
;
300 DriverObject
->MajorFunction
[IRP_MJ_CLOSE
] = SwDispatchClose
;
301 DriverObject
->MajorFunction
[IRP_MJ_PNP
] = SwDispatchPnp
;
302 DriverObject
->MajorFunction
[IRP_MJ_POWER
] = SwDispatchPower
;
303 DriverObject
->MajorFunction
[IRP_MJ_DEVICE_CONTROL
] = SwDispatchDeviceControl
;
304 DriverObject
->MajorFunction
[IRP_MJ_SYSTEM_CONTROL
] = SwDispatchSystemControl
;
307 return STATUS_SUCCESS
;