由于操作系统会使用一些缺省的驱动程序,需要在启动时加载指定的驱动程序。下面这个函数,主要实现系统启动时指定加载的驱动程序。代码如下:@H_301_5@
@H_301_5@#001 VOID
@H_301_5@#002 FASTCALL
@H_301_5@#003 IopInitializeSystemDrivers(VOID)
@H_301_5@#004 {
@H_301_5@#005 PSERVICE_GROUP CurrentGroup;
@H_301_5@#006 PSERVICE CurrentService;
@H_301_5@#007 NTSTATUS Status;
@H_301_5@#008 ULONG i;
@H_301_5@#009 PLIST_ENTRY NextGroupEntry,NextServiceEntry;
@H_301_5@#010
@H_301_5@#011 DPRINT("IopInitializeSystemDrivers()/n");
@H_301_5@#012
@H_301_5@
循环地加载所有当前启动时加载的驱动程序。@H_301_5@
@H_301_5@#013 /* Start looping */
@H_301_5@#014 for (NextGroupEntry = GroupListHead.Flink;
@H_301_5@#015 NextGroupEntry != &GroupListHead;
@H_301_5@#016 NextGroupEntry = NextGroupEntry->Flink)
@H_301_5@#017 {
@H_301_5@#018 /* Get the entry */
@H_301_5@#019 CurrentGroup = CONTAINING_RECORD(NextGroupEntry,
@H_301_5@#020 SERVICE_GROUP,
@H_301_5@#021 GroupListEntry);
@H_301_5@#022
@H_301_5@#023 DPRINT("Group: %wZ/n",&CurrentGroup->GroupName);
@H_301_5@#024
@H_301_5@#025 /* Load all drivers with a valid tag */
@H_301_5@#026 for (i = 0; i < CurrentGroup->TagCount; i++)
@H_301_5@#027 {
@H_301_5@#028 /* Start looping */
@H_301_5@#029 for (NextServiceEntry = ServiceListHead.Flink;
@H_301_5@#030 NextServiceEntry != &ServiceListHead;
@H_301_5@#031 NextServiceEntry = NextServiceEntry->Flink)
@H_301_5@#032 {
@H_301_5@
@H_301_5@#033 /* Get the entry */
@H_301_5@#034 CurrentService = CONTAINING_RECORD(NextServiceEntry,
@H_301_5@#035 SERVICE,
@H_301_5@#036 ServiceListEntry);
@H_301_5@#037
@H_301_5@#038 if ((!RtlCompareUnicodeString(&CurrentGroup->GroupName,
@H_301_5@#039 &CurrentService->ServiceGroup,
@H_301_5@#040 TRUE)) &&
@H_301_5@#041 (CurrentService->Start == SERVICE_SYSTEM_START) &&
@H_301_5@#042 (CurrentService->Tag == CurrentGroup->TagArray[i]))
@H_301_5@#043
@H_301_5@#044 {
@H_301_5@#045 DPRINT(" Path: %wZ/n",&CurrentService->RegistryPath);
@H_301_5@
加载当前服务驱动程序。@H_301_5@
@H_301_5@#046 Status = IopLoadDriver(CurrentService);
@H_301_5@#047 }
@H_301_5@#048 }
@H_301_5@#049 }
@H_301_5@#050
@H_301_5@
@H_301_5@#051 /* Load all drivers without a tag or with an invalid tag */
@H_301_5@#052 for (NextServiceEntry = ServiceListHead.Flink;
@H_301_5@#053 NextServiceEntry != &ServiceListHead;
@H_301_5@#054 NextServiceEntry = NextServiceEntry->Flink)
@H_301_5@#055 {
@H_301_5@#056 /* Get the entry */
@H_301_5@#057 CurrentService = CONTAINING_RECORD(NextServiceEntry,
@H_301_5@#058 SERVICE,
@H_301_5@#059 ServiceListEntry);
@H_301_5@#060
@H_301_5@#061 if ((!RtlCompareUnicodeString(&CurrentGroup->GroupName,
@H_301_5@#062 &CurrentService->ServiceGroup,
@H_301_5@#063 TRUE)) &&
@H_301_5@#064 (CurrentService->Start == SERVICE_SYSTEM_START))
@H_301_5@#065 {
@H_301_5@#066 for (i = 0; i < CurrentGroup->TagCount; i++)
@H_301_5@#067 {
@H_301_5@#068 if (CurrentGroup->TagArray[i] == CurrentService->Tag)
@H_301_5@#069 {
@H_301_5@#070 break;
@H_301_5@#071 }
@H_301_5@#072 }
@H_301_5@#073
@H_301_5@#074 if (i >= CurrentGroup->TagCount)
@H_301_5@#075 {
@H_301_5@#076 DPRINT(" Path: %wZ/n",&CurrentService->RegistryPath);
@H_301_5@
开始加载当前驱动程序。@H_301_5@
@H_301_5@#077 Status = IopLoadDriver(CurrentService);
@H_301_5@#078 }
@H_301_5@#079 }
@H_301_5@#080 }
@H_301_5@#081 }
@H_301_5@#082
@H_301_5@#083 DPRINT("IopInitializeSystemDrivers() done/n");
@H_301_5@#084 }
@H_301_5@#085