ReactOS 0.4.16-dev-329-g9223134
cursoricon.c File Reference
#include <win32k.h>
Include dependency graph for cursoricon.c:

Go to the source code of this file.

Functions

 DBG_DEFAULT_CHANNEL (UserIcon)
 
BOOL InitCursorImpl (VOID)
 
static VOID IntInsertCursorIntoList (_Inout_ PCURICON_OBJECT pcur)
 
static VOID IntRemoveCursorFromList (_Inout_ PCURICON_OBJECT pcur)
 
VOID IntLoadSystenIcons (HICON hcur, DWORD id)
 
PSYSTEM_CURSORINFO IntGetSysCursorInfo (VOID)
 
FORCEINLINE BOOL is_icon (PCURICON_OBJECT object)
 
PCURICON_OBJECT FASTCALL UserGetCurIconObject (HCURSOR hCurIcon)
 
PCURICON_OBJECT IntSystemSetCursor (PCURICON_OBJECT pcurNew)
 
BOOL UserSetCursorPos (INT x, INT y, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
 
HANDLE IntCreateCurIconHandle (BOOLEAN Animated)
 
BOOLEAN IntDestroyCurIconObject (_In_ PVOID Object)
 
VOID FreeCurIconObject (_In_ PVOID Object)
 
VOID FASTCALL IntCleanupCurIconCache (PPROCESSINFO Win32Process)
 
 _Success_ (return !=FALSE)
 
BOOL APIENTRY NtUserGetIconSize (HANDLE hCurIcon, UINT istepIfAniCur, PLONG plcx, PLONG plcy)
 
BOOL APIENTRY NtUserGetCursorInfo (PCURSORINFO pci)
 
BOOL APIENTRY UserClipCursor (RECTL *prcl)
 
BOOL APIENTRY NtUserClipCursor (RECTL *prcl)
 
BOOL APIENTRY NtUserDestroyCursor (_In_ HANDLE hCurIcon, _In_ BOOL bForce)
 
HICON NTAPI NtUserFindExistingCursorIcon (_In_ PUNICODE_STRING pustrModule, _In_ PUNICODE_STRING pustrRsrc, _In_ FINDEXISTINGCURICONPARAM *param)
 
BOOL APIENTRY NtUserGetClipCursor (RECTL *lpRect)
 
HCURSOR APIENTRY NtUserSetCursor (HCURSOR hCursor)
 
BOOL APIENTRY NtUserSetCursorContents (HANDLE hCurIcon, PICONINFO UnsafeIconInfo)
 
static BOOL IntSetCursorData (_Inout_ PCURICON_OBJECT pcur, _In_opt_ PUNICODE_STRING pustrName, _In_ ATOM atomModName, _In_ const CURSORDATA *pcursordata)
 
static BOOL IntSetAconData (_Inout_ PACON pacon, _In_opt_ PUNICODE_STRING pustrName, _In_ ATOM atomModName, _In_ const CURSORDATA *pcursordata)
 
BOOL APIENTRY UserSetCursorIconData (_In_ HCURSOR hcursor, _In_opt_ PUNICODE_STRING pustrModule, _In_opt_ PUNICODE_STRING pustrRsrc, _In_ PCURSORDATA pcursordata)
 
__kernel_entry BOOL APIENTRY NtUserSetCursorIconData (_In_ HCURSOR hcursor, _In_opt_ PUNICODE_STRING pustrModule, _In_opt_ PUNICODE_STRING pustrRsrc, _In_ const CURSORDATA *pCursorData)
 
BOOL UserDrawIconEx (HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth, INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags)
 
BOOL APIENTRY NtUserDrawIconEx (HDC hdc, int xLeft, int yTop, HICON hIcon, int cxWidth, int cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags, BOOL bMetaHDC, PVOID pDIXData)
 
HCURSOR NTAPI NtUserGetCursorFrameInfo (HCURSOR hCursor, DWORD istep, INT *rate_jiffies, DWORD *num_steps)
 
BOOL APIENTRY NtUserSetSystemCursor (HCURSOR hcur, DWORD id)
 

Variables

SYSTEM_CURSORINFO gSysCursorInfo
 
PCURICON_OBJECT gcurFirst = NULL
 
SYSTEMCURICO gasyscur []
 
SYSTEMCURICO gasysico []
 

Function Documentation

◆ _Success_()

_Success_ ( return = FALSE)

Definition at line 411 of file cursoricon.c.

421{
422 ICONINFO ii;
423 PCURICON_OBJECT CurIcon;
425 BOOL Ret = FALSE;
426 DWORD colorBpp = 0;
427
428 TRACE("Enter NtUserGetIconInfo\n");
429
430 /* Check if something was actually asked */
431 if (!IconInfo && !lpModule && !lpResName)
432 {
433 WARN("Nothing to fill.\n");
435 return FALSE;
436 }
437
439
440 if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
441 {
442 WARN("UserGetIconObject(0x%p) Failed.\n", hCurIcon);
443 UserLeave();
444 return FALSE;
445 }
446
447 /* Give back the icon information */
448 if (IconInfo)
449 {
450 PCURICON_OBJECT FrameCurIcon = CurIcon;
451 if (CurIcon->CURSORF_flags & CURSORF_ACON)
452 {
453 /* Get information from first frame. */
454 FrameCurIcon = ((PACON)CurIcon)->aspcur[0];
455 }
456
457 /* Fill data */
458 ii.fIcon = is_icon(FrameCurIcon);
459 ii.xHotspot = FrameCurIcon->xHotspot;
460 ii.yHotspot = FrameCurIcon->yHotspot;
461
462 /* Copy bitmaps */
463 ii.hbmMask = BITMAP_CopyBitmap(FrameCurIcon->hbmMask);
465 ii.hbmColor = BITMAP_CopyBitmap(FrameCurIcon->hbmColor);
467 colorBpp = FrameCurIcon->bpp;
468
469 /* Copy fields */
471 {
472 ProbeForWrite(IconInfo, sizeof(ICONINFO), 1);
473 RtlCopyMemory(IconInfo, &ii, sizeof(ICONINFO));
474
475 if (pbpp)
476 {
477 ProbeForWrite(pbpp, sizeof(DWORD), 1);
478 *pbpp = colorBpp;
479 }
480 }
482 {
484 }
486
487 if (!NT_SUCCESS(Status))
488 {
489 WARN("Status: 0x%08lx\n", Status);
491 goto leave;
492 }
493 }
494
495 /* Give back the module name */
496 if (lpModule)
497 {
498 ULONG BufLen = 0;
499 if (!CurIcon->atomModName)
500 goto leave;
501
503 /* Get the module name from the atom table */
505 {
506 BufLen += sizeof(WCHAR);
507 if (BufLen > (lpModule->MaximumLength))
508 {
509 lpModule->Length = 0;
510 lpModule->MaximumLength = BufLen;
511 }
512 else
513 {
514 ProbeForWrite(lpModule->Buffer, lpModule->MaximumLength, 1);
515 BufLen = lpModule->MaximumLength;
516 RtlQueryAtomInAtomTable(gAtomTable, CurIcon->atomModName, NULL, NULL, lpModule->Buffer, &BufLen);
517 lpModule->Length = BufLen;
518 }
519 }
521 {
523 }
525
526 if (!NT_SUCCESS(Status))
527 {
529 goto leave;
530 }
531 }
532
533 if (lpResName)
534 {
535 if (!CurIcon->strName.Buffer)
536 goto leave;
537
538 /* Copy it */
540 {
542 if (IS_INTRESOURCE(CurIcon->strName.Buffer))
543 {
544 lpResName->Buffer = CurIcon->strName.Buffer;
545 lpResName->Length = 0;
546 lpResName->MaximumLength = 0;
547 }
548 else if (lpResName->MaximumLength < CurIcon->strName.MaximumLength)
549 {
550 lpResName->Length = 0;
551 lpResName->MaximumLength = CurIcon->strName.MaximumLength;
552 }
553 else
554 {
555 ProbeForWrite(lpResName->Buffer, lpResName->MaximumLength, 1);
556 RtlCopyMemory(lpResName->Buffer, CurIcon->strName.Buffer, CurIcon->strName.Length);
557 lpResName->Length = CurIcon->strName.Length;
558 }
559 }
561 {
563 }
565 }
566
567 if (!NT_SUCCESS(Status))
568 {
570 goto leave;
571 }
572
573 Ret = TRUE;
574
575leave:
576 UserDereferenceObject(CurIcon);
577
578 TRACE("Leave NtUserGetIconInfo, ret=%i\n", Ret);
579 UserLeave();
580
581 return Ret;
582}
LONG NTSTATUS
Definition: precomp.h:26
#define WARN(fmt,...)
Definition: precomp.h:61
HBITMAP FASTCALL BITMAP_CopyBitmap(HBITMAP hBitmap)
Definition: bitmaps.c:714
#define leave
Definition: btrfs_drv.h:138
struct tagACON * PACON
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define BufLen
Definition: fatfs.h:167
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
Status
Definition: gdiplustypes.h:25
_Out_opt_ PICONINFO IconInfo
Definition: ntuser.h:2294
_Out_opt_ PICONINFO _Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING lpResName
Definition: ntuser.h:2296
_Out_opt_ PICONINFO _Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING _Out_opt_ LPDWORD pbpp
Definition: ntuser.h:2297
#define CURSORF_ACON
Definition: ntuser.h:1202
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
NTSYSAPI NTSTATUS NTAPI RtlQueryAtomInAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom, _Out_opt_ PULONG RefCount, _Out_opt_ PULONG PinCount, _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName, _Inout_opt_ PULONG NameLength)
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:165
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:66
#define _SEH2_END
Definition: pseh2_64.h:155
#define _SEH2_TRY
Definition: pseh2_64.h:55
#define STATUS_SUCCESS
Definition: shellext.h:65
#define TRACE(s)
Definition: solgame.cpp:4
HBITMAP hbmColor
Definition: cursoricon.h:20
HBITMAP hbmMask
Definition: cursoricon.h:19
UNICODE_STRING strName
Definition: cursoricon.h:13
USHORT atomModName
Definition: cursoricon.h:14
ULONG CURSORF_flags
Definition: cursoricon.h:16
DWORD yHotspot
Definition: winuser.h:3128
BOOL fIcon
Definition: winuser.h:3126
DWORD xHotspot
Definition: winuser.h:3127
HBITMAP hbmColor
Definition: winuser.h:3130
HBITMAP hbmMask
Definition: winuser.h:3129
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
uint32_t ULONG
Definition: typedefs.h:59
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1255
FORCEINLINE BOOL is_icon(PCURICON_OBJECT object)
Definition: cursoricon.c:194
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
__wchar_t WCHAR
Definition: xmlstorage.h:180

◆ DBG_DEFAULT_CHANNEL()

DBG_DEFAULT_CHANNEL ( UserIcon  )

◆ FreeCurIconObject()

VOID FreeCurIconObject ( _In_ PVOID  Object)

Definition at line 336 of file cursoricon.c.

