[USER32_APITEST] Add a test for IsServerSideWindow() (#9229)

CORE-19946
Adapted from PR #7577

This function tests whether a window has a window procedure that resides in kernel mode.
It is not documented by Microsoft, but unofficial (3rd party) documentation[^1] exists.
It is required and used internally by uxtheme.dll from Windows XP/2003/Vista/7/etc.

[^1]: https://undoc.airesoft.co.uk/user32.dll/IsServerSideWindow.php

Co-authored-by: Mohammad Amin Mollazadeh <[email protected]>
This commit is contained in:
Oleg Dubinskiy
2026-07-06 17:58:55 +02:00
co-authored by Mohammad Amin Mollazadeh
parent 55eb678043
commit c126bccb4b
3 changed files with 107 additions and 0 deletions
@@ -29,6 +29,7 @@ list(APPEND SOURCE
GetWindowPlacement.c
GW_ENABLEDPOPUP.c
InitializeLpkHooks.c
IsServerSideWindow.c
KbdLayout.c
keybd_event.c
LoadImage.c
@@ -0,0 +1,104 @@
/*
* PROJECT: ReactOS API tests
* LICENSE: MIT (https://spdx.org/licenses/MIT)
* PURPOSE: Test for IsServerSideWindow
* COPYRIGHT: Copyright 2024 Oleg Dubinskiy <[email protected]>
* Copyright 2026 Mohammad Amin Mollazadeh <[email protected]>
*/
#include "precomp.h"
static const WCHAR WndClass[] = L"window class";
static LRESULT
CALLBACK
Test_WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
switch (msg)
{
case WM_PAINT:
return 0;
case WM_DESTROY:
PostQuitMessage(0);
return 0;
}
return DefWindowProcW(hWnd, msg, wParam, lParam);
}
START_TEST(IsServerSideWindow)
{
HWND hWnd;
WNDCLASSEXW wcx;
BOOL ret;
ZeroMemory(&wcx, sizeof(wcx));
wcx.cbSize = sizeof(wcx);
wcx.lpfnWndProc = Test_WndProc;
wcx.hInstance = GetModuleHandleW(NULL);
wcx.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
wcx.lpszClassName = WndClass;
if (!RegisterClassExW(&wcx))
{
skip("RegisterClassExW failed with error %lu\n", GetLastError());
return;
}
/* 1. Invalid window */
hWnd = (HWND)(UINT_PTR)0xdeadbeef;
SetLastError(0xfeedfab1);
ret = IsServerSideWindow(hWnd);
ok(!ret, "The window %p is invalid but IsServerSideWindow() returned TRUE\n", hWnd);
ok_eq_ulong(GetLastError(), ERROR_INVALID_WINDOW_HANDLE);
/* 2. Window with a kernel-mode WndProc.
* ScrollBar is an example of a server-side window that can be created from user-mode code. */
hWnd = CreateWindowExW(0,
L"ScrollBar",
NULL,
SBS_HORZ | WS_VISIBLE,
CW_USEDEFAULT, CW_USEDEFAULT,
400, 100,
NULL, 0,
wcx.hInstance, NULL);
if (!hWnd)
{
skip("CreateWindowExW failed with error %lu\n", GetLastError());
goto Quit;
}
SetLastError(0xfeedfab1);
ret = IsServerSideWindow(hWnd);
ok(ret, "The window %p is invalid or doesn't have a valid kernel-mode WndProc\n", hWnd);
ok_eq_ulong(GetLastError(), 0xfeedfab1); // The last-error shouldn't change.
DestroyWindow(hWnd);
/* 3. Window with a user-mode WndProc */
hWnd = CreateWindowExW(0,
WndClass,
NULL,
WS_CAPTION | WS_SYSMENU,
CW_USEDEFAULT, CW_USEDEFAULT,
400, 100,
NULL, 0,
wcx.hInstance, NULL);
if (!hWnd)
{
skip("CreateWindowExW failed with error %lu\n", GetLastError());
goto Quit;
}
SetLastError(0xfeedfab1);
ret = IsServerSideWindow(hWnd);
ok(!ret, "The window %p has a valid kernel-mode WndProc when it should not\n", hWnd);
ok_eq_ulong(GetLastError(), 0xfeedfab1); // The last-error shouldn't change.
DestroyWindow(hWnd);
Quit:
UnregisterClassW(WndClass, wcx.hInstance);
return;
}
@@ -29,6 +29,7 @@ extern void func_GetUserObjectInformation(void);
extern void func_GetWindowPlacement(void);
extern void func_GW_ENABLEDPOPUP(void);
extern void func_InitializeLpkHooks(void);
extern void func_IsServerSideWindow(void);
extern void func_KbdLayout(void);
extern void func_keybd_event(void);
extern void func_LoadImage(void);
@@ -94,6 +95,7 @@ const struct test winetest_testlist[] =
{ "GetWindowPlacement", func_GetWindowPlacement },
{ "GW_ENABLEDPOPUP", func_GW_ENABLEDPOPUP },
{ "InitializeLpkHooks", func_InitializeLpkHooks },
{ "IsServerSideWindow", func_IsServerSideWindow },
{ "KbdLayout", func_KbdLayout },
{ "keybd_event", func_keybd_event },
{ "LoadImage", func_LoadImage },