ReactOS  0.4.11-dev-721-g95bc44e
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_ ( return!  = FALSE)

MSDN: GetRegionData, Return Values:

"If the function succeeds and dwCount specifies an adequate number of bytes, the return value is always dwCount. If dwCount is too small or the function fails, the return value is 0. If lpRgnData is NULL, the return value is the required number of bytes.

If the function fails, the return value is zero."

Definition at line 407 of file cursoricon.c.

417 {
418  ICONINFO ii;
419  PCURICON_OBJECT CurIcon;
421  BOOL Ret = FALSE;
422  DWORD colorBpp = 0;
423 
424  TRACE("Enter NtUserGetIconInfo\n");
425 
426  /* Check if something was actually asked */
427  if (!IconInfo && !lpModule && !lpResName)
428  {
429  WARN("Nothing to fill.\n");
431  return FALSE;
432  }
433 
435 
436  if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
437  {
438  WARN("UserGetIconObject(0x%p) Failed.\n", hCurIcon);
439  UserLeave();
440  return FALSE;
441  }
442 
443  /* Give back the icon information */
444  if (IconInfo)
445  {
446  PCURICON_OBJECT FrameCurIcon = CurIcon;
447  if (CurIcon->CURSORF_flags & CURSORF_ACON)
448  {
449  /* Get information from first frame. */
450  FrameCurIcon = ((PACON)CurIcon)->aspcur[0];
451  }
452 
453  /* Fill data */
454  ii.fIcon = is_icon(FrameCurIcon);
455  ii.xHotspot = FrameCurIcon->xHotspot;
456  ii.yHotspot = FrameCurIcon->yHotspot;
457 
458  /* Copy bitmaps */
459  ii.hbmMask = BITMAP_CopyBitmap(FrameCurIcon->hbmMask);
461  ii.hbmColor = BITMAP_CopyBitmap(FrameCurIcon->hbmColor);
463  colorBpp = FrameCurIcon->bpp;
464 
465  /* Copy fields */
466  _SEH2_TRY
467  {
468  ProbeForWrite(IconInfo, sizeof(ICONINFO), 1);
469  RtlCopyMemory(IconInfo, &ii, sizeof(ICONINFO));
470 
471  if (pbpp)
472  {
473  ProbeForWrite(pbpp, sizeof(DWORD), 1);
474  *pbpp = colorBpp;
475  }
476  }
478  {
479  Status = _SEH2_GetExceptionCode();
480  }
481  _SEH2_END
482 
483  if (!NT_SUCCESS(Status))
484  {
485  WARN("Status: 0x%08lx\n", Status);
486  SetLastNtError(Status);
487  goto leave;
488  }
489  }
490 
491  /* Give back the module name */
492  if (lpModule)
493  {
494  ULONG BufLen = 0;
495  if (!CurIcon->atomModName)
496  goto leave;
497 
499  /* Get the module name from the atom table */
500  _SEH2_TRY
501  {
502  BufLen += sizeof(WCHAR);
503  if (BufLen > (lpModule->MaximumLength))
504  {
505  lpModule->Length = 0;
506  lpModule->MaximumLength = BufLen;
507  }
508  else
509  {
510  ProbeForWrite(lpModule->Buffer, lpModule->MaximumLength, 1);
511  BufLen = lpModule->MaximumLength;
512  RtlQueryAtomInAtomTable(gAtomTable, CurIcon->atomModName, NULL, NULL, lpModule->Buffer, &BufLen);
513  lpModule->Length = BufLen;
514  }
515  }
517  {
518  Status = _SEH2_GetExceptionCode();
519  }
520  _SEH2_END
521 
522  if (!NT_SUCCESS(Status))
523  {
524  SetLastNtError(Status);
525  goto leave;
526  }
527  }
528 
529  if (lpResName)
530  {
531  if (!CurIcon->strName.Buffer)
532  goto leave;
533 
534  /* Copy it */
535  _SEH2_TRY
536  {
538  if (IS_INTRESOURCE(CurIcon->strName.Buffer))
539  {
540  lpResName->Buffer = CurIcon->strName.Buffer;
541  lpResName->Length = 0;
542  lpResName->MaximumLength = 0;
543  }
544  else if (lpResName->MaximumLength < CurIcon->strName.MaximumLength)
545  {
546  lpResName->Length = 0;
547  lpResName->MaximumLength = CurIcon->strName.MaximumLength;
548  }
549  else
550  {
551  ProbeForWrite(lpResName->Buffer, lpResName->MaximumLength, 1);
552  RtlCopyMemory(lpResName->Buffer, CurIcon->strName.Buffer, CurIcon->strName.Length);
553  lpResName->Length = CurIcon->strName.Length;
554  }
555  }
557  {
558  Status = _SEH2_GetExceptionCode();
559  }
560  _SEH2_END
561  }
562 
563  if (!NT_SUCCESS(Status))
564  {
565  SetLastNtError(Status);
566  goto leave;
567  }
568 
569  Ret = TRUE;
570 
571 leave:
572  UserDereferenceObject(CurIcon);
573 
574  TRACE("Leave NtUserGetIconInfo, ret=%i\n", Ret);
575  UserLeave();
576 
577  return Ret;
578 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1250
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
HBITMAP hbmColor
Definition: cursoricon.h:20
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
USHORT MaximumLength
Definition: env_spec_w32.h:370
#define BufLen
Definition: fatfs.h:167
DWORD yHotspot
Definition: winuser.h:3078
#define WARN(fmt,...)
Definition: debug.h:111
_Out_opt_ PICONINFO _Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING _Out_opt_ LPDWORD pbpp
Definition: ntuser.h:2267
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
_Out_opt_ PICONINFO _Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING lpResName
Definition: ntuser.h:2267
#define WCHAR
Definition: msvc.h:43
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
DWORD DWORD
Definition: winlogon.h:84
_SEH2_TRY
Definition: create.c:4250
#define CURSORF_ACON
Definition: ntuser.h:1151
#define FALSE
Definition: types.h:117
HBITMAP hbmMask
Definition: winuser.h:3079
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
HBITMAP hbmColor
Definition: winuser.h:3080
USHORT atomModName
Definition: cursoricon.h:14
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:243
UNICODE_STRING strName
Definition: cursoricon.h:13
BOOL fIcon
Definition: winuser.h:3076
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG NTSTATUS
Definition: precomp.h:26
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
DWORD xHotspot
Definition: winuser.h:3077
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)
ULONG CURSORF_flags
Definition: cursoricon.h:16
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
_SEH2_END
Definition: create.c:4424
HBITMAP FASTCALL BITMAP_CopyBitmap(HBITMAP hBitmap)
Definition: bitmaps.c:675
HBITMAP hbmMask
Definition: cursoricon.h:19
FORCEINLINE BOOL is_icon(PCURICON_OBJECT object)
Definition: cursoricon.c:194
struct tagACON * PACON
unsigned int ULONG
Definition: retypes.h:1
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2710
_Out_opt_ PICONINFO IconInfo
Definition: ntuser.h:2267
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
DBG_DEFAULT_CHANNEL ( UserIcon  )
VOID FreeCurIconObject ( _In_ PVOID  Object)