338{
339 PCURICON_OBJECT CurIcon = Object;
340
341 if (!(CurIcon->CURSORF_flags & CURSORF_ACON))
342 {
343 HBITMAP bmpMask = CurIcon->hbmMask;
344 HBITMAP bmpColor = CurIcon->hbmColor;
345 HBITMAP bmpAlpha = CurIcon->hbmAlpha;
346
347 /* Delete bitmaps */
348 if (bmpMask)
349 {
351 NT_VERIFY(GreDeleteObject(bmpMask) == TRUE);
352 CurIcon->hbmMask = NULL;
353 }
354 if (bmpColor)
355 {
357 NT_VERIFY(GreDeleteObject(bmpColor) == TRUE);
358 CurIcon->hbmColor = NULL;
359 }
360 if (bmpAlpha)
361 {
363 NT_VERIFY(GreDeleteObject(bmpAlpha) == TRUE);
364 CurIcon->hbmAlpha = NULL;
365 }
366 }
367 else
368 {
369 PACON AniCurIcon = (PACON)CurIcon;
370 UINT i;
371
372 for (i = 0; i < AniCurIcon->cpcur; i++)
373 {
374 UserDereferenceObject(AniCurIcon->aspcur[i]);
376 }
378 }
379
380 if (CurIcon->CURSORF_flags & CURSORF_LRSHARED)
381 {
382 if (!IS_INTRESOURCE(CurIcon->strName.Buffer))
384 if (CurIcon->atomModName)
386 CurIcon->strName.Buffer = NULL;
387 CurIcon->atomModName = 0;
388 }
389
390 /* Finally free the thing */
391 FreeProcMarkObject(CurIcon);
392}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define CURSORF_LRSHARED
Definition: ntuser.h:1201
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
static HBITMAP
Definition: button.c:44
unsigned int UINT
Definition: ndis.h:50
NTSYSAPI NTSTATUS NTAPI RtlDeleteAtomFromAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom)
#define TAG_STRING
Definition: oslist.h:22
HBITMAP hbmAlpha
Definition: cursoricon.h:21
UINT cpcur
Definition: cursoricon.h:37
PCURICON_OBJECT * aspcur
Definition: cursoricon.h:39
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1158
BOOLEAN IntDestroyCurIconObject(_In_ PVOID Object)
Definition: cursoricon.c:317
void FreeProcMarkObject(_In_ PVOID Object)
Definition: object.c:175
#define USERTAG_CURSOR
Definition: tags.h:209
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3304

◆ InitCursorImpl()

BOOL InitCursorImpl ( VOID  )

◆ IntCleanupCurIconCache()

VOID FASTCALL IntCleanupCurIconCache ( PPROCESSINFO  Win32Process)

Definition at line 395 of file cursoricon.c.

396{
397 PCURICON_OBJECT CurIcon;
398
399 /* Run through the list of icon objects */
400 while (Win32Process->pCursorCache)
401 {
402 CurIcon = Win32Process->pCursorCache;
403 Win32Process->pCursorCache = CurIcon->pcurNext;
404 UserDereferenceObject(CurIcon);
405 }
406}
struct _CURICON_OBJECT * pcurNext
Definition: cursoricon.h:12
struct _CURICON_OBJECT * pCursorCache
Definition: win32.h:273

Referenced by UserProcessDestroy().

◆ IntCreateCurIconHandle()

HANDLE IntCreateCurIconHandle ( BOOLEAN  Animated)

Definition at line 285 of file cursoricon.c.

286{
287 PCURICON_OBJECT CurIcon;
288 HANDLE hCurIcon;
289
290 CurIcon = UserCreateObject(
292 NULL,
294 &hCurIcon,
296 Animated ? sizeof(ACON) : sizeof(CURICON_OBJECT));
297
298 if (!CurIcon)
299 {
301 return FALSE;
302 }
303
304 if (Animated)
305 {
306 /* We MUST set this flag, to track whether this is an ACON! */
307 CurIcon->CURSORF_flags |= CURSORF_ACON;
308 }
309
310 NT_ASSERT(CurIcon->pcurNext == NULL);
311 UserDereferenceObject(CurIcon);
312
313 return hCurIcon;
314}
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:807
@ TYPE_CURSOR
Definition: ntuser.h:43
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:568
#define NT_ASSERT
Definition: rtlfuncs.h:3327

Referenced by IntSetAconData(), and NtUserCallOneParam().

◆ IntDestroyCurIconObject()

BOOLEAN IntDestroyCurIconObject ( _In_ PVOID  Object)

Definition at line 317 of file cursoricon.c.

319{
320 PCURICON_OBJECT CurIcon = Object;
321
322 /* Check if the cursor is in a list */
323 if (CurIcon->CURSORF_flags & CURSORF_LINKED)
324 {
325 /* Remove the cursor from it's list */
327 }
328
329 /* We just mark the handle as being destroyed.
330 * Deleting all the stuff will be deferred to the actual struct free. */
332 return TRUE;
333}
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
#define CURSORF_LINKED
Definition: ntuser.h:1206
static VOID IntRemoveCursorFromList(_Inout_ PCURICON_OBJECT pcur)
Definition: cursoricon.c:101
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:717

Referenced by FreeCurIconObject(), IntDestroyClass(), IntSetAconData(), NtUserDestroyCursor(), and UserSetClassLongPtr().

◆ IntGetSysCursorInfo()

◆ IntInsertCursorIntoList()

static VOID IntInsertCursorIntoList ( _Inout_ PCURICON_OBJECT  pcur)
static

Definition at line 80 of file cursoricon.c.

82{
83 PPROCESSINFO ppi = pcur->head.ppi;
84 PCURICON_OBJECT *ppcurHead;
85 NT_ASSERT((pcur->CURSORF_flags & (CURSORF_GLOBAL|CURSORF_LRSHARED)) != 0);
86 NT_ASSERT((pcur->CURSORF_flags & CURSORF_LINKED) == 0);
87
88 /* Get the right list head */
89 ppcurHead = (pcur->CURSORF_flags & CURSORF_GLOBAL) ?
90 &gcurFirst : &ppi->pCursorCache;
91
93 pcur->pcurNext = *ppcurHead;
94 *ppcurHead = pcur;
96}
#define CURSORF_GLOBAL
Definition: ntuser.h:1200
PCURICON_OBJECT gcurFirst
Definition: cursoricon.c:27
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:731

Referenced by IntLoadSystenIcons(), NtUserSetSystemCursor(), and UserSetCursorIconData().

◆ IntLoadSystenIcons()

VOID IntLoadSystenIcons ( HICON  hcur,
DWORD  id 
)

Definition at line 137 of file cursoricon.c.

138{
139 PCURICON_OBJECT pcur;
140 int i;
141 PPROCESSINFO ppi;
142
143 if (hcur)
144 {
145 pcur = UserGetCurIconObject(hcur);
146 if (!pcur)
147 {
149 return;
150 }
151
153
154 if (!(ppi->W32PF_flags & W32PF_CREATEDWINORDC))
155 return;
156
157 // Set Small Window Icon and do not link.
158 if ( id == OIC_WINLOGO+1 )
159 {
162 pcur->head.ppi = NULL;
163 return;
164 }
165
166 for (i = 0 ; i < 6; i++)
167 {
168 if (gasysico[i].type == id)
169 {
170 gasysico[i].handle = pcur;
172
173 //
174 // The active switch between LR shared and Global public.
175 // This is hacked around to support this while at the initial system start up.
176 //
177 pcur->head.ppi = NULL;
178
180 return;
181 }
182 }
183 }
184}
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
PCURICON_OBJECT handle
Definition: cursoricon.h:99
PROCMARKHEAD head
Definition: cursoricon.h:11
struct _PROCESSINFO * ppi
Definition: ntuser.h:227
#define W32PF_CREATEDWINORDC
Definition: win32.h:34
static VOID IntInsertCursorIntoList(_Inout_ PCURICON_OBJECT pcur)
Definition: cursoricon.c:80
SYSTEMCURICO gasysico[]
Definition: cursoricon.c:54
#define ERROR_INVALID_CURSOR_HANDLE
Definition: winerror.h:883

Referenced by co_IntSetWndIcons().

◆ IntRemoveCursorFromList()

static VOID IntRemoveCursorFromList ( _Inout_ PCURICON_OBJECT  pcur)
static

Definition at line 101 of file cursoricon.c.

103{
104 PPROCESSINFO ppi = pcur->head.ppi;
105 PCURICON_OBJECT *ppcurHead;
106 PCURICON_OBJECT *ppcur;
107 NT_ASSERT((pcur->CURSORF_flags & (CURSORF_GLOBAL|CURSORF_LRSHARED)) != 0);
108 NT_ASSERT((pcur->CURSORF_flags & CURSORF_LINKED) != 0);
109
110 /* Get the right list head */
111 ppcurHead = (pcur->CURSORF_flags & CURSORF_GLOBAL) ?
112 &gcurFirst : &ppi->pCursorCache;
113
114 /* Loop all cursors in the cache */
115 for (ppcur = ppcurHead;
116 (*ppcur) != NULL;
117 ppcur = &(*ppcur)->pcurNext)
118 {
119 /* Check if this is the one we are looking for */
120 if ((*ppcur) == pcur)
121 {
122 /* Remove it from the list */
123 (*ppcur) = pcur->pcurNext;
124
125 /* Dereference it */
127 pcur->CURSORF_flags &= ~CURSORF_LINKED;
128 return;
129 }
130 }
131
132 /* We did not find it, this must not happen */
134}
#define for
Definition: utility.h:88

Referenced by IntDestroyCurIconObject().

◆ IntSetAconData()

static BOOL IntSetAconData ( _Inout_ PACON  pacon,
_In_opt_ PUNICODE_STRING  pustrName,
_In_ ATOM  atomModName,
_In_ const CURSORDATA pcursordata 
)
static

Definition at line 1238 of file cursoricon.c.

