[PATCH] ntdll/tests: Fix SYSTEM_CACHE_INFORMATION failures [try 3]
Detlef Riekenberg
wine.dev at web.de
Wed Jan 16 16:56:43 CST 2013
There is no documentation for the 64 bit version of SYSTEM_CACHE_INFORMATION.
I just used the 32bit version with an extra "unknown" ULONG array.
sorry for the test failures in the first try
try 2:
Handle partial results also on 32bit and avoid crashes on buffers with length 0
try 3:
Add an extra ULONG array on WIN64 instead of changing the size of the "unused" array
--
By by ... Detlef
---
dlls/ntdll/tests/info.c | 53 ++++++++++++++++++++++++++++++++++++++--------
include/winternl.h | 3 +-
2 files changed, 45 insertions(+), 11 deletions(-)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index 47e5587..1c6ba25 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -505,18 +505,51 @@ static void test_query_cache(void)
{
NTSTATUS status;
ULONG ReturnLength;
- SYSTEM_CACHE_INFORMATION sci;
-
- status = pNtQuerySystemInformation(SystemCacheInformation, &sci, 0, &ReturnLength);
- ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
+ BYTE buffer[128];
+ SYSTEM_CACHE_INFORMATION *sci = (SYSTEM_CACHE_INFORMATION *) buffer;
+ ULONG expected;
+ INT i;
+
+ /* the large SYSTEM_CACHE_INFORMATION on WIN64 is not documented */
+ expected = sizeof(SYSTEM_CACHE_INFORMATION);
+ for (i = sizeof(buffer); i>= expected; i--)
+ {
+ ReturnLength = 0xdeadbeef;
+ status = pNtQuerySystemInformation(SystemCacheInformation, sci, i, &ReturnLength);
+ ok(!status && (ReturnLength == expected),
+ "%d: got 0x%x and %u (expected STATUS_SUCCESS and %u)\n", i, status, ReturnLength, expected);
+ }
- status = pNtQuerySystemInformation(SystemCacheInformation, &sci, sizeof(sci), &ReturnLength);
- ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
- ok( sizeof(sci) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
+ /* buffer to small for the full result.
+ Upto win7, the function succeed with a partial result. */
+ status = pNtQuerySystemInformation(SystemCacheInformation, sci, i, &ReturnLength);
+ if (!status)
+ {
+ expected = offsetof(SYSTEM_CACHE_INFORMATION, MinimumWorkingSet);
+ for (; i>= expected; i--)
+ {
+ ReturnLength = 0xdeadbeef;
+ status = pNtQuerySystemInformation(SystemCacheInformation, sci, i, &ReturnLength);
+ ok(!status && (ReturnLength == expected),
+ "%d: got 0x%x and %u (expected STATUS_SUCCESS and %u)\n", i, status, ReturnLength, expected);
+ }
+ }
- status = pNtQuerySystemInformation(SystemCacheInformation, &sci, sizeof(sci) + 2, &ReturnLength);
- ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status);
- ok( sizeof(sci) == ReturnLength, "Inconsistent length %d\n", ReturnLength);
+ /* buffer to small for the result. This call will always fail */
+ ReturnLength = 0xdeadbeef;
+ status = pNtQuerySystemInformation(SystemCacheInformation, sci, i, &ReturnLength);
+ ok( status == STATUS_INFO_LENGTH_MISMATCH &&
+ ((ReturnLength == expected) || broken(!ReturnLength) || broken(ReturnLength == 0xfffffff0)),
+ "%d: got 0x%x and %u (expected STATUS_INFO_LENGTH_MISMATCH and %u)\n", i, status, ReturnLength, expected);
+
+ if (0) {
+ /* This crash on some vista / win7 machines */
+ ReturnLength = 0xdeadbeef;
+ status = pNtQuerySystemInformation(SystemCacheInformation, sci, 0, &ReturnLength);
+ ok( status == STATUS_INFO_LENGTH_MISMATCH &&
+ ((ReturnLength == expected) || broken(!ReturnLength) || broken(ReturnLength == 0xfffffff0)),
+ "0: got 0x%x and %u (expected STATUS_INFO_LENGTH_MISMATCH and %u)\n", status, ReturnLength, expected);
+ }
}
static void test_query_interrupt(void)
diff --git a/include/winternl.h b/include/winternl.h
index 79078f0..b45a56c 100644
--- a/include/winternl.h
+++ b/include/winternl.h
@@ -1287,10 +1287,11 @@ typedef struct _SYSTEM_CACHE_INFORMATION {
ULONG CurrentSize;
ULONG PeakSize;
ULONG PageFaultCount;
-#ifndef _WIN64
ULONG MinimumWorkingSet;
ULONG MaximumWorkingSet;
ULONG unused[4];
+#ifdef _WIN64
+ ULONG unknown64[7];
#endif
} SYSTEM_CACHE_INFORMATION, *PSYSTEM_CACHE_INFORMATION;
--
1.7.5.4
More information about the wine-patches
mailing list