Definition at line 332 of file cursoricon.c.

334 {
335  PCURICON_OBJECT CurIcon = Object;
336 
337  if (!(CurIcon->CURSORF_flags & CURSORF_ACON))
338  {
339  HBITMAP bmpMask = CurIcon->hbmMask;
340  HBITMAP bmpColor = CurIcon->hbmColor;
341  HBITMAP bmpAlpha = CurIcon->hbmAlpha;
342 
343  /* Delete bitmaps */
344  if (bmpMask)
345  {
347  NT_VERIFY(GreDeleteObject(bmpMask) == TRUE);
348  CurIcon->hbmMask = NULL;
349  }
350  if (bmpColor)
351  {
353  NT_VERIFY(GreDeleteObject(bmpColor) == TRUE);
354  CurIcon->hbmColor = NULL;
355  }
356  if (bmpAlpha)
357  {
359  NT_VERIFY(GreDeleteObject(bmpAlpha) == TRUE);
360  CurIcon->hbmAlpha = NULL;
361  }
362  }
363  else
364  {
365  PACON AniCurIcon = (PACON)CurIcon;
366  UINT i;
367 
368  for (i = 0; i < AniCurIcon->cpcur; i++)
369  {
370  UserDereferenceObject(AniCurIcon->aspcur[i]);
371  NT_VERIFY(IntDestroyCurIconObject(AniCurIcon->aspcur[i]) == TRUE);
372  }
374  }
375 
376  if (CurIcon->CURSORF_flags & CURSORF_LRSHARED)
377  {
378  if (!IS_INTRESOURCE(CurIcon->strName.Buffer))
380  if (CurIcon->atomModName)
382  CurIcon->strName.Buffer = NULL;
383  CurIcon->atomModName = 0;
384  }
385 
386  /* Finally free the thing */
387  FreeProcMarkObject(CurIcon);
388 }
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1250
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1153
#define TRUE
Definition: types.h:120
#define HBITMAP
Definition: msvc.h:28
HBITMAP hbmColor
Definition: cursoricon.h:20
UINT cpcur
Definition: cursoricon.h:37
#define TAG_STRING
Definition: oslist.c:24
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3289
#define CURSORF_ACON
Definition: ntuser.h:1151
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define CURSORF_LRSHARED
Definition: ntuser.h:1150
smooth NULL
Definition: ftsmooth.c:416
USHORT atomModName
Definition: cursoricon.h:14
void FreeProcMarkObject(_In_ PVOID Object)
Definition: object.c:175
UNICODE_STRING strName
Definition: cursoricon.h:13
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
static IUnknown Object
Definition: main.c:512
ULONG CURSORF_flags
Definition: cursoricon.h:16
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define USERTAG_CURSOR
Definition: tags.h:208
BOOLEAN IntDestroyCurIconObject(_In_ PVOID Object)
Definition: cursoricon.c:313
unsigned int UINT
Definition: ndis.h:50
HBITMAP hbmMask
Definition: cursoricon.h:19
HBITMAP hbmAlpha
Definition: cursoricon.h:21
NTSYSAPI NTSTATUS NTAPI RtlDeleteAtomFromAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom)
struct tagACON * PACON
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
PCURICON_OBJECT * aspcur
Definition: cursoricon.h:39
BOOL InitCursorImpl ( VOID  )

Definition at line 64 of file cursoricon.c.

Referenced by IntCreateWindowStation().

65 {
74 
75  return TRUE;
76 }
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
PCURICON_OBJECT CurrentCursorObject
Definition: cursoricon.h:74
smooth NULL
Definition: ftsmooth.c:416
SYSTEM_CURSORINFO gSysCursorInfo
Definition: cursoricon.c:25
VOID FASTCALL IntCleanupCurIconCache ( PPROCESSINFO  Win32Process)

Definition at line 391 of file cursoricon.c.

Referenced by UserProcessDestroy().

392 {
393  PCURICON_OBJECT CurIcon;
394 
395  /* Run through the list of icon objects */
396  while (Win32Process->pCursorCache)
397  {
398  CurIcon = Win32Process->pCursorCache;
399  Win32Process->pCursorCache = CurIcon->pcurNext;
400  UserDereferenceObject(CurIcon);
401  }
402 }
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
struct _CURICON_OBJECT * pCursorCache
Definition: win32.h:263
struct _CURICON_OBJECT * pcurNext
Definition: cursoricon.h:12
HANDLE IntCreateCurIconHandle ( BOOLEAN  Animated)

Definition at line 281 of file cursoricon.c.

Referenced by IntSetAconData(), and NtUserCallOneParam().

282 {
283  PCURICON_OBJECT CurIcon;
284  HANDLE hCurIcon;
285 
286  CurIcon = UserCreateObject(
287  gHandleTable,
288  NULL,
290  &hCurIcon,
291  TYPE_CURSOR,
292  Animated ? sizeof(ACON) : sizeof(CURICON_OBJECT));
293 
294  if (!CurIcon)
295  {
297  return FALSE;
298  }
299 
300  if (Animated)
301  {
302  /* We MUST set this flag, to track whether this is an ACON! */
303  CurIcon->CURSORF_flags |= CURSORF_ACON;
304  }
305 
306  NT_ASSERT(CurIcon->pcurNext == NULL);
307  UserDereferenceObject(CurIcon);
308 
309  return hCurIcon;
310 }
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:535
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:783
struct _CURICON_OBJECT * pcurNext
Definition: cursoricon.h:12
#define CURSORF_ACON
Definition: ntuser.h:1151
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
ULONG CURSORF_flags
Definition: cursoricon.h:16
DWORD *typedef HANDLE
Definition: winlogon.h:61
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define NT_ASSERT
Definition: rtlfuncs.h:3312
BOOLEAN IntDestroyCurIconObject ( _In_ PVOID  Object)

Definition at line 313 of file cursoricon.c.

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