1243{
1244 PCURICON_OBJECT *aspcur;
1245 DWORD *aicur;
1246 INT *ajifRate;
1247 PCURSORDATA pcdFrame;
1248 HCURSOR hcurFrame;
1249 UINT cjSize, i;
1250
1251 NT_ASSERT((pacon->CURSORF_flags & CURSORF_ACON) != 0);
1252 NT_ASSERT((pacon->CURSORF_flags & CURSORF_ACONFRAME) == 0);
1253 NT_ASSERT((ULONG_PTR)pcursordata->aspcur > MmUserProbeAddress);
1254 NT_ASSERT((ULONG_PTR)pcursordata->aicur > MmUserProbeAddress);
1255 NT_ASSERT((ULONG_PTR)pcursordata->ajifRate > MmUserProbeAddress);
1256 NT_ASSERT((pcursordata->CURSORF_flags & ~CURSORF_USER_MASK) == 0);
1257 NT_ASSERT(pcursordata->cpcur > 0);
1258 NT_ASSERT(pcursordata->cicur > 0);
1259
1260 /* Check if the CURSORF_ACON is also set in the cursor data */
1261 if (!(pcursordata->CURSORF_flags & CURSORF_ACON))
1262 {
1263 ERR("Mismatch in CURSORF_flags! acon: 0x%08lx, data: 0x%08lx\n",
1264 pacon->CURSORF_flags, pcursordata->CURSORF_flags);
1265 return FALSE;
1266 }
1267
1268 /* Check if this acon was already set */
1269 if (pacon->aspcur != NULL)
1270 {
1271 ERR("Acon data already set!\n");
1272 return FALSE;
1273 }
1274
1275 /* Loop all frames indexes */
1276 for (i = 0; i < pcursordata->cicur; i++)
1277 {
1278 /* Check if the index is within the range of the frames */
1279 if (pcursordata->aicur[i] >= pcursordata->cpcur)
1280 {
1281 ERR("aicur[%lu] is out or range. Got %lu, cpcur = %u\n",
1282 i, pcursordata->aicur[i], pcursordata->cpcur);
1283 return FALSE;
1284 }
1285
1286 /* FIXME: check the JIF rates? */
1287 }
1288
1289 /* Calculate size: one cursor object for each frame, and a frame
1290 index and jiffies for each "step" */
1291 cjSize = (pcursordata->cpcur * sizeof(CURICON_OBJECT*)) +
1292 (pcursordata->cicur * sizeof(DWORD)) +
1293 (pcursordata->cicur * sizeof(INT));
1294
1295 /* Allocate a buffer */
1297 if (aspcur == NULL)
1298 {
1299 ERR("Failed to allocate memory (cpcur = %u, cicur = %u)\n",
1300 pcursordata->cpcur, pcursordata->cicur);
1301 return FALSE;
1302 }
1303
1304 /* Set the pointers */
1305 aicur = (DWORD*)&aspcur[pcursordata->cpcur];
1306 ajifRate = (INT*)&aicur[pcursordata->cicur];
1307
1308 /* Copy the values */
1309 RtlCopyMemory(aicur, pcursordata->aicur, pcursordata->cicur * sizeof(DWORD));
1310 RtlCopyMemory(ajifRate, pcursordata->ajifRate, pcursordata->cicur * sizeof(INT));
1311
1312 /* Zero out the array, so we can handle cleanup */
1313 RtlZeroMemory(aspcur, pcursordata->cpcur * sizeof(PCURICON_OBJECT));
1314
1315 /* Get a pointer to the cursor data for each frame */
1316 pcdFrame = pcursordata->aspcur;
1317
1318 /* Create the cursors */
1319 for (i = 0; i < pcursordata->cpcur; i++)
1320 {
1321 /* Create a cursor for this frame */
1322 hcurFrame = IntCreateCurIconHandle(FALSE);
1323 if (hcurFrame == NULL)
1324 {
1325 ERR("Failed to create a cursor for frame %u\n", i);
1326 goto Cleanup;
1327 }
1328
1329 /* Get a pointer to the frame cursor */
1330 aspcur[i] = UserGetCurIconObject(hcurFrame);
1332 NT_ASSERT(aspcur[i] != NULL);
1333
1334 /* Check if the flags are valid */
1336 {
1337 ERR("Invalid flags for acon frame %u: 0x%08lx\n",
1338 i, pcdFrame->CURSORF_flags);
1339 goto Cleanup;
1340 }
1341
1342 /* Set the cursor data for this frame */
1343 if (!IntSetCursorData(aspcur[i], NULL, 0, &pcdFrame[i]))
1344 {
1345 ERR("Failed to set cursor data for frame %u\n", i);
1346 goto Cleanup;
1347 }
1348
1349 /* Mark this cursor as an acon frame */
1350 aspcur[i]->CURSORF_flags |= CURSORF_ACONFRAME;
1351 }
1352
1353 /* Free the old name (Must be NULL atm.) */
1354 NT_ASSERT(pacon->strName.Buffer == NULL);
1355 if (pacon->strName.Buffer != NULL)
1356 {
1357 if (!IS_INTRESOURCE(pacon->strName.Buffer))
1358 {
1359 ExFreePoolWithTag(pacon->strName.Buffer, TAG_STRING);
1360 }
1361 RtlInitEmptyUnicodeString(&pacon->strName, NULL, 0);
1362 }
1363
1364 /* Free the module atom */
1365 if (pacon->atomModName != 0)
1366 {
1368 }
1369
1370 /* Free the previous frames */
1371 if (pacon->aspcur != NULL)
1372 {
1373 for (i = 0; i < pacon->cpcur; i++)
1374 {
1375 UserDereferenceObject(pacon->aspcur[i]);
1376 NT_VERIFY(IntDestroyCurIconObject(pacon->aspcur[i]) == TRUE);
1377 }
1378 ExFreePoolWithTag(pacon->aspcur, USERTAG_CURSOR);
1379 }
1380
1381 /* Finally set the data in the acon */
1382 pacon->atomModName = atomModName;
1383 pacon->rt = pcursordata->rt;
1384 pacon->CURSORF_flags = pcursordata->CURSORF_flags & CURSORF_USER_MASK;
1385 pacon->cpcur = pcursordata->cpcur;
1386 pacon->cicur = pcursordata->cicur;
1387 pacon->aspcur = aspcur;
1388 pacon->aicur = aicur;
1389 pacon->ajifRate = ajifRate;
1390 pacon->iicur = 0;
1391 if (pustrName != NULL)
1392 {
1393 pacon->strName = *pustrName;
1394 }
1395
1396 return TRUE;
1397
1398Cleanup:
1399
1400 /* Clean up the cursors we created */
1401 for (i = 0; i < pcursordata->cpcur; i++)
1402 {
1403 if (aspcur[i] == NULL)
1404 break;
1405
1406 /* Destroy this cursor */
1407 UserDereferenceObject(aspcur[i]);
1409 }
1410
1411 /* Delete the allocated structure */
1413
1414 return FALSE;
1415}
#define ERR(fmt,...)
Definition: precomp.h:57
#define CURSORF_USER_MASK
Definition: cursoricon.h:6
static const WCHAR Cleanup[]
Definition: register.c:80
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define PagedPool
Definition: env_spec_w32.h:308
#define CURSORF_ACONFRAME
Definition: ntuser.h:1204
#define DWORD
Definition: nt_native.h:44
ULONG MmUserProbeAddress
Definition: init.c:50
#define INT
Definition: polytest.cpp:20
ULONG CURSORF_flags
Definition: ntuser.h:1179
struct tagCURSORDATA * aspcur
Definition: ntuser.h:1192
#define __WARNING_READ_OVERRUN
Definition: suppress.h:142
#define _PRAGMA_WARNING_SUPPRESS(x)
Definition: suppress.h:28
int32_t INT
Definition: typedefs.h:58
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
HANDLE IntCreateCurIconHandle(BOOLEAN Animated)
Definition: cursoricon.c:285
static BOOL IntSetCursorData(_Inout_ PCURICON_OBJECT pcur, _In_opt_ PUNICODE_STRING pustrName, _In_ ATOM atomModName, _In_ const CURSORDATA *pcursordata)
Definition: cursoricon.c:1130
_In_ ULONG cjSize
Definition: winddi.h:3634
HICON HCURSOR
Definition: windef.h:299

Referenced by UserSetCursorIconData().

◆ IntSetCursorData()

static BOOL IntSetCursorData ( _Inout_ PCURICON_OBJECT  pcur,
_In_opt_ PUNICODE_STRING  pustrName,
_In_ ATOM  atomModName,
_In_ const CURSORDATA pcursordata 
)
static

Definition at line 1130 of file cursoricon.c.

1135{
1136 /* Check if the CURSORF_ACON is also set in the cursor data */
1137 if (pcursordata->CURSORF_flags & CURSORF_ACON)
1138 {
1139 ERR("Mismatch in CURSORF_flags! cursor: 0x%08lx, data: 0x%08lx\n",
1140 pcur->CURSORF_flags, pcursordata->CURSORF_flags);
1141 return FALSE;
1142 }
1143
1144 /* Check if this cursor was already set */
1145 if (pcur->hbmMask != NULL)
1146 {
1147 ERR("Cursor data already set!\n");
1148 return FALSE;
1149 }
1150
1151 /* We need a mask */
1152 if (pcursordata->hbmMask == NULL)
1153 {
1154 ERR("NtUserSetCursorIconData was got no hbmMask.\n");
1156 return FALSE;
1157 }
1158
1159 /* Take ownership of the mask bitmap */
1160 if (!GreSetBitmapOwner(pcursordata->hbmMask, GDI_OBJ_HMGR_PUBLIC))
1161 {
1162 ERR("Failed to set ownership of hbmMask %p.\n", pcursordata->hbmMask);
1163 return FALSE;
1164 }
1165
1166 /* Check if we have a color bitmap */
1167 if (pcursordata->hbmColor)
1168 {
1169 /* Take ownership of the color bitmap */
1170 if (!GreSetBitmapOwner(pcursordata->hbmColor, GDI_OBJ_HMGR_PUBLIC))
1171 {
1172 ERR("Failed to set ownership of hbmColor %p.\n", pcursordata->hbmColor);
1173 GreSetBitmapOwner(pcursordata->hbmMask, GDI_OBJ_HMGR_POWNED);
1174 return FALSE;
1175 }
1176 }
1177
1178 /* Check if we have an alpha bitmap */
1179 if (pcursordata->hbmAlpha)
1180 {
1181 /* Take ownership of the alpha bitmap */
1182 if (!GreSetBitmapOwner(pcursordata->hbmAlpha, GDI_OBJ_HMGR_PUBLIC))
1183 {
1184 ERR("Failed to set ownership of hbmAlpha %p.\n", pcursordata->hbmAlpha);
1185 GreSetBitmapOwner(pcursordata->hbmMask, GDI_OBJ_HMGR_POWNED);
1186 if (pcursordata->hbmColor)
1187 {
1188 GreSetBitmapOwner(pcursordata->hbmColor, GDI_OBJ_HMGR_POWNED);
1189 }
1190 return FALSE;
1191 }
1192 }
1193
1194 /* Free the old name (Must be NULL atm, but later we might allow this) */
1195 NT_ASSERT(pcur->strName.Buffer == NULL);
1196 if (pcur->strName.Buffer != NULL)
1197 {
1198 if (!IS_INTRESOURCE(pcur->strName.Buffer))
1199 {
1200 ExFreePoolWithTag(pcur->strName.Buffer, TAG_STRING);
1201 }
1202 RtlInitEmptyUnicodeString(&pcur->strName, NULL, 0);
1203 }
1204
1205 /* Free the module atom */
1206 if (pcur->atomModName != 0)
1207 {
1209 }
1210
1211 /* Now set the new cursor data */
1212 pcur->atomModName = atomModName;
1213 pcur->rt = pcursordata->rt;
1214 pcur->CURSORF_flags = pcursordata->CURSORF_flags & CURSORF_USER_MASK;
1215 pcur->xHotspot = pcursordata->xHotspot;
1216 pcur->yHotspot = pcursordata->yHotspot;
1217 pcur->hbmMask = pcursordata->hbmMask;
1218 pcur->hbmColor = pcursordata->hbmColor;
1219 pcur->hbmAlpha = pcursordata->hbmAlpha;
1220 pcur->rcBounds.left = 0;
1221 pcur->rcBounds.top = 0;
1222 pcur->rcBounds.right = pcursordata->cx;
1223 pcur->rcBounds.bottom = pcursordata->cy;
1224 pcur->hbmUserAlpha = pcursordata->hbmUserAlpha;
1225 pcur->bpp = pcursordata->bpp;
1226 pcur->cx = pcursordata->cx;
1227 pcur->cy = pcursordata->cy;
1228 if (pustrName != NULL)
1229 {
1230 pcur->strName = *pustrName;
1231 }
1232
1233 return TRUE;
1234}
BOOL NTAPI GreSetBitmapOwner(_In_ HBITMAP hbmp, _In_ ULONG ulOwner)
Definition: bitmaps.c:17
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116

Referenced by IntSetAconData(), and UserSetCursorIconData().

◆ IntSystemSetCursor()

PCURICON_OBJECT IntSystemSetCursor ( PCURICON_OBJECT  pcurNew)

Definition at line 230 of file cursoricon.c.

231{
232 PCURICON_OBJECT pcurOld = UserSetCursor(pcurNew, FALSE);
233 if (pcurNew) UserReferenceObject(pcurNew);
234 if (pcurOld) UserDereferenceObject(pcurOld);
235 return pcurOld;
236}
PCURICON_OBJECT FASTCALL UserSetCursor(PCURICON_OBJECT NewCursor, BOOL ForceChange)
Definition: msgqueue.c:93

Referenced by co_IntProcessMouseMessage(), and DefWndHandleSetCursor().

◆ is_icon()

FORCEINLINE BOOL is_icon ( PCURICON_OBJECT  object)

Definition at line 194 of file cursoricon.c.

195{
196 return MAKEINTRESOURCE(object->rt) == RT_ICON;
197}
#define RT_ICON
Definition: pedump.c:365
#define MAKEINTRESOURCE
Definition: winuser.h:591

