https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f70e43c8f34a0cfa44e5f…
commit f70e43c8f34a0cfa44e5fad3279909b18588be4c
Author: Bișoc George <fraizeraust99(a)gmail.com>
AuthorDate: Sun Mar 29 19:01:41 2020 +0200
Commit: Victor Perevertkin <victor(a)perevertkin.ru>
CommitDate: Mon Mar 30 13:52:15 2020 +0300
[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.
---
modules/rostests/apitests/ntdll/CMakeLists.txt | 1 +
.../apitests/ntdll/NtSetInformationProcess.c | 80 ++++++++++++++++++++++
modules/rostests/apitests/ntdll/testlist.c | 2 +
3 files changed, 83 insertions(+)
diff --git a/modules/rostests/apitests/ntdll/CMakeLists.txt
b/modules/rostests/apitests/ntdll/CMakeLists.txt
index 64b147bdeec..7da1843babe 100644
--- a/modules/rostests/apitests/ntdll/CMakeLists.txt
+++ b/modules/rostests/apitests/ntdll/CMakeLists.txt
@@ -33,6 +33,7 @@ list(APPEND SOURCE
NtReadFile.c
NtSaveKey.c
NtSetInformationFile.c
+ NtSetInformationProcess.c
NtSetValueKey.c
NtSetVolumeInformationFile.c
NtUnloadDriver.c
diff --git a/modules/rostests/apitests/ntdll/NtSetInformationProcess.c
b/modules/rostests/apitests/ntdll/NtSetInformationProcess.c
new file mode 100644
index 00000000000..b5fcc18e2db
--- /dev/null
+++ b/modules/rostests/apitests/ntdll/NtSetInformationProcess.c
@@ -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();
+}
diff --git a/modules/rostests/apitests/ntdll/testlist.c
b/modules/rostests/apitests/ntdll/testlist.c
index 7624c3c23af..76357f6ece6 100644
--- a/modules/rostests/apitests/ntdll/testlist.c
+++ b/modules/rostests/apitests/ntdll/testlist.c
@@ -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 },