From 58d276b2d177060c535150d30ab7057364a55972 Mon Sep 17 00:00:00 2001 From: Daniel Miller Date: Wed, 13 Sep 2023 17:15:03 -0500 Subject: [PATCH] Add debug-mode checks for bad accounting --- packetWin7/npf/npf/Openclos.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/packetWin7/npf/npf/Openclos.c b/packetWin7/npf/npf/Openclos.c index da719d42..310e773e 100644 --- a/packetWin7/npf/npf/Openclos.c +++ b/packetWin7/npf/npf/Openclos.c @@ -3438,41 +3438,46 @@ VOID NPF_UpdateTimestampModeCounts( ULONG newmode, ULONG oldmode) { + LONG result = 0; if (pFiltMod == NULL || newmode == oldmode) return; switch (newmode) { case TIMESTAMPMODE_UNSET: + result = 1; break; case TIMESTAMPMODE_SINGLE_SYNCHRONIZATION: - InterlockedIncrement(&pFiltMod->nTimestampQPC); + result = InterlockedIncrement(&pFiltMod->nTimestampQPC); break; case TIMESTAMPMODE_QUERYSYSTEMTIME: - InterlockedIncrement(&pFiltMod->nTimestampQST); + result = InterlockedIncrement(&pFiltMod->nTimestampQST); break; case TIMESTAMPMODE_QUERYSYSTEMTIME_PRECISE: - InterlockedIncrement(&pFiltMod->nTimestampQST_Precise); + result = InterlockedIncrement(&pFiltMod->nTimestampQST_Precise); break; default: NT_ASSERT(FALSE); break; } + NT_ASSERT(result > 0); switch (oldmode) { case TIMESTAMPMODE_UNSET: + result = 0; break; case TIMESTAMPMODE_SINGLE_SYNCHRONIZATION: - InterlockedDecrement(&pFiltMod->nTimestampQPC); + result = InterlockedDecrement(&pFiltMod->nTimestampQPC); break; case TIMESTAMPMODE_QUERYSYSTEMTIME: - InterlockedDecrement(&pFiltMod->nTimestampQST); + result = InterlockedDecrement(&pFiltMod->nTimestampQST); break; case TIMESTAMPMODE_QUERYSYSTEMTIME_PRECISE: - InterlockedDecrement(&pFiltMod->nTimestampQST_Precise); + result = InterlockedDecrement(&pFiltMod->nTimestampQST_Precise); break; default: NT_ASSERT(FALSE); break; } + NT_ASSERT(result >= 0); }