ReactOS 0.4.17-dev-470-gf9e3448
IsServerSideWindow.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 IsServerSideWindow
5 * COPYRIGHT: Copyright 2024 Oleg Dubinskiy <oleg.dubinskiy@reactos.org>
6 * Copyright 2026 Mohammad Amin Mollazadeh <madamin@pm.me>
7 */
8
9#include "precomp.h"
10
11static const WCHAR WndClass[] = L"window class";
12
13static LRESULT
16{
17 switch (msg)
18 {
19 case WM_PAINT:
20 return 0;
21
22 case WM_DESTROY:
24 return 0;
25 }
26
28}
29
31{
32 HWND hWnd;
33 WNDCLASSEXW wcx;
34 BOOL ret;
35
36 ZeroMemory(&wcx, sizeof(wcx));
37 wcx.cbSize = sizeof(wcx);
40 wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
42
43 if (!RegisterClassExW(&wcx))
44 {
45 skip("RegisterClassExW failed with error %lu\n", GetLastError());
46 return;
47 }
48
49 /* 1. Invalid window */
50 hWnd = (HWND)(UINT_PTR)0xdeadbeef;
51 SetLastError(0xfeedfab1);
53 ok(!ret, "The window %p is invalid but IsServerSideWindow() returned TRUE\n", hWnd);
55
56 /* 2. Window with a kernel-mode WndProc.
57 * ScrollBar is an example of a server-side window that can be created from user-mode code. */
59 L"ScrollBar",
60 NULL,
63 400, 100,
64 NULL, 0,
65 wcx.hInstance, NULL);
66 if (!hWnd)
67 {
68 skip("CreateWindowExW failed with error %lu\n", GetLastError());
69 goto Quit;
70 }
71
72 SetLastError(0xfeedfab1);
74 ok(ret, "The window %p is invalid or doesn't have a valid kernel-mode WndProc\n", hWnd);
75 ok_eq_ulong(GetLastError(), 0xfeedfab1); // The last-error shouldn't change.
76
78
79 /* 3. Window with a user-mode WndProc */
82 NULL,
85 400, 100,
86 NULL, 0,
87 wcx.hInstance, NULL);
88 if (!hWnd)
89 {
90 skip("CreateWindowExW failed with error %lu\n", GetLastError());
91 goto Quit;
92 }
93
94 SetLastError(0xfeedfab1);
96 ok(!ret, "The window %p has a valid kernel-mode WndProc when it should not\n", hWnd);
97 ok_eq_ulong(GetLastError(), 0xfeedfab1); // The last-error shouldn't change.
98
100
101Quit:
103 return;
104}
static LRESULT CALLBACK Test_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
static const WCHAR WndClass[]
#define ok_eq_ulong(value, expected)
Definition: apitest.h:120
#define ok(value,...)
Definition: atltest.h:57
#define skip(...)
Definition: atltest.h:64
#define START_TEST(x)
Definition: atltest.h:75
#define msg(x)
Definition: auth_time.c:54
HWND hWnd
Definition: settings.c:17
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define SetLastError(x)
Definition: compat.h:752
HANDLE HWND
Definition: compat.h:19
#define CALLBACK
Definition: compat.h:35
HMODULE WINAPI GetModuleHandleW(LPCWSTR lpModuleName)
Definition: loader.c:838
return ret
Definition: mutex.c:146
#define L(x)
Definition: resources.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned int UINT
Definition: sysinfo.c:13
#define ZeroMemory
Definition: minwinbase.h:31
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
unsigned __int3264 UINT_PTR
Definition: mstsclib_h.h:274
#define WS_CAPTION
Definition: pedump.c:624
#define WS_SYSMENU
Definition: pedump.c:629
short WCHAR
Definition: pedump.c:58
#define WS_VISIBLE
Definition: pedump.c:620
LPCWSTR lpszClassName
Definition: winuser.h:3334
HBRUSH hbrBackground
Definition: winuser.h:3332
WNDPROC lpfnWndProc
Definition: winuser.h:3326
UINT cbSize
Definition: winuser.h:3324
HINSTANCE hInstance
Definition: winuser.h:3329
BOOL WINAPI IsServerSideWindow(HWND)
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
#define ERROR_INVALID_WINDOW_HANDLE
Definition: winerror.h:1226
#define WM_PAINT
Definition: winuser.h:1648
#define COLOR_WINDOW
Definition: winuser.h:929
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
ATOM WINAPI RegisterClassExW(_In_ CONST WNDCLASSEXW *)
#define CW_USEDEFAULT
Definition: winuser.h:225
#define SBS_HORZ
Definition: winuser.h:326
#define WM_DESTROY
Definition: winuser.h:1637
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
BOOL WINAPI DestroyWindow(_In_ HWND)