Referenced by _Success_(), LISTVIEW_DeleteItem(), NtUserFindExistingCursorIcon(), and UserDrawIconEx().

◆ NtUserClipCursor()

BOOL APIENTRY NtUserClipCursor ( RECTL prcl)

Definition at line 753 of file cursoricon.c.

755{
756 RECTL rclLocal;
757 BOOL bResult;
758
759 if (prcl)
760 {
762 {
763 /* Probe and copy rect */
764 ProbeForRead(prcl, sizeof(RECTL), 1);
765 rclLocal = *prcl;
766 }
768 {
770 _SEH2_YIELD(return FALSE;)
771 }
773
774 prcl = &rclLocal;
775 }
776
778
779 /* Call the internal function */
780 bResult = UserClipCursor(prcl);
781
782 UserLeave();
783
784 return bResult;
785}
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:168
BOOL APIENTRY UserClipCursor(RECTL *prcl)
Definition: cursoricon.c:700
_In_ ULONG _In_ CLIPOBJ _In_ RECTL * prcl
Definition: winddi.h:3531

◆ NtUserDestroyCursor()

BOOL APIENTRY NtUserDestroyCursor ( _In_ HANDLE  hCurIcon,
_In_ BOOL  bForce 
)

Definition at line 793 of file cursoricon.c.

796{
797 BOOL ret;
798 PCURICON_OBJECT CurIcon = NULL;
799
800 TRACE("Enter NtUserDestroyCursorIcon (%p, %i)\n", hCurIcon, bForce);
802
803 CurIcon = UserGetCurIconObject(hCurIcon);
804 if (!CurIcon)
805 {
806 ret = FALSE;
807 goto leave;
808 }
809
810 if (!bForce)
811 {
812 /* Can not destroy global objects */
813 if (CurIcon->head.ppi == NULL)
814 {
815 ERR("Trying to delete global cursor!\n");
816 ret = TRUE;
817 goto leave;
818 }
819
820 /* Maybe we have good reasons not to destroy this object */
821 if (CurIcon->head.ppi != PsGetCurrentProcessWin32Process())
822 {
823 /* No way, you're not touching my cursor */
824 ret = FALSE;
825 goto leave;
826 }
827
828 if (CurIcon->CURSORF_flags & CURSORF_CURRENT)
829 {
830 WARN("Trying to delete current cursor!\n");
831 ret = FALSE;
832 goto leave;
833 }
834
835 if (CurIcon->CURSORF_flags & CURSORF_LRSHARED)
836 {
837 WARN("Trying to delete shared cursor.\n");
838 /* This one is not an error */
839 ret = TRUE;
840 goto leave;
841 }
842 }
843
844 /* Destroy the handle */
845 ret = IntDestroyCurIconObject(CurIcon);
846
847leave:
848 if (CurIcon)
849 UserDereferenceObject(CurIcon);
850 TRACE("Leave NtUserDestroyCursorIcon, ret=%i\n", ret);
851 UserLeave();
852 return ret;
853}
#define CURSORF_CURRENT
Definition: ntuser.h:1207
int ret

Referenced by CreateIconFromResourceEx(), CreateIconIndirect(), CURSORICON_CopyImage(), CURSORICON_LoadFromFileW(), CURSORICON_LoadImageW(), DestroyCursor(), DestroyIcon(), START_TEST(), and Test_OneParamRoutine_CreateEmptyCurObject().

◆ NtUserDrawIconEx()

BOOL APIENTRY NtUserDrawIconEx ( HDC  hdc,
int  xLeft,
int  yTop,
HICON  hIcon,
int  cxWidth,
int  cyHeight,
UINT  istepIfAniCur,
HBRUSH  hbrFlickerFreeDraw,
UINT  diFlags,
BOOL  bMetaHDC,
PVOID  pDIXData 
)

Definition at line 2084 of file cursoricon.c.

2096{
2097 PCURICON_OBJECT pIcon;
2098 BOOL Ret;
2099
2100 TRACE("Enter NtUserDrawIconEx\n");
2102
2103 if (!(pIcon = UserGetCurIconObject(hIcon)))
2104 {
2105 ERR("UserGetCurIconObject(0x%p) failed!\n", hIcon);
2106 UserLeave();
2107 return FALSE;
2108 }
2109
2110 Ret = UserDrawIconEx(hdc,
2111 xLeft,
2112 yTop,
2113 pIcon,
2114 cxWidth,
2115 cyHeight,
2116 istepIfAniCur,
2117 hbrFlickerFreeDraw,
2118 diFlags);
2119
2120 UserDereferenceObject(pIcon);
2121
2122 UserLeave();
2123 return Ret;
2124}
HDC hdc
Definition: main.c:9
HICON hIcon
Definition: msconfig.c:44
BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth, INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags)
Definition: cursoricon.c:1689

Referenced by DrawIconEx().

◆ NtUserFindExistingCursorIcon()

HICON NTAPI NtUserFindExistingCursorIcon ( _In_ PUNICODE_STRING  pustrModule,
_In_ PUNICODE_STRING  pustrRsrc,
_In_ FINDEXISTINGCURICONPARAM param 
)

Definition at line 861 of file cursoricon.c.

865{
866 PCURICON_OBJECT CurIcon;
867 HICON Ret = NULL;
868 UNICODE_STRING ustrModuleSafe, ustrRsrcSafe;
869 FINDEXISTINGCURICONPARAM paramSafe;
872 RTL_ATOM atomModName;
873
874 TRACE("Enter NtUserFindExistingCursorIcon\n");
875
877 {
878 ProbeForRead(param, sizeof(*param), 1);
879 RtlCopyMemory(&paramSafe, param, sizeof(paramSafe));
880 }
882 {
884 }
886
887 /* Capture resource name (it can be an INTRESOURCE == ATOM) */
888 Status = ProbeAndCaptureUnicodeStringOrAtom(&ustrRsrcSafe, pustrRsrc);
889 if (!NT_SUCCESS(Status))
890 return NULL;
891 Status = ProbeAndCaptureUnicodeString(&ustrModuleSafe, UserMode, pustrModule);
892 if (!NT_SUCCESS(Status))
893 goto done;
894 Status = RtlLookupAtomInAtomTable(gAtomTable, ustrModuleSafe.Buffer, &atomModName);
895 ReleaseCapturedUnicodeString(&ustrModuleSafe, UserMode);
896 if (!NT_SUCCESS(Status))
897 {
898 /* The module is not in the atom table. No chance to find the cursor */
899 goto done;
900 }
901
903 CurIcon = pProcInfo->pCursorCache;
904 while (CurIcon)
905 {
906 /* Icon/cursor */
907 if (paramSafe.bIcon != is_icon(CurIcon))
908 {
909 CurIcon = CurIcon->pcurNext;
910 continue;
911 }
912 /* See if module names match */
913 if (atomModName == CurIcon->atomModName)
914 {
915 /* They do. Now see if this is the same resource */
916 if (IS_INTRESOURCE(CurIcon->strName.Buffer) != IS_INTRESOURCE(ustrRsrcSafe.Buffer))
917 {
918 /* One is an INT resource and the other is not -> no match */
919 CurIcon = CurIcon->pcurNext;
920 continue;
921 }
922
923 if (IS_INTRESOURCE(CurIcon->strName.Buffer))
924 {
925 if (CurIcon->strName.Buffer == ustrRsrcSafe.Buffer)
926 {
927 /* INT resources match */
928 break;
929 }
930 }
931 else if (RtlCompareUnicodeString(&ustrRsrcSafe, &CurIcon->strName, TRUE) == 0)
932 {
933 /* Resource name strings match */
934 break;
935 }
936 }
937 CurIcon = CurIcon->pcurNext;
938 }
939
940 /* Now search Global Cursors or Icons. */
941 if (CurIcon == NULL)
942 {
943 CurIcon = gcurFirst;
944 while (CurIcon)
945 {
946 /* Icon/cursor */
947 if (paramSafe.bIcon != is_icon(CurIcon))
948 {
949 CurIcon = CurIcon->pcurNext;
950 continue;
951 }
952 /* See if module names match */
953 if (atomModName == CurIcon->atomModName)
954 {
955 /* They do. Now see if this is the same resource */
956 if (IS_INTRESOURCE(CurIcon->strName.Buffer) != IS_INTRESOURCE(ustrRsrcSafe.Buffer))
957 {
958 /* One is an INT resource and the other is not -> no match */
959 CurIcon = CurIcon->pcurNext;
960 continue;
961 }
962 if (IS_INTRESOURCE(CurIcon->strName.Buffer))
963 {
964 if (CurIcon->strName.Buffer == ustrRsrcSafe.Buffer)
965 {
966 /* INT resources match */
967 break;
968 }
969 }
970 else if (RtlCompareUnicodeString(&ustrRsrcSafe, &CurIcon->strName, TRUE) == 0)
971 {
972 /* Resource name strings match */
973 break;
974 }
975 }
976 CurIcon = CurIcon->pcurNext;
977 }
978 }
979 if (CurIcon)
980 Ret = UserHMGetHandle(CurIcon);
981 UserLeave();
982
983done:
984 if (!IS_INTRESOURCE(ustrRsrcSafe.Buffer))
985 ExFreePoolWithTag(ustrRsrcSafe.Buffer, TAG_STRING);
986
987 return Ret;
988}
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
GLfloat param
Definition: glext.h:5796
static HICON
Definition: imagelist.c:80
unsigned short RTL_ATOM
Definition: atom.c:42
#define UserMode
Definition: asm.h:35
NTSYSAPI NTSTATUS NTAPI RtlLookupAtomInAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ PWSTR AtomName, _Out_ PRTL_ATOM Atom)
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:242
static __inline NTSTATUS ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest, IN KPROCESSOR_MODE CurrentMode, IN const UNICODE_STRING *UnsafeSrc)
Definition: probe.h:142
static __inline VOID ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString, IN KPROCESSOR_MODE CurrentMode)
Definition: probe.h:239
_Must_inspect_result_ NTSTATUS NTAPI ProbeAndCaptureUnicodeStringOrAtom(_Out_ _When_(return >=0, _At_(pustrOut->Buffer, _Post_ _Notnull_)) PUNICODE_STRING pustrOut, __in_data_source(USER_MODE) _In_ PUNICODE_STRING pustrUnsafe)
Definition: class.c:152

Referenced by CURSORICON_LoadImageW().

◆ NtUserGetClipCursor()

BOOL APIENTRY NtUserGetClipCursor ( RECTL lpRect)

Definition at line 996 of file cursoricon.c.

998{
999 PSYSTEM_CURSORINFO CurInfo;
1000 RECTL Rect;
1002 BOOL Ret = FALSE;
1003
1004 TRACE("Enter NtUserGetClipCursor\n");
1006
1008 {
1009 goto Exit; // Return FALSE
1010 }
1011
1012 if (!lpRect)
1013 goto Exit; // Return FALSE
1014
1015 CurInfo = IntGetSysCursorInfo();
1016 if (CurInfo->bClipped)
1017 {
1018 Rect = CurInfo->rcClip;
1019 }
1020 else
1021 {
1022 Rect.left = 0;
1023 Rect.top = 0;
1026 }
1027
1028 Status = MmCopyToCaller(lpRect, &Rect, sizeof(RECT));
1029 if (!NT_SUCCESS(Status))
1030 {
1032 goto Exit; // Return FALSE
1033 }
1034
1035 Ret = TRUE;
1036
1037Exit:
1038 TRACE("Leave NtUserGetClipCursor, ret=%i\n", Ret);
1039 UserLeave();
1040 return Ret;
1041}
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
BOOL FASTCALL CheckWinstaAttributeAccess(ACCESS_MASK DesiredAccess)
Definition: winsta.c:377
static void Exit(void)
Definition: sock.c:1330
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:214
#define SM_CYSCREEN
Definition: winuser.h:963
#define WINSTA_READATTRIBUTES
Definition: winuser.h:414
#define SM_CXSCREEN
Definition: winuser.h:962