315 {
316  PCURICON_OBJECT CurIcon = Object;
317 
318  /* Check if the cursor is in a list */
319  if (CurIcon->CURSORF_flags & CURSORF_LINKED)
320  {
321  /* Remove the cursor from it's list */
322  IntRemoveCursorFromList(CurIcon);
323  }
324 
325  /* We just mark the handle as being destroyed.
326  * Deleting all the stuff will be deferred to the actual struct free. */
327  UserDeleteObject(CurIcon->head.h, TYPE_CURSOR);
328  return TRUE;
329 }
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:683
#define TRUE
Definition: types.h:120
static VOID IntRemoveCursorFromList(_Inout_ PCURICON_OBJECT pcur)
Definition: cursoricon.c:101
#define CURSORF_LINKED
Definition: ntuser.h:1155
PROCMARKHEAD head
Definition: cursoricon.h:11
static IUnknown Object
Definition: main.c:512
ULONG CURSORF_flags
Definition: cursoricon.h:16
static VOID IntInsertCursorIntoList ( _Inout_ PCURICON_OBJECT  pcur)
static

Definition at line 80 of file cursoricon.c.

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

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 
92  UserReferenceObject(pcur);
93  pcur->pcurNext = *ppcurHead;
94  *ppcurHead = pcur;
96 }
struct _CURICON_OBJECT * pCursorCache
Definition: win32.h:263
#define CURSORF_LRSHARED
Definition: ntuser.h:1150
#define CURSORF_LINKED
Definition: ntuser.h:1155
PCURICON_OBJECT gcurFirst
Definition: cursoricon.c:27
#define CURSORF_GLOBAL
Definition: ntuser.h:1149
ULONG CURSORF_flags
Definition: cursoricon.h:16
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697
#define NT_ASSERT
Definition: rtlfuncs.h:3312
VOID IntLoadSystenIcons ( HICON  hcur,
DWORD  id 
)

Definition at line 137 of file cursoricon.c.

Referenced by co_IntSetWndIcons().

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  {
160  pcur->CURSORF_flags |= CURSORF_GLOBAL;
161  UserReferenceObject(pcur);
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;
171  pcur->CURSORF_flags |= CURSORF_GLOBAL;
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 }
#define ERROR_INVALID_CURSOR_HANDLE
Definition: winerror.h:883
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
HCURSOR hcur
Definition: msvc.h:68
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static VOID IntInsertCursorIntoList(_Inout_ PCURICON_OBJECT pcur)
Definition: cursoricon.c:80
#define OIC_WINLOGO
Definition: winuser.h:1153
GLenum GLclampf GLint i
Definition: glfuncs.h:14
SYSTEMCURICO gasysico[]
Definition: cursoricon.c:54
smooth NULL
Definition: ftsmooth.c:416
PROCMARKHEAD head
Definition: cursoricon.h:11
#define CURSORF_GLOBAL
Definition: ntuser.h:1149
struct _PROCESSINFO * ppi
Definition: ntuser.h:205
ULONG CURSORF_flags
Definition: cursoricon.h:16
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
#define W32PF_CREATEDWINORDC
Definition: win32.h:33
PCURICON_OBJECT handle
Definition: cursoricon.h:99
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697
static VOID IntRemoveCursorFromList ( _Inout_ PCURICON_OBJECT  pcur)
static

Definition at line 101 of file cursoricon.c.

Referenced by IntDestroyCurIconObject().

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 */
126  UserDereferenceObject(pcur);
127  pcur->CURSORF_flags &= ~CURSORF_LINKED;
128  return;
129  }
130  }
131 
132  /* We did not find it, this must not happen */
133  NT_ASSERT(FALSE);
134 }
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
struct _CURICON_OBJECT * pCursorCache
Definition: win32.h:263
struct _CURICON_OBJECT * pcurNext
Definition: cursoricon.h:12
#define FALSE
Definition: types.h:117
#define CURSORF_LRSHARED
Definition: ntuser.h:1150
#define CURSORF_LINKED
Definition: ntuser.h:1155
smooth NULL
Definition: ftsmooth.c:416
PCURICON_OBJECT gcurFirst
Definition: cursoricon.c:27
#define for
Definition: utility.h:88
#define CURSORF_GLOBAL
Definition: ntuser.h:1149
#define NT_ASSERT
Definition: rtlfuncs.h:3312
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.

Referenced by UserSetCursorIconData().

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 */
1296  aspcur = ExAllocatePoolWithTag(PagedPool, cjSize, USERTAG_CURSOR);
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 
1398 Cleanup:
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]);
1408  NT_VERIFY(IntDestroyCurIconObject(aspcur[i]) == TRUE);
1409  }
1410 
1411  /* Delete the allocated structure */
1413 
1414  return FALSE;
1415 }
ULONG MmUserProbeAddress
Definition: init.c:50
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG CURSORF_flags
Definition: ntuser.h:1128
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
struct tagCURSORDATA * aspcur
Definition: ntuser.h:1141
#define TAG_STRING
Definition: oslist.c:24
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
HICON HCURSOR
Definition: windef.h:289
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3289
#define DWORD
Definition: msvc.h:34
int32_t INT
Definition: typedefs.h:56
static BOOL IntSetCursorData(_Inout_ PCURICON_OBJECT pcur, _In_opt_ PUNICODE_STRING pustrName, _In_ ATOM atomModName, _In_ const CURSORDATA *pcursordata)
Definition: cursoricon.c:1130
DWORD DWORD
Definition: winlogon.h:84
#define CURSORF_ACONFRAME
Definition: ntuser.h:1153
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define CURSORF_ACON
Definition: ntuser.h:1151
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
#define __WARNING_READ_OVERRUN
Definition: suppress.h:142
#define INT(a)
Definition: assyntax.h:463
smooth NULL
Definition: ftsmooth.c:416
UNICODE_STRING strName
Definition: cursoricon.h:13
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
#define CURSORF_USER_MASK
Definition: cursoricon.h:6
ULONG CURSORF_flags
Definition: cursoricon.h:16
static const WCHAR Cleanup[]
Definition: register.c:80
#define ERR(fmt,...)
Definition: debug.h:109
#define USERTAG_CURSOR
Definition: tags.h:208
BOOLEAN IntDestroyCurIconObject(_In_ PVOID Object)
Definition: cursoricon.c:313
unsigned int UINT
Definition: ndis.h:50
HANDLE IntCreateCurIconHandle(BOOLEAN Animated)
Definition: cursoricon.c:281
NTSYSAPI NTSTATUS NTAPI RtlDeleteAtomFromAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom)
_In_ ULONG cjSize
Definition: winddi.h:3634
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:261
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _PRAGMA_WARNING_SUPPRESS(x)
Definition: suppress.h:28
#define NT_ASSERT
Definition: rtlfuncs.h:3312
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.

