From 3a0f9f2fa06e9d3010714a0cd84bf9ae93243b39 Mon Sep 17 00:00:00 2001 From: Timo Kreuzer Date: Sat, 26 Jul 2025 11:19:30 +0300 Subject: [PATCH] [NTOS:EX] Fix query of SystemLookasideInformation Prevents a failed ASSSERT --- ntoskrnl/ex/sysinfo.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ntoskrnl/ex/sysinfo.c b/ntoskrnl/ex/sysinfo.c index 85d8fe06a08..b05328d0600 100644 --- a/ntoskrnl/ex/sysinfo.c +++ b/ntoskrnl/ex/sysinfo.c @@ -2120,7 +2120,7 @@ ExpCopyLookasideInformation( /* Loop as long as we have lookaside lists and free array elements */ for (ListEntry = ListHead->Flink; (ListEntry != ListHead) && (Remaining > 0); - ListEntry = ListEntry->Flink, Remaining--) + ListEntry = ListEntry->Flink, Info++, Remaining--) { LookasideList = CONTAINING_RECORD(ListEntry, GENERAL_LOOKASIDE, ListEntry); @@ -2165,6 +2165,13 @@ QSI_DEF(SystemLookasideInformation) KIRQL OldIrql; NTSTATUS Status; + /* Calculate how many items we can store */ + Remaining = MaxCount = Size / sizeof(SYSTEM_LOOKASIDE_INFORMATION); + if (Remaining == 0) + { + return STATUS_INFO_LENGTH_MISMATCH; + } + /* First we need to lock down the memory, since we are going to access it at high IRQL */ PreviousMode = ExGetPreviousMode(); @@ -2180,13 +2187,6 @@ QSI_DEF(SystemLookasideInformation) return Status; } - /* Calculate how many items we can store */ - Remaining = MaxCount = Size / sizeof(SYSTEM_LOOKASIDE_INFORMATION); - if (Remaining == 0) - { - goto Leave; - } - /* Copy info from pool lookaside lists */ ExpCopyLookasideInformation(&Info, &Remaining,