- Implemented IoGetDriverObjectExtension and IoAllocateDriverObjectExtension.

- Fixed the parts of IoGetDeviceProperty that were incorrectly sending IRP_MN_QUERY_BUS_INFORMATION.

svn path=/trunk/; revision=8663
This commit is contained in:
Filip Navara 2004-03-12 19:40:29 +00:00
parent 5c45ab6ac0
commit 0e8946cb44
4 changed files with 126 additions and 34 deletions

View file

@ -1,4 +1,4 @@
/* $Id: driver.c,v 1.34 2004/01/10 14:24:30 hbirr Exp $ /* $Id: driver.c,v 1.35 2004/03/12 19:40:29 navaraf Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS kernel * PROJECT: ReactOS kernel
@ -1237,4 +1237,80 @@ IopReinitializeDrivers(VOID)
} }
} }
typedef struct _PRIVATE_DRIVER_EXTENSIONS {
struct _PRIVATE_DRIVER_EXTENSIONS *Link;
PVOID ClientIdentificationAddress;
CHAR Extension[1];
} PRIVATE_DRIVER_EXTENSIONS, *PPRIVATE_DRIVER_EXTENSIONS;
NTSTATUS STDCALL
IoAllocateDriverObjectExtension(
PDRIVER_OBJECT DriverObject,
PVOID ClientIdentificationAddress,
ULONG DriverObjectExtensionSize,
PVOID *DriverObjectExtension)
{
KIRQL OldIrql;
PPRIVATE_DRIVER_EXTENSIONS DriverExtensions;
PPRIVATE_DRIVER_EXTENSIONS NewDriverExtension;
NewDriverExtension = ExAllocatePoolWithTag(
NonPagedPool,
sizeof(PRIVATE_DRIVER_EXTENSIONS) - sizeof(CHAR) +
DriverObjectExtensionSize,
TAG_DRIVER_EXTENSION);
if (NewDriverExtension == NULL)
{
return STATUS_INSUFFICIENT_RESOURCES;
}
OldIrql = KeRaiseIrqlToDpcLevel();
NewDriverExtension->Link = DriverObject->DriverSection;
NewDriverExtension->ClientIdentificationAddress = ClientIdentificationAddress;
for (DriverExtensions = DriverObject->DriverSection;
DriverExtensions != NULL;
DriverExtensions = DriverExtensions->Link)
{
if (DriverExtensions->ClientIdentificationAddress ==
ClientIdentificationAddress)
return STATUS_OBJECT_NAME_COLLISION;
}
DriverObject->DriverSection = NewDriverExtension;
KfLowerIrql(OldIrql);
*DriverObjectExtension = &NewDriverExtension->Extension;
return STATUS_SUCCESS;
}
PVOID STDCALL
IoGetDriverObjectExtension(
PDRIVER_OBJECT DriverObject,
PVOID ClientIdentificationAddress)
{
KIRQL OldIrql;
PPRIVATE_DRIVER_EXTENSIONS DriverExtensions;
OldIrql = KeRaiseIrqlToDpcLevel();
for (DriverExtensions = DriverObject->DriverSection;
DriverExtensions != NULL &&
DriverExtensions->ClientIdentificationAddress !=
ClientIdentificationAddress;
DriverExtensions = DriverExtensions->Link)
;
KfLowerIrql(OldIrql);
if (DriverExtensions == NULL)
return NULL;
return &DriverExtensions->Extension;
}
/* EOF */ /* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: pnpmgr.c,v 1.22 2003/10/16 14:49:05 ekohl Exp $ /* $Id: pnpmgr.c,v 1.23 2004/03/12 19:40:29 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,17 +62,16 @@ IoInvalidateDeviceRelations(
{ {
} }
NTSTATUS PPNP_BUS_INFORMATION FASTCALL
IopQueryBusInformation( IopQueryBusInformation(
PDEVICE_OBJECT DeviceObject, PDEVICE_OBJECT DeviceObject)
PPNP_BUS_INFORMATION BusInformation)
{ {
IO_STATUS_BLOCK IoStatusBlock; IO_STATUS_BLOCK IoStatusBlock;
IO_STACK_LOCATION Stack; IO_STACK_LOCATION Stack;
IoStatusBlock.Information = (ULONG)BusInformation; return NT_SUCCESS(IopInitiatePnpIrp(DeviceObject, &IoStatusBlock,
return IopInitiatePnpIrp(DeviceObject, &IoStatusBlock, IRP_MN_QUERY_BUS_INFORMATION, &Stack)) ?
IRP_MN_QUERY_BUS_INFORMATION, &Stack); (PPNP_BUS_INFORMATION)IoStatusBlock.Information : NULL;
} }
/* /*
@ -87,8 +86,7 @@ IoGetDeviceProperty(
OUT PVOID PropertyBuffer, OUT PVOID PropertyBuffer,
OUT PULONG ResultLength) OUT PULONG ResultLength)
{ {
PNP_BUS_INFORMATION BusInformation; PPNP_BUS_INFORMATION BusInformation;
NTSTATUS Status;
DPRINT("IoGetDeviceProperty called"); DPRINT("IoGetDeviceProperty called");
@ -104,43 +102,57 @@ IoGetDeviceProperty(
*ResultLength = sizeof(ULONG); *ResultLength = sizeof(ULONG);
if (BufferLength < sizeof(ULONG)) if (BufferLength < sizeof(ULONG))
return STATUS_BUFFER_TOO_SMALL; return STATUS_BUFFER_TOO_SMALL;
Status = IopQueryBusInformation(DeviceObject, &BusInformation); BusInformation = IopQueryBusInformation(DeviceObject);
if (NT_SUCCESS(Status)) if (BusInformation != NULL)
*((ULONG *)PropertyBuffer) = BusInformation.BusNumber; {
return Status; *((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;
Status = IopQueryBusInformation(DeviceObject, &BusInformation); BusInformation = IopQueryBusInformation(DeviceObject);
if (NT_SUCCESS(Status)) if (BusInformation != NULL)
{
swprintf((PWSTR)PropertyBuffer, swprintf((PWSTR)PropertyBuffer,
L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}", L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
BusInformation.BusTypeGuid.Data1, BusInformation->BusTypeGuid.Data1,
BusInformation.BusTypeGuid.Data2, BusInformation->BusTypeGuid.Data2,
BusInformation.BusTypeGuid.Data3, BusInformation->BusTypeGuid.Data3,
BusInformation.BusTypeGuid.Data4[0], BusInformation->BusTypeGuid.Data4[0],
BusInformation.BusTypeGuid.Data4[1], BusInformation->BusTypeGuid.Data4[1],
BusInformation.BusTypeGuid.Data4[2], BusInformation->BusTypeGuid.Data4[2],
BusInformation.BusTypeGuid.Data4[3], BusInformation->BusTypeGuid.Data4[3],
BusInformation.BusTypeGuid.Data4[4], BusInformation->BusTypeGuid.Data4[4],
BusInformation.BusTypeGuid.Data4[5], BusInformation->BusTypeGuid.Data4[5],
BusInformation.BusTypeGuid.Data4[6], BusInformation->BusTypeGuid.Data4[6],
BusInformation.BusTypeGuid.Data4[7]); BusInformation->BusTypeGuid.Data4[7]);
return Status; ExFreePool(BusInformation);
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
/* Complete, untested */ /* Complete, untested */
case DevicePropertyLegacyBusType: case DevicePropertyLegacyBusType:
*ResultLength = sizeof(INTERFACE_TYPE); *ResultLength = sizeof(INTERFACE_TYPE);
if (BufferLength < sizeof(INTERFACE_TYPE)) if (BufferLength < sizeof(INTERFACE_TYPE))
return STATUS_BUFFER_TOO_SMALL; return STATUS_BUFFER_TOO_SMALL;
Status = IopQueryBusInformation(DeviceObject, &BusInformation); BusInformation = IopQueryBusInformation(DeviceObject);
if (NT_SUCCESS(Status)) if (BusInformation != NULL)
memcpy(PropertyBuffer, &BusInformation.LegacyBusType, {
RtlCopyMemory(
PropertyBuffer,
&BusInformation->LegacyBusType,
sizeof(INTERFACE_TYPE)); sizeof(INTERFACE_TYPE));
return Status; ExFreePool(BusInformation);
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
case DevicePropertyAddress: case DevicePropertyAddress:
case DevicePropertyBootConfiguration: case DevicePropertyBootConfiguration:

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.def,v 1.178 2004/03/08 08:05:27 navaraf Exp $ ; $Id: ntoskrnl.def,v 1.179 2004/03/12 19:40:29 navaraf Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -238,6 +238,7 @@ IoAcquireVpbSpinLock@4
IoAdapterObjectType DATA IoAdapterObjectType DATA
IoAllocateAdapterChannel@20 IoAllocateAdapterChannel@20
IoAllocateController@16 IoAllocateController@16
IoAllocateDriverObjectExtension@16
IoAllocateErrorLogEntry@8 IoAllocateErrorLogEntry@8
IoAllocateIrp@8 IoAllocateIrp@8
IoAllocateMdl@20 IoAllocateMdl@20
@ -287,6 +288,7 @@ IoGetAttachedDeviceReference@4
IoGetBaseFileSystemDeviceObject@4 IoGetBaseFileSystemDeviceObject@4
IoGetConfigurationInformation@0 IoGetConfigurationInformation@0
IoGetCurrentProcess@0 IoGetCurrentProcess@0
IoGetDriverObjectExtension@8
IoGetDeviceObjectPointer@16 IoGetDeviceObjectPointer@16
IoGetDeviceProperty@20 IoGetDeviceProperty@20
IoGetDeviceToVerify@4 IoGetDeviceToVerify@4

View file

@ -1,4 +1,4 @@
; $Id: ntoskrnl.edf,v 1.164 2004/03/08 08:05:27 navaraf Exp $ ; $Id: ntoskrnl.edf,v 1.165 2004/03/12 19:40:29 navaraf Exp $
; ;
; reactos/ntoskrnl/ntoskrnl.def ; reactos/ntoskrnl/ntoskrnl.def
; ;
@ -239,6 +239,7 @@ IoAllocateAdapterChannel=IoAllocateAdapterChannel@20
IoAllocateIrp=IoAllocateIrp@8 IoAllocateIrp=IoAllocateIrp@8
IoAllocateMdl=IoAllocateMdl@20 IoAllocateMdl=IoAllocateMdl@20
IoAllocateController=IoAllocateController@16 IoAllocateController=IoAllocateController@16
IoAllocateDriverObjectExtension=IoAllocateDriverObjectExtension@16
IoAllocateErrorLogEntry=IoAllocateErrorLogEntry@8 IoAllocateErrorLogEntry=IoAllocateErrorLogEntry@8
IoAllocateWorkItem=IoAllocateWorkItem@4 IoAllocateWorkItem=IoAllocateWorkItem@4
IoAssignResources=IoAssignResources@24 IoAssignResources=IoAssignResources@24
@ -287,6 +288,7 @@ IoGetBaseFileSystemDeviceObject=IoGetBaseFileSystemDeviceObject@4
IoGetConfigurationInformation=IoGetConfigurationInformation@0 IoGetConfigurationInformation=IoGetConfigurationInformation@0
IoGetCurrentProcess=IoGetCurrentProcess@0 IoGetCurrentProcess=IoGetCurrentProcess@0
IoGetDeviceObjectPointer=IoGetDeviceObjectPointer@16 IoGetDeviceObjectPointer=IoGetDeviceObjectPointer@16
IoGetDriverObjectExtension=IoGetDriverObjectExtension@8
IoGetDeviceProperty=IoGetDeviceProperty@20 IoGetDeviceProperty=IoGetDeviceProperty@20
IoGetDeviceToVerify=IoGetDeviceToVerify@4 IoGetDeviceToVerify=IoGetDeviceToVerify@4
IoGetDmaAdapter=IoGetDmaAdapter@12 IoGetDmaAdapter=IoGetDmaAdapter@12