Referenced by IntSetAconData(), and UserSetCursorIconData().

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 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define TRUE
Definition: types.h:120
#define TAG_STRING
Definition: oslist.c:24
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3289
#define CURSORF_ACON
Definition: ntuser.h:1151
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define CURSORF_USER_MASK
Definition: cursoricon.h:6
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define ERR(fmt,...)
Definition: debug.h:109
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
BOOL NTAPI GreSetBitmapOwner(_In_ HBITMAP hbmp, _In_ ULONG ulOwner)
Definition: bitmaps.c:16
NTSYSAPI NTSTATUS NTAPI RtlDeleteAtomFromAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom)
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define NT_ASSERT
Definition: rtlfuncs.h:3312
PCURICON_OBJECT IntSystemSetCursor ( PCURICON_OBJECT  pcurNew)

Definition at line 230 of file cursoricon.c.

Referenced by co_IntProcessMouseMessage(), and DefWndHandleSetCursor().

231 {
232  PCURICON_OBJECT pcurOld = UserSetCursor(pcurNew, FALSE);
233  if (pcurNew) UserReferenceObject(pcurNew);
234  if (pcurOld) UserDereferenceObject(pcurOld);
235  return pcurOld;
236 }
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
#define FALSE
Definition: types.h:117
PCURICON_OBJECT FASTCALL UserSetCursor(PCURICON_OBJECT NewCursor, BOOL ForceChange)
Definition: msgqueue.c:93
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697
FORCEINLINE BOOL is_icon ( PCURICON_OBJECT  object)

Definition at line 194 of file cursoricon.c.

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

195 {
196  return MAKEINTRESOURCE(object->rt) == RT_ICON;
197 }
#define RT_ICON
Definition: pedump.c:365
#define MAKEINTRESOURCE
Definition: cursoricon.c:17
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  {
761  _SEH2_TRY
762  {
763  /* Probe and copy rect */
764  ProbeForRead(prcl, sizeof(RECTL), 1);
765  rclLocal = *prcl;
766  }
768  {
770  _SEH2_YIELD(return FALSE;)
771  }
772  _SEH2_END
773 
774  prcl = &rclLocal;
775  }
776 
778 
779  /* Call the internal function */
780  bResult = UserClipCursor(prcl);
781 
782  UserLeave();
783 
784  return bResult;
785 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
_SEH2_TRY
Definition: create.c:4250
#define FALSE
Definition: types.h:117
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
BOOL APIENTRY UserClipCursor(RECTL *prcl)
Definition: cursoricon.c:700
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:243
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _SEH2_YIELD(STMT_)
Definition: pseh2_64.h:8
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
_SEH2_END
Definition: create.c:4424
_In_ ULONG _In_ CLIPOBJ _In_ RECTL * prcl
Definition: winddi.h:3529
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
BOOL APIENTRY NtUserDestroyCursor ( _In_ HANDLE  hCurIcon,
_In_ BOOL  bForce 
)

Definition at line 793 of file cursoricon.c.

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

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 
847 leave:
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:1156
#define TRUE
Definition: types.h:120
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
#define WARN(fmt,...)
Definition: debug.h:111
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
#define FALSE
Definition: types.h:117
#define CURSORF_LRSHARED
Definition: ntuser.h:1150
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:243
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
PROCMARKHEAD head
Definition: cursoricon.h:11
int ret
struct _PROCESSINFO * ppi
Definition: ntuser.h:205
ULONG CURSORF_flags
Definition: cursoricon.h:16
#define ERR(fmt,...)
Definition: debug.h:109
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
BOOLEAN IntDestroyCurIconObject(_In_ PVOID Object)
Definition: cursoricon.c:313
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
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 2083 of file cursoricon.c.

Referenced by DrawIconEx().

2095 {
2096  PCURICON_OBJECT pIcon;
2097  BOOL Ret;
2098 
2099  TRACE("Enter NtUserDrawIconEx\n");
2101 
2102  if (!(pIcon = UserGetCurIconObject(hIcon)))
2103  {
2104  ERR("UserGetCurIconObject(0x%p) failed!\n", hIcon);
2105  UserLeave();
2106  return FALSE;
2107  }
2108 
2109  Ret = UserDrawIconEx(hdc,
2110  xLeft,
2111  yTop,
2112  pIcon,
2113  cxWidth,
2114  cyHeight,
2115  istepIfAniCur,
2116  hbrFlickerFreeDraw,
2117  diFlags);
2118 
2119  UserDereferenceObject(pIcon);
2120 
2121  UserLeave();
2122  return Ret;
2123 }
BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth, INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags)
Definition: cursoricon.c:1688
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
#define FALSE
Definition: types.h:117
HDC hdc
Definition: msvc.h:53
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:243
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define ERR(fmt,...)
Definition: debug.h:109
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
HICON hIcon
Definition: msconfig.c:44
HICON NTAPI NtUserFindExistingCursorIcon ( _In_ PUNICODE_STRING  pustrModule,
_In_ PUNICODE_STRING  pustrRsrc,
_In_ FINDEXISTINGCURICONPARAM param 
)

Definition at line 861 of file cursoricon.c.

Referenced by CURSORICON_LoadImageW().

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 
876  _SEH2_TRY
877  {
878  ProbeForRead(param, sizeof(*param), 1);
879  RtlCopyMemory(&paramSafe, param, sizeof(paramSafe));
880  }
882  {
883  Status = _SEH2_GetExceptionCode();
884  }
885  _SEH2_END
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 
902  UserEnterShared();
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 = CurIcon->head.h;
981  UserLeave();
982 
983 done:
984  if (!IS_INTRESOURCE(ustrRsrcSafe.Buffer))
985  ExFreePoolWithTag(ustrRsrcSafe.Buffer, TAG_STRING);
986 
987  return Ret;
988 }
static __inline NTSTATUS ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest, IN KPROCESSOR_MODE CurrentMode, IN const UNICODE_STRING *UnsafeSrc)
Definition: probe.h:142
NTSYSAPI NTSTATUS NTAPI RtlLookupAtomInAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ PWSTR AtomName, _Out_ PRTL_ATOM Atom)
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:237
static HICON
Definition: imagelist.c:84
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
unsigned short RTL_ATOM
Definition: atom.c:42
#define TAG_STRING
Definition: oslist.c:24
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
_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:150
struct _CURICON_OBJECT * pCursorCache
Definition: win32.h:263
_SEH2_TRY
Definition: create.c:4250
struct _CURICON_OBJECT * pcurNext
Definition: cursoricon.h:12
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
USHORT atomModName
Definition: cursoricon.h:14
UNICODE_STRING strName
Definition: cursoricon.h:13
static __inline VOID ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString, IN KPROCESSOR_MODE CurrentMode)
Definition: probe.h:228
#define TRACE(s)
Definition: solgame.cpp:4
LONG NTSTATUS
Definition: precomp.h:26
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
PCURICON_OBJECT gcurFirst
Definition: cursoricon.c:27
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
PROCMARKHEAD head
Definition: cursoricon.h:11
GLfloat param
Definition: glext.h:5796
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
Status
Definition: gdiplustypes.h:24
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
_SEH2_END
Definition: create.c:4424
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
FORCEINLINE BOOL is_icon(PCURICON_OBJECT object)
Definition: cursoricon.c:194
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
BOOL APIENTRY NtUserGetClipCursor ( RECTL lpRect)

