User Mode Driver Framework Architecture (Windows Embedded CE 6.0)
The User Mode Driver Framework is divided into two physical components. The first component is the User Mode Driver Reflector, which resides inside the device manager. The second component is the User Mode Driver Host, which is a user mode application that is launched and managed by the User Mode Driver Reflector.
When a driver is flagged as a User Mode Driver in the registry, the device manager will access the User Mode Driver Reflector. The User Mode Driver Reflector launches the appropriate User Mode Driver Host process and forwards I/O requests to it. The User Mode Driver Host process in turn forwards I/O requests to the User Mode Driver.
The process of using a User Mode Driver begins with a user application or with a parent bus driver. User applications and parent bus drivers can load User Mode Drivers by calling ActivateDevice or ActivateDeviceEx. User applications and parent bus drivers can unload User Mode Drivers by calling DeactivateDevice. Once loaded, any user application or driver can access the User Mode Driver by using the device handle.
If the driver is a User Mode Driver, the call to ActivateDevice or to ActivateDeviceEx will result in the device manager calling the User Mode Driver Reflector function as well. A driver is recognized as a User Mode Driver when the FLAGS value is set to the setting
DEVFLAGS_LOAD_AS_USERPROC (0x10) in the registry key of the device.
When a driver is in user mode, the pBusContext passed into ActivateDeviceEx must be a DWORD instead of a pointer.
The User Mode Driver Reflector, which is aware of the original process and the destination process, uses CeFsIoControl to forward the device manager's request to the User Mode Driver Host. The User Mode Driver Host then parses the request to either load, unload, or call the parent bus driver's entry.
The User Mode Driver has restricted access rights to the hardware, which prevents it from being able to accommodate requests such as mapping physical memory or calling interrupt functions. To accomplish these types of requests, the User Mode Driver calls the User Mode Driver Reflector, and enables the User Mode Driver Reflector to handle the request. The User Mode Driver Reflector then checks the user request against the registry settings to determine whether it should perform the requested action. Unlike with interrupts and the mapping of physical addresses, the User Mode Driver can, via the device handle and without the aid of the User Mode Driver Reflector, access the parent bus driver regardless of where the parent bus driver is located.