◆ NtUserGetCursorFrameInfo()

HCURSOR NTAPI NtUserGetCursorFrameInfo ( HCURSOR  hCursor,
DWORD  istep,
INT rate_jiffies,
DWORD num_steps 
)

Definition at line 2131 of file cursoricon.c.

2136{
2137 PCURICON_OBJECT CurIcon;
2138 HCURSOR ret;
2139 INT jiffies = 0;
2140 DWORD steps = 1;
2142
2143 TRACE("Enter NtUserGetCursorFrameInfo\n");
2145
2146 if (!(CurIcon = UserGetCurIconObject(hCursor)))
2147 {
2148 UserLeave();
2149 return NULL;
2150 }
2151
2152 ret = UserHMGetHandle(CurIcon);
2153
2154 if (CurIcon->CURSORF_flags & CURSORF_ACON)
2155 {
2156 PACON AniCurIcon = (PACON)CurIcon;
2157 if (istep >= AniCurIcon->cicur)
2158 {
2159 UserDereferenceObject(CurIcon);
2160 UserLeave();
2161 return NULL;
2162 }
2163 jiffies = AniCurIcon->ajifRate[istep];
2164 steps = AniCurIcon->cicur;
2165 ret = UserHMGetHandle(AniCurIcon->aspcur[AniCurIcon->aicur[istep]]);
2166 }
2167
2168 _SEH2_TRY
2169 {
2170 ProbeForWrite(rate_jiffies, sizeof(INT), 1);
2171 ProbeForWrite(num_steps, sizeof(DWORD), 1);
2172 *rate_jiffies = jiffies;
2173 *num_steps = steps;
2174 }
2176 {
2178 }
2179 _SEH2_END
2180
2181 if (!NT_SUCCESS(Status))
2182 {
2183 WARN("Status: 0x%08lx\n", Status);
2185 ret = NULL;
2186 }
2187
2188 UserDereferenceObject(CurIcon);
2189 UserLeave();
2190
2191 TRACE("Leaving NtUserGetCursorFrameInfo, ret = 0x%p\n", ret);
2192
2193 return ret;
2194}
#define jiffies
Definition: module.h:1085
static DWORD DWORD DWORD DWORD * steps
Definition: cursoricon.c:1638
static DWORD DWORD istep
Definition: cursoricon.c:1638
UINT cicur
Definition: cursoricon.h:38
DWORD * aicur
Definition: cursoricon.h:40
INT * ajifRate
Definition: cursoricon.h:41

Referenced by GetCursorFrameInfo().

◆ NtUserGetCursorInfo()

BOOL APIENTRY NtUserGetCursorInfo ( PCURSORINFO  pci)

Definition at line 649 of file cursoricon.c.

651{
652 CURSORINFO SafeCi;
653 PSYSTEM_CURSORINFO CurInfo;
655 PCURICON_OBJECT CurIcon;
656 BOOL Ret = FALSE;
657
658 TRACE("Enter NtUserGetCursorInfo\n");
660
661 CurInfo = IntGetSysCursorInfo();
662 CurIcon = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
663
664 SafeCi.cbSize = sizeof(CURSORINFO);
665 SafeCi.flags = ((CurIcon && CurInfo->ShowingCursor >= 0) ? CURSOR_SHOWING : 0);
666 SafeCi.hCursor = (CurIcon ? UserHMGetHandle(CurIcon) : NULL);
667
668 SafeCi.ptScreenPos = gpsi->ptCursor;
669
671 {
672 if (pci->cbSize == sizeof(CURSORINFO))
673 {
674 ProbeForWrite(pci, sizeof(CURSORINFO), 1);
675 RtlCopyMemory(pci, &SafeCi, sizeof(CURSORINFO));
676 Ret = TRUE;
677 }
678 else
679 {
681 }
682 }
684 {
686 }
687 _SEH2_END;
688 if (!NT_SUCCESS(Status))
689 {
691 }
692
693 TRACE("Leave NtUserGetCursorInfo, ret=%i\n", Ret);
694 UserLeave();
695 return Ret;
696}
struct _CURICON_OBJECT * PCURICON_OBJECT
PSERVERINFO gpsi
Definition: imm.c:18
DWORD flags
Definition: winuser.h:3723
DWORD cbSize
Definition: winuser.h:3722
HCURSOR hCursor
Definition: winuser.h:3724
POINT ptScreenPos
Definition: winuser.h:3725
#define CURSOR_SHOWING
Definition: winuser.h:2661

Referenced by GetCursorInfo().

◆ NtUserGetIconSize()

BOOL APIENTRY NtUserGetIconSize ( HANDLE  hCurIcon,
UINT  istepIfAniCur,
PLONG  plcx,
PLONG  plcy 
)

Definition at line 590 of file cursoricon.c.

595{
596 PCURICON_OBJECT CurIcon;
598 BOOL bRet = FALSE;
599
600 TRACE("Enter NtUserGetIconSize\n");
602
603 if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
604 {
605 goto cleanup;
606 }
607
608 if (CurIcon->CURSORF_flags & CURSORF_ACON)
609 {
610 /* Use first frame for animated cursors */
611 PACON AniCurIcon = (PACON)CurIcon;
612 CurIcon = AniCurIcon->aspcur[0];
613 UserDereferenceObject(AniCurIcon);
614 UserReferenceObject(CurIcon);
615 }
616
618 {
619 ProbeForWrite(plcx, sizeof(LONG), 1);
620 *plcx = CurIcon->cx;
621 ProbeForWrite(plcy, sizeof(LONG), 1);
622 *plcy = CurIcon->cy;
623 }
625 {
627 }
629
630 if (NT_SUCCESS(Status))
631 bRet = TRUE;
632 else
633 SetLastNtError(Status); // Maybe not, test this
634
635 UserDereferenceObject(CurIcon);
636
637cleanup:
638 TRACE("Leave NtUserGetIconSize, ret=%i\n", bRet);
639 UserLeave();
640 return bRet;
641}
static void cleanup(void)
Definition: main.c:1335
long LONG
Definition: pedump.c:60

Referenced by get_icon_size().

◆ NtUserSetCursor()

HCURSOR APIENTRY NtUserSetCursor ( HCURSOR  hCursor)

Definition at line 1049 of file cursoricon.c.

