[Wine-devel] [2/6] winedevice: Call IRP_MJ_PNP handler only with IRP_MN_START_DEVICE.
Alexander Morozov
=?iso-8859-1?q?amorozov_=CE=C1_etersoft=2Eru?=
Пт Окт 3 19:57:13 MSD 2008
Вызывать с другими IRP_MN_* не обязательно. Всё работает и так.
----------- следующая часть -----------
From 43857d4e50d10260ab9e07fc77b034c82f2db479 Mon Sep 17 00:00:00 2001
From: Alexander Morozov <amorozov на etersoft.ru>
Date: Fri, 3 Oct 2008 12:54:58 +0400
Subject: [PATCH] winedevice: Call IRP_MJ_PNP handler only with IRP_MN_START_DEVICE.
---
programs/winedevice/device.c | 70 ++++++++++++++----------------------------
1 files changed, 23 insertions(+), 47 deletions(-)
diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c
index 2cd0130..f37678d 100644
--- a/programs/winedevice/device.c
+++ b/programs/winedevice/device.c
@@ -277,18 +277,9 @@ static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
{
UNICODE_STRING drvname;
NTSTATUS ret = STATUS_SUCCESS;
- UCHAR pnpFuncs[] = { IRP_MN_QUERY_LEGACY_BUS_INFORMATION,
- IRP_MN_QUERY_RESOURCE_REQUIREMENTS,
- IRP_MN_FILTER_RESOURCE_REQUIREMENTS,
- IRP_MN_START_DEVICE,
- IRP_MN_QUERY_CAPABILITIES,
- IRP_MN_QUERY_PNP_DEVICE_STATE,
- IRP_MN_QUERY_DEVICE_RELATIONS };
- ULONG k;
IRP *irp;
IO_STACK_LOCATION *irpsp;
PDRIVER_DISPATCH dispatch;
- DEVICE_CAPABILITIES cpbts;
status.dwCurrentState = SERVICE_RUNNING;
status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
@@ -330,47 +321,32 @@ static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
}
}
- for (k = 0; k < sizeof(pnpFuncs); ++k)
+ if (driver_obj.MajorFunction[IRP_MJ_PNP])
{
- if (STATUS_SUCCESS != ret)
- break;
- if (driver_obj.MajorFunction[IRP_MJ_PNP])
+ irp = IoAllocateIrp( driver_obj.DeviceObject->StackSize, FALSE );
+ if (irp != NULL)
{
- irp = IoAllocateIrp( driver_obj.DeviceObject->StackSize, FALSE );
- if (irp != NULL)
- {
- --irp->CurrentLocation;
- irpsp = --irp->Tail.Overlay.s.u.CurrentStackLocation;
-
- irp->RequestorMode = KernelMode;
- irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
-
- irpsp->MajorFunction = IRP_MJ_PNP;
- irpsp->MinorFunction = pnpFuncs[k];
- irpsp->DeviceObject = driver_obj.DeviceObject;
-
- driver_obj.DeviceObject->CurrentIrp = irp;
-
- if (IRP_MN_QUERY_CAPABILITIES == pnpFuncs[k])
- {
- RtlZeroMemory( &cpbts, sizeof(cpbts) );
- cpbts.Size = 64;
- cpbts.Version = 1;
- cpbts.Address = ULONG_MAX;
- cpbts.UINumber = ULONG_MAX;
- irpsp->Parameters.DeviceCapabilities.Capabilities = &cpbts;
- }
-
- dispatch = driver_obj.MajorFunction[IRP_MJ_PNP];
- ret = dispatch( driver_obj.DeviceObject, irp );
- if (STATUS_SUCCESS != ret)
- WINE_ERR( "MajorFunction[IRP_MJ_PNP] failed: %x\n", ret );
-
- IoFreeIrp( irp );
- }
- else
- ret = STATUS_UNSUCCESSFUL;
+ --irp->CurrentLocation;
+ irpsp = --irp->Tail.Overlay.s.u.CurrentStackLocation;
+
+ irp->RequestorMode = KernelMode;
+ irp->IoStatus.u.Status = STATUS_NOT_SUPPORTED;
+
+ irpsp->MajorFunction = IRP_MJ_PNP;
+ irpsp->MinorFunction = IRP_MN_START_DEVICE;
+ irpsp->DeviceObject = driver_obj.DeviceObject;
+
+ driver_obj.DeviceObject->CurrentIrp = irp;
+
+ dispatch = driver_obj.MajorFunction[IRP_MJ_PNP];
+ ret = dispatch( driver_obj.DeviceObject, irp );
+ if (STATUS_SUCCESS != ret)
+ WINE_ERR( "MajorFunction[IRP_MJ_PNP] failed: %x\n", ret );
+
+ IoFreeIrp( irp );
}
+ else
+ ret = STATUS_UNSUCCESSFUL;
}
wine_ntoskrnl_main_loop( stop_event );
--
1.5.6.5.GIT
Подробная информация о списке рассылки Wine-devel