https://git.reactos.org/?p=reactos.git;a=commitdiff;h=efaa7b6a24aac27013519…
commit efaa7b6a24aac270135194c0b6104d73930d1a24
Author: George Bișoc <george.bisoc(a)reactos.org>
AuthorDate: Sun May 2 20:58:40 2021 +0200
Commit: George Bișoc <george.bisoc(a)reactos.org>
CommitDate: Sun May 2 20:58:40 2021 +0200
[NTDLL_APITEST] Add alignment probing tests for Query/Set information thread related
routines
---
.../apitests/ntdll/NtQueryInformationThread.c | 34 ++++++++++++++++++++++
.../apitests/ntdll/NtSetInformationThread.c | 34 ++++++++++++++++++++++
2 files changed, 68 insertions(+)
diff --git a/modules/rostests/apitests/ntdll/NtQueryInformationThread.c
b/modules/rostests/apitests/ntdll/NtQueryInformationThread.c
index df4d2d0b939..6dafdd87e67 100644
--- a/modules/rostests/apitests/ntdll/NtQueryInformationThread.c
+++ b/modules/rostests/apitests/ntdll/NtQueryInformationThread.c
@@ -6,6 +6,7 @@
*/
#include "precomp.h"
+#include <internal/ps_i.h>
static
void
@@ -100,7 +101,40 @@ Test_ThreadBasicInformationClass(void)
HeapFree(GetProcessHeap(), 0, ThreadInfoBasic);
}
+static
+void
+Test_ThreadQueryAlignmentProbe(void)
+{
+ ULONG InfoClass;
+
+ /* Iterate over the process info classes and begin the tests */
+ for (InfoClass = 0; InfoClass < _countof(PsThreadInfoClass); InfoClass++)
+ {
+ /* The buffer is misaligned */
+ QuerySetThreadValidator(QUERY,
+ InfoClass,
+ (PVOID)(ULONG_PTR)1,
+ PsThreadInfoClass[InfoClass].RequiredSizeQUERY,
+ STATUS_DATATYPE_MISALIGNMENT);
+
+ /* We query an invalid buffer address */
+ QuerySetThreadValidator(QUERY,
+ InfoClass,
+
(PVOID)(ULONG_PTR)PsThreadInfoClass[InfoClass].AlignmentQUERY,
+ PsThreadInfoClass[InfoClass].RequiredSizeQUERY,
+ STATUS_ACCESS_VIOLATION);
+
+ /* The information length is wrong */
+ QuerySetThreadValidator(QUERY,
+ InfoClass,
+
(PVOID)(ULONG_PTR)PsThreadInfoClass[InfoClass].AlignmentQUERY,
+ PsThreadInfoClass[InfoClass].RequiredSizeQUERY - 1,
+ STATUS_INFO_LENGTH_MISMATCH);
+ }
+}
+
START_TEST(NtQueryInformationThread)
{
Test_ThreadBasicInformationClass();
+ Test_ThreadQueryAlignmentProbe();
}
diff --git a/modules/rostests/apitests/ntdll/NtSetInformationThread.c
b/modules/rostests/apitests/ntdll/NtSetInformationThread.c
index f1835ed5198..0aa9a206eab 100644
--- a/modules/rostests/apitests/ntdll/NtSetInformationThread.c
+++ b/modules/rostests/apitests/ntdll/NtSetInformationThread.c
@@ -6,6 +6,7 @@
*/
#include "precomp.h"
+#include <internal/ps_i.h>
static
void
@@ -94,7 +95,40 @@ Test_ThreadPriorityClass(void)
HeapFree(GetProcessHeap(), 0, Priority);
}
+static
+void
+Test_ThreadSetAlignmentProbe(void)
+{
+ ULONG InfoClass;
+
+ /* Iterate over the process info classes and begin the tests */
+ for (InfoClass = 0; InfoClass < _countof(PsThreadInfoClass); InfoClass++)
+ {
+ /* The buffer is misaligned */
+ QuerySetThreadValidator(SET,
+ InfoClass,
+ (PVOID)(ULONG_PTR)1,
+ PsThreadInfoClass[InfoClass].RequiredSizeSET,
+ STATUS_DATATYPE_MISALIGNMENT);
+
+ /* We set an invalid buffer address */
+ QuerySetThreadValidator(SET,
+ InfoClass,
+
(PVOID)(ULONG_PTR)PsThreadInfoClass[InfoClass].AlignmentSET,
+ PsThreadInfoClass[InfoClass].RequiredSizeSET,
+ STATUS_ACCESS_VIOLATION);
+
+ /* The information length is wrong */
+ QuerySetThreadValidator(SET,
+ InfoClass,
+
(PVOID)(ULONG_PTR)PsThreadInfoClass[InfoClass].AlignmentSET,
+ PsThreadInfoClass[InfoClass].RequiredSizeSET - 1,
+ STATUS_INFO_LENGTH_MISMATCH);
+ }
+}
+
START_TEST(NtSetInformationThread)
{
Test_ThreadPriorityClass();
+ Test_ThreadSetAlignmentProbe();
}