ReactOS 0.4.17-dev-1196-gb6224c3
RtlInitializeNtUserPfn.c
Go to the documentation of this file.
1/*
2 * PROJECT: ReactOS API tests
3 * LICENSE: MIT (https://spdx.org/licenses/MIT)
4 * PURPOSE: Test for RtlRetrieveNtUserPfn
5 * COPYRIGHT: Copyright 2026 Timo Kreuzer <timo.kreuzer@reactos.org>
6 */
7
8#include "precomp.h"
9
10typedef
14 PVOID* ProcsA,
15 SIZE_T SizeOfProcsA,
16 PVOID* ProcsW,
17 SIZE_T SizeOfProcsW,
18 PVOID* OtherProcs,
19 SIZE_T SizeOfOtherProcs);
20
22
24{
25 HINSTANCE hinstNtdll = GetModuleHandleW(L"ntdll.dll");
26 pRtlInitializeNtUserPfn = (FN_RtlInitializeNtUserPfn*)GetProcAddress(hinstNtdll, "RtlInitializeNtUserPfn");
28 {
29 skip("RtlInitializeNtUserPfn is not available\n");
30 return;
31 }
32
34 PVOID ProcsA[24] = { 0 };
35 PVOID ProcsW[24] = { 0 };
36 PVOID OtherProcs[11] = { 0 };
37 ULONG Count1, Count2;
38
45 Status = pRtlInitializeNtUserPfn(ProcsA, 0, ProcsW, 0, OtherProcs, 1);
47
48 printf("NTDDI version: %lx\n", GetNTDDIVersion());
49
50 /* OS version specific count of A/W functions */
51 Count1 = (GetNTDDIVersion() >= NTDDI_WIN10) ? 24 : 23;
52
53 /* OS version specific count of other functions */
54 Count2 = (GetNTDDIVersion() >= NTDDI_WIN11) ? 18 : 11;
55
56 /* Try different variants of too large sizes */
57 Status = pRtlInitializeNtUserPfn(ProcsA, (Count1 + 1) * sizeof(PVOID), ProcsW, Count1 * sizeof(PVOID), OtherProcs, Count2 * sizeof(PVOID));
59 Status = pRtlInitializeNtUserPfn(ProcsA, Count1 * sizeof(PVOID), ProcsW, (Count1 + 1) * sizeof(PVOID), OtherProcs, Count2 * sizeof(PVOID));
61 Status = pRtlInitializeNtUserPfn(ProcsA, (Count1 + 1) * sizeof(PVOID), ProcsW, (Count1 + 1) * sizeof(PVOID), OtherProcs, Count2 * sizeof(PVOID));
63 Status = pRtlInitializeNtUserPfn(ProcsA, Count1 * sizeof(PVOID), ProcsW, Count1 * sizeof(PVOID), OtherProcs, (Count2 + 1) * sizeof(PVOID));
65
67 {
68 /* Try different variants of too small sizes (these succeed on Windows 10) */
69 Status = pRtlInitializeNtUserPfn(ProcsA, (Count1 - 1) * sizeof(PVOID), ProcsW, Count1 * sizeof(PVOID), OtherProcs, Count2 * sizeof(PVOID));
71 Status = pRtlInitializeNtUserPfn(ProcsA, Count1 * sizeof(PVOID), ProcsW, (Count1 - 1) * sizeof(PVOID), OtherProcs, Count2 * sizeof(PVOID));
73 Status = pRtlInitializeNtUserPfn(ProcsA, (Count1 - 1) * sizeof(PVOID), ProcsW, (Count1 - 1) * sizeof(PVOID), OtherProcs, Count2 * sizeof(PVOID));
75 Status = pRtlInitializeNtUserPfn(ProcsA, Count1 * sizeof(PVOID), ProcsW, Count1 * sizeof(PVOID), OtherProcs, (Count2 - 1) * sizeof(PVOID));
77 }
78
79 /* Try unaligned sizes */
80 Status = pRtlInitializeNtUserPfn(ProcsA, (Count1 * sizeof(PVOID)) - 1, ProcsW, Count1 * sizeof(PVOID), OtherProcs, Count2 * sizeof(PVOID));
82 Status = pRtlInitializeNtUserPfn(ProcsA, Count1 * sizeof(PVOID), ProcsW, (Count1 * sizeof(PVOID)) - 1, OtherProcs, Count2 * sizeof(PVOID));
84 Status = pRtlInitializeNtUserPfn(ProcsA, Count1 * sizeof(PVOID), ProcsW, Count1 * sizeof(PVOID), OtherProcs, (Count2 * sizeof(PVOID)) - 1);
86
87 /* Pass the expected sizes */
88 Status = pRtlInitializeNtUserPfn(ProcsA, Count1 * sizeof(PVOID), ProcsW, Count1 * sizeof(PVOID), OtherProcs, Count2 * sizeof(PVOID));
90
91 /* Try to initialize again */
92 Status = pRtlInitializeNtUserPfn(ProcsA, Count1 * sizeof(PVOID), ProcsW, Count1 * sizeof(PVOID), OtherProcs, Count2 * sizeof(PVOID));
94}
NTSTATUS NTAPI FN_RtlInitializeNtUserPfn(PVOID *ProcsA, SIZE_T SizeOfProcsA, PVOID *ProcsW, SIZE_T SizeOfProcsW, PVOID *OtherProcs, SIZE_T SizeOfOtherProcs)
FN_RtlInitializeNtUserPfn * pRtlInitializeNtUserPfn
#define GetNTVersion()
Definition: apitest.h:17
static ULONG GetNTDDIVersion(VOID)
Definition: apitest.h:23
#define ok_ntstatus(status, expected)
Definition: atltest.h:135
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
LONG NTSTATUS
Definition: precomp.h:26
#define NULL
Definition: types.h:112
#define GetProcAddress(x, y)
Definition: compat.h:753
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
#define L(x)
Definition: resources.c:13
#define printf
Definition: freeldr.h:103
Status
Definition: gdiplustypes.h:24
#define _WIN32_WINNT_WIN10
Definition: sdkddkver.h:32
#define NTDDI_WIN11
Definition: sdkddkver.h:131
#define NTDDI_WIN10
Definition: sdkddkver.h:117
#define STATUS_SUCCESS
Definition: shellext.h:65
#define NTAPI
Definition: typedefs.h:36
ULONG_PTR SIZE_T
Definition: typedefs.h:80
uint32_t ULONG
Definition: typedefs.h:59
#define STATUS_INVALID_PARAMETER
Definition: udferr_usr.h:135
NTSYSAPI NTSTATUS WINAPI RtlInitializeNtUserPfn(const void *, ULONG, const void *, ULONG, const void *, ULONG)