ReactOS  0.4.15-dev-5097-g328cc41
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 
11 static
12 void
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 */
38  Priority,
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 */
52  Priority,
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 */
80  Priority,
81  sizeof(KPRIORITY));
83 
84  /*
85  * Set the priority as LOW_REALTIME_PRIORITY,
86  * we don't have privileges to do so.
87  */
91  Priority,
92  sizeof(KPRIORITY));
94 
96 }
97 
98 static
99 void
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
#define SET(field, seg, reg)
#define STATUS_INFO_LENGTH_MISMATCH
Definition: udferr_usr.h:133
LONG NTSTATUS
Definition: precomp.h:26
#define LOW_REALTIME_PRIORITY
#define ok_hex(expression, result)
Definition: atltest.h:94
LONG KPRIORITY
Definition: compat.h:662
#define STATUS_INVALID_HANDLE
Definition: ntstatus.h:245
uint32_t ULONG_PTR
Definition: typedefs.h:65
HANDLE WINAPI GetCurrentThread(VOID)
Definition: proc.c:1148
NTSTATUS NTAPI NtSetInformationThread(IN HANDLE ThreadHandle, IN THREADINFOCLASS ThreadInformationClass, IN PVOID ThreadInformation, IN ULONG ThreadInformationLength)
Definition: query.c:2018
Status
Definition: gdiplustypes.h:24
#define GetProcessHeap()
Definition: compat.h:595
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define _countof(array)
Definition: sndvol32.h:68
VOID QuerySetThreadValidator(_In_ ALIGNMENT_PROBE_MODE ValidationMode, _In_ ULONG InfoClassIndex, _In_ PVOID InfoPointer, _In_ ULONG InfoLength, _In_ NTSTATUS ExpectedStatus)
Definition: probelib.c:189
_In_ WDFINTERRUPT _In_ WDF_INTERRUPT_POLICY _In_ WDF_INTERRUPT_PRIORITY Priority
Definition: wdfinterrupt.h:651
#define STATUS_ACCESS_VIOLATION
Definition: ntstatus.h:242
#define NULL
Definition: types.h:112
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define skip(...)
Definition: atltest.h:64
#define STATUS_DATATYPE_MISALIGNMENT
Definition: ntstatus.h:183
unsigned int ULONG
Definition: retypes.h:1
START_TEST(NtSetInformationThread)
static void Test_ThreadSetAlignmentProbe(void)
#define STATUS_SUCCESS
Definition: shellext.h:65
static void Test_ThreadPriorityClass(void)
static const INFORMATION_CLASS_INFO PsThreadInfoClass[]
Definition: ps_i.h:360
#define HeapFree(x, y, z)
Definition: compat.h:594