Definition at line 996 of file cursoricon.c.

998 {
999  PSYSTEM_CURSORINFO CurInfo;
1000  RECTL Rect;
1001  NTSTATUS Status;
1003 
1004  TRACE("Enter NtUserGetClipCursor\n");
1005  UserEnterShared();
1006 
1008  {
1009  RETURN(FALSE);
1010  }
1011 
1012  if (!lpRect)
1013  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  {
1031  SetLastNtError(Status);
1032  RETURN(FALSE);
1033  }
1034 
1035  RETURN(TRUE);
1036 
1037 CLEANUP:
1038  TRACE("Leave NtUserGetClipCursor, ret=%i\n",_ret_);
1039  UserLeave();
1040  END_CLEANUP;
1041 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:237
#define TRUE
Definition: types.h:120
#define CLEANUP
Definition: ntuser.h:5
long bottom
Definition: polytest.cpp:53
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
long right
Definition: polytest.cpp:53
#define SM_CXSCREEN
Definition: winuser.h:949
#define FALSE
Definition: types.h:117
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:180
#define SM_CYSCREEN
Definition: winuser.h:950
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG NTSTATUS
Definition: precomp.h:26
BOOL FASTCALL CheckWinstaAttributeAccess(ACCESS_MASK DesiredAccess)
Definition: winsta.c:345
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define WINSTA_READATTRIBUTES
Definition: winuser.h:414
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
#define RETURN(rrr)
Definition: decompress.c:40
struct Rect Rect
#define END_CLEANUP
Definition: ntuser.h:6
HCURSOR NTAPI NtUserGetCursorFrameInfo ( HCURSOR  hCursor,
DWORD  istep,
INT rate_jiffies,
DWORD num_steps 
)

Definition at line 2130 of file cursoricon.c.

Referenced by GetCursorFrameInfo().

2135 {
2136  PCURICON_OBJECT CurIcon;
2137  HCURSOR ret;
2138  INT jiffies = 0;
2139  DWORD steps = 1;
2141 
2142  TRACE("Enter NtUserGetCursorFrameInfo\n");
2143  UserEnterShared();
2144 
2145  if (!(CurIcon = UserGetCurIconObject(hCursor)))
2146  {
2147  UserLeave();
2148  return NULL;
2149  }
2150 
2151  ret = CurIcon->head.h;
2152 
2153  if (CurIcon->CURSORF_flags & CURSORF_ACON)
2154  {
2155  PACON AniCurIcon = (PACON)CurIcon;
2156  if (istep >= AniCurIcon->cicur)
2157  {
2158  UserDereferenceObject(CurIcon);
2159  UserLeave();
2160  return NULL;
2161  }
2162  jiffies = AniCurIcon->ajifRate[istep];
2163  steps = AniCurIcon->cicur;
2164  ret = AniCurIcon->aspcur[AniCurIcon->aicur[istep]]->head.h;
2165  }
2166 
2167  _SEH2_TRY
2168  {
2169  ProbeForWrite(rate_jiffies, sizeof(INT), 1);
2170  ProbeForWrite(num_steps, sizeof(DWORD), 1);
2171  *rate_jiffies = jiffies;
2172  *num_steps = steps;
2173  }
2175  {
2176  Status = _SEH2_GetExceptionCode();
2177  }
2178  _SEH2_END
2179 
2180  if (!NT_SUCCESS(Status))
2181  {
2182  WARN("Status: 0x%08lx\n", Status);
2183  SetLastNtError(Status);
2184  ret = NULL;
2185  }
2186 
2187  UserDereferenceObject(CurIcon);
2188  UserLeave();
2189 
2190  TRACE("Leaving NtUserGetCursorFrameInfo, ret = 0x%p\n", ret);
2191 
2192  return ret;
2193 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:237
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
static DWORD DWORD istep
Definition: cursoricon.c:1521
#define WARN(fmt,...)
Definition: debug.h:111
#define jiffies
Definition: module.h:1075
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
INT * ajifRate
Definition: cursoricon.h:41
HICON HCURSOR
Definition: windef.h:289
int32_t INT
Definition: typedefs.h:56
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
DWORD DWORD
Definition: winlogon.h:84
_SEH2_TRY
Definition: create.c:4250
#define CURSORF_ACON
Definition: ntuser.h:1151
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
static DWORD DWORD DWORD DWORD * steps
Definition: cursoricon.c:1521
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
PROCMARKHEAD head
Definition: cursoricon.h:11
UINT cicur
Definition: cursoricon.h:38
int ret
ULONG CURSORF_flags
Definition: cursoricon.h:16
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
_SEH2_END
Definition: create.c:4424
DWORD * aicur
Definition: cursoricon.h:40
struct tagACON * PACON
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
PCURICON_OBJECT * aspcur
Definition: cursoricon.h:39
return STATUS_SUCCESS
Definition: btrfs.c:2710
BOOL APIENTRY NtUserGetCursorInfo ( PCURSORINFO  pci)

Definition at line 645 of file cursoricon.c.

Referenced by GetCursorInfo().

647 {
648  CURSORINFO SafeCi;
649  PSYSTEM_CURSORINFO CurInfo;
651  PCURICON_OBJECT CurIcon;
652  BOOL Ret = FALSE;
654 
655  TRACE("Enter NtUserGetCursorInfo\n");
656  UserEnterShared();
657 
658  CurInfo = IntGetSysCursorInfo();
659  CurIcon = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
660 
661  SafeCi.cbSize = sizeof(CURSORINFO);
662  SafeCi.flags = ((CurIcon && CurInfo->ShowingCursor >= 0) ? CURSOR_SHOWING : 0);
663  SafeCi.hCursor = (CurIcon ? CurIcon->head.h : NULL);
664 
665  SafeCi.ptScreenPos = gpsi->ptCursor;
666 
667  _SEH2_TRY
668  {
669  if (pci->cbSize == sizeof(CURSORINFO))
670  {
671  ProbeForWrite(pci, sizeof(CURSORINFO), 1);
672  RtlCopyMemory(pci, &SafeCi, sizeof(CURSORINFO));
673  Ret = TRUE;
674  }
675  else
676  {
678  }
679  }
681  {
682  Status = _SEH2_GetExceptionCode();
683  }
684  _SEH2_END;
685  if (!NT_SUCCESS(Status))
686  {
687  SetLastNtError(Status);
688  }
689 
690  RETURN(Ret);
691 
692 CLEANUP:
693  TRACE("Leave NtUserGetCursorInfo, ret=%i\n",_ret_);
694  UserLeave();
695  END_CLEANUP;
696 }
#define ERROR_INVALID_PARAMETER
Definition: compat.h:91
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:237
#define TRUE
Definition: types.h:120
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
#define CLEANUP
Definition: ntuser.h:5
PSERVERINFO gpsi
Definition: main.c:27
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
#define FALSE
Definition: types.h:117
PCURICON_OBJECT CurrentCursorObject
Definition: cursoricon.h:74
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
#define CURSOR_SHOWING
Definition: winuser.h:2612
PROCMARKHEAD head
Definition: cursoricon.h:11
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
#define DECLARE_RETURN(type)
Definition: ntuser.h:3
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
HCURSOR hCursor
Definition: winuser.h:3663
Status
Definition: gdiplustypes.h:24
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
_SEH2_END
Definition: create.c:4424
struct _CURICON_OBJECT * PCURICON_OBJECT
DWORD cbSize
Definition: winuser.h:3661
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
return STATUS_SUCCESS
Definition: btrfs.c:2710
DWORD flags
Definition: winuser.h:3662
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
#define RETURN(rrr)
Definition: decompress.c:40
#define END_CLEANUP
Definition: ntuser.h:6
POINT ptScreenPos
Definition: winuser.h:3664
BOOL APIENTRY NtUserGetIconSize ( HANDLE  hCurIcon,
UINT  istepIfAniCur,
PLONG  plcx,
PLONG  plcy 
)

Definition at line 586 of file cursoricon.c.

Referenced by get_icon_size().

591 {
592  PCURICON_OBJECT CurIcon;
594  BOOL bRet = FALSE;
595 
596  TRACE("Enter NtUserGetIconSize\n");
597  UserEnterShared();
598 
599  if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
600  {
601  goto cleanup;
602  }
603 
604  if (CurIcon->CURSORF_flags & CURSORF_ACON)
605  {
606  /* Use first frame for animated cursors */
607  PACON AniCurIcon = (PACON)CurIcon;
608  CurIcon = AniCurIcon->aspcur[0];
609  UserDereferenceObject(AniCurIcon);
610  UserReferenceObject(CurIcon);
611  }
612 
613  _SEH2_TRY
614  {
615  ProbeForWrite(plcx, sizeof(LONG), 1);
616  *plcx = CurIcon->cx;
617  ProbeForWrite(plcy, sizeof(LONG), 1);
618  *plcy = CurIcon->cy;
619  }
621  {
622  Status = _SEH2_GetExceptionCode();
623  }
624  _SEH2_END
625 
626  if (NT_SUCCESS(Status))
627  bRet = TRUE;
628  else
629  SetLastNtError(Status); // Maybe not, test this
630 
631  UserDereferenceObject(CurIcon);
632 
633 cleanup:
634  TRACE("Leave NtUserGetIconSize, ret=%i\n", bRet);
635  UserLeave();
636  return bRet;
637 }
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:237
#define TRUE
Definition: types.h:120
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
_SEH2_TRY
Definition: create.c:4250
#define CURSORF_ACON
Definition: ntuser.h:1151
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
ULONG CURSORF_flags
Definition: cursoricon.h:16
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
Status
Definition: gdiplustypes.h:24
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
_SEH2_END
Definition: create.c:4424
struct tagACON * PACON
char * cleanup(char *str)
Definition: wpickclick.c:99
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
PCURICON_OBJECT * aspcur
Definition: cursoricon.h:39
return STATUS_SUCCESS
Definition: btrfs.c:2710
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:697
HCURSOR APIENTRY NtUserSetCursor ( HCURSOR  hCursor)

Definition at line 1049 of file cursoricon.c.

Referenced by SetCursor().

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 
1108 leave:
1109  UserLeave();
1110  return hOldCursor;
1111 }
#define CURSORF_CURRENT
Definition: ntuser.h:1156
#define ERROR_INVALID_CURSOR_HANDLE
Definition: winerror.h:883
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:448
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
HICON HCURSOR
Definition: windef.h:289
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:669
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:243
#define UserHMGetHandle(obj)
Definition: ntuser.h:208
#define TRACE(s)
Definition: solgame.cpp:4
#define CURSORF_GLOBAL
Definition: ntuser.h:1149
ULONG CURSORF_flags
Definition: cursoricon.h:16
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
PCURICON_OBJECT FASTCALL UserSetCursor(PCURICON_OBJECT NewCursor, BOOL ForceChange)
Definition: msgqueue.c:93
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
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 FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:110
__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.

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

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;
1523  NTSTATUS status;
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 */
1558  pvBuffer = ExAllocatePoolWithTag(PagedPool, cjSize, USERTAG_CURSOR);
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 
1652 Exit:
1653 
1654  /* Free the captured module name */
1655  if ((ustrModule.Buffer != NULL) && !IS_INTRESOURCE(ustrModule.Buffer))
1656  {
1657  ReleaseCapturedUnicodeString(&ustrModule, UserMode);
1658  }
1659 
1660  if (pvBuffer != NULL)
1661  {
1662  ExFreePoolWithTag(pvBuffer, USERTAG_CURSOR);
1663  }
1664 
1665  /* Additional cleanup on failure */
1666  if (bResult == FALSE)
1667  {
1668  if (ustrRsrc.Buffer != NULL)
1669  {
1670  ExFreePoolWithTag(ustrRsrc.Buffer, TAG_STRING);
1671  }
1672  }
1673 
1674  TRACE("Leave NtUserSetCursorIconData, bResult = %i\n", bResult);
1675 
1676  return bResult;
1677 }
static __inline NTSTATUS ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest, IN KPROCESSOR_MODE CurrentMode, IN const UNICODE_STRING *UnsafeSrc)
Definition: probe.h:142
DWORD *typedef PVOID
Definition: winlogon.h:61
NTSYSAPI VOID NTAPI RtlCopyMemory(VOID UNALIGNED *Destination, CONST VOID UNALIGNED *Source, ULONG Length)
ULONG CURSORF_flags
Definition: ntuser.h:1128
struct tagCURSORDATA * aspcur
Definition: ntuser.h:1141
#define TAG_STRING
Definition: oslist.c:24
UINT cicur
Definition: ntuser.h:1140
_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:150
#define DWORD
Definition: msvc.h:34
int32_t INT
Definition: typedefs.h:56
DWORD DWORD
Definition: winlogon.h:84
_SEH2_TRY
Definition: create.c:4250
#define CURSORF_ACON
Definition: ntuser.h:1151
#define FALSE
Definition: types.h:117
#define INT(a)
Definition: assyntax.h:463
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:85
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:243
static __inline VOID ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString, IN KPROCESSOR_MODE CurrentMode)
Definition: probe.h:228
#define TRACE(s)
Definition: solgame.cpp:4
int * PINT
Definition: windef.h:177
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG NTSTATUS
Definition: precomp.h:26
#define IS_INTRESOURCE(i)
Definition: winuser.h:580
DWORD * aicur
Definition: ntuser.h:1142
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
UINT cpcur
Definition: ntuser.h:1139
static void Exit(void)
Definition: sock.c:1331
struct tagCURSORDATA CURSORDATA
BOOL APIENTRY UserSetCursorIconData(_In_ HCURSOR hcursor, _In_opt_ PUNICODE_STRING pustrModule, _In_opt_ PUNICODE_STRING pustrRsrc, _In_ PCURSORDATA pcursordata)
Definition: cursoricon.c:1419
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
#define CURSORF_USER_MASK
Definition: cursoricon.h:6
VOID FASTCALL SetLastNtError(NTSTATUS Status)
Definition: error.c:36
#define ERR(fmt,...)
Definition: debug.h:109
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
_SEH2_END
Definition: create.c:4424
#define USERTAG_CURSOR
Definition: tags.h:208
INT * ajifRate
Definition: ntuser.h:1143
unsigned int UINT
Definition: ndis.h:50
_In_ ULONG cjSize
Definition: winddi.h:3634
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:6
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1099
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:12
static SERVICE_STATUS status
Definition: service.c:31
BOOL APIENTRY NtUserSetSystemCursor ( HCURSOR  hcur,
DWORD  id 
)

