mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 21:32:56 +00:00
- Don't load PnP drivers if they're disabled.
- Save pointer to PnP tree device node in device object's DeviceObjectExtension. - Add function IopGetDeviceNode for getting device node from device object pointer. - Rewritten IoGetDeviceProperty to use values that are in device node instead of sending Irps. svn path=/trunk/; revision=8718
This commit is contained in:
parent
c5058d5a3c
commit
b4e4cd6676
4 changed files with 95 additions and 80 deletions
|
@ -16,7 +16,7 @@
|
||||||
* along with this program; if not, write to the Free Software
|
* along with this program; if not, write to the Free Software
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
*/
|
*/
|
||||||
/* $Id: io.h,v 1.38 2003/12/15 17:49:41 ekohl Exp $
|
/* $Id: io.h,v 1.39 2004/03/14 17:10:48 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -48,6 +48,13 @@ typedef struct _IO_COMPLETION_PACKET{
|
||||||
LIST_ENTRY ListEntry;
|
LIST_ENTRY ListEntry;
|
||||||
} IO_COMPLETION_PACKET, *PIO_COMPLETION_PACKET;
|
} IO_COMPLETION_PACKET, *PIO_COMPLETION_PACKET;
|
||||||
|
|
||||||
|
typedef struct _DEVOBJ_EXTENSION {
|
||||||
|
CSHORT Type;
|
||||||
|
USHORT Size;
|
||||||
|
PDEVICE_OBJECT DeviceObject;
|
||||||
|
ULONG Unknown[3];
|
||||||
|
struct _DEVICE_NODE *DeviceNode;
|
||||||
|
} DEVOBJ_EXTENSION, *PDEVOBJ_EXTENSION;
|
||||||
|
|
||||||
typedef struct _DEVICE_NODE
|
typedef struct _DEVICE_NODE
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: device.c,v 1.66 2004/03/07 11:59:10 navaraf Exp $
|
/* $Id: device.c,v 1.67 2004/03/14 17:10:48 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -636,6 +636,7 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT CreatedDeviceObject;
|
PDEVICE_OBJECT CreatedDeviceObject;
|
||||||
|
PDEVOBJ_EXTENSION DeviceObjectExtension;
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
|
||||||
|
@ -740,6 +741,17 @@ IoCreateDevice(PDRIVER_OBJECT DriverObject,
|
||||||
IoAttachVpb(CreatedDeviceObject);
|
IoAttachVpb(CreatedDeviceObject);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DeviceObjectExtension =
|
||||||
|
ExAllocatePoolWithTag(NonPagedPool, sizeof(DEVOBJ_EXTENSION),
|
||||||
|
TAG_DEVICE_EXTENSION);
|
||||||
|
|
||||||
|
DeviceObjectExtension->Type = 0 /* ?? */;
|
||||||
|
DeviceObjectExtension->Size = sizeof(DEVOBJ_EXTENSION);
|
||||||
|
DeviceObjectExtension->DeviceObject = CreatedDeviceObject;
|
||||||
|
DeviceObjectExtension->DeviceNode = NULL;
|
||||||
|
|
||||||
|
CreatedDeviceObject->DeviceObjectExtension = DeviceObjectExtension;
|
||||||
|
|
||||||
*DeviceObject = CreatedDeviceObject;
|
*DeviceObject = CreatedDeviceObject;
|
||||||
|
|
||||||
return(STATUS_SUCCESS);
|
return(STATUS_SUCCESS);
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: driver.c,v 1.35 2004/03/12 19:40:29 navaraf Exp $
|
/* $Id: driver.c,v 1.36 2004/03/14 17:10:48 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -802,33 +802,34 @@ NTSTATUS
|
||||||
IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode, BOOLEAN BootDriverOnly)
|
IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode, BOOLEAN BootDriverOnly)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
ULONG ServiceStart;
|
||||||
|
RTL_QUERY_REGISTRY_TABLE QueryTable[2];
|
||||||
|
|
||||||
if (DeviceNode->ServiceName.Buffer == NULL)
|
if (DeviceNode->ServiceName.Buffer == NULL)
|
||||||
{
|
{
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Get service start value
|
||||||
|
*/
|
||||||
|
|
||||||
|
RtlZeroMemory(QueryTable, sizeof(QueryTable));
|
||||||
|
QueryTable[0].Name = L"Start";
|
||||||
|
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
|
||||||
|
QueryTable[0].EntryContext = &ServiceStart;
|
||||||
|
Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES,
|
||||||
|
DeviceNode->ServiceName.Buffer, QueryTable, NULL, NULL);
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DPRINT("RtlQueryRegistryValues() failed (Status %x)\n", Status);
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
if (BootDriverOnly)
|
if (BootDriverOnly)
|
||||||
{
|
{
|
||||||
ULONG ServiceStart;
|
|
||||||
RTL_QUERY_REGISTRY_TABLE QueryTable[2];
|
|
||||||
PLOADER_MODULE KeLoaderModules = (PLOADER_MODULE)KeLoaderBlock.ModsAddr;
|
PLOADER_MODULE KeLoaderModules = (PLOADER_MODULE)KeLoaderBlock.ModsAddr;
|
||||||
|
|
||||||
/*
|
|
||||||
* Get service start value
|
|
||||||
*/
|
|
||||||
RtlZeroMemory(QueryTable, sizeof(QueryTable));
|
|
||||||
QueryTable[0].Name = L"Start";
|
|
||||||
QueryTable[0].Flags = RTL_QUERY_REGISTRY_DIRECT;
|
|
||||||
QueryTable[0].EntryContext = &ServiceStart;
|
|
||||||
Status = RtlQueryRegistryValues(RTL_REGISTRY_SERVICES,
|
|
||||||
DeviceNode->ServiceName.Buffer, QueryTable, NULL, NULL);
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
DPRINT("RtlQueryRegistryValues() failed (Status %x)\n", Status);
|
|
||||||
return Status;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find and initialize boot driver
|
* Find and initialize boot driver
|
||||||
*/
|
*/
|
||||||
|
@ -860,6 +861,7 @@ IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode, BOOLEAN BootDriverOnly)
|
||||||
return STATUS_UNSUCCESSFUL;
|
return STATUS_UNSUCCESSFUL;
|
||||||
}
|
}
|
||||||
} else
|
} else
|
||||||
|
if (ServiceStart < 4)
|
||||||
{
|
{
|
||||||
UNICODE_STRING ImagePath;
|
UNICODE_STRING ImagePath;
|
||||||
|
|
||||||
|
@ -889,6 +891,8 @@ IopInitializeDeviceNodeService(PDEVICE_NODE DeviceNode, BOOLEAN BootDriverOnly)
|
||||||
*/
|
*/
|
||||||
RtlFreeUnicodeString(&ImagePath);
|
RtlFreeUnicodeString(&ImagePath);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
Status = STATUS_UNSUCCESSFUL;
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: pnpmgr.c,v 1.23 2004/03/12 19:40:29 navaraf Exp $
|
/* $Id: pnpmgr.c,v 1.24 2004/03/14 17:10:48 navaraf Exp $
|
||||||
*
|
*
|
||||||
* COPYRIGHT: See COPYING in the top level directory
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
* PROJECT: ReactOS kernel
|
* PROJECT: ReactOS kernel
|
||||||
|
@ -62,16 +62,11 @@ IoInvalidateDeviceRelations(
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
PPNP_BUS_INFORMATION FASTCALL
|
PDEVICE_NODE FASTCALL
|
||||||
IopQueryBusInformation(
|
IopGetDeviceNode(
|
||||||
PDEVICE_OBJECT DeviceObject)
|
PDEVICE_OBJECT DeviceObject)
|
||||||
{
|
{
|
||||||
IO_STATUS_BLOCK IoStatusBlock;
|
return DeviceObject->DeviceObjectExtension->DeviceNode;
|
||||||
IO_STACK_LOCATION Stack;
|
|
||||||
|
|
||||||
return NT_SUCCESS(IopInitiatePnpIrp(DeviceObject, &IoStatusBlock,
|
|
||||||
IRP_MN_QUERY_BUS_INFORMATION, &Stack)) ?
|
|
||||||
(PPNP_BUS_INFORMATION)IoStatusBlock.Information : NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -86,9 +81,18 @@ IoGetDeviceProperty(
|
||||||
OUT PVOID PropertyBuffer,
|
OUT PVOID PropertyBuffer,
|
||||||
OUT PULONG ResultLength)
|
OUT PULONG ResultLength)
|
||||||
{
|
{
|
||||||
PPNP_BUS_INFORMATION BusInformation;
|
PDEVICE_NODE DeviceNode = IopGetDeviceNode(DeviceObject);
|
||||||
|
ULONG Length;
|
||||||
|
PVOID Data;
|
||||||
|
|
||||||
DPRINT("IoGetDeviceProperty called");
|
DPRINT("IoGetDeviceProperty called\n");
|
||||||
|
|
||||||
|
if (DeviceNode == NULL ||
|
||||||
|
DeviceNode->BusInformation == NULL ||
|
||||||
|
DeviceNode->CapabilityFlags == NULL)
|
||||||
|
{
|
||||||
|
return STATUS_INVALID_DEVICE_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Used IRPs:
|
* Used IRPs:
|
||||||
|
@ -97,64 +101,46 @@ IoGetDeviceProperty(
|
||||||
*/
|
*/
|
||||||
switch (DeviceProperty)
|
switch (DeviceProperty)
|
||||||
{
|
{
|
||||||
/* Complete, untested */
|
|
||||||
case DevicePropertyBusNumber:
|
case DevicePropertyBusNumber:
|
||||||
*ResultLength = sizeof(ULONG);
|
Length = sizeof(ULONG);
|
||||||
if (BufferLength < sizeof(ULONG))
|
Data = &DeviceNode->BusInformation->BusNumber;
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
break;
|
||||||
BusInformation = IopQueryBusInformation(DeviceObject);
|
|
||||||
if (BusInformation != NULL)
|
|
||||||
{
|
|
||||||
*((ULONG *)PropertyBuffer) = BusInformation->BusNumber;
|
|
||||||
ExFreePool(BusInformation);
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
|
|
||||||
/* Complete, untested */
|
/* Complete, untested */
|
||||||
case DevicePropertyBusTypeGuid:
|
case DevicePropertyBusTypeGuid:
|
||||||
*ResultLength = 39 * sizeof(WCHAR);
|
*ResultLength = 39 * sizeof(WCHAR);
|
||||||
if (BufferLength < (39 * sizeof(WCHAR)))
|
if (BufferLength < (39 * sizeof(WCHAR)))
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
BusInformation = IopQueryBusInformation(DeviceObject);
|
swprintf((PWSTR)PropertyBuffer,
|
||||||
if (BusInformation != NULL)
|
L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
||||||
{
|
DeviceNode->BusInformation->BusTypeGuid.Data1,
|
||||||
swprintf((PWSTR)PropertyBuffer,
|
DeviceNode->BusInformation->BusTypeGuid.Data2,
|
||||||
L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
|
DeviceNode->BusInformation->BusTypeGuid.Data3,
|
||||||
BusInformation->BusTypeGuid.Data1,
|
DeviceNode->BusInformation->BusTypeGuid.Data4[0],
|
||||||
BusInformation->BusTypeGuid.Data2,
|
DeviceNode->BusInformation->BusTypeGuid.Data4[1],
|
||||||
BusInformation->BusTypeGuid.Data3,
|
DeviceNode->BusInformation->BusTypeGuid.Data4[2],
|
||||||
BusInformation->BusTypeGuid.Data4[0],
|
DeviceNode->BusInformation->BusTypeGuid.Data4[3],
|
||||||
BusInformation->BusTypeGuid.Data4[1],
|
DeviceNode->BusInformation->BusTypeGuid.Data4[4],
|
||||||
BusInformation->BusTypeGuid.Data4[2],
|
DeviceNode->BusInformation->BusTypeGuid.Data4[5],
|
||||||
BusInformation->BusTypeGuid.Data4[3],
|
DeviceNode->BusInformation->BusTypeGuid.Data4[6],
|
||||||
BusInformation->BusTypeGuid.Data4[4],
|
DeviceNode->BusInformation->BusTypeGuid.Data4[7]);
|
||||||
BusInformation->BusTypeGuid.Data4[5],
|
|
||||||
BusInformation->BusTypeGuid.Data4[6],
|
|
||||||
BusInformation->BusTypeGuid.Data4[7]);
|
|
||||||
ExFreePool(BusInformation);
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
|
|
||||||
/* Complete, untested */
|
|
||||||
case DevicePropertyLegacyBusType:
|
case DevicePropertyLegacyBusType:
|
||||||
*ResultLength = sizeof(INTERFACE_TYPE);
|
Length = sizeof(INTERFACE_TYPE);
|
||||||
if (BufferLength < sizeof(INTERFACE_TYPE))
|
Data = &DeviceNode->BusInformation->LegacyBusType;
|
||||||
return STATUS_BUFFER_TOO_SMALL;
|
break;
|
||||||
BusInformation = IopQueryBusInformation(DeviceObject);
|
|
||||||
if (BusInformation != NULL)
|
|
||||||
{
|
|
||||||
RtlCopyMemory(
|
|
||||||
PropertyBuffer,
|
|
||||||
&BusInformation->LegacyBusType,
|
|
||||||
sizeof(INTERFACE_TYPE));
|
|
||||||
ExFreePool(BusInformation);
|
|
||||||
return STATUS_UNSUCCESSFUL;
|
|
||||||
}
|
|
||||||
return STATUS_SUCCESS;
|
|
||||||
|
|
||||||
case DevicePropertyAddress:
|
case DevicePropertyAddress:
|
||||||
|
Length = sizeof(ULONG);
|
||||||
|
Data = &DeviceNode->CapabilityFlags->Address;
|
||||||
|
break;
|
||||||
|
|
||||||
|
case DevicePropertyUINumber:
|
||||||
|
Length = sizeof(ULONG);
|
||||||
|
Data = &DeviceNode->CapabilityFlags->UINumber;
|
||||||
|
break;
|
||||||
|
|
||||||
case DevicePropertyBootConfiguration:
|
case DevicePropertyBootConfiguration:
|
||||||
case DevicePropertyBootConfigurationTranslated:
|
case DevicePropertyBootConfigurationTranslated:
|
||||||
case DevicePropertyClassGuid:
|
case DevicePropertyClassGuid:
|
||||||
|
@ -168,13 +154,17 @@ IoGetDeviceProperty(
|
||||||
case DevicePropertyLocationInformation:
|
case DevicePropertyLocationInformation:
|
||||||
case DevicePropertyManufacturer:
|
case DevicePropertyManufacturer:
|
||||||
case DevicePropertyPhysicalDeviceObjectName:
|
case DevicePropertyPhysicalDeviceObjectName:
|
||||||
case DevicePropertyUINumber:
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return STATUS_INVALID_PARAMETER_2;
|
return STATUS_INVALID_PARAMETER_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
*ResultLength = Length;
|
||||||
|
if (BufferLength < Length)
|
||||||
|
return STATUS_BUFFER_TOO_SMALL;
|
||||||
|
RtlCopyMemory(PropertyBuffer, Data, Length);
|
||||||
|
|
||||||
return STATUS_NOT_IMPLEMENTED;
|
return STATUS_NOT_IMPLEMENTED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,6 +299,8 @@ IopCreateDeviceNode(PDEVICE_NODE ParentNode,
|
||||||
|
|
||||||
Node->Pdo = PhysicalDeviceObject;
|
Node->Pdo = PhysicalDeviceObject;
|
||||||
|
|
||||||
|
PhysicalDeviceObject->DeviceObjectExtension->DeviceNode = Node;
|
||||||
|
|
||||||
if (ParentNode)
|
if (ParentNode)
|
||||||
{
|
{
|
||||||
KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql);
|
KeAcquireSpinLock(&IopDeviceTreeLock, &OldIrql);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue