Author: pschweitzer Date: Tue Jun 22 18:47:22 2010 New Revision: 47828
URL: http://svn.reactos.org/svn/reactos?rev=47828&view=rev Log: [NTOSKRNL] Add a macro to check for a valid PDO and use it in IoOpenDeviceRegistryKey(). Requested by sir_richard.
Modified: trunk/reactos/ntoskrnl/include/internal/io.h trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c
Modified: trunk/reactos/ntoskrnl/include/internal/io.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/include/internal/i... ============================================================================== --- trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/include/internal/io.h [iso-8859-1] Tue Jun 22 18:47:22 2010 @@ -207,6 +207,16 @@ (_DeviceNode); \ (_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
Modified: trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c... ============================================================================== --- trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] (original) +++ trunk/reactos/ntoskrnl/io/pnpmgr/pnpmgr.c [iso-8859-1] Tue Jun 22 18:47:22 2010 @@ -3527,9 +3527,9 @@ } else { + if (!IopIsValidPhysicalDeviceObject(DeviceObject)) + return STATUS_INVALID_DEVICE_REQUEST; DeviceNode = IopGetDeviceNode(DeviceObject); - if (!DeviceNode) - return STATUS_INVALID_DEVICE_REQUEST; KeyNameLength += sizeof(EnumKeyName) - sizeof(UNICODE_NULL) + DeviceNode->InstancePath.Length; }