mirror of
https://github.com/reactos/reactos.git
synced 2024-10-04 16:36:11 +00:00
Implement proper error-handling in IoRegisterDeviceInterface() (based on testing and MSDN documentation)
svn path=/trunk/; revision=22981
This commit is contained in:
parent
b77e8f5145
commit
8892a1ea62
|
@ -630,13 +630,37 @@ IoRegisterDeviceInterface(IN PDEVICE_OBJECT PhysicalDeviceObject,
|
||||||
OBJECT_ATTRIBUTES ObjectAttributes;
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
ULONG i;
|
ULONG i;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
PEXTENDED_DEVOBJ_EXTENSION DeviceObjectExtension;
|
||||||
|
|
||||||
ASSERT_IRQL(PASSIVE_LEVEL);
|
ASSERT_IRQL(PASSIVE_LEVEL);
|
||||||
|
|
||||||
if (!(PhysicalDeviceObject->Flags & DO_BUS_ENUMERATED_DEVICE))
|
/* Parameters must pass three border of checks */
|
||||||
|
DeviceObjectExtension = (PEXTENDED_DEVOBJ_EXTENSION)PhysicalDeviceObject->DeviceObjectExtension;
|
||||||
|
|
||||||
|
/* 1st level: Presence of a Device Node */
|
||||||
|
if (DeviceObjectExtension->DeviceNode == NULL)
|
||||||
{
|
{
|
||||||
DPRINT("PhysicalDeviceObject 0x%p is not a valid Pdo\n", PhysicalDeviceObject);
|
DPRINT("PhysicalDeviceObject 0x%p doesn't have a DeviceNode\n", PhysicalDeviceObject);
|
||||||
return STATUS_INVALID_PARAMETER_1;
|
return STATUS_INVALID_DEVICE_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 2nd level: Presence of an non-zero length InstancePath */
|
||||||
|
if (DeviceObjectExtension->DeviceNode->InstancePath.Length == 0)
|
||||||
|
{
|
||||||
|
DPRINT("PhysicalDeviceObject 0x%p's DOE has zero-length InstancePath\n", PhysicalDeviceObject);
|
||||||
|
return STATUS_INVALID_DEVICE_REQUEST;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 3rd level: Optional, based on WDK documentation */
|
||||||
|
if (ReferenceString != NULL)
|
||||||
|
{
|
||||||
|
/* Reference string must not contain path-separator symbols */
|
||||||
|
for (i = 0; i < ReferenceString->Length / sizeof(WCHAR); i++)
|
||||||
|
{
|
||||||
|
if ((ReferenceString->Buffer[i] == '\\') ||
|
||||||
|
(ReferenceString->Buffer[i] == '/'))
|
||||||
|
return STATUS_INVALID_DEVICE_REQUEST;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Status = RtlStringFromGUID(InterfaceClassGuid, &GuidString);
|
Status = RtlStringFromGUID(InterfaceClassGuid, &GuidString);
|
||||||
|
|
Loading…
Reference in a new issue