差異處
這裏顯示兩個版本的差異處。
cpp:wdm:hlk:nonpagedpool_error [2017/11/25 01:02] tony [How to resolve?] |
cpp:wdm:hlk:nonpagedpool_error [2023/06/25 09:48] |
||
---|---|---|---|
行 1: | 行 1: | ||
- | ====== Non-zero Code Integrity statistic found: Execute Pool Type Count ====== | ||
- | ===== Problem ===== | ||
- | 這是跑HLK HyperVisor Code Integrity Readiness Test中的錯誤。問題是Windows在Win8後基於安全性考量,建議將NonPagedPool改為使用NonPagedPoolNx。本篇文章主要分享我的改法。\\ | ||
- | \\ | ||
- | Note. 我的方法儘以解決問題為目的,可能非最佳解。 | ||
- | ===== How to resolve? ===== | ||
- | 由於我的情況不需要使用到Executable nonpaged pool,因此只需要將NonPagedPool改為NonPagedPoolNx即可。在我們的情況,有以下幾點要考慮: | ||
- | - WDK是6000,因此某些Macro要自己宣告。 | ||
- | - NonPagedPoolNx為win8以後才支援,但我們又要共用同一隻driver,因此code要針對版本做處理。 | ||
- | <code cpp> | ||
- | #define NonPagedPoolNx 512 | ||
- | #define NTDDI_WIN8 0x06020000 | ||
- | int getNonPagePoolNx(){ | ||
- | // Win8 later | ||
- | if( RtlIsNtDdiVersionAvailable(NTDDI_WIN8) ) { | ||
- | return NonPagedPoolNx; | ||
- | } | ||
- | return NonPagedPool; | ||
- | } | ||
- | </code> | ||
- | 假如系統版本大於等於Win8,我就會使用NonPagedPoolNx;反之則使用NonPagedPool。Client code如下: | ||
- | <code cpp> | ||
- | pci_bus_interface=(PCI_BUS_INTERFACE)ExAllocatePool(getNonPagePoolNx(), | ||
- | sizeof(PCI_BUS_INTERFACE)); | ||
- | </code> | ||
- | ===== Reference ===== | ||
- | * [[https://social.msdn.microsoft.com/Forums/windowsdesktop/en-US/d88ecbe5-7d30-425f-9bf8-7d4255f4774e/driver-verification-is-failing-due-to-code-integrity-check-with-latest-hlk-build?forum=wdk|Driver verification is failing due to code integrity check with latest HLK build.]] | ||
- | * [[https://msdn.microsoft.com/en-us/library/windows/hardware/ff561954(v=vs.85).aspx|MSDN - RtlIsNtDdiVersionAvailable routine]] | ||
- | * [[http://blog.csdn.net/wlj1973/article/details/5659124|判断操作系统的小技巧(来自WDK)]] | ||
- | * [[https://github.com/pixie16/xia-api/blob/master/software/inc/PciTypes.h|Github - PciTypes.h]] 用以參考OS version常數 | ||
- | * [[https://msdn.microsoft.com/en-us/library/windows/hardware/ff559707(v=vs.85).aspx|POOL_TYPE enumeration]] | ||
- | * [[https://docs.microsoft.com/en-us/windows-hardware/drivers/gettingstarted/platforms-and-driver-versions|Writing drivers for different versions of Windows]] | ||
- | * [[https://msdn.microsoft.com/en-us/library/windows/desktop/aa383745(v=vs.85).aspx|Using the Windows Headers]] |