mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 16:02:56 +00:00
- Refactor device attachment into a private routine.
- We shouldn't allow attaching to a device that's still initlizaing, but ROS currently does because of some device that tries to do this, in the PnP manager or early boot-phase drivers (it has an auto-generated name). Please fix this! svn path=/trunk/; revision=26258
This commit is contained in:
parent
6a5123b065
commit
f623df7b11
1 changed files with 21 additions and 43 deletions
|
@ -37,9 +37,18 @@ IopAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice,
|
||||||
SourceDeviceExtension = IoGetDevObjExtension(SourceDevice);
|
SourceDeviceExtension = IoGetDevObjExtension(SourceDevice);
|
||||||
ASSERT(SourceDeviceExtension->AttachedTo == NULL);
|
ASSERT(SourceDeviceExtension->AttachedTo == NULL);
|
||||||
|
|
||||||
|
/* FIXME: ROS HACK */
|
||||||
|
if (AttachedDevice->Flags & DO_DEVICE_INITIALIZING)
|
||||||
|
{
|
||||||
|
DPRINT1("Io: CRITICAL: Allowing attach to device which hasn't "
|
||||||
|
"cleared its DO_DEVICE_INITIALIZING flag. Fix the damn "
|
||||||
|
"thing: %p %wZ\n",
|
||||||
|
AttachedDevice,
|
||||||
|
&AttachedDevice->DriverObject->DriverName);
|
||||||
|
}
|
||||||
|
|
||||||
/* Make sure that it's in a correct state */
|
/* Make sure that it's in a correct state */
|
||||||
if ((AttachedDevice->Flags & DO_DEVICE_INITIALIZING) ||
|
if ((IoGetDevObjExtension(AttachedDevice)->ExtensionFlags &
|
||||||
(IoGetDevObjExtension(AttachedDevice)->ExtensionFlags &
|
|
||||||
(DOE_UNLOAD_PENDING |
|
(DOE_UNLOAD_PENDING |
|
||||||
DOE_DELETE_PENDING |
|
DOE_DELETE_PENDING |
|
||||||
DOE_REMOVE_PENDING |
|
DOE_REMOVE_PENDING |
|
||||||
|
@ -629,16 +638,10 @@ NTAPI
|
||||||
IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice,
|
IoAttachDeviceToDeviceStack(IN PDEVICE_OBJECT SourceDevice,
|
||||||
IN PDEVICE_OBJECT TargetDevice)
|
IN PDEVICE_OBJECT TargetDevice)
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
|
||||||
PDEVICE_OBJECT LocalAttach;
|
|
||||||
|
|
||||||
/* Attach it safely */
|
/* Attach it safely */
|
||||||
Status = IoAttachDeviceToDeviceStackSafe(SourceDevice,
|
return IopAttachDeviceToDeviceStackSafe(SourceDevice,
|
||||||
TargetDevice,
|
TargetDevice,
|
||||||
&LocalAttach);
|
NULL);
|
||||||
|
|
||||||
/* Return it */
|
|
||||||
return LocalAttach;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -650,41 +653,16 @@ IoAttachDeviceToDeviceStackSafe(IN PDEVICE_OBJECT SourceDevice,
|
||||||
IN PDEVICE_OBJECT TargetDevice,
|
IN PDEVICE_OBJECT TargetDevice,
|
||||||
IN OUT PDEVICE_OBJECT *AttachedToDeviceObject)
|
IN OUT PDEVICE_OBJECT *AttachedToDeviceObject)
|
||||||
{
|
{
|
||||||
PDEVICE_OBJECT AttachedDevice;
|
/* Call the internal function */
|
||||||
PEXTENDED_DEVOBJ_EXTENSION SourceDeviceExtension;
|
if (!IopAttachDeviceToDeviceStackSafe(SourceDevice,
|
||||||
|
TargetDevice,
|
||||||
/* Get the Attached Device and source extension */
|
AttachedToDeviceObject))
|
||||||
AttachedDevice = IoGetAttachedDevice(TargetDevice);
|
|
||||||
SourceDeviceExtension = IoGetDevObjExtension(SourceDevice);
|
|
||||||
|
|
||||||
/* Make sure that it's in a correct state */
|
|
||||||
if (!IoGetDevObjExtension(AttachedDevice)->ExtensionFlags &
|
|
||||||
(DOE_UNLOAD_PENDING |
|
|
||||||
DOE_DELETE_PENDING |
|
|
||||||
DOE_REMOVE_PENDING |
|
|
||||||
DOE_REMOVE_PROCESSED))
|
|
||||||
{
|
{
|
||||||
/* Update atached device fields */
|
/* Nothing found */
|
||||||
AttachedDevice->AttachedDevice = SourceDevice;
|
return STATUS_NO_SUCH_DEVICE;
|
||||||
AttachedDevice->Spare1++;
|
|
||||||
|
|
||||||
/* Update the source with the attached data */
|
|
||||||
SourceDevice->StackSize = AttachedDevice->StackSize + 1;
|
|
||||||
SourceDevice->AlignmentRequirement = AttachedDevice->
|
|
||||||
AlignmentRequirement;
|
|
||||||
SourceDevice->SectorSize = AttachedDevice->SectorSize;
|
|
||||||
|
|
||||||
/* Set the attachment in the device extension */
|
|
||||||
SourceDeviceExtension->AttachedTo = AttachedDevice;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Device was unloading or being removed */
|
|
||||||
AttachedDevice = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return the attached device */
|
/* Success! */
|
||||||
*AttachedToDeviceObject = AttachedDevice;
|
|
||||||
return STATUS_SUCCESS;
|
return STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue