https://git.reactos.org/?p=reactos.git;a=commitdiff;h=3b53b3d07ffbfda00812b…
commit 3b53b3d07ffbfda00812ba63acfa2e2a7e772386
Author: George Bișoc <george.bisoc(a)reactos.org>
AuthorDate: Sun May 2 20:56:14 2021 +0200
Commit: George Bișoc <george.bisoc(a)reactos.org>
CommitDate: Sun May 2 20:56:14 2021 +0200
[NTDLL_APITEST] Add alignment probing tests for Query/Set information process related
routines
---
.../apitests/ntdll/NtQueryInformationProcess.c | 35 ++++++++++++++++++++++
.../apitests/ntdll/NtSetInformationProcess.c | 34 +++++++++++++++++++++
2 files changed, 69 insertions(+)
diff --git a/modules/rostests/apitests/ntdll/NtQueryInformationProcess.c
b/modules/rostests/apitests/ntdll/NtQueryInformationProcess.c
index 777f8f36810..1fd990a3ef6 100644
--- a/modules/rostests/apitests/ntdll/NtQueryInformationProcess.c
+++ b/modules/rostests/apitests/ntdll/NtQueryInformationProcess.c
@@ -3,9 +3,11 @@
* LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
* PURPOSE: Tests for the NtQueryInformationProcess API
* PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org>
+ * George Bișoc <george.bisoc(a)reactos.org>
*/
#include "precomp.h"
+#include <internal/ps_i.h>
static LARGE_INTEGER TestStartTime;
@@ -322,6 +324,38 @@ Test_ProcessWx86Information(void)
trace("VdmPower = %lu\n", VdmPower);
}
+static
+void
+Test_ProcQueryAlignmentProbe(void)
+{
+ ULONG InfoClass;
+
+ /* Iterate over the process info classes and begin the tests */
+ for (InfoClass = 0; InfoClass < _countof(PsProcessInfoClass); InfoClass++)
+ {
+ /* The buffer is misaligned */
+ QuerySetProcessValidator(QUERY,
+ InfoClass,
+ (PVOID)(ULONG_PTR)1,
+ PsProcessInfoClass[InfoClass].RequiredSizeQUERY,
+ STATUS_DATATYPE_MISALIGNMENT);
+
+ /* We query an invalid buffer address */
+ QuerySetProcessValidator(QUERY,
+ InfoClass,
+
(PVOID)(ULONG_PTR)PsProcessInfoClass[InfoClass].AlignmentQUERY,
+ PsProcessInfoClass[InfoClass].RequiredSizeQUERY,
+ STATUS_ACCESS_VIOLATION);
+
+ /* The information length is wrong */
+ QuerySetProcessValidator(QUERY,
+ InfoClass,
+
(PVOID)(ULONG_PTR)PsProcessInfoClass[InfoClass].AlignmentQUERY,
+ PsProcessInfoClass[InfoClass].RequiredSizeQUERY - 1,
+ STATUS_INFO_LENGTH_MISMATCH);
+ }
+}
+
START_TEST(NtQueryInformationProcess)
{
NTSTATUS Status;
@@ -335,4 +369,5 @@ START_TEST(NtQueryInformationProcess)
Test_ProcessTimes();
Test_ProcessPriorityClassAlignment();
Test_ProcessWx86Information();
+ Test_ProcQueryAlignmentProbe();
}
diff --git a/modules/rostests/apitests/ntdll/NtSetInformationProcess.c
b/modules/rostests/apitests/ntdll/NtSetInformationProcess.c
index 93ec35d5776..79588848db7 100644
--- a/modules/rostests/apitests/ntdll/NtSetInformationProcess.c
+++ b/modules/rostests/apitests/ntdll/NtSetInformationProcess.c
@@ -6,6 +6,7 @@
*/
#include "precomp.h"
+#include <internal/ps_i.h>
static
void
@@ -265,10 +266,43 @@ Test_ProcessWx86InformationClass(void)
ok_hex(Status, STATUS_PRIVILEGE_NOT_HELD);
}
+static
+void
+Test_ProcSetAlignmentProbe(void)
+{
+ ULONG InfoClass;
+
+ /* Iterate over the process info classes and begin the tests */
+ for (InfoClass = 0; InfoClass < _countof(PsProcessInfoClass); InfoClass++)
+ {
+ /* The buffer is misaligned */
+ QuerySetProcessValidator(SET,
+ InfoClass,
+ (PVOID)(ULONG_PTR)1,
+ PsProcessInfoClass[InfoClass].RequiredSizeSET,
+ STATUS_DATATYPE_MISALIGNMENT);
+
+ /* We set an invalid buffer address */
+ QuerySetProcessValidator(SET,
+ InfoClass,
+
(PVOID)(ULONG_PTR)PsProcessInfoClass[InfoClass].AlignmentSET,
+ PsProcessInfoClass[InfoClass].RequiredSizeSET,
+ STATUS_ACCESS_VIOLATION);
+
+ /* The information length is wrong */
+ QuerySetProcessValidator(SET,
+ InfoClass,
+
(PVOID)(ULONG_PTR)PsProcessInfoClass[InfoClass].AlignmentSET,
+ PsProcessInfoClass[InfoClass].RequiredSizeSET - 1,
+ STATUS_INFO_LENGTH_MISMATCH);
+ }
+}
+
START_TEST(NtSetInformationProcess)
{
Test_ProcForegroundBackgroundClass();
Test_ProcBasePriorityClass();
Test_ProcRaisePriorityClass();
Test_ProcessWx86InformationClass();
+ Test_ProcSetAlignmentProbe();
}