https://git.reactos.org/?p=reactos.git;a=commitdiff;h=103c43861b239604341a7…
commit 103c43861b239604341a7c213a0e39ea89b1ab50
Author: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
AuthorDate: Sat Sep 4 19:53:09 2021 +0200
Commit: Hermès Bélusca-Maïto <hermes.belusca-maito(a)reactos.org>
CommitDate: Thu Sep 9 16:15:05 2021 +0200
[WIN32KNT_APITEST] Add more tests for NtUserProcessConnect() (#3937)
Show that NtUserProcessConnect() should return pointers in user client-space.
---
.../apitests/win32nt/ntuser/NtUserProcessConnect.c | 40 ++++++++++++++++++----
1 file changed, 34 insertions(+), 6 deletions(-)
diff --git a/modules/rostests/apitests/win32nt/ntuser/NtUserProcessConnect.c
b/modules/rostests/apitests/win32nt/ntuser/NtUserProcessConnect.c
index e89a65b7073..9ff9e7d82f4 100644
--- a/modules/rostests/apitests/win32nt/ntuser/NtUserProcessConnect.c
+++ b/modules/rostests/apitests/win32nt/ntuser/NtUserProcessConnect.c
@@ -1,22 +1,29 @@
/*
- * PROJECT: ReactOS api tests
- * LICENSE: GPL - See COPYING in the top level directory
- * PURPOSE: Test for NtUserProcessConnect
- * PROGRAMMERS:
+ * PROJECT: ReactOS api tests
+ * LICENSE: LGPL-2.0-or-later (
https://spdx.org/licenses/LGPL-2.0-or-later)
+ * PURPOSE: Test for NtUserProcessConnect
+ * COPYRIGHT: Copyright 2008-2020 Timo Kreuzer
+ * Copyright 2021 Hermes Belusca-Maito
*/
#include <win32nt.h>
+#define NTOS_MODE_USER
+#include <ndk/exfuncs.h>
+
START_TEST(NtUserProcessConnect)
{
HANDLE hProcess;
NTSTATUS Status;
USERCONNECT UserConnect = {0};
+ SYSTEM_BASIC_INFORMATION SystemInformation;
+ ULONG_PTR MaximumUserModeAddress;
hProcess = GetCurrentProcess();
- UserConnect.ulVersion = MAKELONG(0, 5);
- Status = NtUserProcessConnect(hProcess, &UserConnect, sizeof(USERCONNECT));
+ UserConnect.ulVersion = MAKELONG(0, 5); // == USER_VERSION
+ // UserConnect.dwDispatchCount;
+ Status = NtUserProcessConnect(hProcess, &UserConnect, sizeof(UserConnect));
TEST(NT_SUCCESS(Status));
printf("UserConnect.ulVersion = 0x%lx\n", UserConnect.ulVersion);
@@ -27,4 +34,25 @@ START_TEST(NtUserProcessConnect)
printf("UserConnect.siClient.pDispInfo = 0x%p\n",
UserConnect.siClient.pDispInfo);
printf("UserConnect.siClient.ulSharedDelta = 0x%Ix\n",
UserConnect.siClient.ulSharedDelta);
+ /* Verify the validity of some mandatory fields */
+ TEST(UserConnect.ulVersion == MAKELONG(0, 5));
+ TEST(UserConnect.ulCurrentVersion == 0);
+ TEST(UserConnect.siClient.ulSharedDelta != 0);
+
+ /* Get the max um address */
+ Status = NtQuerySystemInformation(SystemBasicInformation,
+ &SystemInformation,
+ sizeof(SystemInformation),
+ NULL);
+ TEST(NT_SUCCESS(Status));
+
+ MaximumUserModeAddress = SystemInformation.MaximumUserModeAddress;
+
+ /* Verify the validity of pointers -- They must be in client space */
+ TEST(UserConnect.siClient.psi != NULL);
+ TEST(UserConnect.siClient.aheList != NULL);
+ // TEST(UserConnect.siClient.pDispInfo != NULL);
+ TEST((ULONG_PTR)UserConnect.siClient.psi < MaximumUserModeAddress);
+ TEST((ULONG_PTR)UserConnect.siClient.aheList < MaximumUserModeAddress);
+ // TEST((ULONG_PTR)UserConnect.siClient.pDispInfo < MaximumUserModeAddress);
}