diff options
| author | Chris Kleynhans <[email protected]> | 2021-10-15 14:04:50 -0700 |
|---|---|---|
| committer | GitHub <[email protected]> | 2021-10-15 14:04:50 -0700 |
| commit | f5fb15f5913fea0a7ee00da5c566c0f614c34bd4 (patch) | |
| tree | 7c9d9cb7c844c6f330e2923141fda0b01d03dc49 | |
| parent | 7895dd22785ddba5e973662ed942be3b3452b89d (diff) | |
Replace regfltr sample calls to ExAllocatePoolWithTag with ExAllocatePoolZero. (#501)
| -rw-r--r-- | general/registry/regfltr/sys/capture.c | 16 | ||||
| -rw-r--r-- | general/registry/regfltr/sys/driver.c | 6 | ||||
| -rw-r--r-- | general/registry/regfltr/sys/regfltr.vcxproj | 4 | ||||
| -rw-r--r-- | general/registry/regfltr/sys/txr.c | 9 | ||||
| -rw-r--r-- | general/registry/regfltr/sys/util.c | 12 |
5 files changed, 26 insertions, 21 deletions
diff --git a/general/registry/regfltr/sys/capture.c b/general/registry/regfltr/sys/capture.c index 7b350e73..5d4d53d5 100644 --- a/general/registry/regfltr/sys/capture.c +++ b/general/registry/regfltr/sys/capture.c @@ -443,9 +443,9 @@ Return Value: return Status; } - TempBuffer = (PCALLBACK_CONTEXT) ExAllocatePoolWithTag( - PagedPool, - Length, + TempBuffer = (PCALLBACK_CONTEXT) ExAllocatePoolZero( + PagedPool, + Length, PoolTag); // @@ -550,16 +550,14 @@ Return Value: DestString->Length = SourceString->Length; DestString->MaximumLength = SourceString->Length + sizeof(WCHAR); - - DestString->Buffer = (PWSTR) ExAllocatePoolWithTag( - PagedPool, - DestString->MaximumLength, + + DestString->Buffer = (PWSTR) ExAllocatePoolZero( + PagedPool, + DestString->MaximumLength, PoolTag); if (DestString->Buffer != NULL) { - RtlZeroMemory(DestString->Buffer, DestString->MaximumLength); - // // It's a good practice to keep the contents of a try-except block to // the bare minimum. By keeping the pool allocation call outside of the diff --git a/general/registry/regfltr/sys/driver.c b/general/registry/regfltr/sys/driver.c index d169a1be..1cda2103 100644 --- a/general/registry/regfltr/sys/driver.c +++ b/general/registry/regfltr/sys/driver.c @@ -163,6 +163,12 @@ Return value: "RegFltr: Use ed nt!Kd_IHVDRIVER_Mask 8 to enable more detailed printouts\n"); // + // Default to NonPagedPoolNx for non paged pool allocations where supported. + // + + ExInitializeDriverRuntime(DrvRtPoolNxOptIn); + + // // Create our device object. // diff --git a/general/registry/regfltr/sys/regfltr.vcxproj b/general/registry/regfltr/sys/regfltr.vcxproj index 957be3ba..437752a8 100644 --- a/general/registry/regfltr/sys/regfltr.vcxproj +++ b/general/registry/regfltr/sys/regfltr.vcxproj @@ -177,24 +177,28 @@ <ClCompile> <ExceptionHandling> </ExceptionHandling> + <PreprocessorDefinitions>POOL_NX_OPTIN;POOL_ZERO_DOWN_LEVEL_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <ClCompile> <ExceptionHandling> </ExceptionHandling> + <PreprocessorDefinitions>POOL_NX_OPTIN;POOL_ZERO_DOWN_LEVEL_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'"> <ClCompile> <ExceptionHandling> </ExceptionHandling> + <PreprocessorDefinitions>POOL_NX_OPTIN;POOL_ZERO_DOWN_LEVEL_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> </ItemDefinitionGroup> <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'"> <ClCompile> <ExceptionHandling> </ExceptionHandling> + <PreprocessorDefinitions>POOL_NX_OPTIN;POOL_ZERO_DOWN_LEVEL_SUPPORT;%(PreprocessorDefinitions)</PreprocessorDefinitions> </ClCompile> </ItemDefinitionGroup> <ItemGroup> diff --git a/general/registry/regfltr/sys/txr.c b/general/registry/regfltr/sys/txr.c index 6fd3c8a6..63a2f79f 100644 --- a/general/registry/regfltr/sys/txr.c +++ b/general/registry/regfltr/sys/txr.c @@ -61,21 +61,20 @@ Return Value: // // Create the registry callback context and the transaction callback context. // - + CallbackCtx = CreateCallbackContext(CALLBACK_MODE_TRANSACTION_ENLIST, CALLBACK_ALTITUDE); if (CallbackCtx == NULL) { goto Exit; } - RMCallbackCtx = (PRMCALLBACK_CONTEXT) ExAllocatePoolWithTag ( - PagedPool, - sizeof(RMCALLBACK_CONTEXT), + RMCallbackCtx = (PRMCALLBACK_CONTEXT) ExAllocatePoolZero ( + PagedPool, + sizeof(RMCALLBACK_CONTEXT), REGFLTR_CONTEXT_POOL_TAG); if (RMCallbackCtx == NULL) { goto Exit; } - RtlZeroMemory(RMCallbackCtx, sizeof(RMCALLBACK_CONTEXT)); CallbackCtx->RMCallbackCtx = RMCallbackCtx; // diff --git a/general/registry/regfltr/sys/util.c b/general/registry/regfltr/sys/util.c index 068416c8..5a3db344 100644 --- a/general/registry/regfltr/sys/util.c +++ b/general/registry/regfltr/sys/util.c @@ -91,18 +91,16 @@ Return Value: PCALLBACK_CONTEXT CallbackCtx = NULL; NTSTATUS Status; BOOLEAN Success = FALSE; - - CallbackCtx = (PCALLBACK_CONTEXT) ExAllocatePoolWithTag ( - PagedPool, - sizeof(CALLBACK_CONTEXT), + + CallbackCtx = (PCALLBACK_CONTEXT) ExAllocatePoolZero ( + PagedPool, + sizeof(CALLBACK_CONTEXT), REGFLTR_CONTEXT_POOL_TAG); - if (CallbackCtx == NULL) { + if (CallbackCtx == NULL) { ErrorPrint("CreateCallbackContext failed due to insufficient resources."); goto Exit; } - - RtlZeroMemory(CallbackCtx, sizeof(CALLBACK_CONTEXT)); CallbackCtx->CallbackMode = CallbackMode; CallbackCtx->ProcessId = PsGetCurrentProcessId(); |