1051{
1052 PCURICON_OBJECT pcurOld, pcurNew;
1053 HCURSOR hOldCursor = NULL;
1054
1055 TRACE("Enter NtUserSetCursor: %p\n", hCursor);
1057
1058 if (hCursor)
1059 {
1060 pcurNew = UserGetCurIconObject(hCursor);
1061 if (!pcurNew)
1062 {
1064 goto leave;
1065 }
1066 pcurNew->CURSORF_flags |= CURSORF_CURRENT;
1067 }
1068 else
1069 {
1070 pcurNew = NULL;
1071 }
1072
1073 pcurOld = UserSetCursor(pcurNew, FALSE);
1074
1075 // If returning an old cursor than validate it, Justin Case!
1076 if ( pcurOld &&
1078 {
1079 hOldCursor = UserHMGetHandle(pcurOld);
1080 /*
1081 Problem:
1082
1083 System Global Cursors start out having at least 2 lock counts. If a system
1084 cursor is the default cursor and is returned to the caller twice in its
1085 life, the count will reach zero. Causing an assert to occur in objects.
1086
1087 This fixes a SeaMonkey crash while the mouse crosses a boundary.
1088 */
1089 if (pcurOld->CURSORF_flags & CURSORF_GLOBAL)
1090 {
1091 TRACE("Returning Global Cursor hcur %p\n",hOldCursor);
1092
1093 /*if (pcurOld->head.cLockObj > 2) // Throttle down to 2.
1094 {
1095 UserDereferenceObject(pcurOld);
1096 }
1097
1098 goto leave;*/
1099 }
1100
1101 /* See if it was destroyed in the meantime */
1102 if (UserObjectInDestroy(hOldCursor))
1103 hOldCursor = NULL;
1104 pcurOld->CURSORF_flags &= ~CURSORF_CURRENT;
1105 UserDereferenceObject(pcurOld);
1106 }
1107
1108leave:
1109 UserLeave();
1110 return hOldCursor;
1111}
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:703
PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:481

Referenced by SetCursor().

◆ NtUserSetCursorContents()

BOOL APIENTRY NtUserSetCursorContents ( HANDLE  hCurIcon,
PICONINFO  UnsafeIconInfo 
)

Definition at line 1119 of file cursoricon.c.

1122{
1123 FIXME(" is UNIMPLEMENTED.\n");
1124 return FALSE;
1125}
#define FIXME(fmt,...)
Definition: precomp.h:53

◆ NtUserSetCursorIconData()

__kernel_entry BOOL APIENTRY NtUserSetCursorIconData ( _In_ HCURSOR  hcursor,
_In_opt_ PUNICODE_STRING  pustrModule,
_In_opt_ PUNICODE_STRING  pustrRsrc,
_In_ const CURSORDATA pCursorData 
)

Definition at line 1510 of file cursoricon.c.

1515{
1516 CURSORDATA cursordata;
1517 UNICODE_STRING ustrModule, ustrRsrc;
1518 _SEH2_VOLATILE PVOID pvBuffer;
1519 CURSORDATA* aspcur;
1520 DWORD* aicur;
1521 PINT ajifRate;
1522 UINT cjSize;
1524 BOOL bResult = FALSE;
1525
1526 TRACE("Enter NtUserSetCursorIconData\n");
1527
1528 /* Initialize buffer, so we can handle cleanup */
1529 ustrRsrc.Buffer = NULL;
1530 ustrModule.Buffer = NULL;
1531 pvBuffer = NULL;
1532
1533 _SEH2_TRY
1534 {
1535 /* Probe and capture the cursor data structure */
1536 ProbeForRead(pCursorData, sizeof(*pCursorData), 1);
1537 cursordata = *pCursorData;
1538
1539 /* Check if this is an animated cursor */
1540 if (cursordata.CURSORF_flags & CURSORF_ACON)
1541 {
1542 /* Check of the range is ok */
1543 if ((cursordata.cpcur == 0) || (cursordata.cicur == 0) ||
1544 (cursordata.cpcur > 1000) || (cursordata.cicur > 1000))
1545 {
1546 ERR("Range error (cpcur = %u, cicur = %u)\n",
1547 cursordata.cpcur, cursordata.cicur);
1548 goto Exit;
1549 }
1550
1551 /* Calculate size: one cursor data structure for each frame,
1552 and a frame index and jiffies for each "step" */
1553 cjSize = (cursordata.cpcur * sizeof(CURSORDATA)) +
1554 (cursordata.cicur * sizeof(DWORD)) +
1555 (cursordata.cicur * sizeof(INT));
1556
1557 /* Allocate a buffer */
1559 if (pvBuffer == NULL)
1560 {
1561 ERR("Failed to allocate memory (cpcur = %u, cicur = %u)\n",
1562 cursordata.cpcur, cursordata.cicur);
1563 goto Exit;
1564 }
1565
1566 /* Calculate the kernel mode pointers */
1567 aspcur = (CURSORDATA*)pvBuffer;
1568 aicur = (DWORD*)&aspcur[cursordata.cpcur];
1569 ajifRate = (INT*)&aicur[cursordata.cicur];
1570
1571 /* Probe and copy aspcur */
1572 ProbeForRead(cursordata.aspcur, cursordata.cpcur * sizeof(CURSORDATA), 1);
1573 RtlCopyMemory(aspcur,
1574 cursordata.aspcur,
1575 cursordata.cpcur * sizeof(CURSORDATA));
1576
1577 /* Probe and copy aicur */
1578 ProbeForRead(cursordata.aicur, cursordata.cicur * sizeof(DWORD), 1);
1579 RtlCopyMemory(aicur,
1580 cursordata.aicur,
1581 cursordata.cicur * sizeof(DWORD));
1582
1583 /* Probe and copy ajifRate */
1584 ProbeForRead(cursordata.ajifRate, cursordata.cicur * sizeof(INT), 1);
1585 RtlCopyMemory(ajifRate,
1586 cursordata.ajifRate,
1587 cursordata.cicur * sizeof(INT));
1588
1589 /* Set the new pointers */
1590 cursordata.aspcur = aspcur;
1591 cursordata.aicur = aicur;
1592 cursordata.ajifRate = ajifRate;
1593 }
1594 else
1595 {
1596 /* This is a standard cursor, we don't use the pointers */
1597 cursordata.aspcur = NULL;
1598 cursordata.aicur = NULL;
1599 cursordata.ajifRate = NULL;
1600 }
1601 }
1603 {
1605 goto Exit;
1606 }
1607 _SEH2_END
1608
1609 /* Check if we got a module name */
1610 if (pustrModule != NULL)
1611 {
1612 /* Capture the name */
1613 status = ProbeAndCaptureUnicodeString(&ustrModule, UserMode, pustrModule);
1614 if (!NT_SUCCESS(status))
1615 {
1616 ERR("Failed to copy pustrModule: status 0x%08lx\n", status);
1617 goto Exit;
1618 }
1619 }
1620
1621 /* Check if we got a resource name */
1622 if (pustrRsrc != NULL)
1623 {
1624 /* We use this function, because INTRESOURCEs and ATOMs are the same */
1625 status = ProbeAndCaptureUnicodeStringOrAtom(&ustrRsrc, pustrRsrc);
1626 if (!NT_SUCCESS(status))
1627 {
1628 ERR("Failed to copy pustrRsrc: status 0x%08lx\n", status);
1629 goto Exit;
1630 }
1631 }
1632
1633 /* Make sure the caller doesn't give us invalid flags */
1634 if (cursordata.CURSORF_flags & ~CURSORF_USER_MASK)
1635 {
1636 ERR("Invalid cursor flags: 0x%08lx\n", cursordata.CURSORF_flags);
1637 goto Exit;
1638 }
1639
1640 /* Acquire the global user lock */
1642
1643 /* Call the internal function */
1644 bResult = UserSetCursorIconData(hcursor,
1645 pustrModule ? &ustrModule : NULL,
1646 pustrRsrc ? &ustrRsrc : NULL,
1647 &cursordata);
1648
1649 /* Release the global user lock */
1650 UserLeave();
1651
1652Exit:
1653
1654 /* Free the captured module name */
1655 if ((ustrModule.Buffer != NULL) && !IS_INTRESOURCE(ustrModule.Buffer))
1656 {
1658 }
1659
1660 if (pvBuffer != NULL)
1661 {
1663 }
1664
1665 /* Additional cleanup on failure */
1666 if (bResult == FALSE)
1667 {
1668 if ((ustrRsrc.Buffer != NULL) &&
1669 !IS_INTRESOURCE(ustrRsrc.Buffer))
1670 {
1672 }
1673 }
1674
1675 TRACE("Leave NtUserSetCursorIconData, bResult = %i\n", bResult);
1676
1677 return bResult;
1678}
struct tagCURSORDATA CURSORDATA
#define _SEH2_VOLATILE
Definition: pseh2_64.h:169
Definition: ps.c:97
DWORD * aicur
Definition: ntuser.h:1193
INT * ajifRate
Definition: ntuser.h:1194
UINT cpcur
Definition: ntuser.h:1190
UINT cicur
Definition: ntuser.h:1191
BOOL APIENTRY UserSetCursorIconData(_In_ HCURSOR hcursor, _In_opt_ PUNICODE_STRING pustrModule, _In_opt_ PUNICODE_STRING pustrRsrc, _In_ PCURSORDATA pcursordata)
Definition: cursoricon.c:1419
int * PINT
Definition: windef.h:177

Referenced by CreateIconFromResourceEx(), CreateIconIndirect(), CURSORICON_CopyImage(), CURSORICON_LoadFromFileW(), and CURSORICON_LoadImageW().

◆ NtUserSetSystemCursor()

BOOL APIENTRY NtUserSetSystemCursor ( HCURSOR  hcur,
DWORD  id 
)

Definition at line 2201 of file cursoricon.c.

2204{
2205 PCURICON_OBJECT pcur, pcurOrig = NULL;
2206 int i;
2207 PPROCESSINFO ppi;
2208 BOOL Ret = FALSE;
2210
2212 {
2213 goto Exit;
2214 }
2215
2216 if (hcur)
2217 {
2218 pcur = UserGetCurIconObject(hcur);
2219 if (!pcur)
2220 {
2222 goto Exit;
2223 }
2224
2226
2227 for (i = 0 ; i < 16; i++)
2228 {
2229 if (gasyscur[i].type == id)
2230 {
2231 pcurOrig = gasyscur[i].handle;
2232
2233 if (pcurOrig) break;
2234
2235 if (ppi->W32PF_flags & W32PF_CREATEDWINORDC)
2236 {
2237 gasyscur[i].handle = pcur;
2239 pcur->head.ppi = NULL;
2241 Ret = TRUE;
2242 }
2243 break;
2244 }
2245 }
2246 if (pcurOrig)
2247 {
2248 FIXME("Need to copy cursor data or do something! pcurOrig %p new pcur %p\n",pcurOrig,pcur);
2249 }
2250 }
2251Exit:
2252 UserLeave();
2253 return Ret;
2254}
SYSTEMCURICO gasyscur[]
Definition: cursoricon.c:32
#define WINSTA_WRITEATTRIBUTES
Definition: winuser.h:416

Referenced by LoadSystemCursors(), and SetSystemCursor().

◆ UserClipCursor()

BOOL APIENTRY UserClipCursor ( RECTL prcl)

Definition at line 700 of file cursoricon.c.

702{
703 PSYSTEM_CURSORINFO CurInfo;
705
707 {
708 return FALSE;
709 }
710
711 CurInfo = IntGetSysCursorInfo();
712
714
715 if (prcl != NULL && DesktopWindow != NULL)
716 {
717 if (prcl->right < prcl->left || prcl->bottom < prcl->top)
718 {
720 return FALSE;
721 }
722
723 CurInfo->bClipped = TRUE;
724
725 /* Set nw cliping region. Note: we can't use RECTL_bIntersectRect because
726 it sets rect to 0 0 0 0 when it's empty. For more info see monitor winetest */
727 CurInfo->rcClip.left = max(prcl->left, DesktopWindow->rcWindow.left);
728 CurInfo->rcClip.right = min(prcl->right, DesktopWindow->rcWindow.right);
729 if (CurInfo->rcClip.right < CurInfo->rcClip.left)
730 CurInfo->rcClip.right = CurInfo->rcClip.left;
731
732 CurInfo->rcClip.top = max(prcl->top, DesktopWindow->rcWindow.top);
733 CurInfo->rcClip.bottom = min(prcl->bottom, DesktopWindow->rcWindow.bottom);
734 if (CurInfo->rcClip.bottom < CurInfo->rcClip.top)
735 CurInfo->rcClip.bottom = CurInfo->rcClip.top;
736
737 /* Make sure cursor is in clipping region */
738 UserSetCursorPos(gpsi->ptCursor.x, gpsi->ptCursor.y, 0, 0, FALSE);
739 }
740 else
741 {
742 CurInfo->bClipped = FALSE;
743 }
744
745 return TRUE;
746}
#define min(a, b)
Definition: monoChain.cc:55
Implementation of the Explorer desktop window.
Definition: desktop.h:52
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
Definition: ntuser.h:694
#define max(a, b)
Definition: svc.c:63
BOOL UserSetCursorPos(INT x, INT y, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: cursoricon.c:238
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1403

Referenced by DefWndDoSizeMove(), NtUserClipCursor(), and UserChangeDisplaySettings().

◆ UserDrawIconEx()

BOOL UserDrawIconEx ( HDC  hDc,
INT  xLeft,
INT  yTop,
PCURICON_OBJECT  pIcon,
INT  cxWidth,
INT  cyHeight,
UINT  istepIfAniCur,
HBRUSH  hbrFlickerFreeDraw,
UINT  diFlags 
)

Definition at line 1689 of file cursoricon.c.

1699{
1700 PSURFACE psurfDest, psurfMask, psurfColor; //, psurfOffScreen = NULL;
1701 PDC pdc = NULL;
1702 BOOL Ret = FALSE;
1703 HBITMAP hbmMask, hbmColor, hbmAlpha;
1704 BOOL bOffScreen;
1705 RECTL rcDest, rcSrc;
1706 CLIPOBJ* pdcClipObj = NULL;
1707 EXLATEOBJ exlo;
1708
1709 /* Stupid case */
1710 if ((diFlags & DI_NORMAL) == 0)
1711 {
1712 ERR("DrawIconEx called without mask or color bitmap to draw.\n");
1713 return FALSE;
1714 }
1715
1716 if (pIcon->CURSORF_flags & CURSORF_ACON)
1717 {
1718 ACON* pAcon = (ACON*)pIcon;
1719 if (istepIfAniCur >= pAcon->cicur)
1720 {
1721 ERR("NtUserDrawIconEx: istepIfAniCur too big!\n");
1722 return FALSE;
1723 }
1724 pIcon = pAcon->aspcur[pAcon->aicur[istepIfAniCur]];
1725 }
1726
1727 hbmMask = pIcon->hbmMask;
1728 hbmColor = pIcon->hbmColor;
1729 hbmAlpha = pIcon->hbmAlpha;
1730
1731 /*
1732 * Get our objects.
1733 * Shared locks are enough, we are only reading those bitmaps
1734 */
1735 psurfMask = SURFACE_ShareLockSurface(hbmMask);
1736 if (psurfMask == NULL)
1737 {
1738 ERR("Unable to lock the mask surface.\n");
1739 return FALSE;
1740 }
1741
1742 /* Color bitmap is not mandatory */
1743 if (hbmColor == NULL)
1744 {
1745 /* But then the mask bitmap must have the information in it's bottom half */
1746 ASSERT(psurfMask->SurfObj.sizlBitmap.cy == 2*pIcon->cy);
1747 psurfColor = NULL;
1748 }
1749 else if ((psurfColor = SURFACE_ShareLockSurface(hbmColor)) == NULL)
1750 {
1751 ERR("Unable to lock the color bitmap.\n");
1752 SURFACE_ShareUnlockSurface(psurfMask);
1753 return FALSE;
1754 }
1755
1756 pdc = DC_LockDc(hDc);
1757 if (!pdc)
1758 {
1759 ERR("Could not lock the destination DC.\n");
1760 SURFACE_ShareUnlockSurface(psurfMask);
1761 if (psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
1762 return FALSE;
1763 }
1764
1765 /* Fix width parameter, if needed */
1766 if (!cxWidth)
1767 {
1768 if (diFlags & DI_DEFAULTSIZE)
1769 cxWidth = is_icon(pIcon) ?
1771 else
1772 cxWidth = pIcon->cx;
1773 }
1774
1775 /* Fix height parameter, if needed */
1776 if (!cyHeight)
1777 {
1778 if (diFlags & DI_DEFAULTSIZE)
1779 cyHeight = is_icon(pIcon) ?
1781 else
1782 cyHeight = pIcon->cy;
1783 }
1784
1785 /* Calculate destination rectangle */
1786 RECTL_vSetRect(&rcDest, xLeft, yTop, xLeft + cxWidth, yTop + cyHeight);
1787 IntLPtoDP(pdc, (LPPOINT)&rcDest, 2);
1788 RECTL_vOffsetRect(&rcDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
1789
1790 /* Prepare the underlying surface */
1791 DC_vPrepareDCsForBlit(pdc, &rcDest, NULL, NULL);
1792
1793 /* We now have our destination surface and rectangle */
1794 psurfDest = pdc->dclevel.pSurface;
1795
1796 if (psurfDest == NULL)
1797 {
1798 /* Empty DC */
1799 DC_vFinishBlit(pdc, NULL);
1800 DC_UnlockDc(pdc);
1801 SURFACE_ShareUnlockSurface(psurfMask);
1802 if (psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
1803 return FALSE;
1804 }
1805
1806 /* Set source rect */
1807 RECTL_vSetRect(&rcSrc, 0, 0, pIcon->cx, pIcon->cy);
1808
1809 /* Should we render off-screen? */
1810 bOffScreen = hbrFlickerFreeDraw &&
1811 (GDI_HANDLE_GET_TYPE(hbrFlickerFreeDraw) == GDI_OBJECT_TYPE_BRUSH);
1812
1813 if (bOffScreen)
1814 {
1815 /* Yes: Allocate and paint the offscreen surface */
1816 EBRUSHOBJ eboFill;
1817 PBRUSH pbrush = BRUSH_ShareLockBrush(hbrFlickerFreeDraw);
1818
1819 TRACE("Performing off-screen rendering.\n");
1820
1821 if (!pbrush)
1822 {
1823 ERR("Failed to get brush object.\n");
1824 goto Cleanup;
1825 }
1826
1827#if 0 //We lock the hdc surface during the whole function it makes no sense to use an offscreen surface for "flicker free" drawing
1828 psurfOffScreen = SURFACE_AllocSurface(STYPE_BITMAP,
1829 cxWidth, cyHeight, psurfDest->SurfObj.iBitmapFormat,
1830 0, 0, NULL);
1831 if (!psurfOffScreen)
1832 {
1833 ERR("Failed to allocate the off-screen surface.\n");
1834 BRUSH_ShareUnlockBrush(pbrush);
1835 goto Cleanup;
1836 }
1837
1838 /* Paint the brush */
1839 EBRUSHOBJ_vInit(&eboFill, pbrush, psurfOffScreen, 0x00FFFFFF, 0, NULL);
1840 RECTL_vSetRect(&rcDest, 0, 0, cxWidth, cyHeight);
1841
1842 Ret = IntEngBitBlt(&psurfOffScreen->SurfObj,
1843 NULL,
1844 NULL,
1845 NULL,
1846 NULL,
1847 &rcDest,
1848 NULL,
1849 NULL,
1850 &eboFill.BrushObject,
1851 &pbrush->ptOrigin,
1852 ROP4_PATCOPY);
1853
1854 /* Clean up everything */
1855 EBRUSHOBJ_vCleanup(&eboFill);
1856 BRUSH_ShareUnlockBrush(pbrush);
1857
1858 if (!Ret)
1859 {
1860 ERR("Failed to paint the off-screen surface.\n");
1861 goto Cleanup;
1862 }
1863
1864 /* We now have our destination surface */
1865 psurfDest = psurfOffScreen;
1866#else
1867 pdcClipObj = (CLIPOBJ *)&pdc->co;
1868 /* Paint the brush */
1869 EBRUSHOBJ_vInit(&eboFill, pbrush, psurfDest, 0x00FFFFFF, 0, NULL);
1870
1871 Ret = IntEngBitBlt(&psurfDest->SurfObj,
1872 NULL,
1873 NULL,
1874 pdcClipObj,
1875 NULL,
1876 &rcDest,
1877 NULL,
1878 NULL,
1879 &eboFill.BrushObject,
1880 &pbrush->ptOrigin,
1881 ROP4_PATCOPY);
1882
1883 /* Clean up everything */
1884 EBRUSHOBJ_vCleanup(&eboFill);
1885 BRUSH_ShareUnlockBrush(pbrush);
1886
1887 if (!Ret)
1888 {
1889 ERR("Failed to paint the off-screen surface.\n");
1890 goto Cleanup;
1891 }
1892#endif
1893 }
1894 else
1895 {
1896 /* We directly draw to the DC */
1897 TRACE("Performing on screen rendering.\n");
1898 pdcClipObj = (CLIPOBJ *)&pdc->co;
1899 // psurfOffScreen = NULL;
1900 }
1901
1902 /* Now do the rendering */
1903 if (hbmAlpha && ((diFlags & DI_NORMAL) == DI_NORMAL))
1904 {
1905 BLENDOBJ blendobj = { {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA } };
1906 PSURFACE psurf = NULL;
1907
1908 psurf = SURFACE_ShareLockSurface(hbmAlpha);
1909 if (!psurf)
1910 {
1911 ERR("SURFACE_LockSurface failed!\n");
1912 goto NoAlpha;
1913 }
1914
1915 /* Initialize color translation object */
1916 EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0xFFFFFFFF, 0xFFFFFFFF, 0);
1917
1918 /* Now do it */
1919 Ret = IntEngAlphaBlend(&psurfDest->SurfObj,
1920 &psurf->SurfObj,
1921 pdcClipObj,
1922 &exlo.xlo,
1923 &rcDest,
1924 &rcSrc,
1925 &blendobj);
1926
1927 EXLATEOBJ_vCleanup(&exlo);
1929 if (Ret) goto done;
1930 ERR("NtGdiAlphaBlend failed!\n");
1931 }
1932NoAlpha:
1933 if (diFlags & DI_MASK)
1934 {
1935 DWORD rop4 = (diFlags & DI_IMAGE) ? ROP4_SRCAND : ROP4_SRCCOPY;
1936
1937 EXLATEOBJ_vInitSrcMonoXlate(&exlo, psurfDest->ppal, 0x00FFFFFF, 0);
1938
1939 Ret = IntEngStretchBlt(&psurfDest->SurfObj,
1940 &psurfMask->SurfObj,
1941 NULL,
1942 pdcClipObj,
1943 &exlo.xlo,
1944 NULL,
1945 &rcDest,
1946 &rcSrc,
1947 NULL,
1948 NULL,
1949 NULL,
1950 rop4);
1951
1952 EXLATEOBJ_vCleanup(&exlo);
1953
1954 if (!Ret)
1955 {
1956 ERR("Failed to mask the bitmap data.\n");
1957 goto Cleanup;
1958 }
1959 }
1960
1961 if (diFlags & DI_IMAGE)
1962 {
1963 if (psurfColor)
1964 {
1965 DWORD rop4 = (diFlags & DI_MASK) ? ROP4_SRCINVERT : ROP4_SRCCOPY ;
1966
1967 EXLATEOBJ_vInitialize(&exlo, psurfColor->ppal, psurfDest->ppal, 0x00FFFFFF, 0x00FFFFFF, 0);
1968
1969 Ret = IntEngStretchBlt(&psurfDest->SurfObj,
1970 &psurfColor->SurfObj,
1971 NULL,
1972 pdcClipObj,
1973 &exlo.xlo,
1974 NULL,
1975 &rcDest,
1976 &rcSrc,
1977 NULL,
1978 NULL,
1979 NULL,
1980 rop4);
1981
1982 EXLATEOBJ_vCleanup(&exlo);
1983
1984 if (!Ret)
1985 {
1986 ERR("Failed to render the icon bitmap.\n");
1987 goto Cleanup;
1988 }
1989 }
1990 else
1991 {
1992 /* Mask bitmap holds the information in its bottom half */
1993 DWORD rop4 = (diFlags & DI_MASK) ? ROP4_SRCINVERT : ROP4_SRCCOPY;
1994 RECTL_vOffsetRect(&rcSrc, 0, pIcon->cy);
1995
1996 EXLATEOBJ_vInitSrcMonoXlate(&exlo, psurfDest->ppal, 0x00FFFFFF, 0);
1997
1998 Ret = IntEngStretchBlt(&psurfDest->SurfObj,
1999 &psurfMask->SurfObj,
2000 NULL,
2001 pdcClipObj,
2002 &exlo.xlo,
2003 NULL,
2004 &rcDest,
2005 &rcSrc,
2006 NULL,
2007 NULL,
2008 NULL,
2009 rop4);
2010
2011 EXLATEOBJ_vCleanup(&exlo);
2012
2013 if (!Ret)
2014 {
2015 ERR("Failed to render the icon bitmap.\n");
2016 goto Cleanup;
2017 }
2018 }
2019 }
2020
2021done:
2022#if 0
2023 /* We're done. Was it a double buffered draw ? */
2024 if (bOffScreen)
2025 {
2026 /* Yes. Draw it back to our DC */
2027 POINTL ptSrc = {0, 0};
2028
2029 /* Calculate destination rectangle */
2030 RECTL_vSetRect(&rcDest, xLeft, yTop, xLeft + cxWidth, yTop + cyHeight);
2031 IntLPtoDP(pdc, (LPPOINT)&rcDest, 2);
2032 RECTL_vOffsetRect(&rcDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
2033
2034 /* Get the clip object */
2035 pdcClipObj = pdc->rosdc.CombinedClip;
2036
2037 /* We now have our destination surface and rectangle */
2038 psurfDest = pdc->dclevel.pSurface;
2039
2040 /* Color translation */
2041 EXLATEOBJ_vInitialize(&exlo, psurfOffScreen->ppal, psurfDest->ppal, 0x00FFFFFF, 0x00FFFFFF, 0);
2042
2043 /* Blt it! */
2044 Ret = IntEngBitBlt(&psurfDest->SurfObj,
2045 &psurfOffScreen->SurfObj,
2046 NULL,
2047 pdcClipObj,
2048 &exlo.xlo,
2049 &rcDest,
2050 &ptSrc,
2051 NULL,
2052 NULL,
2053 NULL,
2054 ROP4_SRCCOPY);
2055
2056 EXLATEOBJ_vCleanup(&exlo);
2057 }
2058#endif
2059Cleanup:
2060 if (pdc)
2061 {
2062 DC_vFinishBlit(pdc, NULL);
2063 DC_UnlockDc(pdc);
2064 }
2065
2066#if 0
2067 /* Delete off screen rendering surface */
2068 if (psurfOffScreen)
2069 GDIOBJ_vDeleteObject(&psurfOffScreen->BaseObject);
2070#endif
2071
2072 /* Unlock other surfaces */
2073 SURFACE_ShareUnlockSurface(psurfMask);
2074 if (psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
2075
2076 return Ret;
2077}
static BOOLEAN IntLPtoDP(DC *pdc, PPOINTL ppt, UINT count)
Definition: coord.h:182
VOID FASTCALL DC_vPrepareDCsForBlit(PDC pdcDest, const RECT *rcDest, PDC pdcSrc, const RECT *rcSrc)
Definition: dclife.c:505
VOID FASTCALL DC_vFinishBlit(PDC pdc1, PDC pdc2)
Definition: dclife.c:614
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
VOID NTAPI EBRUSHOBJ_vCleanup(EBRUSHOBJ *pebo)
Definition: engbrush.c:153
VOID NTAPI EBRUSHOBJ_vInit(EBRUSHOBJ *pebo, PBRUSH pbrush, PSURFACE psurf, COLORREF crBackgroundClr, COLORREF crForegroundClr, PPALETTE ppalDC)
Definition: engbrush.c:52
#define BRUSH_ShareLockBrush(hBrush)
Definition: brush.h:117
#define BRUSH_ShareUnlockBrush(pBrush)
Definition: brush.h:118
#define GDI_OBJECT_TYPE_BRUSH
Definition: gdi.h:52
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
BOOL APIENTRY IntEngStretchBlt(SURFOBJ *DestObj, SURFOBJ *SourceObj, SURFOBJ *Mask, CLIPOBJ *ClipRegion, XLATEOBJ *ColorTranslation, COLORADJUSTMENT *pca, RECTL *DestRect, RECTL *SourceRect, POINTL *pMaskOrigin, BRUSHOBJ *Brush, POINTL *BrushOrigin, ULONG Mode)
#define ASSERT(a)
Definition: mode.c:44
#define AC_SRC_ALPHA
Definition: alphablend.c:9
Definition: polytest.cpp:41
CLIPOBJ CombinedClip
Definition: polytest.cpp:42
Definition: types.h:101
BRUSHOBJ BrushObject
Definition: brush.h:71
XLATEOBJ xlo
Definition: xlateobj.h:21
LONG cy
Definition: kdterminal.h:28
SURFOBJ SurfObj
Definition: surface.h:8
struct _PALETTE *const ppal
Definition: surface.h:11
SIZEL sizlBitmap
Definition: winddi.h:1209
ULONG iBitmapFormat
Definition: winddi.h:1215
#define ROP4_SRCCOPY
Definition: dib.h:13
#define ROP4_PATCOPY
Definition: dib.h:15
#define ROP4_SRCINVERT
Definition: dib.h:9
#define ROP4_SRCAND
Definition: dib.h:10
BOOL APIENTRY IntEngAlphaBlend(_Inout_ SURFOBJ *psoDest, _In_ SURFOBJ *psoSource, _In_opt_ CLIPOBJ *pco, _In_opt_ XLATEOBJ *pxlo, _In_ RECTL *prclDest, _In_ RECTL *prclSrc, _In_ BLENDOBJ *pBlendObj)
Definition: alphablend.c:198
BOOL APIENTRY IntEngBitBlt(SURFOBJ *psoTrg, SURFOBJ *psoSrc, SURFOBJ *psoMask, CLIPOBJ *pco, XLATEOBJ *pxlo, RECTL *prclTrg, POINTL *pptlSrc, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush, ROP4 Rop4)
Definition: bitblt.c:656
PSURFACE NTAPI SURFACE_AllocSurface(_In_ USHORT iType, _In_ ULONG cx, _In_ ULONG cy, _In_ ULONG iFormat, _In_ ULONG fjBitmap, _In_opt_ ULONG cjWidth, _In_opt_ ULONG cjBufSize, _In_opt_ PVOID pvBits)
Definition: surface.c:116
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
Definition: gdiobj.c:1111
FORCEINLINE VOID RECTL_vSetRect(_Out_ RECTL *prcl, _In_ LONG left, _In_ LONG top, _In_ LONG right, _In_ LONG bottom)
Definition: rect.h:5
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
#define STYPE_BITMAP
Definition: winddi.h:1175
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL _In_opt_ BRUSHOBJ _In_opt_ POINTL _In_ ROP4 rop4
Definition: winddi.h:3442
#define AC_SRC_OVER
Definition: wingdi.h:1369
#define DI_NORMAL
Definition: wingdi.h:72
#define DI_IMAGE
Definition: wingdi.h:70
#define DI_MASK
Definition: wingdi.h:71
#define DI_DEFAULTSIZE
Definition: wingdi.h:69
#define SM_CYICON
Definition: winuser.h:976
#define SM_CYCURSOR
Definition: winuser.h:978
#define SM_CXICON
Definition: winuser.h:975
#define SM_CXCURSOR
Definition: winuser.h:977
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:358
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:649
VOID NTAPI EXLATEOBJ_vInitSrcMonoXlate(PEXLATEOBJ pexlo, PPALETTE ppalDst, COLORREF crBackgroundClr, COLORREF crForegroundClr)
Definition: xlateobj.c:632

Referenced by IntDefWindowProc(), MENU_DrawBitmapItem(), NtUserDrawIconEx(), UserDrawCaption(), and UserDrawSysMenuButton().

◆ UserGetCurIconObject()

PCURICON_OBJECT FASTCALL UserGetCurIconObject ( HCURSOR  hCurIcon)

Definition at line 200 of file cursoricon.c.

201{
202 PCURICON_OBJECT CurIcon;
203
204 if (!hCurIcon)
205 {
207 return NULL;
208 }
209
210 if (UserObjectInDestroy(hCurIcon))
211 {
212 WARN("Requesting invalid/destroyed cursor.\n");
214 return NULL;
215 }
216
218 if (!CurIcon)
219 {
220 /* We never set ERROR_INVALID_ICON_HANDLE. lets hope noone ever checks for it */
222 return NULL;
223 }
224
225 ASSERT(CurIcon->head.cLockObj >= 1);
226 return CurIcon;
227}
PVOID FASTCALL UserReferenceObjectByHandle(HANDLE handle, HANDLE_TYPE type)
Definition: object.c:741

Referenced by _Success_(), DefWndDoSizeMove(), DesktopWindowProc(), IntCreateClass(), IntCreateWindow(), IntLoadSystenIcons(), IntSetAconData(), NtUserDestroyCursor(), NtUserDrawIconEx(), NtUserGetCursorFrameInfo(), NtUserGetIconSize(), NtUserSetCursor(), NtUserSetSystemCursor(), UserDrawCaption(), UserSetClassLongPtr(), and UserSetCursorIconData().

◆ UserSetCursorIconData()

BOOL APIENTRY UserSetCursorIconData ( _In_ HCURSOR  hcursor,
_In_opt_ PUNICODE_STRING  pustrModule,
_In_opt_ PUNICODE_STRING  pustrRsrc,
_In_ PCURSORDATA  pcursordata 
)

Definition at line 1419 of file cursoricon.c.

1424{
1425 PCURICON_OBJECT pcur;
1426 ATOM atomModName;
1428 BOOL bResult;
1429
1430 /* Do we have a module name? */
1431 if (pustrModule != NULL)
1432 {
1433 /* Create an atom for the module name */
1435 pustrModule->Buffer,
1436 &atomModName);
1437 if (!NT_SUCCESS(status))
1438 {
1439 ERR("Failed to create atom from module name '%wZ': 0x%08lx\n",
1440 pustrModule, status);
1441 return FALSE;
1442 }
1443 }
1444 else
1445 {
1446 /* No module name atom */
1447 atomModName = 0;
1448 }
1449
1450 /* Reference the cursor */
1451 pcur = UserGetCurIconObject(hcursor);
1452 if (pcur == NULL)
1453 {
1454 ERR("Failed to reference cursor %p\n", hcursor);
1455 bResult = FALSE;
1456 goto Exit;
1457 }
1458
1459 /* Check if this is an acon */
1460 if (pcur->CURSORF_flags & CURSORF_ACON)
1461 {
1462 bResult = IntSetAconData((PACON)pcur,
1463 pustrRsrc,
1464 atomModName,
1465 pcursordata);
1466 }
1467 else
1468 {
1469 bResult = IntSetCursorData(pcur,
1470 pustrRsrc,
1471 atomModName,
1472 pcursordata);
1473 }
1474
1475Exit:
1476
1477 /* Check if we had success */
1478 if (bResult != FALSE)
1479 {
1480 /* Check if this is an LRSHARED cursor now */
1481 if (pcur->CURSORF_flags & CURSORF_LRSHARED)
1482 {
1483 /* Insert the cursor into the list. */
1485 }
1486 }
1487 else
1488 {
1489 /* Cleanup on failure */
1490 if (atomModName != 0)
1491 {
1493 }
1494 }
1495
1496 /* Dereference the cursor and return the result */
1497 if (pcur)
1499
1500 return bResult;
1501}
WORD ATOM
Definition: dimm.idl:113
NTSYSAPI NTSTATUS NTAPI RtlAddAtomToAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ PWSTR AtomName, _Out_ PRTL_ATOM Atom)
static BOOL IntSetAconData(_Inout_ PACON pacon, _In_opt_ PUNICODE_STRING pustrName, _In_ ATOM atomModName, _In_ const CURSORDATA *pcursordata)
Definition: cursoricon.c:1238

Referenced by NtUserSetCursorIconData().

◆ UserSetCursorPos()

BOOL UserSetCursorPos ( INT  x,
INT  y,
DWORD  flags,
ULONG_PTR  dwExtraInfo,
BOOL  Hook 
)

Definition at line 238 of file cursoricon.c.

239{
241 PSYSTEM_CURSORINFO CurInfo;
242 MSG Msg;
243 RECTL rcClip;
244 POINT pt;
245
247 {
248 return FALSE;
249 }
250
251 CurInfo = IntGetSysCursorInfo();
252
253 /* Clip cursor position */
254 if (!CurInfo->bClipped)
255 rcClip = DesktopWindow->rcClient;
256 else
257 rcClip = CurInfo->rcClip;
258
259 if (x >= rcClip.right) x = rcClip.right - 1;
260 if (x < rcClip.left) x = rcClip.left;
261 if (y >= rcClip.bottom) y = rcClip.bottom - 1;
262 if (y < rcClip.top) y = rcClip.top;
263
264 /* Nothing to do if position did not actually change */
265 if (x == gpsi->ptCursor.x && y == gpsi->ptCursor.y)
266 return TRUE;
267
268 pt.x = x;
269 pt.y = y;
270
271 /* 1. Generate a mouse move message, this sets the htEx and Track Window too */
272 Msg.message = WM_MOUSEMOVE;
273 Msg.wParam = UserGetMouseButtonsState();
274 Msg.lParam = MAKELPARAM(x, y);
275 Msg.pt = pt;
276 co_MsqInsertMouseMessage(&Msg, flags, dwExtraInfo, Hook);
277
278 /* 2. Store the new cursor position */
279 gpsi->ptCursor = pt;
280
281 return TRUE;
282}
struct @1642 Msg[]
#define pt(x, y)
Definition: drawing.c:79
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLbitfield flags
Definition: glext.h:7161
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:580
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
#define MAKELPARAM(l, h)
Definition: winuser.h:4011
#define WM_MOUSEMOVE
Definition: winuser.h:1778

Referenced by DefWndDoSizeMove(), DefWndStartSizeMove(), NtUserCallTwoParam(), UserClipCursor(), and UserSendMouseInput().

Variable Documentation

◆ gasyscur

SYSTEMCURICO gasyscur[]
Initial value:
= {
{OCR_NORMAL, NULL},
{OCR_IBEAM, NULL},
{OCR_WAIT, NULL},
{OCR_CROSS, NULL},
{OCR_UP, NULL},
{OCR_ICON, NULL},
{OCR_SIZE, NULL},
{OCR_SIZENWSE, NULL},
{OCR_SIZENESW, NULL},
{OCR_SIZEWE, NULL},
{OCR_SIZENS, NULL},
{OCR_SIZEALL, NULL},
{OCR_NO, NULL},
{OCR_HAND, NULL},
{OCR_APPSTARTING,NULL},
{OCR_HELP, NULL},
}

Definition at line 32 of file cursoricon.c.

Referenced by NtUserSetSystemCursor().

◆ gasysico

SYSTEMCURICO gasysico[]
Initial value:
= {
{OIC_SAMPLE, NULL},
{OIC_HAND, NULL},
{OIC_QUES, NULL},
{OIC_BANG, NULL},
{OIC_NOTE, NULL},
{OIC_WINLOGO,NULL},
}

Definition at line 54 of file cursoricon.c.

Referenced by IntLoadSystenIcons().

◆ gcurFirst

◆ gSysCursorInfo

SYSTEM_CURSORINFO gSysCursorInfo

Definition at line 25 of file cursoricon.c.

Referenced by InitCursorImpl(), and IntGetSysCursorInfo().