Definition at line 2200 of file cursoricon.c.

Referenced by LoadSystemCursors(), and SetSystemCursor().

2203 {
2204  PCURICON_OBJECT pcur, pcurOrig = NULL;
2205  int i;
2206  PPROCESSINFO ppi;
2207  BOOL Ret = FALSE;
2209 
2211  {
2212  goto Exit;
2213  }
2214 
2215  if (hcur)
2216  {
2217  pcur = UserGetCurIconObject(hcur);
2218  if (!pcur)
2219  {
2221  goto Exit;
2222  }
2223 
2225 
2226  for (i = 0 ; i < 16; i++)
2227  {
2228  if (gasyscur[i].type == id)
2229  {
2230  pcurOrig = gasyscur[i].handle;
2231 
2232  if (pcurOrig) break;
2233 
2234  if (ppi->W32PF_flags & W32PF_CREATEDWINORDC)
2235  {
2236  gasyscur[i].handle = pcur;
2237  pcur->CURSORF_flags |= CURSORF_GLOBAL;
2238  pcur->head.ppi = NULL;
2240  Ret = TRUE;
2241  }
2242  break;
2243  }
2244  }
2245  if (pcurOrig)
2246  {
2247  FIXME("Need to copy cursor data or do something! pcurOrig %p new pcur %p\n",pcurOrig,pcur);
2248  }
2249  }
2250 Exit:
2251  UserLeave();
2252  return Ret;
2253 }
#define WINSTA_WRITEATTRIBUTES
Definition: winuser.h:416
#define ERROR_INVALID_CURSOR_HANDLE
Definition: winerror.h:883
#define TRUE
Definition: types.h:120
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
HCURSOR hcur
Definition: msvc.h:68
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
static VOID IntInsertCursorIntoList(_Inout_ PCURICON_OBJECT pcur)
Definition: cursoricon.c:80
SYSTEMCURICO gasyscur[]
Definition: cursoricon.c:32
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:243
unsigned int BOOL
Definition: ntddk_ex.h:94
BOOL FASTCALL CheckWinstaAttributeAccess(ACCESS_MASK DesiredAccess)
Definition: winsta.c:345
static void Exit(void)
Definition: sock.c:1331
PROCMARKHEAD head
Definition: cursoricon.h:11
#define CURSORF_GLOBAL
Definition: ntuser.h:1149
struct _PROCESSINFO * ppi
Definition: ntuser.h:205
ULONG CURSORF_flags
Definition: cursoricon.h:16
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:251
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
#define W32PF_CREATEDWINORDC
Definition: win32.h:33
PCURICON_OBJECT handle
Definition: cursoricon.h:99
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
BOOL APIENTRY UserClipCursor ( RECTL prcl)

