一、
Microsoft 官网介绍 https://docs.microsoft.com/en-us/windows/win32/services/protecting-anti-malware-services-
参考网址 https://blog.tofile.dev/2020/12/16/elam.html 它的代码在:https://github.com/pathtofile/PPLRunner
二、开发阶段注意事项
(1)目标机可以用 测试模式启动 bcdedit /set testsigning on 重启生效。
生成签名证书过程:
Windows_Engineering_Guide_for_Antimalware_Integration_with_Windows_v2.11.pdf 里面有标准流程(第11章节)
Testing & Development
To create a suitable test signature for use with your ELAM driver during development and testing, please follow the instructions below.
1. bcdedit /set testsigning on
2. makecert.exe -r -pe -a sha256 -len 2048 -eku 1.3.6.1.5.5.7.3.3,1.3.6.1.4.1.311.61.4.1 -n CN=Foo - sv elam.pvk elam.cer
3. pvk2pfx.exe -pvk elam.pvk -spc elam.cer -pi <Password entered during makecert prompt> -spc elam.cer -pfx elam.pfx
4. signtool sign /fd sha256 /f elam.pfx /p <Password entered during makecert prompt> elam.sys
(2)服务程序必须是64bit的(windows 11系统上),我这边是用delphi10.4.1 开发的服务程序,UpdateProcThreadAttribute 这个api 导出时有些问题,做过相应修改。
api一定要按照msdn上的声明来,避免踩坑。
(3)elam驱动 微软有例子:https://github.com/Microsoft/Windows-driver-samples/tree/master/security/elam
三、发布阶段注意事项
elam的签名是微软负责的,必须经过一系列测试然后再提交给微软去签名,微软官网的介绍流程有兼容以前的考虑,完全按照它的步骤来会有很多坑。
我参考了 https://www.cnblogs.com/talenth/p/15634364.html,我用的是 VHLK,https://docs.microsoft.com/en-ca/windows-hardware/test/hlk/getstarted/getstarted-vhlk
安装好微软的Hyper-V虚拟机,直接导入即可。
\\服务器主机名(或者ip)\HLKInstall\Client\Setup.cmd 执行后 后续命令不需要执行了。
INI的写法与配置也可以参考: Windows_Engineering_Guide_for_Antimalware_Integration_with_Windows_v2.11.pdf 第11章节的
To create and sign an ELAM driver
注意: 为保证elam驱动程序 hlk测试正确,要先安装好使用此elam 驱动文件的产品,不然很容易出现找不到elam驱动文件的情况,无法测试下去。
step example:
1:安装 xxx
2:开启测试模式,给elam签名,并安装elam驱动 (用.inf安装);并按提示重启.
3: Powershell 开启 hyper-v 虚拟机.
4: 虚拟机配置链接 https://docs.microsoft.com/en-ca/windows-hardware/test/hlk/getstarted/getstarted-vhlk
5:安装客户端.\\服务器主机名(或者ip)\HLKInstall\Client\Setup.cmd