- 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
* 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 */

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
* PROJECT: ReactOS kernel
@ -62,17 +62,16 @@ IoInvalidateDeviceRelations(
{
}
NTSTATUS
PPNP_BUS_INFORMATION FASTCALL
IopQueryBusInformation(
PDEVICE_OBJECT DeviceObject,
PPNP_BUS_INFORMATION BusInformation)
PDEVICE_OBJECT DeviceObject)
{
IO_STATUS_BLOCK IoStatusBlock;
IO_STACK_LOCATION Stack;
IoStatusBlock.Information = (ULONG)BusInformation;
return IopInitiatePnpIrp(DeviceObject, &IoStatusBlock,
IRP_MN_QUERY_BUS_INFORMATION, &Stack);
return NT_SUCCESS(IopInitiatePnpIrp(DeviceObject, &IoStatusBlock,
IRP_MN_QUERY_BUS_INFORMATION, &Stack)) ?
(PPNP_BUS_INFORMATION)IoStatusBlock.Information : NULL;
}
/*
@ -87,8 +86,7 @@ IoGetDeviceProperty(
OUT PVOID PropertyBuffer,
OUT PULONG ResultLength)
{
PNP_BUS_INFORMATION BusInformation;
NTSTATUS Status;
PPNP_BUS_INFORMATION BusInformation;
DPRINT("IoGetDeviceProperty called");
@ -104,43 +102,57 @@ IoGetDeviceProperty(
*ResultLength = sizeof(ULONG);
if (BufferLength < sizeof(ULONG))
return STATUS_BUFFER_TOO_SMALL;
Status = IopQueryBusInformation(DeviceObject, &BusInformation);
if (NT_SUCCESS(Status))
*((ULONG *)PropertyBuffer) = BusInformation.BusNumber;
return Status;
BusInformation = IopQueryBusInformation(DeviceObject);
if (BusInformation != NULL)
{
*((ULONG *)PropertyBuffer) = BusInformation->BusNumber;
ExFreePool(BusInformation);
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
/* Complete, untested */
case DevicePropertyBusTypeGuid:
*ResultLength = 39 * sizeof(WCHAR);
if (BufferLength < (39 * sizeof(WCHAR)))
return STATUS_BUFFER_TOO_SMALL;
Status = IopQueryBusInformation(DeviceObject, &BusInformation);
if (NT_SUCCESS(Status))
BusInformation = IopQueryBusInformation(DeviceObject);
if (BusInformation != NULL)
{
swprintf((PWSTR)PropertyBuffer,
L"{%08lX-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
BusInformation.BusTypeGuid.Data1,
BusInformation.BusTypeGuid.Data2,
BusInformation.BusTypeGuid.Data3,
BusInformation.BusTypeGuid.Data4[0],
BusInformation.BusTypeGuid.Data4[1],
BusInformation.BusTypeGuid.Data4[2],
BusInformation.BusTypeGuid.Data4[3],
BusInformation.BusTypeGuid.Data4[4],
BusInformation.BusTypeGuid.Data4[5],
BusInformation.BusTypeGuid.Data4[6],
BusInformation.BusTypeGuid.Data4[7]);
return Status;
BusInformation->BusTypeGuid.Data1,
BusInformation->BusTypeGuid.Data2,
BusInformation->BusTypeGuid.Data3,
BusInformation->BusTypeGuid.Data4[0],
BusInformation->BusTypeGuid.Data4[1],
BusInformation->BusTypeGuid.Data4[2],
BusInformation->BusTypeGuid.Data4[3],
BusInformation->BusTypeGuid.Data4[4],
BusInformation->BusTypeGuid.Data4[5],
BusInformation->BusTypeGuid.Data4[6],
BusInformation->BusTypeGuid.Data4[7]);
ExFreePool(BusInformation);
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
/* Complete, untested */
case DevicePropertyLegacyBusType:
*ResultLength = sizeof(INTERFACE_TYPE);
if (BufferLength < sizeof(INTERFACE_TYPE))
return STATUS_BUFFER_TOO_SMALL;
Status = IopQueryBusInformation(DeviceObject, &BusInformation);
if (NT_SUCCESS(Status))
memcpy(PropertyBuffer, &BusInformation.LegacyBusType,
BusInformation = IopQueryBusInformation(DeviceObject);
if (BusInformation != NULL)
{
RtlCopyMemory(
PropertyBuffer,
&BusInformation->LegacyBusType,
sizeof(INTERFACE_TYPE));
return Status;
ExFreePool(BusInformation);
return STATUS_UNSUCCESSFUL;
}
return STATUS_SUCCESS;
case DevicePropertyAddress:
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
;
@ -238,6 +238,7 @@ IoAcquireVpbSpinLock@4
IoAdapterObjectType DATA
IoAllocateAdapterChannel@20
IoAllocateController@16
IoAllocateDriverObjectExtension@16
IoAllocateErrorLogEntry@8
IoAllocateIrp@8
IoAllocateMdl@20
@ -287,6 +288,7 @@ IoGetAttachedDeviceReference@4
IoGetBaseFileSystemDeviceObject@4
IoGetConfigurationInformation@0
IoGetCurrentProcess@0
IoGetDriverObjectExtension@8
IoGetDeviceObjectPointer@16
IoGetDeviceProperty@20
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
;
@ -239,6 +239,7 @@ IoAllocateAdapterChannel=IoAllocateAdapterChannel@20
IoAllocateIrp=IoAllocateIrp@8
IoAllocateMdl=IoAllocateMdl@20
IoAllocateController=IoAllocateController@16
IoAllocateDriverObjectExtension=IoAllocateDriverObjectExtension@16
IoAllocateErrorLogEntry=IoAllocateErrorLogEntry@8
IoAllocateWorkItem=IoAllocateWorkItem@4
IoAssignResources=IoAssignResources@24
@ -287,6 +288,7 @@ IoGetBaseFileSystemDeviceObject=IoGetBaseFileSystemDeviceObject@4
IoGetConfigurationInformation=IoGetConfigurationInformation@0
IoGetCurrentProcess=IoGetCurrentProcess@0
IoGetDeviceObjectPointer=IoGetDeviceObjectPointer@16
IoGetDriverObjectExtension=IoGetDriverObjectExtension@8
IoGetDeviceProperty=IoGetDeviceProperty@20
IoGetDeviceToVerify=IoGetDeviceToVerify@4
IoGetDmaAdapter=IoGetDmaAdapter@12