From 04d07d65e3e411d807a0447f5bc892ec669640f1 Mon Sep 17 00:00:00 2001 From: Huw Davies Date: Fri, 24 Jun 2022 11:06:39 +0100 Subject: [PATCH] wow64: Report the correct size for SystemLogicalProcessorInformationEx. Spotted by Brendan Shanks. Signed-off-by: Huw Davies --- dlls/ntdll/tests/info.c | 5 +++-- dlls/wow64/system.c | 6 +++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c index e019fcb5975..c367b4f372e 100644 --- a/dlls/ntdll/tests/info.c +++ b/dlls/ntdll/tests/info.c @@ -1168,7 +1168,7 @@ static void test_query_logicalprocex(void) { SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *infoex, *infoex_public, *infoex_core, *infoex_numa, *infoex_cache, *infoex_package, *infoex_group, *ex; - DWORD relationship, len, len_public, len_core, len_numa, len_cache, len_package, len_group, len_union; + DWORD relationship, len, len_public, len_core, len_numa, len_cache, len_package, len_group, len_union, ret_len; unsigned int i, j; NTSTATUS status; BOOL ret; @@ -1226,8 +1226,9 @@ static void test_query_logicalprocex(void) infoex_group = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len_group); relationship = RelationAll; - status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), infoex, len, &len); + status = pNtQuerySystemInformationEx(SystemLogicalProcessorInformationEx, &relationship, sizeof(relationship), infoex, len, &ret_len); ok(status == STATUS_SUCCESS, "got 0x%08lx\n", status); + ok(ret_len == len, "got %08lx expected %08lx\n", ret_len, len); ret = pGetLogicalProcessorInformationEx(RelationAll, infoex_public, &len_public); ok(ret, "got %d, error %ld\n", ret, GetLastError()); diff --git a/dlls/wow64/system.c b/dlls/wow64/system.c index 0727bc25bbe..c5c1563afc2 100644 --- a/dlls/wow64/system.c +++ b/dlls/wow64/system.c @@ -617,7 +617,7 @@ NTSTATUS WINAPI wow64_NtQuerySystemInformationEx( UINT *args ) status = NtQuerySystemInformationEx( class, &handle, sizeof(handle), info, size, &size ); if (!status) { - for (pos = pos32 = 0; pos < size && pos32 < len; pos += ex->Size, pos32 += size32) + for (pos = pos32 = 0; pos < size; pos += ex->Size, pos32 += size32) { ex = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX *)((char *)info + pos); ex32 = (SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX32 *)((char *)info32 + pos32); @@ -645,8 +645,8 @@ NTSTATUS WINAPI wow64_NtQuerySystemInformationEx( UINT *args ) } if (pos32 + size32 <= len) put_logical_proc_info_ex( ex32, ex ); } - if (pos < size) status = STATUS_INFO_LENGTH_MISMATCH; - else size = pos32; + if (pos32 > len) status = STATUS_INFO_LENGTH_MISMATCH; + size = pos32; } if (retlen) *retlen = size; return status;