[APITEST][NTDLL] Initial implementation of NtSetInformationProcess() testcase

The following testcase only performs argument checks for ProcessForegroundInformation class for the moment. The testcase will be expanded with further tests when needed.
This commit is contained in:
Bișoc George 2020-03-29 19:01:41 +02:00 committed by Victor Perevertkin
parent 724466597f
commit f70e43c8f3
3 changed files with 83 additions and 0 deletions

View file

@ -33,6 +33,7 @@ list(APPEND SOURCE
NtReadFile.c
NtSaveKey.c
NtSetInformationFile.c
NtSetInformationProcess.c
NtSetValueKey.c
NtSetVolumeInformationFile.c
NtUnloadDriver.c

View file

@ -0,0 +1,80 @@
/*
* PROJECT: ReactOS API tests
* LICENSE: GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
* PURPOSE: Tests for the NtSetInformationProcess API
* COPYRIGHT: Copyright 2020 Bișoc George <fraizeraust99 at gmail dot com>
*/
#include "precomp.h"
static
void
Test_ProcForegroundBackgroundClass(void)
{
NTSTATUS Status;
PPROCESS_FOREGROUND_BACKGROUND ProcForeground;
ProcForeground = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PROCESS_FOREGROUND_BACKGROUND));
if (ProcForeground == NULL)
{
skip("Failed to allocate memory block from heap for PROCESS_FOREGROUND_BACKGROUND!\n");
return;
}
/* As a test, set the foreground of the retrieved current process to FALSE */
ProcForeground->Foreground = FALSE;
/* Set everything NULL for the caller */
Status = NtSetInformationProcess(NULL,
ProcessForegroundInformation,
NULL,
0);
ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
/* Give an invalid process handle (but the input buffer and length are correct) */
Status = NtSetInformationProcess(NULL,
ProcessForegroundInformation,
ProcForeground,
sizeof(PROCESS_FOREGROUND_BACKGROUND));
ok_hex(Status, STATUS_INVALID_HANDLE);
/* Give a buffer data to the argument input as NULL */
Status = NtSetInformationProcess(NtCurrentProcess(),
ProcessForegroundInformation,
NULL,
sizeof(PROCESS_FOREGROUND_BACKGROUND));
ok_hex(Status, STATUS_ACCESS_VIOLATION);
/* Set the information process foreground with an incorrect buffer alignment and zero buffer length */
Status = NtSetInformationProcess(NtCurrentProcess(),
ProcessForegroundInformation,
(PVOID)1,
0);
ok_hex(Status, STATUS_INFO_LENGTH_MISMATCH);
/*
* Set the information process foreground with an incorrect buffer alignment but correct size length.
* The function will return STATUS_ACCESS_VIOLATION as the alignment probe requirement is not performed
* in this class.
*/
Status = NtSetInformationProcess(NtCurrentProcess(),
ProcessForegroundInformation,
(PVOID)1,
sizeof(PROCESS_FOREGROUND_BACKGROUND));
ok_hex(Status, STATUS_ACCESS_VIOLATION);
/* Set the foreground information to the current given process, we must expect the function should succeed */
Status = NtSetInformationProcess(NtCurrentProcess(),
ProcessForegroundInformation,
ProcForeground,
sizeof(PROCESS_FOREGROUND_BACKGROUND));
ok_hex(Status, STATUS_SUCCESS);
/* Clear all the stuff */
HeapFree(GetProcessHeap(), 0, ProcForeground);
}
START_TEST(NtSetInformationProcess)
{
Test_ProcForegroundBackgroundClass();
}

View file

@ -31,6 +31,7 @@ extern void func_NtQueryVolumeInformationFile(void);
extern void func_NtReadFile(void);
extern void func_NtSaveKey(void);
extern void func_NtSetInformationFile(void);
extern void func_NtSetInformationProcess(void);
extern void func_NtSetValueKey(void);
extern void func_NtSetVolumeInformationFile(void);
extern void func_NtSystemInformation(void);
@ -98,6 +99,7 @@ const struct test winetest_testlist[] =
{ "NtReadFile", func_NtReadFile },
{ "NtSaveKey", func_NtSaveKey},
{ "NtSetInformationFile", func_NtSetInformationFile },
{ "NtSetInformationProcess", func_NtSetInformationProcess },
{ "NtSetValueKey", func_NtSetValueKey},
{ "NtSetVolumeInformationFile", func_NtSetVolumeInformationFile },
{ "NtSystemInformation", func_NtSystemInformation },