reactos操作系统实现(81)

由于操作系统会使用一些缺省的驱动程序,需要在启动时加载指定的驱动程序。下面这个函数,主要实现系统启动时指定加载的驱动程序。代码如下:

#001  VOID

#002  FASTCALL

#003  IopInitializeSystemDrivers(VOID)

#004  {

#005       PSERVICE_GROUP CurrentGroup;

#006       PSERVICE CurrentService;

#007       NTSTATUS Status;

#008       ULONG i;

#009       PLIST_ENTRY NextGroupEntry, NextServiceEntry;

#010 

#011       DPRINT("IopInitializeSystemDrivers()/n");

#012 

 

循环地加载所有当前启动时加载的驱动程序。

#013       /* Start looping */

#014       for (NextGroupEntry = GroupListHead.Flink;

#015              NextGroupEntry != &GroupListHead;

#016              NextGroupEntry = NextGroupEntry->Flink)

#017       {

#018              /* Get the entry */

#019              CurrentGroup = CONTAINING_RECORD(NextGroupEntry,

#020                     SERVICE_GROUP,

#021                     GroupListEntry);

#022 

#023              DPRINT("Group: %wZ/n", &CurrentGroup->GroupName);

#024 

#025              /* Load all drivers with a valid tag */

#026              for (i = 0; i < CurrentGroup->TagCount; i++)

#027              {

#028                     /* Start looping */

#029                     for (NextServiceEntry = ServiceListHead.Flink;

#030                            NextServiceEntry != &ServiceListHead;

#031                            NextServiceEntry = NextServiceEntry->Flink)

#032                     {

 

获取当服务的入口。

#033                            /* Get the entry */

#034                            CurrentService = CONTAINING_RECORD(NextServiceEntry,

#035                                   SERVICE,

#036                                   ServiceListEntry);

#037 

#038                            if ((!RtlCompareUnicodeString(&CurrentGroup->GroupName,

#039                                   &CurrentService->ServiceGroup,

#040                                   TRUE)) &&

#041                                   (CurrentService->Start == SERVICE_SYSTEM_START) &&

#042                                   (CurrentService->Tag == CurrentGroup->TagArray[i]))

#043 

#044                            {

#045                                   DPRINT("  Path: %wZ/n", &CurrentService->RegistryPath);

 

加载当前服务驱动程序。

#046                                   Status = IopLoadDriver(CurrentService);

#047                            }

#048                     }

#049              }

#050 

 

加载所有没有标记的驱动程序。

#051              /* Load all drivers without a tag or with an invalid tag */

#052              for (NextServiceEntry = ServiceListHead.Flink;

#053                     NextServiceEntry != &ServiceListHead;

#054                     NextServiceEntry = NextServiceEntry->Flink)

#055              {

#056                     /* Get the entry */

#057                     CurrentService = CONTAINING_RECORD(NextServiceEntry,

#058                            SERVICE,

#059                            ServiceListEntry);

#060 

#061                     if ((!RtlCompareUnicodeString(&CurrentGroup->GroupName,

#062                            &CurrentService->ServiceGroup,

#063                            TRUE)) &&

#064                            (CurrentService->Start == SERVICE_SYSTEM_START))

#065                     {

#066                            for (i = 0; i < CurrentGroup->TagCount; i++)

#067                            {

#068                                   if (CurrentGroup->TagArray[i] == CurrentService->Tag)

#069                                   {

#070                                          break;

#071                                   }

#072                            }

#073 

#074                            if (i >= CurrentGroup->TagCount)

#075                            {

#076                                   DPRINT("  Path: %wZ/n", &CurrentService->RegistryPath);

 

开始加载当前驱动程序。

#077                                   Status = IopLoadDriver(CurrentService);

#078                            }

#079                     }

#080              }

#081       }

#082 

#083       DPRINT("IopInitializeSystemDrivers() done/n");

#084  }

#085  

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

caimouse

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值