Skip to content

Commit

Permalink
Switch WSK Echosrv to ExAllocatePoolZero (#720)
Browse files Browse the repository at this point in the history
  • Loading branch information
thhous-msft authored May 11, 2022
1 parent cf17d8d commit ca1f038
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions network/wsk/echosrv/wsksmple.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ Revision History:
#pragma warning(disable:4201) // nameless struct/union
#pragma warning(disable:4214) // bit field types other than int

#define POOL_ZERO_DOWN_LEVEL_SUPPORT

#include <ntddk.h>
#include <wsk.h>

Expand Down Expand Up @@ -317,6 +319,8 @@ DriverEntry(
UNREFERENCED_PARAMETER(RegistryPath);

PAGED_CODE();

ExInitializeDriverRuntime(DrvRtPoolNxOptIn);

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

socketContext = ExAllocatePoolWithTag(
NonPagedPool, sizeof(*socketContext), WSKSAMPLE_SOCKET_POOL_TAG);
socketContext = ExAllocatePoolZero(
NonPagedPoolNx, sizeof(*socketContext), WSKSAMPLE_SOCKET_POOL_TAG);

if(socketContext != NULL) {

ULONG i;

RtlZeroMemory(socketContext, sizeof(WSKSAMPLE_SOCKET_CONTEXT));

socketContext->WorkQueue = WorkQueue;

for(i = 0; i < WSKSAMPLE_OP_COUNT; i++) {
Expand All @@ -507,8 +509,8 @@ WskSampleAllocateSocketContext(
}

if(BufferLength > 0) {
socketContext->OpContext[i].DataBuffer = ExAllocatePoolWithTag(
NonPagedPool, BufferLength, WSKSAMPLE_BUFFER_POOL_TAG);
socketContext->OpContext[i].DataBuffer = ExAllocatePoolUninitialized(
NonPagedPoolNx, BufferLength, WSKSAMPLE_BUFFER_POOL_TAG);
if(socketContext->OpContext[i].DataBuffer == NULL) {
goto failure;
}
Expand Down

0 comments on commit ca1f038

Please sign in to comment.