Jacek Caban : ntoskrnl.exe/tests: Add more NtOpenThread tests.
Alexandre Julliard
julliard at winehq.org
Tue Apr 23 17:39:54 CDT 2019
Module: wine
Branch: master
Commit: c448550e7435946ac5501100ef06245fa9e5482e
URL: https://source.winehq.org/git/wine.git/?a=commit;h=c448550e7435946ac5501100ef06245fa9e5482e
Author: Jacek Caban <jacek at codeweavers.com>
Date: Tue Apr 23 16:22:50 2019 +0200
ntoskrnl.exe/tests: Add more NtOpenThread tests.
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/kernel32/thread.c | 2 +-
dlls/ntdll/tests/info.c | 61 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 62 insertions(+), 1 deletion(-)
diff --git a/dlls/kernel32/thread.c b/dlls/kernel32/thread.c
index ac5d465..d167abe 100644
--- a/dlls/kernel32/thread.c
+++ b/dlls/kernel32/thread.c
@@ -142,7 +142,7 @@ HANDLE WINAPI OpenThread( DWORD dwDesiredAccess, BOOL bInheritHandle, DWORD dwTh
attr.SecurityDescriptor = NULL;
attr.SecurityQualityOfService = NULL;
- cid.UniqueProcess = 0; /* FIXME */
+ cid.UniqueProcess = 0;
cid.UniqueThread = ULongToHandle(dwThreadId);
status = NtOpenThread( &handle, dwDesiredAccess, &attr, &cid );
if (status)
diff --git a/dlls/ntdll/tests/info.c b/dlls/ntdll/tests/info.c
index c278c8d..262d2f4 100644
--- a/dlls/ntdll/tests/info.c
+++ b/dlls/ntdll/tests/info.c
@@ -39,6 +39,8 @@ static ULONG (WINAPI * pNtGetCurrentProcessorNumber)(void);
static BOOL (WINAPI * pIsWow64Process)(HANDLE, PBOOL);
static BOOL (WINAPI * pGetLogicalProcessorInformationEx)(LOGICAL_PROCESSOR_RELATIONSHIP,SYSTEM_LOGICAL_PROCESSOR_INFORMATION_EX*,DWORD*);
static DEP_SYSTEM_POLICY_TYPE (WINAPI * pGetSystemDEPPolicy)(void);
+static NTSTATUS (WINAPI * pNtOpenThread)(HANDLE *, ACCESS_MASK, const OBJECT_ATTRIBUTES *, const CLIENT_ID *);
+static NTSTATUS (WINAPI * pNtQueryObject)(HANDLE, OBJECT_INFORMATION_CLASS, void *, ULONG, ULONG *);
static BOOL is_wow64;
@@ -84,6 +86,8 @@ static BOOL InitFunctionPtrs(void)
NTDLL_GET_PROC(NtCreateSection);
NTDLL_GET_PROC(NtMapViewOfSection);
NTDLL_GET_PROC(NtUnmapViewOfSection);
+ NTDLL_GET_PROC(NtOpenThread);
+ NTDLL_GET_PROC(NtQueryObject);
/* not present before XP */
pNtGetCurrentProcessorNumber = (void *) GetProcAddress(hntdll, "NtGetCurrentProcessorNumber");
@@ -2247,6 +2251,61 @@ static void test_query_data_alignment(void)
ok(value == 64, "Expected 64, got %u\n", value);
}
+static void test_thread_lookup(void)
+{
+ OBJECT_BASIC_INFORMATION obj_info;
+ THREAD_BASIC_INFORMATION info;
+ OBJECT_ATTRIBUTES attr;
+ CLIENT_ID cid;
+ HANDLE handle;
+ NTSTATUS status;
+
+ InitializeObjectAttributes( &attr, NULL, 0, NULL, NULL );
+ cid.UniqueProcess = ULongToHandle(GetCurrentProcessId());
+ cid.UniqueThread = ULongToHandle(GetCurrentThreadId());
+ status = pNtOpenThread(&handle, THREAD_QUERY_INFORMATION, &attr, &cid);
+ ok(!status, "NtOpenThread returned %#x\n", status);
+
+ status = pNtQueryObject(handle, ObjectBasicInformation, &obj_info, sizeof(obj_info), NULL);
+ ok(!status, "NtQueryObject returned: %#x\n", status);
+ ok(obj_info.GrantedAccess == (THREAD_QUERY_LIMITED_INFORMATION | THREAD_QUERY_INFORMATION)
+ || broken(obj_info.GrantedAccess == THREAD_QUERY_INFORMATION), /* winxp */
+ "GrantedAccess = %x\n", obj_info.GrantedAccess);
+
+ status = pNtQueryInformationThread(handle, ThreadBasicInformation, &info, sizeof(info), NULL);
+ ok(!status, "NtQueryInformationThread returned %#x\n", status);
+ ok(info.ClientId.UniqueProcess == ULongToHandle(GetCurrentProcessId()),
+ "UniqueProcess = %p expected %x\n", info.ClientId.UniqueProcess, GetCurrentProcessId());
+ ok(info.ClientId.UniqueThread == ULongToHandle(GetCurrentThreadId()),
+ "UniqueThread = %p expected %x\n", info.ClientId.UniqueThread, GetCurrentThreadId());
+ pNtClose(handle);
+
+ cid.UniqueProcess = 0;
+ cid.UniqueThread = ULongToHandle(GetCurrentThreadId());
+ status = pNtOpenThread(&handle, THREAD_QUERY_INFORMATION, &attr, &cid);
+ ok(!status, "NtOpenThread returned %#x\n", status);
+ status = pNtQueryInformationThread(handle, ThreadBasicInformation, &info, sizeof(info), NULL);
+ ok(!status, "NtQueryInformationThread returned %#x\n", status);
+ ok(info.ClientId.UniqueProcess == ULongToHandle(GetCurrentProcessId()),
+ "UniqueProcess = %p expected %x\n", info.ClientId.UniqueProcess, GetCurrentProcessId());
+ ok(info.ClientId.UniqueThread == ULongToHandle(GetCurrentThreadId()),
+ "UniqueThread = %p expected %x\n", info.ClientId.UniqueThread, GetCurrentThreadId());
+ pNtClose(handle);
+
+ cid.UniqueProcess = ULongToHandle(0xdeadbeef);
+ cid.UniqueThread = ULongToHandle(GetCurrentThreadId());
+ status = pNtOpenThread(&handle, THREAD_QUERY_INFORMATION, &attr, &cid);
+ todo_wine
+ ok(status == STATUS_INVALID_CID, "NtOpenThread returned %#x\n", status);
+ if (!status) pNtClose(handle);
+
+ cid.UniqueProcess = 0;
+ cid.UniqueThread = ULongToHandle(0xdeadbeef);
+ status = pNtOpenThread(&handle, THREAD_QUERY_INFORMATION, &attr, &cid);
+ ok(status == STATUS_INVALID_CID || broken(status == STATUS_INVALID_PARAMETER) /* winxp */,
+ "NtOpenThread returned %#x\n", status);
+}
+
START_TEST(info)
{
char **argv;
@@ -2390,4 +2449,6 @@ START_TEST(info)
trace("Starting test_query_data_alignment()\n");
test_query_data_alignment();
+
+ test_thread_lookup();
}
More information about the wine-cvs
mailing list