ntdll/tests: Add more tests for SystemHandleInformation.
Signed-off-by: Sebastian Lackner <sebastian@fds-team.de> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
723146ca6d
commit
e4e906c871
@ -474,30 +474,62 @@ static void test_query_module(void)
|
|||||||
static void test_query_handle(void)
|
static void test_query_handle(void)
|
||||||
{
|
{
|
||||||
NTSTATUS status;
|
NTSTATUS status;
|
||||||
ULONG ReturnLength;
|
ULONG ExpectedLength, ReturnLength;
|
||||||
ULONG SystemInformationLength = sizeof(SYSTEM_HANDLE_INFORMATION);
|
ULONG SystemInformationLength = sizeof(SYSTEM_HANDLE_INFORMATION);
|
||||||
SYSTEM_HANDLE_INFORMATION* shi = HeapAlloc(GetProcessHeap(), 0, SystemInformationLength);
|
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 */
|
/* Request the needed length : a SystemInformationLength greater than one struct sets ReturnLength */
|
||||||
|
ReturnLength = 0xdeadbeef;
|
||||||
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
|
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
|
||||||
todo_wine ok( status == STATUS_INFO_LENGTH_MISMATCH, "Expected STATUS_INFO_LENGTH_MISMATCH, got %08x\n", status);
|
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;
|
SystemInformationLength = ReturnLength;
|
||||||
shi = HeapReAlloc(GetProcessHeap(), 0, shi , SystemInformationLength);
|
shi = HeapReAlloc(GetProcessHeap(), 0, shi , SystemInformationLength);
|
||||||
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
|
|
||||||
if (status != STATUS_INFO_LENGTH_MISMATCH) /* vista */
|
|
||||||
{
|
|
||||||
ok( status == STATUS_SUCCESS,
|
|
||||||
"Expected STATUS_SUCCESS, got %08x\n", status);
|
|
||||||
|
|
||||||
/* Check if we have some return values */
|
ReturnLength = 0xdeadbeef;
|
||||||
trace("Number of Handles : %d\n", shi->Count);
|
status = pNtQuerySystemInformation(SystemHandleInformation, shi, SystemInformationLength, &ReturnLength);
|
||||||
todo_wine
|
while (status == STATUS_INFO_LENGTH_MISMATCH) /* Vista / 2008 */
|
||||||
{
|
{
|
||||||
/* our implementation is a stub for now */
|
SystemInformationLength *= 2;
|
||||||
ok( shi->Count > 1, "Expected more than 1 handles, got (%d)\n", shi->Count);
|
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);
|
||||||
|
|
||||||
|
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);
|
HeapFree( GetProcessHeap(), 0, shi);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user