The CodeQL static analysis tests used for driver certification suggest us to replace the deprecated ExAllocatePoolWithTag function with ExAllocatePoolZero or ExAllocatePool2. The main reason is that those replacements will zero the allocated memory by default.
ExAllocatePool2 is only available on hosts >= 2004, while we intend to support older versions as well. For this reason, we'll use
ExAllocatePoolZero instead.
For Windows versions prior to 2004, we'll also have to define POOL_ZERO_DOWN_LEVEL_SUPPORT and call
ExInitializeDriverRuntime(DrvRtPoolNxOptIn) during driver initialization [1]. Apart from zero-ing the allocated memory, this
also marks it as non-executable by default.
We'll rename the Malloc and NbdMalloc ExAllocatePoolWithTag wrappers to MallocZero and NbdMallocZero to explicitly tell that the allocated memory is zero-ed out. At the same time, we're going to drop some RtlZeroMemory calls that become redundant.
The CodeQL static analysis tests used for driver certification suggest us to replace the deprecated ExAllocatePoolWithTag function with ExAllocatePoolZero or ExAllocatePool2. The main reason is that those replacements will zero the allocated memory by default.
ExAllocatePool2 is only available on hosts >= 2004, while we intend to support older versions as well. For this reason, we'll use ExAllocatePoolZero instead.
For Windows versions prior to 2004, we'll also have to define POOL_ZERO_DOWN_LEVEL_SUPPORT and call ExInitializeDriverRuntime(DrvRtPoolNxOptIn) during driver initialization [1]. Apart from zero-ing the allocated memory, this also marks it as non-executable by default.
We'll rename the Malloc and NbdMalloc ExAllocatePoolWithTag wrappers to MallocZero and NbdMallocZero to explicitly tell that the allocated memory is zero-ed out. At the same time, we're going to drop some RtlZeroMemory calls that become redundant.
[1] https://learn.microsoft.com/en-us/windows-hardware/drivers/kernel/updating-deprecated-exallocatepool-calls#driver-updates-for-versions-of-windows-earlier-than-windows-10-version-2004
Signed-off-by: Lucian Petrut lpetrut@cloudbasesolutions.com