Commit e4e906c8 authored by Sebastian Lackner's avatar Sebastian Lackner Committed by Alexandre Julliard

ntdll/tests: Add more tests for SystemHandleInformation.

parent 723146ca
......@@ -474,30 +474,62 @@ static void test_query_module(void)
static void test_query_handle(void)
{
NTSTATUS status;
ULONG ReturnLength;
ULONG ExpectedLength, ReturnLength;
ULONG SystemInformationLength = sizeof(SYSTEM_HANDLE_INFORMATION);
SYSTEM_HANDLE_INFORMATION* shi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
HANDLE EventHandle;
BOOL found;
INT i;
EventHandle = CreateEventA(NULL, FALSE, FALSE, NULL);
ok( EventHandle != NULL, "CreateEventA failed %u\n", GetLastError() );
/* Request the needed length : a SystemInformationLength greater than one struct sets ReturnLength */
ReturnLength = 0xdeadbeef;
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
todo_wine ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
ok( ReturnLength != 0xdeadbeef, "Expected valid ReturnLength\n" );
SystemInformationLength = ReturnLength;
shi = HeapReAlloc(GetProcessHeap(), 0, shi , SystemInformationLength);
ReturnLength = 0xdeadbeef;
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
if (status != STATUS_INFO_LENGTH_MISMATCH) /* vista */
while (status == STATUS_INFO_LENGTH_MISMATCH) /* Vista / 2008 */
{
ok( status == STATUS_SUCCESS,
"Expected STATUS_SUCCESS, got %08x\n", status);
SystemInformationLength *= 2;
shi = HeapReAlloc(GetProcessHeap(), 0, shi, SystemInformationLength);
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
}
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
ExpectedLength = FIELD_OFFSET(SYSTEM_HANDLE_INFORMATION, Handle[shi->Count]);
todo_wine ok( ReturnLength == ExpectedLength || broken(ReturnLength == ExpectedLength - sizeof(DWORD)), /* Vista / 2008 */
"Expected length %u, got %u\n", ExpectedLength, ReturnLength );
todo_wine ok( shi->Count > 1, "Expected more than 1 handle, got %u\n", shi->Count );
for (i = 0, found = FALSE; i < shi->Count && !found; i++)
found = (shi->Handle[i].OwnerPid == GetCurrentProcessId()) &&
((HANDLE)(ULONG_PTR)shi->Handle[i].HandleValue == EventHandle);
todo_wine ok( found, "Expected to find event handle in handle list\n" );
CloseHandle(EventHandle);
/* Check if we have some return values */
trace("Number of Handles : %d\n", shi->Count);
todo_wine
{
/* our implementation is a stub for now */
ok( shi->Count > 1, "Expected more than 1 handles, got (%d)\n", shi->Count);
}
ReturnLength = 0xdeadbeef;
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
while (status == STATUS_INFO_LENGTH_MISMATCH) /* Vista / 2008 */
{
SystemInformationLength *= 2;
shi = HeapReAlloc(GetProcessHeap(), 0, shi, SystemInformationLength);
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
}
ok( status == STATUS_SUCCESS, "Expected STATUS_SUCCESS, got %08x\n", status );
for (i = 0, found = FALSE; i < shi->Count && !found; i++)
found = (shi->Handle[i].OwnerPid == GetCurrentProcessId()) &&
((HANDLE)(ULONG_PTR)shi->Handle[i].HandleValue == EventHandle);
ok( !found, "Unexpectedly found event handle in handle list\n" );
status = pNtQuerySystemInformation(SystemHandleInformation, NULL, SystemInformationLength, &ReturnLength);
ok( status == STATUS_ACCESS_VIOLATION, "Expected STATUS_ACCESS_VIOLATION, got %08x\n", status );
HeapFree( GetProcessHeap(), 0, shi);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment