[NTDLL_APITEST] Add alignment probing tests for Query/Set information process related routines

This commit is contained in:
George Bișoc 2021-05-02 20:56:14 +02:00
parent 74e527b452
commit 3b53b3d07f
No known key found for this signature in database
GPG key ID: 688C4FBE25D7DEF6
2 changed files with 69 additions and 0 deletions

View file

@ -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@reactos.org>
* George Bișoc <george.bisoc@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();
}

View file

@ -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();
}