If exclusive access to a device is enabled, only one handle to the device can be open at a time. For the I/O Manager to enforce exclusive access to the device, the exclusive property must be set for the named device object in the device stack.
For a WDM device stack that has a both a PDO and an FDO, this means that the exclusive property can only be set by the INF file, using an INF AddReg directive. The PDO is the named object in the stack, but it is created by the bus driver on behalf of the function driver, not by the function driver itself. The only way to direct the bus driver to set the exclusive flag for the PDO is by the class or device INF files. (The call to IoCreateDevice creates the FDO; setting the exclusive flag for the FDO has no effect.)
Drivers whose device objects are not stacked, such as non-WDM drivers and devices that operate in raw mode, can use IoCreateDeviceSecure to set the exclusive property for their named device object.
The I/O Manager enforces exclusivity on a per-name basis. If two objects in the device stack are named (which is not recommended), the I/O Manager allows a single handle to be opened for each named object. In such a case, drivers must enforce exclusivity themselves within their DispatchCreate routines.
Also note that the I/O Manager only enforces exclusivity for opens against the device object itself, not for any requests to open files within the device object's namespace. For example, suppose the device object has the name "\Device\DeviceName". The I/O Manager does not enforce exclusivity for a request to open "\Device\DeviceName\FileName". For more information about file open requests in the device's namespace, see Controlling Device Namespace Access.