https://git.reactos.org/?p=reactos.git;a=commitdiff;h=161b6728ef4522a069e2a…
commit 161b6728ef4522a069e2a6375fc2d1a39b683aa5
Author: Pierre Schweitzer <pierre(a)reactos.org>
AuthorDate: Fri Oct 5 10:36:52 2018 +0200
Commit: Pierre Schweitzer <pierre(a)reactos.org>
CommitDate: Fri Oct 5 10:49:59 2018 +0200
[NTOSKRNL] Implement IopVerifyDeviceObjectOnStack()
---
ntoskrnl/io/iomgr/device.c | 34 ++++++++++++++++++++++++++++++++++
1 file changed, 34 insertions(+)
diff --git a/ntoskrnl/io/iomgr/device.c b/ntoskrnl/io/iomgr/device.c
index 04f7d5d2db..189e47b71b 100644
--- a/ntoskrnl/io/iomgr/device.c
+++ b/ntoskrnl/io/iomgr/device.c
@@ -687,6 +687,40 @@ IopGetRelatedTargetDevice(IN PFILE_OBJECT FileObject,
return Status;
}
+BOOLEAN
+NTAPI
+IopVerifyDeviceObjectOnStack(IN PDEVICE_OBJECT BaseDeviceObject,
+ IN PDEVICE_OBJECT TopDeviceObjectHint)
+{
+ KIRQL OldIrql;
+ BOOLEAN Result;
+ PDEVICE_OBJECT LoopObject;
+
+ ASSERT(BaseDeviceObject != NULL);
+
+ Result = FALSE;
+ /* Simply loop on the device stack and try to find our hint */
+ OldIrql = KeAcquireQueuedSpinLock(LockQueueIoDatabaseLock);
+ for (LoopObject = BaseDeviceObject; ; LoopObject = LoopObject->AttachedDevice)
+ {
+ /* It was found, it's a success */
+ if (LoopObject == TopDeviceObjectHint)
+ {
+ Result = TRUE;
+ break;
+ }
+
+ /* End of the stack, that's a failure - default */
+ if (LoopObject == NULL)
+ {
+ break;
+ }
+ }
+ KeReleaseQueuedSpinLock(LockQueueIoDatabaseLock, OldIrql);
+
+ return Result;
+}
+
/* PUBLIC FUNCTIONS ***********************************************************/
/*