ReactOS 0.4.16-dev-334-g4d9f67c
NtSetInformationThread.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 NtSetInformationThread 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{
17
19 if (Priority == NULL)
20 {
21 skip("Failed to allocate memory for thread priority variable!\n");
22 return;
23 }
24
25 /* Assign a priority */
26 *Priority = 11;
27
28 /* Everything is NULL */
31 NULL,
32 0);
34
35 /* Give an invalid thread handle */
39 sizeof(KPRIORITY));
41
42 /* Don't set any priority to the thread */
45 NULL,
46 sizeof(KPRIORITY));
48
49 /* The information length is incorrect */
53 0);
55
56 /* The buffer is misaligned and information length is incorrect */
59 (PVOID)1,
60 0);
62
63 /* The buffer is misaligned */
66 (PVOID)1,
67 sizeof(KPRIORITY));
69
70 /* The buffer is misaligned -- try with an alignment size of 2 */
73 (PVOID)2,
74 sizeof(KPRIORITY));
76
77 /* Set the priority to the current thread */
81 sizeof(KPRIORITY));
83
84 /*
85 * Set the priority as LOW_REALTIME_PRIORITY,
86 * we don't have privileges to do so.
87 */
92 sizeof(KPRIORITY));
94
96}
97
98static
99void
101{
102 ULONG InfoClass;
103
104 /* Iterate over the process info classes and begin the tests */
105 for (InfoClass = 0; InfoClass < _countof(PsThreadInfoClass); InfoClass++)
106 {
107 /* The buffer is misaligned */
109 InfoClass,
110 (PVOID)(ULONG_PTR)1,
111 PsThreadInfoClass[InfoClass].RequiredSizeSET,
113
114 /* We set an invalid buffer address */
116 InfoClass,
117 (PVOID)(ULONG_PTR)PsThreadInfoClass[InfoClass].AlignmentSET,
118 PsThreadInfoClass[InfoClass].RequiredSizeSET,
120
121 /* The information length is wrong */
123 InfoClass,
124 (PVOID)(ULONG_PTR)PsThreadInfoClass[InfoClass].AlignmentSET,
125 PsThreadInfoClass[InfoClass].RequiredSizeSET - 1,
127 }
128}
129
131{
134}
#define STATUS_PRIVILEGE_NOT_HELD
Definition: DriverTester.h:9
static void Test_ThreadSetAlignmentProbe(void)
static void Test_ThreadPriorityClass(void)
#define ok_hex(expression, result)
Definition: atltest.h:94
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
#define SET(field, seg, reg)
#define STATUS_INVALID_HANDLE
Definition: d3dkmdt.h:40
#define NULL
Definition: types.h:112
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
@ ThreadPriority
Definition: compat.h:937
#define HeapFree(x, y, z)
Definition: compat.h:735
LONG KPRIORITY
Definition: compat.h:803
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
Status
Definition: gdiplustypes.h:25
#define LOW_REALTIME_PRIORITY
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 NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:2018
#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:70
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
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:655
HANDLE WINAPI GetCurrentThread(void)
Definition: proc.c:1148