Installing and Configuring a Kernel-Mode Driver, Using VCUser.lib

User-mode drivers are responsible for installing their associated kernel-mode drivers and for providing kernel-mode drivers with configuration parameter values. The first VCUser.lib function that a user-mode driver should call is VC_OpenProfileAccess. This function, which specifies the kernel-mode driver's name and sets up storage for access to the Service Control Manager and the registry, should be called when the driver receives a DRV_LOAD message.

Next, the driver should call VC_ConfigAccess. If the client has Administrators privilege and is thus allowed to install drivers, this function establishes a connection to the Service Control Manager. The driver should call the function when it receives a DRV_QUERYCONFIGURE message.

When the driver receives a DRV_CONFIGURE message, it should call VC_InstallDriver to install the kernel-mode driver. This function allows you to specify a callback function, from which your driver can make calls to VC_WriteProfile to store driver configuration parameters in the registry. If your kernel-mode driver encounters installation errors, it should write an error code into the registry. Your user-mode driver can call VC_ReadProfile to check the error code or to obtain the stored configuration information.

Upon receipt of a DRV_REMOVE message, your driver should call VC_RemoveDriver to remove the kernel-mode driver's installation. The last message your driver can receive is DRV_FREE, at which time it should call VC_CloseProfileAccess to remove its connection to the Service Control Manager.