mirror of
https://github.com/reactos/reactos.git
synced 2026-05-30 14:34:57 +08:00
[NTUSER][WIN32U_APITEST] Fix NtUserGetCursorInfo BSOD, add tests (#8473)
Probe structure pointer before reading its cbSize. Also move the TRACE debug print outside the user critical region. CORE-18125
This commit is contained in:
@@ -59,6 +59,7 @@ list(APPEND SOURCE
|
||||
ntuser/NtUserFindExistingCursorIcon.c
|
||||
ntuser/NtUserGetAsyncKeyState.c
|
||||
ntuser/NtUserGetClassInfo.c
|
||||
ntuser/NtUserGetCursorInfo.c
|
||||
# ntuser/NtUserGetIconInfo.c
|
||||
ntuser/NtUserGetKeyboardLayoutName.c
|
||||
ntuser/NtUserGetThreadState.c
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* PROJECT: ReactOS API tests
|
||||
* LICENSE: MIT (https://spdx.org/licenses/MIT)
|
||||
* PURPOSE: Test for NtUserCreateAcceleratorTable
|
||||
* COPYRIGHT: Copyright 2025 Max Korostil <mrmks04@yandex.ru>
|
||||
*/
|
||||
|
||||
#include "../win32nt.h"
|
||||
|
||||
START_TEST(NtUserGetCursorInfo)
|
||||
{
|
||||
CURSORINFO cursor;
|
||||
DWORD error;
|
||||
BOOL res;
|
||||
|
||||
/* 1. NULL pointer */
|
||||
SetLastError(0);
|
||||
res = NtUserGetCursorInfo(NULL);
|
||||
error = GetLastError();
|
||||
|
||||
ok_int(res, FALSE);
|
||||
ok_int(error, ERROR_NOACCESS);
|
||||
|
||||
/* 2. Hardcoded invalid pointer */
|
||||
SetLastError(0);
|
||||
res = NtUserGetCursorInfo((PCURSORINFO)(ULONG_PTR)0xDEADBEEF);
|
||||
error = GetLastError();
|
||||
|
||||
ok_int(res, FALSE);
|
||||
ok_int(error, ERROR_NOACCESS);
|
||||
|
||||
/* 3. Invalid cbSize */
|
||||
SetLastError(0);
|
||||
cursor.cbSize = 0;
|
||||
res = NtUserGetCursorInfo(&cursor);
|
||||
error = GetLastError();
|
||||
|
||||
ok_int(res, FALSE);
|
||||
ok_int(error, ERROR_INVALID_PARAMETER);
|
||||
|
||||
/* 4. Single CURSORINFO pointer */
|
||||
SetLastError(0);
|
||||
cursor.cbSize = sizeof(cursor);
|
||||
res = NtUserGetCursorInfo(&cursor);
|
||||
error = GetLastError();
|
||||
|
||||
ok_int(res, TRUE);
|
||||
ok_int(error, ERROR_SUCCESS);
|
||||
|
||||
/* 5. Double CURSORINFO pointer */
|
||||
SetLastError(0);
|
||||
cursor.cbSize = sizeof(cursor) * 2;
|
||||
res = NtUserGetCursorInfo(&cursor);
|
||||
error = GetLastError();
|
||||
|
||||
ok_int(res, FALSE);
|
||||
ok_int(error, ERROR_INVALID_PARAMETER);
|
||||
}
|
||||
@@ -54,6 +54,7 @@ extern void func_NtUserEnumDisplaySettings(void);
|
||||
extern void func_NtUserFindExistingCursorIcon(void);
|
||||
extern void func_NtUserGetAsyncKeyState(void);
|
||||
extern void func_NtUserGetClassInfo(void);
|
||||
extern void func_NtUserGetCursorInfo(void);
|
||||
//extern void func_NtUserGetIconInfo(void);
|
||||
extern void func_NtUserGetKeyboardLayoutName(void);
|
||||
extern void func_NtUserGetThreadState(void);
|
||||
@@ -124,6 +125,7 @@ const struct test winetest_testlist[] =
|
||||
{ "NtUserFindExistingCursorIcon", func_NtUserFindExistingCursorIcon },
|
||||
{ "NtUserGetAsyncKeyState", func_NtUserGetAsyncKeyState },
|
||||
{ "NtUserGetClassInfo", func_NtUserGetClassInfo },
|
||||
{ "NtUserGetCursorInfo", func_NtUserGetCursorInfo },
|
||||
//{ "NtUserGetIconInfo", func_NtUserGetIconInfo },
|
||||
{ "NtUserGetKeyboardLayoutName", func_NtUserGetKeyboardLayoutName },
|
||||
{ "NtUserGetThreadState", func_NtUserGetThreadState },
|
||||
|
||||
@@ -669,9 +669,10 @@ NtUserGetCursorInfo(
|
||||
|
||||
_SEH2_TRY
|
||||
{
|
||||
ProbeForWrite(pci, sizeof(CURSORINFO), 1);
|
||||
|
||||
if (pci->cbSize == sizeof(CURSORINFO))
|
||||
{
|
||||
ProbeForWrite(pci, sizeof(CURSORINFO), 1);
|
||||
RtlCopyMemory(pci, &SafeCi, sizeof(CURSORINFO));
|
||||
Ret = TRUE;
|
||||
}
|
||||
@@ -690,8 +691,9 @@ NtUserGetCursorInfo(
|
||||
SetLastNtError(Status);
|
||||
}
|
||||
|
||||
TRACE("Leave NtUserGetCursorInfo, ret=%i\n", Ret);
|
||||
UserLeave();
|
||||
TRACE("Leave NtUserGetCursorInfo, ret=%i\n", Ret);
|
||||
|
||||
return Ret;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user