Definition at line 700 of file cursoricon.c.

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

702 {
703  PSYSTEM_CURSORINFO CurInfo;
705 
707  {
708  return FALSE;
709  }
710 
711  CurInfo = IntGetSysCursorInfo();
712 
713  DesktopWindow = UserGetDesktopWindow();
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 ERROR_INVALID_PARAMETER
Definition: compat.h:91
#define WINSTA_WRITEATTRIBUTES
Definition: winuser.h:416
#define max(a, b)
Definition: svc.c:63
#define TRUE
Definition: types.h:120
LONG top
Definition: windef.h:297
long bottom
Definition: polytest.cpp:53
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
BOOL UserSetCursorPos(INT x, INT y, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: cursoricon.c:238
PSERVERINFO gpsi
Definition: main.c:27
long right
Definition: polytest.cpp:53
#define FALSE
Definition: types.h:117
long top
Definition: polytest.cpp:53
smooth NULL
Definition: ftsmooth.c:416
long left
Definition: polytest.cpp:53
BOOL FASTCALL CheckWinstaAttributeAccess(ACCESS_MASK DesiredAccess)
Definition: winsta.c:345
Implementation of the Explorer desktop window.
Definition: desktop.h:51
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1332
RECT rcWindow
Definition: ntuser.h:680
Definition: ntuser.h:657
#define min(a, b)
Definition: monoChain.cc:55
LONG bottom
Definition: windef.h:299
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
BOOL UserDrawIconEx ( HDC  hDc,
INT  xLeft,
INT  yTop,
PCURICON_OBJECT  pIcon,
INT  cxWidth,
INT  cyHeight,
UINT  istepIfAniCur,
HBRUSH  hbrFlickerFreeDraw,
UINT  diFlags 
)

Definition at line 1688 of file cursoricon.c.

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

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

Definition at line 200 of file cursoricon.c.

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

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:707
#define ERROR_INVALID_CURSOR_HANDLE
Definition: winerror.h:883
ASSERT((InvokeOnSuccess||InvokeOnError||InvokeOnCancel)?(CompletionRoutine!=NULL):TRUE)
#define WARN(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:669
PROCMARKHEAD head
Definition: cursoricon.h:11
struct _CURICON_OBJECT * PCURICON_OBJECT
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:27
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.

Referenced by NtUserSetCursorIconData().

1424 {
1425  PCURICON_OBJECT pcur;
1426  ATOM atomModName;
1427  NTSTATUS status;
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 
1475 Exit:
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)
1498  UserDereferenceObject(pcur);
1499 
1500  return bResult;
1501 }
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
WORD ATOM
Definition: dimm.idl:113
NTSYSAPI NTSTATUS NTAPI RtlAddAtomToAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ PWSTR AtomName, _Out_ PRTL_ATOM Atom)
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
static VOID IntInsertCursorIntoList(_Inout_ PCURICON_OBJECT pcur)
Definition: cursoricon.c:80
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:610
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3289
static BOOL IntSetCursorData(_Inout_ PCURICON_OBJECT pcur, _In_opt_ PUNICODE_STRING pustrName, _In_ ATOM atomModName, _In_ const CURSORDATA *pcursordata)
Definition: cursoricon.c:1130
#define CURSORF_ACON
Definition: ntuser.h:1151
#define FALSE
Definition: types.h:117
#define CURSORF_LRSHARED
Definition: ntuser.h:1150
smooth NULL
Definition: ftsmooth.c:416
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG NTSTATUS
Definition: precomp.h:26
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:24
static void Exit(void)
Definition: sock.c:1331
ULONG CURSORF_flags
Definition: cursoricon.h:16
#define ERR(fmt,...)
Definition: debug.h:109
NTSYSAPI NTSTATUS NTAPI RtlDeleteAtomFromAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom)
static BOOL IntSetAconData(_Inout_ PACON pacon, _In_opt_ PUNICODE_STRING pustrName, _In_ ATOM atomModName, _In_ const CURSORDATA *pcursordata)
Definition: cursoricon.c:1238
static SERVICE_STATUS status
Definition: service.c:31
BOOL UserSetCursorPos ( INT  x,
INT  y,
DWORD  flags,
ULONG_PTR  dwExtraInfo,
BOOL  Hook 
)

