当键盘类驱动程序或鼠标类驱动程序枚举时,会找到很多设备,这些设备需要使用回调的方式来进行初始化。下面的函数,就是实现回调初始化驱动程序,如下:
#001 VOID
#002 NTAPI
#003 IopReinitializeBootDrivers(VOID)
#004 {
#005 PDRIVER_REINIT_ITEM ReinitItem;
#006 PLIST_ENTRY Entry;
#007
找到需要重新初始化入口列表头。
#008 /* Get the first entry and start looping */
#009 Entry = ExInterlockedRemoveHeadList(&DriverBootReinitListHead,
#010 &DriverBootReinitListLock);
#011 while (Entry)
#012 {
#013 /* Get the item*/
#014 ReinitItem = CONTAINING_RECORD(Entry,DRIVER_REINIT_ITEM,ItemEntry);
#015
增加初始化计数。
#016 /* Increment reinitialization counter */
#017 ReinitItem->DriverObject->DriverExtension->Count++;
#018
删除需要重新初始化的标志。
#019 /* Remove the device object flag */
#020 ReinitItem->DriverObject->Flags &= ~DRVO_BOOTREINIT_REGISTERED;
#021
#022 /* Call the routine */
#023 ReinitItem->ReinitRoutine(ReinitItem->DriverObject,
#024 ReinitItem->Context,
#025 ReinitItem->DriverObject->
#026 DriverExtension->Count);
#027
#028 /* Free the entry */
#029 ExFreePool(Entry);
#030
移动下一次节点初始化。
#031 /* Move to the next one */
#032 Entry = ExInterlockedRemoveHeadList(&DriverBootReinitListHead,
#033 &DriverBootReinitListLock);
#034 }
#035}