ReactOS  0.4.15-dev-5455-g015cd25
NtUserProcessConnect.c
Go to the documentation of this file.
1 /*
2  * PROJECT: ReactOS api tests
3  * LICENSE: LGPL-2.0-or-later (https://spdx.org/licenses/LGPL-2.0-or-later)
4  * PURPOSE: Test for NtUserProcessConnect
5  * COPYRIGHT: Copyright 2008-2020 Timo Kreuzer
6  * Copyright 2021 Hermes Belusca-Maito
7  */
8 
9 #include <win32nt.h>
10 
11 #define NTOS_MODE_USER
12 #include <ndk/exfuncs.h>
13 
15 {
18  USERCONNECT UserConnect = {0};
19  SYSTEM_BASIC_INFORMATION SystemInformation;
20  ULONG_PTR MaximumUserModeAddress;
21 
23 
24  UserConnect.ulVersion = MAKELONG(0, 5); // == USER_VERSION
25  // UserConnect.dwDispatchCount;
26  Status = NtUserProcessConnect(hProcess, &UserConnect, sizeof(UserConnect));
28 
29  printf("UserConnect.ulVersion = 0x%lx\n", UserConnect.ulVersion);
30  printf("UserConnect.ulCurrentVersion = 0x%lx\n", UserConnect.ulCurrentVersion);
31  printf("UserConnect.dwDispatchCount = 0x%lx\n", UserConnect.dwDispatchCount);
32  printf("UserConnect.siClient.psi = 0x%p\n", UserConnect.siClient.psi);
33  printf("UserConnect.siClient.aheList = 0x%p\n", UserConnect.siClient.aheList);
34  printf("UserConnect.siClient.pDispInfo = 0x%p\n", UserConnect.siClient.pDispInfo);
35  printf("UserConnect.siClient.ulSharedDelta = 0x%Ix\n", UserConnect.siClient.ulSharedDelta);
36 
37  /* Verify the validity of some mandatory fields */
38  TEST(UserConnect.ulVersion == MAKELONG(0, 5));
39  TEST(UserConnect.ulCurrentVersion == 0);
40  TEST(UserConnect.siClient.ulSharedDelta != 0);
41 
42  /* Get the max um address */
44  &SystemInformation,
45  sizeof(SystemInformation),
46  NULL);
48 
49  MaximumUserModeAddress = SystemInformation.MaximumUserModeAddress;
50 
51  /* Verify the validity of pointers -- They must be in client space */
52  TEST(UserConnect.siClient.psi != NULL);
53  TEST(UserConnect.siClient.aheList != NULL);
54  // TEST(UserConnect.siClient.pDispInfo != NULL);
55  TEST((ULONG_PTR)UserConnect.siClient.psi < MaximumUserModeAddress);
56  TEST((ULONG_PTR)UserConnect.siClient.aheList < MaximumUserModeAddress);
57  // TEST((ULONG_PTR)UserConnect.siClient.pDispInfo < MaximumUserModeAddress);
58 }
NTSYSAPI NTSTATUS NTAPI NtQuerySystemInformation(IN SYSTEM_INFORMATION_CLASS SystemInfoClass, OUT PVOID SystemInfoBuffer, IN ULONG SystemInfoBufferSize, OUT PULONG BytesReturned OPTIONAL)
LONG NTSTATUS
Definition: precomp.h:26
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:70
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MAKELONG(a, b)
Definition: typedefs.h:249
DWORD dwDispatchCount
Definition: ntuser.h:1139
PSERVERINFO psi
Definition: ntuser.h:1125
ULONG ulCurrentVersion
Definition: ntuser.h:1138
Status
Definition: gdiplustypes.h:24
PVOID pDispInfo
Definition: ntuser.h:1127
#define printf
Definition: freeldr.h:94
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:32
#define TEST(x)
Definition: precomp.h:20
ULONG ulVersion
Definition: ntuser.h:1137
START_TEST(NtUserProcessConnect)
#define GetCurrentProcess()
Definition: compat.h:759
ULONG_PTR ulSharedDelta
Definition: ntuser.h:1128
SHAREDINFO siClient
Definition: ntuser.h:1140
#define NULL
Definition: types.h:112
NTSTATUS NTAPI NtUserProcessConnect(IN HANDLE ProcessHandle, OUT PUSERCONNECT pUserConnect, IN ULONG Size)
Definition: ntstubs.c:476
PVOID aheList
Definition: ntuser.h:1126