different to driver attachment

Hi,
What is a different between IoGetLowerDeviceObject and IoGetDeviceAttachmentBaseRef?

One obvious difference is that IoGetLowerDeviceObject gets the immediate next object down, while IoGetDeviceAttachmentBaseRef goes straight to the bottom.

1 Like

so if I have three stack driver on !drvobj sample and then call IoGetDeviceAttachmentBaseRef, I will Attached on level_1?

!drvobj \filesystem\sample

Level_1
sample (lower)
Level_2
Level_3
?
or
Level_1
Level_2
Level_3
sample (upper)

No, you misunderstand. Those APIs are only useful when you are already part of a stack. They can tell you what the bottommost device object is, but you can’t attach anywhere except the top.

What happens next after booting the system and on what basis they are placed higher or lower in the drivers stack?

Did you search for this information at all? Google is faster than this forum. The rules for file systems are different from the rules for other PnP drivers. For PnP drivers, the order of loading is determined by the order in the LowerFilters and UpperFilters registry values. For file system drivers, it’s determined by your load order group, and the order within a single group is random. Note that I am not a file system guy, so I may have misstated the details.

https://docs.microsoft.com/en-us/windows-hardware/drivers/ifs/load-order-groups-for-file-system-filter-drivers