通过WFP,我们可以编译得到sys驱动文件。此时需要我们把sys驱动文件部署到目标主机上,本文介绍部署的方式方法。

术语

host computer: 宿主主机,开发、编译驱动的主机
target/test computer:目标主机,安装驱动产品的主机
deploying the driver:部署过程,将宿主主机编译得到的驱动安装到目标主机的过程。

实测发现,当目标主机为 Windows 7时,部署驱动时会相当简单。

步骤

  1. 在目标主机,以管理员权限打开cmd,输入:
 bcdedit /set TESTSIGNING ON

但是,此时一般都会报错:

设置元素数据时出错。
该值受安全引导策略保护,无法进行修改或删除。

方法:重启系统,进入BIOS,找到Security——Secure Boot,将Secure Boot Control改为Disabled(一般默认为Enabled),按F10保存退出进入系统。

PS C:\WINDOWS\system32> bcdedit /set TESTSIGNING ON
操作成功完成。
  1. 编译msnmntr项目
    下载微软官方项目——msnmntr
    https://github.com/Microsoft/Windows-driver-samples
    msn项目目录为 network/trans/msnmntr
    使用vs2017打开该项目的.sln文件
    先编译msnmntr驱动项目。
    编译过程有几个注意点:
    • 设置驱动的目标平台为Windows 7
    • 设置驱动版本为release,x64
    • 设置msnmntr.inf文件,把DriverVer的值改成一个靠近当前时间的时间值,否则会编译报错,讲时间错误。
      WFP(三)——编译、部署驱动文件*.sys——微软msnmntr项目
      编译成功后,会得到如下文件:
      WFP(三)——编译、部署驱动文件*.sys——微软msnmntr项目
      将这些文件拷贝至目标主机。在目标主机右键inf文件,选择安装即可。
      同时将驱动的pdb文件拷贝到目标主机,这个文件可以用于获取驱动的输出。
      WFP(三)——编译、部署驱动文件*.sys——微软msnmntr项目
  2. 试运行msnmntr服务
    使用管理员权限,打开powershell
    输入net start msnmntr
    输出:msnmntr服务已经启动成功 说明驱动安装成功。
    如果输出发生系统错误 1275,那么需要做如下检查:
  • 是否禁止驱动检查
  • 是否生成x64的驱动文件,编译过程中是否是64位编译
  • 编译过程中是否配置好目标平台为windows 7.
  1. 编译monitor项目,这个项目是规则库的管理工具
    注意配置目标平台为windows 7,编译器为x64。

  2. 将得到的monitor.exe复制到目标主机

  3. 把traceview.exe拷贝到目标主机,该文件在 C:\Program Files (x86)\Windows Kits\10\Tools\x64 目录下

  4. 打开命令行

PS C:\Windows\system32> cd C:\Users\jmh081801\Desktop\msnmntr
PS C:\Users\jmh081801\Desktop\msnmntr> .\monitor.exe addcallouts
PS C:\Users\jmh081801\Desktop\msnmntr> .\monitor.exe
PS C:\Users\jmh081801\Desktop\msnmntr> .\monitor.exe
PS C:\Users\jmh081801\Desktop\msnmntr> .\monitor.exe addcallouts
Opening Filtering Engine
Starting Transaction for adding callouts
Successfully started the Transaction
Adding Persistent Flow Established callout through the Filtering Engine
Successfully Added Persistent Flow Established callout.
Adding Persistent Stream callout through the Filtering Engine
Successfully Added Persistent Stream callout.
Committing Transaction
Successfully Committed Transaction.

可以看到一开始运行monitor.exe时没有任何结果输出,这是因为缺乏vc++2015的运行库。安装好对应的运行库即可。

最后一条命令就是安装好运行库后,成功运行的输出。
8. 添加监控,例如chrome.exe

PS C:\Users\jmh081801\Desktop\msnmntr> .\monitor.exe monitor "C:\Program Files (x86)\Google\Chrome\Application\chrome.ex
e"
Opening Filtering Engine
Successfully opened Filtering Engine
Looking up Application ID from BFE
Successfully retrieved Application ID
Opening Monitor Sample Device
Successfully opened Monitor Device
Adding Filters through the Filtering Engine
Starting Transaction
Successfully Started Transaction
Adding Sublayer
Sucessfully added Sublayer
Adding Flow Established Filter
Successfully added Flow Established filter
Adding Stream Filter
Successfully added Stream filter
Committing Transaction
Successfully Committed Transaction
Successfully added Filters through the Filtering Engine
Enabling monitoring through the Monitor Sample Device
Successfully enabled monitoring.
Events will be traced through WMI. Please press any key to exit and cleanup filters.

运行chrome.exe,访问网页看看效果。在traceview.exe看看效果。。。。。

WFP(三)——编译、部署驱动文件*.sys——微软msnmntr项目

相关文章:

  • 2022-12-23
  • 2022-01-10
  • 2021-04-28
  • 2021-07-13
  • 2021-11-17
  • 2022-03-01
  • 2021-11-06
猜你喜欢
  • 2021-09-03
  • 2021-08-30
  • 2022-12-23
  • 2021-09-07
  • 2022-12-23
  • 2021-10-06
  • 2021-04-02
相关资源
相似解决方案