[WIN32KNT_APITEST] Add more tests for NtUserProcessConnect() (#3937)

Show that NtUserProcessConnect() should return pointers in user client-space.
This commit is contained in:
Hermès Bélusca-Maïto 2021-09-04 19:53:09 +02:00
parent a2e9dcf0a7
commit 103c43861b
No known key found for this signature in database
GPG key ID: 3B2539C65E7B93D0

View file

@ -1,22 +1,29 @@
/* /*
* PROJECT: ReactOS api tests * PROJECT: ReactOS api tests
* LICENSE: GPL - See COPYING in the top level directory * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
* PURPOSE: Test for NtUserProcessConnect * PURPOSE: Test for NtUserProcessConnect
* PROGRAMMERS: * COPYRIGHT: Copyright 2008-2020 Timo Kreuzer
* Copyright 2021 Hermes Belusca-Maito
*/ */
#include <win32nt.h> #include <win32nt.h>
#define NTOS_MODE_USER
#include <ndk/exfuncs.h>
START_TEST(NtUserProcessConnect) START_TEST(NtUserProcessConnect)
{ {
HANDLE hProcess; HANDLE hProcess;
NTSTATUS Status; NTSTATUS Status;
USERCONNECT UserConnect = {0}; USERCONNECT UserConnect = {0};
SYSTEM_BASIC_INFORMATION SystemInformation;
ULONG_PTR MaximumUserModeAddress;
hProcess = GetCurrentProcess(); hProcess = GetCurrentProcess();
UserConnect.ulVersion = MAKELONG(0, 5); UserConnect.ulVersion = MAKELONG(0, 5); // == USER_VERSION
Status = NtUserProcessConnect(hProcess, &UserConnect, sizeof(USERCONNECT)); // UserConnect.dwDispatchCount;
Status = NtUserProcessConnect(hProcess, &UserConnect, sizeof(UserConnect));
TEST(NT_SUCCESS(Status)); TEST(NT_SUCCESS(Status));
printf("UserConnect.ulVersion = 0x%lx\n", UserConnect.ulVersion); 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.pDispInfo = 0x%p\n", UserConnect.siClient.pDispInfo);
printf("UserConnect.siClient.ulSharedDelta = 0x%Ix\n", UserConnect.siClient.ulSharedDelta); 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);
} }