[NTOSKRNL]

Add a macro to check for a valid PDO and use it in IoOpenDeviceRegistryKey().
Requested by sir_richard.

svn path=/trunk/; revision=47828
This commit is contained in:
Pierre Schweitzer 2010-06-22 18:47:22 +00:00
parent b362a62a7e
commit 0ad7647067
2 changed files with 12 additions and 2 deletions

View file

@ -208,6 +208,16 @@
(_DeviceTreeTraverseContext)->Action = (_Action); \
(_DeviceTreeTraverseContext)->Context = (_Context); }
/*
* BOOLEAN
* IopIsValidPhysicalDeviceObject(
* IN PDEVICE_OBJECT PhysicalDeviceObject);
*/
#define IopIsValidPhysicalDeviceObject(PhysicalDeviceObject) \
(((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject) && \
(((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode) && \
(((PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension)->DeviceNode->Flags & DNF_ENUMERATED))
//
// Device List Operations
//

View file

@ -3527,9 +3527,9 @@ IoOpenDeviceRegistryKey(IN PDEVICE_OBJECT DeviceObject,
}
else
{
DeviceNode = IopGetDeviceNode(DeviceObject);
if (!DeviceNode)
if (!IopIsValidPhysicalDeviceObject(DeviceObject))
return STATUS_INVALID_DEVICE_REQUEST;
DeviceNode = IopGetDeviceNode(DeviceObject);
KeyNameLength += sizeof(EnumKeyName) - sizeof(UNICODE_NULL) +
DeviceNode->InstancePath.Length;
}