Skip to content

Commit ca1f038

Browse files
authored
Switch WSK Echosrv to ExAllocatePoolZero (#720)
1 parent cf17d8d commit ca1f038

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

network/wsk/echosrv/wsksmple.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ Revision History:
3838
#pragma warning(disable:4201) // nameless struct/union
3939
#pragma warning(disable:4214) // bit field types other than int
4040

41+
#define POOL_ZERO_DOWN_LEVEL_SUPPORT
42+
4143
#include <ntddk.h>
4244
#include <wsk.h>
4345

@@ -317,6 +319,8 @@ DriverEntry(
317319
UNREFERENCED_PARAMETER(RegistryPath);
318320

319321
PAGED_CODE();
322+
323+
ExInitializeDriverRuntime(DrvRtPoolNxOptIn);
320324

321325
// Allocate a socket context that will be used for queueing an operation
322326
// to setup a listening socket that will accept incoming connections
@@ -486,15 +490,13 @@ WskSampleAllocateSocketContext(
486490
// use multiple work queues (say a work queue per processor), a given
487491
// socket will/must always use the same work queue.
488492

489-
socketContext = ExAllocatePoolWithTag(
490-
NonPagedPool, sizeof(*socketContext), WSKSAMPLE_SOCKET_POOL_TAG);
493+
socketContext = ExAllocatePoolZero(
494+
NonPagedPoolNx, sizeof(*socketContext), WSKSAMPLE_SOCKET_POOL_TAG);
491495

492496
if(socketContext != NULL) {
493497

494498
ULONG i;
495499

496-
RtlZeroMemory(socketContext, sizeof(WSKSAMPLE_SOCKET_CONTEXT));
497-
498500
socketContext->WorkQueue = WorkQueue;
499501

500502
for(i = 0; i < WSKSAMPLE_OP_COUNT; i++) {
@@ -507,8 +509,8 @@ WskSampleAllocateSocketContext(
507509
}
508510

509511
if(BufferLength > 0) {
510-
socketContext->OpContext[i].DataBuffer = ExAllocatePoolWithTag(
511-
NonPagedPool, BufferLength, WSKSAMPLE_BUFFER_POOL_TAG);
512+
socketContext->OpContext[i].DataBuffer = ExAllocatePoolUninitialized(
513+
NonPagedPoolNx, BufferLength, WSKSAMPLE_BUFFER_POOL_TAG);
512514
if(socketContext->OpContext[i].DataBuffer == NULL) {
513515
goto failure;
514516
}

0 commit comments

Comments
 (0)