Commit cba5674d authored by Zebediah Figura's avatar Zebediah Figura Committed by Alexandre Julliard

winebus.sys: Implement AddDevice().

parent 9fa62ce6
......@@ -88,6 +88,9 @@ static DRIVER_OBJECT *driver_obj;
static DEVICE_OBJECT *mouse_obj;
/* The root-enumerated device stack. */
static DEVICE_OBJECT *bus_pdo, *bus_fdo;
HANDLE driver_key;
struct pnp_device
......@@ -490,7 +493,33 @@ static NTSTATUS handle_IRP_MN_QUERY_ID(DEVICE_OBJECT *device, IRP *irp)
return status;
}
static NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
static NTSTATUS fdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
{
IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp);
NTSTATUS ret;
switch (irpsp->MinorFunction)
{
case IRP_MN_START_DEVICE:
case IRP_MN_SURPRISE_REMOVAL:
irp->IoStatus.u.Status = STATUS_SUCCESS;
break;
case IRP_MN_REMOVE_DEVICE:
irp->IoStatus.u.Status = STATUS_SUCCESS;
IoSkipCurrentIrpStackLocation(irp);
ret = IoCallDriver(bus_pdo, irp);
IoDetachDevice(bus_pdo);
IoDeleteDevice(device);
return ret;
default:
FIXME("Unhandled minor function %#x.\n", irpsp->MinorFunction);
}
IoSkipCurrentIrpStackLocation(irp);
return IoCallDriver(bus_pdo, irp);
}
static NTSTATUS pdo_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
{
NTSTATUS status = irp->IoStatus.u.Status;
IO_STACK_LOCATION *irpsp = IoGetCurrentIrpStackLocation(irp);
......@@ -519,6 +548,13 @@ static NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
return status;
}
static NTSTATUS WINAPI common_pnp_dispatch(DEVICE_OBJECT *device, IRP *irp)
{
if (device == bus_fdo)
return fdo_pnp_dispatch(device, irp);
return pdo_pnp_dispatch(device, irp);
}
static NTSTATUS deliver_last_report(struct device_extension *ext, DWORD buffer_length, BYTE* buffer, ULONG_PTR *out_length)
{
if (buffer_length < ext->last_report_size)
......@@ -592,6 +628,12 @@ static NTSTATUS WINAPI hid_internal_dispatch(DEVICE_OBJECT *device, IRP *irp)
TRACE("(%p, %p)\n", device, irp);
if (device == bus_fdo)
{
IoSkipCurrentIrpStackLocation(irp);
return IoCallDriver(bus_pdo, irp);
}
switch (irpsp->Parameters.DeviceIoControl.IoControlCode)
{
case IOCTL_HID_GET_DEVICE_ATTRIBUTES:
......@@ -836,6 +878,26 @@ BOOL is_xbox_gamepad(WORD vid, WORD pid)
return FALSE;
}
static NTSTATUS WINAPI driver_add_device(DRIVER_OBJECT *driver, DEVICE_OBJECT *pdo)
{
NTSTATUS ret;
TRACE("driver %p, pdo %p.\n", driver, pdo);
if ((ret = IoCreateDevice(driver, 0, NULL, FILE_DEVICE_BUS_EXTENDER, 0, FALSE, &bus_fdo)))
{
ERR("Failed to create FDO, status %#x.\n", ret);
return ret;
}
IoAttachDeviceToDeviceStack(bus_fdo, pdo);
bus_pdo = pdo;
bus_fdo->Flags &= ~DO_DEVICE_INITIALIZING;
return STATUS_SUCCESS;
}
static void WINAPI driver_unload(DRIVER_OBJECT *driver)
{
udev_driver_unload();
......@@ -933,6 +995,7 @@ NTSTATUS WINAPI DriverEntry( DRIVER_OBJECT *driver, UNICODE_STRING *path )
driver->MajorFunction[IRP_MJ_PNP] = common_pnp_dispatch;
driver->MajorFunction[IRP_MJ_INTERNAL_DEVICE_CONTROL] = hid_internal_dispatch;
driver->DriverExtension->AddDevice = driver_add_device;
driver->DriverUnload = driver_unload;
mouse_device_create();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment