ReactOS 0.4.15-dev-7918-g2a2556c
NtQueryInformationThread.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4 * PURPOSE: Tests for the NtQueryInformationThread API
5 * COPYRIGHT: Copyright 2020 George Bișoc <george.bisoc@reactos.org>
6 */
7
8#include "precomp.h"
9#include <internal/ps_i.h>
10
11static
12void
14{
16 PTHREAD_BASIC_INFORMATION ThreadInfoBasic;
18
20 if (!ThreadInfoBasic)
21 {
22 skip("Failed to allocate memory for THREAD_BASIC_INFORMATION!\n");
23 return;
24 }
25
26 /* Everything is NULL */
29 NULL,
30 0,
31 NULL);
33
34 /* Don't give a valid thread handle */
37 ThreadInfoBasic,
39 NULL);
41
42 /* The information length is incorrect */
45 ThreadInfoBasic,
46 0,
47 NULL);
49
50 /* Don't query anything from the function */
53 NULL,
55 NULL);
57
58 /* The buffer is misaligned and length information is wrong */
61 (PVOID)1,
62 0,
63 NULL);
65
66 /* The buffer is misaligned */
69 (PVOID)1,
71 NULL);
73
74 /* The buffer is misaligned, try with an alignment size of 2 */
77 (PVOID)2,
79 NULL);
81
82 /* Query the basic information we need from the thread */
85 ThreadInfoBasic,
89 ok(ReturnedLength != 0, "The size of the buffer pointed by ThreadInformation shouldn't be 0!\n");
90
91 /* Output the thread basic information details */
92 trace("ReturnedLength = %lu\n", ReturnedLength);
93 trace("ThreadInfoBasic->ExitStatus = 0x%08lx\n", ThreadInfoBasic->ExitStatus);
94 trace("ThreadInfoBasic->TebBaseAddress = %p\n", ThreadInfoBasic->TebBaseAddress);
95 trace("ThreadInfoBasic->ClientId.UniqueProcess = %p\n", ThreadInfoBasic->ClientId.UniqueProcess);
96 trace("ThreadInfoBasic->ClientId.UniqueThread = %p\n", ThreadInfoBasic->ClientId.UniqueThread);
97 trace("ThreadInfoBasic->AffinityMask = %lu\n", ThreadInfoBasic->AffinityMask);
98 trace("ThreadInfoBasic->Priority = %li\n", ThreadInfoBasic->Priority);
99 trace("ThreadInfoBasic->BasePriority = %li\n", ThreadInfoBasic->BasePriority);
100
101 HeapFree(GetProcessHeap(), 0, ThreadInfoBasic);
102}
103
104static
105void
107{
108 ULONG InfoClass;
109
110 /* Iterate over the process info classes and begin the tests */
111 for (InfoClass = 0; InfoClass < _countof(PsThreadInfoClass); InfoClass++)
112 {
113 /* The buffer is misaligned */
115 InfoClass,
116 (PVOID)(ULONG_PTR)1,
117 PsThreadInfoClass[InfoClass].RequiredSizeQUERY,
119
120 /* We query an invalid buffer address */
122 InfoClass,
123 (PVOID)(ULONG_PTR)PsThreadInfoClass[InfoClass].AlignmentQUERY,
124 PsThreadInfoClass[InfoClass].RequiredSizeQUERY,
126
127 /* The information length is wrong */
129 InfoClass,
130 (PVOID)(ULONG_PTR)PsThreadInfoClass[InfoClass].AlignmentQUERY,
131 PsThreadInfoClass[InfoClass].RequiredSizeQUERY - 1,
133 }
134}
135
137{
140}
static void Test_ThreadBasicInformationClass(void)
static void Test_ThreadQueryAlignmentProbe(void)
#define ok_hex(expression, result)
Definition: atltest.h:94
#define trace
Definition: atltest.h:70
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
_In_ ULONG _In_ BATTERY_QUERY_INFORMATION_LEVEL _In_ LONG _In_ ULONG _Out_ PULONG ReturnedLength
Definition: batclass.h:188
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
@ ThreadBasicInformation
Definition: compat.h:935
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
Status
Definition: gdiplustypes.h:25
@ QUERY
Definition: precomp.h:18
VOID QuerySetThreadValidator(_In_ ALIGNMENT_PROBE_MODE ValidationMode, _In_ ULONG InfoClassIndex, _In_ PVOID InfoPointer, _In_ ULONG InfoLength, _In_ NTSTATUS ExpectedStatus)
Definition: probelib.c:210
NTSTATUS NTAPI NtQueryInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, OUT PVOID ThreadInformation, IN ULONG ThreadInformationLength, OUT PULONG ReturnLength OPTIONAL)
Definition: query.c:2624
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:183
static const INFORMATION_CLASS_INFO PsThreadInfoClass[]
Definition: ps_i.h:360
#define STATUS_SUCCESS
Definition: shellext.h:65
#define _countof(array)
Definition: sndvol32.h:68
HANDLE UniqueThread
Definition: compat.h:826
HANDLE UniqueProcess
Definition: compat.h:825
KPRIORITY BasePriority
Definition: compat.h:932
KAFFINITY AffinityMask
Definition: compat.h:930
uint32_t ULONG_PTR
Definition: typedefs.h:65
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148