Definition at line 238 of file cursoricon.c.

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

239 {
241  PSYSTEM_CURSORINFO CurInfo;
242  MSG Msg;
243  RECTL rcClip;
244  POINT pt;
245 
246  if (!(DesktopWindow = UserGetDesktopWindow()))
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  pt.x = x;
265  pt.y = y;
266 
267  /* 1. Generate a mouse move message, this sets the htEx and Track Window too. */
268  Msg.message = WM_MOUSEMOVE;
269  Msg.wParam = UserGetMouseButtonsState();
270  Msg.lParam = MAKELPARAM(x, y);
271  Msg.pt = pt;
272  co_MsqInsertMouseMessage(&Msg, flags, dwExtraInfo, Hook);
273 
274  /* 2. Store the new cursor position */
275  gpsi->ptCursor = pt;
276 
277  return TRUE;
278 }
#define TRUE
Definition: types.h:120
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:582
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
#define pt(x, y)
Definition: drawing.c:79
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define MAKELPARAM(l, h)
Definition: winuser.h:3915
long bottom
Definition: polytest.cpp:53
RECT rcClient
Definition: ntuser.h:681
PSERVERINFO gpsi
Definition: main.c:27
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
struct @1571 Msg[]
long right
Definition: polytest.cpp:53
#define FALSE
Definition: types.h:117
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
Implementation of the Explorer desktop window.
Definition: desktop.h:51
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
GLbitfield flags
Definition: glext.h:7161
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1332
Definition: ntuser.h:657
#define WM_MOUSEMOVE
Definition: winuser.h:1751
INT INT y
Definition: msvc.h:62
INT x
Definition: msvc.h:62

Variable Documentation

SYSTEMCURICO gasyscur[]
Initial value:
= {
}
#define OCR_SIZEWE
Definition: winuser.h:1141
#define OCR_ICON
Definition: winuser.h:1138
#define OCR_HELP
Definition: winuser.h:1147
#define OCR_WAIT
Definition: winuser.h:1134
#define OCR_NO
Definition: winuser.h:1144
#define OCR_SIZENESW
Definition: winuser.h:1140
smooth NULL
Definition: ftsmooth.c:416
#define OCR_UP
Definition: winuser.h:1136
#define OCR_SIZE
Definition: winuser.h:1137
#define OCR_CROSS
Definition: winuser.h:1135
#define OCR_SIZEALL
Definition: winuser.h:1143
#define OCR_SIZENWSE
Definition: winuser.h:1139
#define OCR_IBEAM
Definition: winuser.h:1133
#define OCR_HAND
Definition: winuser.h:1145
#define OCR_NORMAL
Definition: winuser.h:1132
#define OCR_SIZENS
Definition: winuser.h:1142
#define OCR_APPSTARTING
Definition: winuser.h:1146

Definition at line 32 of file cursoricon.c.

SYSTEMCURICO gasysico[]
Initial value:
= {
}
#define OIC_WINLOGO
Definition: winuser.h:1153
#define OIC_NOTE
Definition: winuser.h:1152
smooth NULL
Definition: ftsmooth.c:416
#define OIC_BANG
Definition: winuser.h:1151
#define OIC_QUES
Definition: winuser.h:1150
#define OIC_SAMPLE
Definition: winuser.h:1148
#define OIC_HAND
Definition: winuser.h:1149

Definition at line 54 of file cursoricon.c.

PCURICON_OBJECT gcurFirst = NULL

Definition at line 27 of file cursoricon.c.

Referenced by NtUserFindExistingCursorIcon().

SYSTEM_CURSORINFO gSysCursorInfo

Definition at line 25 of file cursoricon.c.

Referenced by IntGetSysCursorInfo().