ReactOS 0.4.16-dev-2104-gb84fa49
cursoricon.c
Go to the documentation of this file.
1/*
2 * COPYRIGHT: See COPYING in the top level directory
3 * PROJECT: ReactOS Win32k subsystem
4 * PURPOSE: Cursor and icon functions
5 * FILE: win32ss/user/ntuser/cursoricon.c
6 * PROGRAMER: ReactOS Team
7 */
8/*
9 * We handle two types of cursors/icons:
10 * - Private
11 * Loaded without LR_SHARED flag
12 * Private to a process
13 * Can be deleted by calling NtDestroyCursorIcon()
14 * CurIcon->hModule, CurIcon->hRsrc and CurIcon->hGroupRsrc set to NULL
15 * - Shared
16 * Loaded with LR_SHARED flag
17 * Possibly shared by multiple processes
18 * Immune to NtDestroyCursorIcon()
19 * CurIcon->hModule, CurIcon->hRsrc and CurIcon->hGroupRsrc are valid
20 */
21
22#include <win32k.h>
24
26
27PCURICON_OBJECT gcurFirst = NULL; // After all is done, this should be WINLOGO!
28
29//
30// System Cursors
31//
33 {OCR_NORMAL, NULL},
34 {OCR_IBEAM, NULL},
35 {OCR_WAIT, NULL},
36 {OCR_CROSS, NULL},
37 {OCR_UP, NULL},
38 {OCR_ICON, NULL},
39 {OCR_SIZE, NULL},
40 {OCR_SIZENWSE, NULL},
41 {OCR_SIZENESW, NULL},
42 {OCR_SIZEWE, NULL},
43 {OCR_SIZENS, NULL},
44 {OCR_SIZEALL, NULL},
45 {OCR_NO, NULL},
46 {OCR_HAND, NULL},
47 {OCR_APPSTARTING,NULL},
48 {OCR_HELP, NULL},
49 };
50
51//
52// System Icons
53//
55 {OIC_SAMPLE, NULL},
56 {OIC_HAND, NULL},
57 {OIC_QUES, NULL},
58 {OIC_BANG, NULL},
59 {OIC_NOTE, NULL},
60 {OIC_WINLOGO,NULL},
61 };
62
63BOOL
65{
74
75 return TRUE;
76}
77
78static
79VOID
82{
83 PPROCESSINFO ppi = pcur->head.ppi;
84 PCURICON_OBJECT *ppcurHead;
85 NT_ASSERT((pcur->CURSORF_flags & (CURSORF_GLOBAL|CURSORF_LRSHARED)) != 0);
86 NT_ASSERT((pcur->CURSORF_flags & CURSORF_LINKED) == 0);
87
88 /* Get the right list head */
89 ppcurHead = (pcur->CURSORF_flags & CURSORF_GLOBAL) ?
90 &gcurFirst : &ppi->pCursorCache;
91
93 pcur->pcurNext = *ppcurHead;
94 *ppcurHead = pcur;
96}
97
98// FIXME: should think about using a LIST_ENTRY!
99static
100VOID
103{
104 PPROCESSINFO ppi = pcur->head.ppi;
105 PCURICON_OBJECT *ppcurHead;
106 PCURICON_OBJECT *ppcur;
107 NT_ASSERT((pcur->CURSORF_flags & (CURSORF_GLOBAL|CURSORF_LRSHARED)) != 0);
108 NT_ASSERT((pcur->CURSORF_flags & CURSORF_LINKED) != 0);
109
110 /* Get the right list head */
111 ppcurHead = (pcur->CURSORF_flags & CURSORF_GLOBAL) ?
112 &gcurFirst : &ppi->pCursorCache;
113
114 /* Loop all cursors in the cache */
115 for (ppcur = ppcurHead;
116 (*ppcur) != NULL;
117 ppcur = &(*ppcur)->pcurNext)
118 {
119 /* Check if this is the one we are looking for */
120 if ((*ppcur) == pcur)
121 {
122 /* Remove it from the list */
123 (*ppcur) = pcur->pcurNext;
124
125 /* Dereference it */
127 pcur->CURSORF_flags &= ~CURSORF_LINKED;
128 return;
129 }
130 }
131
132 /* We did not find it, this must not happen */
134}
135
136VOID
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_INTERNAL_WINSMALL )
159 {
162 pcur->head.ppi = NULL;
163 return;
164 }
165
166 for (i = 0 ; i < 6; i++)
167 {
168 if (gasysico[i].type == id)
169 {
170 gasysico[i].handle = pcur;
172
173 //
174 // The active switch between LR shared and Global public.
175 // This is hacked around to support this while at the initial system start up.
176 //
177 pcur->head.ppi = NULL;
178
180 return;
181 }
182 }
183 }
184}
185
188{
189 return &gSysCursorInfo;
190}
191
193BOOL
195{
196 return MAKEINTRESOURCE(object->rt) == RT_ICON;
197}
198
199/* This function creates a reference for the object! */
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}
228
231{
232 PCURICON_OBJECT pcurOld = UserSetCursor(pcurNew, FALSE);
233 if (pcurNew) UserReferenceObject(pcurNew);
234 if (pcurOld) UserDereferenceObject(pcurOld);
235 return pcurOld;
236}
237
239{
241 PSYSTEM_CURSORINFO CurInfo;
242 MSG Msg;
243 RECTL rcClip;
244 POINT pt;
245
247 {
248 return FALSE;
249 }
250
251 CurInfo = IntGetSysCursorInfo();
252
253 /* Clip cursor position */
254 if (!CurInfo->bClipped)
255 rcClip = DesktopWindow->rcClient;
256 else
257 rcClip = CurInfo->rcClip;
258
259 if (x >= rcClip.right) x = rcClip.right - 1;
260 if (x < rcClip.left) x = rcClip.left;
261 if (y >= rcClip.bottom) y = rcClip.bottom - 1;
262 if (y < rcClip.top) y = rcClip.top;
263
264 /* Nothing to do if position did not actually change */
265 if (x == gpsi->ptCursor.x && y == gpsi->ptCursor.y)
266 return TRUE;
267
268 pt.x = x;
269 pt.y = y;
270
271 /* 1. Generate a mouse move message, this sets the htEx and Track Window too */
272 Msg.message = WM_MOUSEMOVE;
273 Msg.wParam = UserGetMouseButtonsState();
274 Msg.lParam = MAKELPARAM(x, y);
275 Msg.pt = pt;
276 co_MsqInsertMouseMessage(&Msg, flags, dwExtraInfo, Hook);
277
278 /* 2. Store the new cursor position */
279 gpsi->ptCursor = pt;
280
281 return TRUE;
282}
283
284HANDLE
286{
287 PCURICON_OBJECT CurIcon;
288 HANDLE hCurIcon;
289
290 CurIcon = UserCreateObject(
292 NULL,
294 &hCurIcon,
296 Animated ? sizeof(ACON) : sizeof(CURICON_OBJECT));
297
298 if (!CurIcon)
299 {
301 return FALSE;
302 }
303
304 if (Animated)
305 {
306 /* We MUST set this flag, to track whether this is an ACON! */
307 CurIcon->CURSORF_flags |= CURSORF_ACON;
308 }
309
310 NT_ASSERT(CurIcon->pcurNext == NULL);
311 UserDereferenceObject(CurIcon);
312
313 return hCurIcon;
314}
315
319{
320 PCURICON_OBJECT CurIcon = Object;
321
322 /* Check if the cursor is in a list */
323 if (CurIcon->CURSORF_flags & CURSORF_LINKED)
324 {
325 /* Remove the cursor from it's list */
327 }
328
329 /* We just mark the handle as being destroyed.
330 * Deleting all the stuff will be deferred to the actual struct free. */
332 return TRUE;
333}
334
335VOID
338{
339 PCURICON_OBJECT CurIcon = Object;
340
341 if (!(CurIcon->CURSORF_flags & CURSORF_ACON))
342 {
343 HBITMAP bmpMask = CurIcon->hbmMask;
344 HBITMAP bmpColor = CurIcon->hbmColor;
345 HBITMAP bmpAlpha = CurIcon->hbmAlpha;
346
347 /* Delete bitmaps */
348 if (bmpMask)
349 {
351 NT_VERIFY(GreDeleteObject(bmpMask) == TRUE);
352 CurIcon->hbmMask = NULL;
353 }
354 if (bmpColor)
355 {
357 NT_VERIFY(GreDeleteObject(bmpColor) == TRUE);
358 CurIcon->hbmColor = NULL;
359 }
360 if (bmpAlpha)
361 {
363 NT_VERIFY(GreDeleteObject(bmpAlpha) == TRUE);
364 CurIcon->hbmAlpha = NULL;
365 }
366 }
367 else
368 {
369 PACON AniCurIcon = (PACON)CurIcon;
370 UINT i;
371
372 for (i = 0; i < AniCurIcon->cpcur; i++)
373 {
374 UserDereferenceObject(AniCurIcon->aspcur[i]);
376 }
378 }
379
380 if (CurIcon->CURSORF_flags & CURSORF_LRSHARED)
381 {
382 if (!IS_INTRESOURCE(CurIcon->strName.Buffer))
384 if (CurIcon->atomModName)
386 CurIcon->strName.Buffer = NULL;
387 CurIcon->atomModName = 0;
388 }
389
390 /* Finally free the thing */
391 FreeProcMarkObject(CurIcon);
392}
393
396{
397 PCURICON_OBJECT CurIcon;
398
399 /* Run through the list of icon objects */
400 while (Win32Process->pCursorCache)
401 {
402 CurIcon = Win32Process->pCursorCache;
403 Win32Process->pCursorCache = CurIcon->pcurNext;
404 UserDereferenceObject(CurIcon);
405 }
406}
407
408/*
409 * @implemented
410 */
411_Success_(return != FALSE)
412BOOL
413NTAPI
414NtUserGetIconInfo(
415 _In_ HANDLE hCurIcon,
421{
422 ICONINFO ii;
423 PCURICON_OBJECT CurIcon;
425 BOOL Ret = FALSE;
426 DWORD colorBpp = 0;
427
428 TRACE("Enter NtUserGetIconInfo\n");
429
430 /* Check if something was actually asked */
431 if (!IconInfo && !lpModule && !lpResName)
432 {
433 WARN("Nothing to fill.\n");
435 return FALSE;
436 }
437
439
440 if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
441 {
442 WARN("UserGetIconObject(0x%p) Failed.\n", hCurIcon);
443 UserLeave();
444 return FALSE;
445 }
446
447 /* Give back the icon information */
448 if (IconInfo)
449 {
450 PCURICON_OBJECT FrameCurIcon = CurIcon;
451 if (CurIcon->CURSORF_flags & CURSORF_ACON)
452 {
453 /* Get information from first frame. */
454 FrameCurIcon = ((PACON)CurIcon)->aspcur[0];
455 }
456
457 /* Fill data */
458 ii.fIcon = is_icon(FrameCurIcon);
459 ii.xHotspot = FrameCurIcon->xHotspot;
460 ii.yHotspot = FrameCurIcon->yHotspot;
461
462 /* Copy bitmaps */
463 ii.hbmMask = BITMAP_CopyBitmap(FrameCurIcon->hbmMask);
465 ii.hbmColor = BITMAP_CopyBitmap(FrameCurIcon->hbmColor);
467 colorBpp = FrameCurIcon->bpp;
468
469 /* Copy fields */
471 {
472 ProbeForWrite(IconInfo, sizeof(ICONINFO), 1);
473 RtlCopyMemory(IconInfo, &ii, sizeof(ICONINFO));
474
475 if (pbpp)
476 {
477 ProbeForWrite(pbpp, sizeof(DWORD), 1);
478 *pbpp = colorBpp;
479 }
480 }
482 {
484 }
486
487 if (!NT_SUCCESS(Status))
488 {
489 WARN("Status: 0x%08lx\n", Status);
491 goto leave;
492 }
493 }
494
495 /* Give back the module name */
496 if (lpModule)
497 {
498 ULONG BufLen = 0;
499 if (!CurIcon->atomModName)
500 goto leave;
501
503 /* Get the module name from the atom table */
505 {
506 BufLen += sizeof(WCHAR);
507 if (BufLen > (lpModule->MaximumLength))
508 {
509 lpModule->Length = 0;
510 lpModule->MaximumLength = BufLen;
511 }
512 else
513 {
514 ProbeForWrite(lpModule->Buffer, lpModule->MaximumLength, 1);
515 BufLen = lpModule->MaximumLength;
516 RtlQueryAtomInAtomTable(gAtomTable, CurIcon->atomModName, NULL, NULL, lpModule->Buffer, &BufLen);
517 lpModule->Length = BufLen;
518 }
519 }
521 {
523 }
525
526 if (!NT_SUCCESS(Status))
527 {
529 goto leave;
530 }
531 }
532
533 if (lpResName)
534 {
535 if (!CurIcon->strName.Buffer)
536 goto leave;
537
538 /* Copy it */
540 {
542 if (IS_INTRESOURCE(CurIcon->strName.Buffer))
543 {
544 lpResName->Buffer = CurIcon->strName.Buffer;
545 lpResName->Length = 0;
546 lpResName->MaximumLength = 0;
547 }
548 else if (lpResName->MaximumLength < CurIcon->strName.MaximumLength)
549 {
550 lpResName->Length = 0;
551 lpResName->MaximumLength = CurIcon->strName.MaximumLength;
552 }
553 else
554 {
555 ProbeForWrite(lpResName->Buffer, lpResName->MaximumLength, 1);
556 RtlCopyMemory(lpResName->Buffer, CurIcon->strName.Buffer, CurIcon->strName.Length);
557 lpResName->Length = CurIcon->strName.Length;
558 }
559 }
561 {
563 }
565 }
566
567 if (!NT_SUCCESS(Status))
568 {
570 goto leave;
571 }
572
573 Ret = TRUE;
574
575leave:
576 UserDereferenceObject(CurIcon);
577
578 TRACE("Leave NtUserGetIconInfo, ret=%i\n", Ret);
579 UserLeave();
580
581 return Ret;
582}
583
584
585/*
586 * @implemented
587 */
588BOOL
591 HANDLE hCurIcon,
592 UINT istepIfAniCur,
593 PLONG plcx, // &size.cx
594 PLONG plcy) // &size.cy
595{
596 PCURICON_OBJECT CurIcon;
598 BOOL bRet = FALSE;
599
600 TRACE("Enter NtUserGetIconSize\n");
602
603 if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
604 {
605 goto cleanup;
606 }
607
608 if (CurIcon->CURSORF_flags & CURSORF_ACON)
609 {
610 /* Use first frame for animated cursors */
611 PACON AniCurIcon = (PACON)CurIcon;
612 CurIcon = AniCurIcon->aspcur[0];
613 UserDereferenceObject(AniCurIcon);
614 UserReferenceObject(CurIcon);
615 }
616
618 {
619 ProbeForWrite(plcx, sizeof(LONG), 1);
620 *plcx = CurIcon->cx;
621 ProbeForWrite(plcy, sizeof(LONG), 1);
622 *plcy = CurIcon->cy;
623 }
625 {
627 }
629
630 if (NT_SUCCESS(Status))
631 bRet = TRUE;
632 else
633 SetLastNtError(Status); // Maybe not, test this
634
635 UserDereferenceObject(CurIcon);
636
637cleanup:
638 TRACE("Leave NtUserGetIconSize, ret=%i\n", bRet);
639 UserLeave();
640 return bRet;
641}
642
643
644/*
645 * @implemented
646 */
647BOOL
650 PCURSORINFO pci)
651{
652 CURSORINFO SafeCi;
653 PSYSTEM_CURSORINFO CurInfo;
655 PCURICON_OBJECT CurIcon;
656 BOOL Ret = FALSE;
657
658 TRACE("Enter NtUserGetCursorInfo\n");
660
661 CurInfo = IntGetSysCursorInfo();
662 CurIcon = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
663
664 SafeCi.cbSize = sizeof(CURSORINFO);
665 SafeCi.flags = ((CurIcon && CurInfo->ShowingCursor >= 0) ? CURSOR_SHOWING : 0);
666 SafeCi.hCursor = (CurIcon ? UserHMGetHandle(CurIcon) : NULL);
667
668 SafeCi.ptScreenPos = gpsi->ptCursor;
669
671 {
672 ProbeForWrite(pci, sizeof(CURSORINFO), 1);
673
674 if (pci->cbSize == sizeof(CURSORINFO))
675 {
676 RtlCopyMemory(pci, &SafeCi, sizeof(CURSORINFO));
677 Ret = TRUE;
678 }
679 else
680 {
682 }
683 }
685 {
687 }
688 _SEH2_END;
689 if (!NT_SUCCESS(Status))
690 {
692 }
693
694 UserLeave();
695 TRACE("Leave NtUserGetCursorInfo, ret=%i\n", Ret);
696
697 return Ret;
698}
699
700BOOL
703 RECTL *prcl)
704{
705 PSYSTEM_CURSORINFO CurInfo;
707
709 {
710 return FALSE;
711 }
712
713 CurInfo = IntGetSysCursorInfo();
714
716
717 if (prcl != NULL && DesktopWindow != NULL)
718 {
719 if (prcl->right < prcl->left || prcl->bottom < prcl->top)
720 {
722 return FALSE;
723 }
724
725 CurInfo->bClipped = TRUE;
726
727 /* Set nw cliping region. Note: we can't use RECTL_bIntersectRect because
728 it sets rect to 0 0 0 0 when it's empty. For more info see monitor winetest */
729 CurInfo->rcClip.left = max(prcl->left, DesktopWindow->rcWindow.left);
730 CurInfo->rcClip.right = min(prcl->right, DesktopWindow->rcWindow.right);
731 if (CurInfo->rcClip.right < CurInfo->rcClip.left)
732 CurInfo->rcClip.right = CurInfo->rcClip.left;
733
734 CurInfo->rcClip.top = max(prcl->top, DesktopWindow->rcWindow.top);
735 CurInfo->rcClip.bottom = min(prcl->bottom, DesktopWindow->rcWindow.bottom);
736 if (CurInfo->rcClip.bottom < CurInfo->rcClip.top)
737 CurInfo->rcClip.bottom = CurInfo->rcClip.top;
738
739 /* Make sure cursor is in clipping region */
740 UserSetCursorPos(gpsi->ptCursor.x, gpsi->ptCursor.y, 0, 0, FALSE);
741 }
742 else
743 {
744 CurInfo->bClipped = FALSE;
745 }
746
747 return TRUE;
748}
749
750/*
751 * @implemented
752 */
753BOOL
756 RECTL *prcl)
757{
758 RECTL rclLocal;
759 BOOL bResult;
760
761 if (prcl)
762 {
764 {
765 /* Probe and copy rect */
766 ProbeForRead(prcl, sizeof(RECTL), 1);
767 rclLocal = *prcl;
768 }
770 {
772 _SEH2_YIELD(return FALSE;)
773 }
775
776 prcl = &rclLocal;
777 }
778
780
781 /* Call the internal function */
782 bResult = UserClipCursor(prcl);
783
784 UserLeave();
785
786 return bResult;
787}
788
789
790/*
791 * @implemented
792 */
793BOOL
796 _In_ HANDLE hCurIcon,
797 _In_ BOOL bForce)
798{
799 BOOL ret;
800 PCURICON_OBJECT CurIcon = NULL;
801
802 TRACE("Enter NtUserDestroyCursorIcon (%p, %i)\n", hCurIcon, bForce);
804
805 CurIcon = UserGetCurIconObject(hCurIcon);
806 if (!CurIcon)
807 {
808 ret = FALSE;
809 goto leave;
810 }
811
812 if (!bForce)
813 {
814 /* Can not destroy global objects */
815 if (CurIcon->head.ppi == NULL)
816 {
817 ERR("Trying to delete global cursor!\n");
818 ret = TRUE;
819 goto leave;
820 }
821
822 /* Maybe we have good reasons not to destroy this object */
823 if (CurIcon->head.ppi != PsGetCurrentProcessWin32Process())
824 {
825 /* No way, you're not touching my cursor */
826 ret = FALSE;
827 goto leave;
828 }
829
830 if (CurIcon->CURSORF_flags & CURSORF_CURRENT)
831 {
832 WARN("Trying to delete current cursor!\n");
833 ret = FALSE;
834 goto leave;
835 }
836
837 if (CurIcon->CURSORF_flags & CURSORF_LRSHARED)
838 {
839 WARN("Trying to delete shared cursor.\n");
840 /* This one is not an error */
841 ret = TRUE;
842 goto leave;
843 }
844 }
845
846 /* Destroy the handle */
847 ret = IntDestroyCurIconObject(CurIcon);
848
849leave:
850 if (CurIcon)
851 UserDereferenceObject(CurIcon);
852 TRACE("Leave NtUserDestroyCursorIcon, ret=%i\n", ret);
853 UserLeave();
854 return ret;
855}
856
857
858/*
859 * @implemented
860 */
861HICON
862NTAPI
864 _In_ PUNICODE_STRING pustrModule,
865 _In_ PUNICODE_STRING pustrRsrc,
867{
868 PCURICON_OBJECT CurIcon;
869 HICON Ret = NULL;
870 UNICODE_STRING ustrModuleSafe, ustrRsrcSafe;
871 FINDEXISTINGCURICONPARAM paramSafe;
874 RTL_ATOM atomModName;
875
876 TRACE("Enter NtUserFindExistingCursorIcon\n");
877
879 {
880 ProbeForRead(param, sizeof(*param), 1);
881 RtlCopyMemory(&paramSafe, param, sizeof(paramSafe));
882 }
884 {
886 }
888
889 /* Capture resource name (it can be an INTRESOURCE == ATOM) */
890 Status = ProbeAndCaptureUnicodeStringOrAtom(&ustrRsrcSafe, pustrRsrc);
891 if (!NT_SUCCESS(Status))
892 return NULL;
893 Status = ProbeAndCaptureUnicodeString(&ustrModuleSafe, UserMode, pustrModule);
894 if (!NT_SUCCESS(Status))
895 goto done;
896 Status = RtlLookupAtomInAtomTable(gAtomTable, ustrModuleSafe.Buffer, &atomModName);
897 ReleaseCapturedUnicodeString(&ustrModuleSafe, UserMode);
898 if (!NT_SUCCESS(Status))
899 {
900 /* The module is not in the atom table. No chance to find the cursor */
901 goto done;
902 }
903
905 CurIcon = pProcInfo->pCursorCache;
906 while (CurIcon)
907 {
908 /* Icon/cursor */
909 if (paramSafe.bIcon != is_icon(CurIcon))
910 {
911 CurIcon = CurIcon->pcurNext;
912 continue;
913 }
914 /* See if module names match */
915 if (atomModName == CurIcon->atomModName)
916 {
917 /* They do. Now see if this is the same resource */
918 if (IS_INTRESOURCE(CurIcon->strName.Buffer) != IS_INTRESOURCE(ustrRsrcSafe.Buffer))
919 {
920 /* One is an INT resource and the other is not -> no match */
921 CurIcon = CurIcon->pcurNext;
922 continue;
923 }
924
925 if (IS_INTRESOURCE(CurIcon->strName.Buffer))
926 {
927 if (CurIcon->strName.Buffer == ustrRsrcSafe.Buffer)
928 {
929 /* INT resources match */
930 break;
931 }
932 }
933 else if (RtlCompareUnicodeString(&ustrRsrcSafe, &CurIcon->strName, TRUE) == 0)
934 {
935 /* Resource name strings match */
936 break;
937 }
938 }
939 CurIcon = CurIcon->pcurNext;
940 }
941
942 /* Now search Global Cursors or Icons. */
943 if (CurIcon == NULL)
944 {
945 CurIcon = gcurFirst;
946 while (CurIcon)
947 {
948 /* Icon/cursor */
949 if (paramSafe.bIcon != is_icon(CurIcon))
950 {
951 CurIcon = CurIcon->pcurNext;
952 continue;
953 }
954 /* See if module names match */
955 if (atomModName == CurIcon->atomModName)
956 {
957 /* They do. Now see if this is the same resource */
958 if (IS_INTRESOURCE(CurIcon->strName.Buffer) != IS_INTRESOURCE(ustrRsrcSafe.Buffer))
959 {
960 /* One is an INT resource and the other is not -> no match */
961 CurIcon = CurIcon->pcurNext;
962 continue;
963 }
964 if (IS_INTRESOURCE(CurIcon->strName.Buffer))
965 {
966 if (CurIcon->strName.Buffer == ustrRsrcSafe.Buffer)
967 {
968 /* INT resources match */
969 break;
970 }
971 }
972 else if (RtlCompareUnicodeString(&ustrRsrcSafe, &CurIcon->strName, TRUE) == 0)
973 {
974 /* Resource name strings match */
975 break;
976 }
977 }
978 CurIcon = CurIcon->pcurNext;
979 }
980 }
981 if (CurIcon)
982 Ret = UserHMGetHandle(CurIcon);
983 UserLeave();
984
985done:
986 if (!IS_INTRESOURCE(ustrRsrcSafe.Buffer))
987 ExFreePoolWithTag(ustrRsrcSafe.Buffer, TAG_STRING);
988
989 return Ret;
990}
991
992
993/*
994 * @implemented
995 */
996BOOL
999 RECTL *lpRect)
1000{
1001 PSYSTEM_CURSORINFO CurInfo;
1002 RECTL Rect;
1004 BOOL Ret = FALSE;
1005
1006 TRACE("Enter NtUserGetClipCursor\n");
1008
1010 {
1011 goto Exit; // Return FALSE
1012 }
1013
1014 if (!lpRect)
1015 goto Exit; // Return FALSE
1016
1017 CurInfo = IntGetSysCursorInfo();
1018 if (CurInfo->bClipped)
1019 {
1020 Rect = CurInfo->rcClip;
1021 }
1022 else
1023 {
1024 Rect.left = 0;
1025 Rect.top = 0;
1028 }
1029
1030 Status = MmCopyToCaller(lpRect, &Rect, sizeof(RECT));
1031 if (!NT_SUCCESS(Status))
1032 {
1034 goto Exit; // Return FALSE
1035 }
1036
1037 Ret = TRUE;
1038
1039Exit:
1040 TRACE("Leave NtUserGetClipCursor, ret=%i\n", Ret);
1041 UserLeave();
1042 return Ret;
1043}
1044
1045
1046/*
1047 * @implemented
1048 */
1049HCURSOR
1052 HCURSOR hCursor)
1053{
1054 PCURICON_OBJECT pcurOld, pcurNew;
1055 HCURSOR hOldCursor = NULL;
1056
1057 TRACE("Enter NtUserSetCursor: %p\n", hCursor);
1059
1060 if (hCursor)
1061 {
1062 pcurNew = UserGetCurIconObject(hCursor);
1063 if (!pcurNew)
1064 {
1066 goto leave;
1067 }
1068 pcurNew->CURSORF_flags |= CURSORF_CURRENT;
1069 }
1070 else
1071 {
1072 pcurNew = NULL;
1073 }
1074
1075 pcurOld = UserSetCursor(pcurNew, FALSE);
1076
1077 // If returning an old cursor than validate it, Justin Case!
1078 if ( pcurOld &&
1080 {
1081 hOldCursor = UserHMGetHandle(pcurOld);
1082 /*
1083 Problem:
1084
1085 System Global Cursors start out having at least 2 lock counts. If a system
1086 cursor is the default cursor and is returned to the caller twice in its
1087 life, the count will reach zero. Causing an assert to occur in objects.
1088
1089 This fixes a SeaMonkey crash while the mouse crosses a boundary.
1090 */
1091 if (pcurOld->CURSORF_flags & CURSORF_GLOBAL)
1092 {
1093 TRACE("Returning Global Cursor hcur %p\n",hOldCursor);
1094
1095 /*if (pcurOld->head.cLockObj > 2) // Throttle down to 2.
1096 {
1097 UserDereferenceObject(pcurOld);
1098 }
1099
1100 goto leave;*/
1101 }
1102
1103 /* See if it was destroyed in the meantime */
1104 if (UserObjectInDestroy(hOldCursor))
1105 hOldCursor = NULL;
1106 pcurOld->CURSORF_flags &= ~CURSORF_CURRENT;
1107 UserDereferenceObject(pcurOld);
1108 }
1109
1110leave:
1111 UserLeave();
1112 return hOldCursor;
1113}
1114
1115
1116/*
1117 * @unimplemented
1118 */
1119BOOL
1122 HANDLE hCurIcon,
1123 PICONINFO UnsafeIconInfo)
1124{
1125 FIXME(" is UNIMPLEMENTED.\n");
1126 return FALSE;
1127}
1128
1129
1130static
1131BOOL
1134 _In_opt_ PUNICODE_STRING pustrName,
1135 _In_ ATOM atomModName,
1136 _In_ const CURSORDATA* pcursordata)
1137{
1138 /* Check if the CURSORF_ACON is also set in the cursor data */
1139 if (pcursordata->CURSORF_flags & CURSORF_ACON)
1140 {
1141 ERR("Mismatch in CURSORF_flags! cursor: 0x%08lx, data: 0x%08lx\n",
1142 pcur->CURSORF_flags, pcursordata->CURSORF_flags);
1143 return FALSE;
1144 }
1145
1146 /* Check if this cursor was already set */
1147 if (pcur->hbmMask != NULL)
1148 {
1149 ERR("Cursor data already set!\n");
1150 return FALSE;
1151 }
1152
1153 /* We need a mask */
1154 if (pcursordata->hbmMask == NULL)
1155 {
1156 ERR("NtUserSetCursorIconData was got no hbmMask.\n");
1158 return FALSE;
1159 }
1160
1161 /* Take ownership of the mask bitmap */
1162 if (!GreSetBitmapOwner(pcursordata->hbmMask, GDI_OBJ_HMGR_PUBLIC))
1163 {
1164 ERR("Failed to set ownership of hbmMask %p.\n", pcursordata->hbmMask);
1165 return FALSE;
1166 }
1167
1168 /* Check if we have a color bitmap */
1169 if (pcursordata->hbmColor)
1170 {
1171 /* Take ownership of the color bitmap */
1172 if (!GreSetBitmapOwner(pcursordata->hbmColor, GDI_OBJ_HMGR_PUBLIC))
1173 {
1174 ERR("Failed to set ownership of hbmColor %p.\n", pcursordata->hbmColor);
1175 GreSetBitmapOwner(pcursordata->hbmMask, GDI_OBJ_HMGR_POWNED);
1176 return FALSE;
1177 }
1178 }
1179
1180 /* Check if we have an alpha bitmap */
1181 if (pcursordata->hbmAlpha)
1182 {
1183 /* Take ownership of the alpha bitmap */
1184 if (!GreSetBitmapOwner(pcursordata->hbmAlpha, GDI_OBJ_HMGR_PUBLIC))
1185 {
1186 ERR("Failed to set ownership of hbmAlpha %p.\n", pcursordata->hbmAlpha);
1187 GreSetBitmapOwner(pcursordata->hbmMask, GDI_OBJ_HMGR_POWNED);
1188 if (pcursordata->hbmColor)
1189 {
1190 GreSetBitmapOwner(pcursordata->hbmColor, GDI_OBJ_HMGR_POWNED);
1191 }
1192 return FALSE;
1193 }
1194 }
1195
1196 /* Free the old name (Must be NULL atm, but later we might allow this) */
1197 NT_ASSERT(pcur->strName.Buffer == NULL);
1198 if (pcur->strName.Buffer != NULL)
1199 {
1200 if (!IS_INTRESOURCE(pcur->strName.Buffer))
1201 {
1202 ExFreePoolWithTag(pcur->strName.Buffer, TAG_STRING);
1203 }
1204 RtlInitEmptyUnicodeString(&pcur->strName, NULL, 0);
1205 }
1206
1207 /* Free the module atom */
1208 if (pcur->atomModName != 0)
1209 {
1211 }
1212
1213 /* Now set the new cursor data */
1214 pcur->atomModName = atomModName;
1215 pcur->rt = pcursordata->rt;
1216 pcur->CURSORF_flags = pcursordata->CURSORF_flags & CURSORF_USER_MASK;
1217 pcur->xHotspot = pcursordata->xHotspot;
1218 pcur->yHotspot = pcursordata->yHotspot;
1219 pcur->hbmMask = pcursordata->hbmMask;
1220 pcur->hbmColor = pcursordata->hbmColor;
1221 pcur->hbmAlpha = pcursordata->hbmAlpha;
1222 pcur->rcBounds.left = 0;
1223 pcur->rcBounds.top = 0;
1224 pcur->rcBounds.right = pcursordata->cx;
1225 pcur->rcBounds.bottom = pcursordata->cy;
1226 pcur->hbmUserAlpha = pcursordata->hbmUserAlpha;
1227 pcur->bpp = pcursordata->bpp;
1228 pcur->cx = pcursordata->cx;
1229 pcur->cy = pcursordata->cy;
1230 if (pustrName != NULL)
1231 {
1232 pcur->strName = *pustrName;
1233 }
1234
1235 return TRUE;
1236}
1237
1238static
1239BOOL
1241 _Inout_ PACON pacon,
1242 _In_opt_ PUNICODE_STRING pustrName,
1243 _In_ ATOM atomModName,
1244 _In_ const CURSORDATA *pcursordata)
1245{
1246 PCURICON_OBJECT *aspcur;
1247 DWORD *aicur;
1248 INT *ajifRate;
1249 PCURSORDATA pcdFrame;
1250 HCURSOR hcurFrame;
1251 UINT cjSize, i;
1252
1253 NT_ASSERT((pacon->CURSORF_flags & CURSORF_ACON) != 0);
1254 NT_ASSERT((pacon->CURSORF_flags & CURSORF_ACONFRAME) == 0);
1255 NT_ASSERT((ULONG_PTR)pcursordata->aspcur > MmUserProbeAddress);
1256 NT_ASSERT((ULONG_PTR)pcursordata->aicur > MmUserProbeAddress);
1257 NT_ASSERT((ULONG_PTR)pcursordata->ajifRate > MmUserProbeAddress);
1258 NT_ASSERT((pcursordata->CURSORF_flags & ~CURSORF_USER_MASK) == 0);
1259 NT_ASSERT(pcursordata->cpcur > 0);
1260 NT_ASSERT(pcursordata->cicur > 0);
1261
1262 /* Check if the CURSORF_ACON is also set in the cursor data */
1263 if (!(pcursordata->CURSORF_flags & CURSORF_ACON))
1264 {
1265 ERR("Mismatch in CURSORF_flags! acon: 0x%08lx, data: 0x%08lx\n",
1266 pacon->CURSORF_flags, pcursordata->CURSORF_flags);
1267 return FALSE;
1268 }
1269
1270 /* Check if this acon was already set */
1271 if (pacon->aspcur != NULL)
1272 {
1273 ERR("Acon data already set!\n");
1274 return FALSE;
1275 }
1276
1277 /* Loop all frames indexes */
1278 for (i = 0; i < pcursordata->cicur; i++)
1279 {
1280 /* Check if the index is within the range of the frames */
1281 if (pcursordata->aicur[i] >= pcursordata->cpcur)
1282 {
1283 ERR("aicur[%lu] is out or range. Got %lu, cpcur = %u\n",
1284 i, pcursordata->aicur[i], pcursordata->cpcur);
1285 return FALSE;
1286 }
1287
1288 /* FIXME: check the JIF rates? */
1289 }
1290
1291 /* Calculate size: one cursor object for each frame, and a frame
1292 index and jiffies for each "step" */
1293 cjSize = (pcursordata->cpcur * sizeof(CURICON_OBJECT*)) +
1294 (pcursordata->cicur * sizeof(DWORD)) +
1295 (pcursordata->cicur * sizeof(INT));
1296
1297 /* Allocate a buffer */
1299 if (aspcur == NULL)
1300 {
1301 ERR("Failed to allocate memory (cpcur = %u, cicur = %u)\n",
1302 pcursordata->cpcur, pcursordata->cicur);
1303 return FALSE;
1304 }
1305
1306 /* Set the pointers */
1307 aicur = (DWORD*)&aspcur[pcursordata->cpcur];
1308 ajifRate = (INT*)&aicur[pcursordata->cicur];
1309
1310 /* Copy the values */
1311 RtlCopyMemory(aicur, pcursordata->aicur, pcursordata->cicur * sizeof(DWORD));
1312 RtlCopyMemory(ajifRate, pcursordata->ajifRate, pcursordata->cicur * sizeof(INT));
1313
1314 /* Zero out the array, so we can handle cleanup */
1315 RtlZeroMemory(aspcur, pcursordata->cpcur * sizeof(PCURICON_OBJECT));
1316
1317 /* Get a pointer to the cursor data for each frame */
1318 pcdFrame = pcursordata->aspcur;
1319
1320 /* Create the cursors */
1321 for (i = 0; i < pcursordata->cpcur; i++)
1322 {
1323 /* Create a cursor for this frame */
1324 hcurFrame = IntCreateCurIconHandle(FALSE);
1325 if (hcurFrame == NULL)
1326 {
1327 ERR("Failed to create a cursor for frame %u\n", i);
1328 goto Cleanup;
1329 }
1330
1331 /* Get a pointer to the frame cursor */
1332 aspcur[i] = UserGetCurIconObject(hcurFrame);
1334 NT_ASSERT(aspcur[i] != NULL);
1335
1336 /* Check if the flags are valid */
1338 {
1339 ERR("Invalid flags for acon frame %u: 0x%08lx\n",
1340 i, pcdFrame->CURSORF_flags);
1341 goto Cleanup;
1342 }
1343
1344 /* Set the cursor data for this frame */
1345 if (!IntSetCursorData(aspcur[i], NULL, 0, &pcdFrame[i]))
1346 {
1347 ERR("Failed to set cursor data for frame %u\n", i);
1348 goto Cleanup;
1349 }
1350
1351 /* Mark this cursor as an acon frame */
1352 aspcur[i]->CURSORF_flags |= CURSORF_ACONFRAME;
1353 }
1354
1355 /* Free the old name (Must be NULL atm.) */
1356 NT_ASSERT(pacon->strName.Buffer == NULL);
1357 if (pacon->strName.Buffer != NULL)
1358 {
1359 if (!IS_INTRESOURCE(pacon->strName.Buffer))
1360 {
1361 ExFreePoolWithTag(pacon->strName.Buffer, TAG_STRING);
1362 }
1363 RtlInitEmptyUnicodeString(&pacon->strName, NULL, 0);
1364 }
1365
1366 /* Free the module atom */
1367 if (pacon->atomModName != 0)
1368 {
1370 }
1371
1372 /* Free the previous frames */
1373 if (pacon->aspcur != NULL)
1374 {
1375 for (i = 0; i < pacon->cpcur; i++)
1376 {
1377 UserDereferenceObject(pacon->aspcur[i]);
1378 NT_VERIFY(IntDestroyCurIconObject(pacon->aspcur[i]) == TRUE);
1379 }
1380 ExFreePoolWithTag(pacon->aspcur, USERTAG_CURSOR);
1381 }
1382
1383 /* Finally set the data in the acon */
1384 pacon->atomModName = atomModName;
1385 pacon->rt = pcursordata->rt;
1386 pacon->CURSORF_flags = pcursordata->CURSORF_flags & CURSORF_USER_MASK;
1387 pacon->cpcur = pcursordata->cpcur;
1388 pacon->cicur = pcursordata->cicur;
1389 pacon->aspcur = aspcur;
1390 pacon->aicur = aicur;
1391 pacon->ajifRate = ajifRate;
1392 pacon->iicur = 0;
1393 if (pustrName != NULL)
1394 {
1395 pacon->strName = *pustrName;
1396 }
1397
1398 return TRUE;
1399
1400Cleanup:
1401
1402 /* Clean up the cursors we created */
1403 for (i = 0; i < pcursordata->cpcur; i++)
1404 {
1405 if (aspcur[i] == NULL)
1406 break;
1407
1408 /* Destroy this cursor */
1409 UserDereferenceObject(aspcur[i]);
1411 }
1412
1413 /* Delete the allocated structure */
1415
1416 return FALSE;
1417}
1418
1419BOOL
1422 _In_ HCURSOR hcursor,
1423 _In_opt_ PUNICODE_STRING pustrModule,
1424 _In_opt_ PUNICODE_STRING pustrRsrc,
1425 _In_ PCURSORDATA pcursordata)
1426{
1427 PCURICON_OBJECT pcur;
1428 ATOM atomModName;
1430 BOOL bResult;
1431
1432 /* Do we have a module name? */
1433 if (pustrModule != NULL)
1434 {
1435 /* Create an atom for the module name */
1437 pustrModule->Buffer,
1438 &atomModName);
1439 if (!NT_SUCCESS(status))
1440 {
1441 ERR("Failed to create atom from module name '%wZ': 0x%08lx\n",
1442 pustrModule, status);
1443 return FALSE;
1444 }
1445 }
1446 else
1447 {
1448 /* No module name atom */
1449 atomModName = 0;
1450 }
1451
1452 /* Reference the cursor */
1453 pcur = UserGetCurIconObject(hcursor);
1454 if (pcur == NULL)
1455 {
1456 ERR("Failed to reference cursor %p\n", hcursor);
1457 bResult = FALSE;
1458 goto Exit;
1459 }
1460
1461 /* Check if this is an acon */
1462 if (pcur->CURSORF_flags & CURSORF_ACON)
1463 {
1464 bResult = IntSetAconData((PACON)pcur,
1465 pustrRsrc,
1466 atomModName,
1467 pcursordata);
1468 }
1469 else
1470 {
1471 bResult = IntSetCursorData(pcur,
1472 pustrRsrc,
1473 atomModName,
1474 pcursordata);
1475 }
1476
1477Exit:
1478
1479 /* Check if we had success */
1480 if (bResult != FALSE)
1481 {
1482 /* Check if this is an LRSHARED cursor now */
1483 if (pcur->CURSORF_flags & CURSORF_LRSHARED)
1484 {
1485 /* Insert the cursor into the list. */
1487 }
1488 }
1489 else
1490 {
1491 /* Cleanup on failure */
1492 if (atomModName != 0)
1493 {
1495 }
1496 }
1497
1498 /* Dereference the cursor and return the result */
1499 if (pcur)
1501
1502 return bResult;
1503}
1504
1505
1506/*
1507 * @implemented
1508 */
1510BOOL
1513 _In_ HCURSOR hcursor,
1514 _In_opt_ PUNICODE_STRING pustrModule,
1515 _In_opt_ PUNICODE_STRING pustrRsrc,
1516 _In_ const CURSORDATA* pCursorData)
1517{
1518 CURSORDATA cursordata;
1519 UNICODE_STRING ustrModule, ustrRsrc;
1520 _SEH2_VOLATILE PVOID pvBuffer;
1521 CURSORDATA* aspcur;
1522 DWORD* aicur;
1523 PINT ajifRate;
1524 UINT cjSize;
1526 BOOL bResult = FALSE;
1527
1528 TRACE("Enter NtUserSetCursorIconData\n");
1529
1530 /* Initialize buffer, so we can handle cleanup */
1531 ustrRsrc.Buffer = NULL;
1532 ustrModule.Buffer = NULL;
1533 pvBuffer = NULL;
1534
1535 _SEH2_TRY
1536 {
1537 /* Probe and capture the cursor data structure */
1538 ProbeForRead(pCursorData, sizeof(*pCursorData), 1);
1539 cursordata = *pCursorData;
1540
1541 /* Check if this is an animated cursor */
1542 if (cursordata.CURSORF_flags & CURSORF_ACON)
1543 {
1544 /* Check of the range is ok */
1545 if ((cursordata.cpcur == 0) || (cursordata.cicur == 0) ||
1546 (cursordata.cpcur > 1000) || (cursordata.cicur > 1000))
1547 {
1548 ERR("Range error (cpcur = %u, cicur = %u)\n",
1549 cursordata.cpcur, cursordata.cicur);
1550 goto Exit;
1551 }
1552
1553 /* Calculate size: one cursor data structure for each frame,
1554 and a frame index and jiffies for each "step" */
1555 cjSize = (cursordata.cpcur * sizeof(CURSORDATA)) +
1556 (cursordata.cicur * sizeof(DWORD)) +
1557 (cursordata.cicur * sizeof(INT));
1558
1559 /* Allocate a buffer */
1561 if (pvBuffer == NULL)
1562 {
1563 ERR("Failed to allocate memory (cpcur = %u, cicur = %u)\n",
1564 cursordata.cpcur, cursordata.cicur);
1565 goto Exit;
1566 }
1567
1568 /* Calculate the kernel mode pointers */
1569 aspcur = (CURSORDATA*)pvBuffer;
1570 aicur = (DWORD*)&aspcur[cursordata.cpcur];
1571 ajifRate = (INT*)&aicur[cursordata.cicur];
1572
1573 /* Probe and copy aspcur */
1574 ProbeForRead(cursordata.aspcur, cursordata.cpcur * sizeof(CURSORDATA), 1);
1575 RtlCopyMemory(aspcur,
1576 cursordata.aspcur,
1577 cursordata.cpcur * sizeof(CURSORDATA));
1578
1579 /* Probe and copy aicur */
1580 ProbeForRead(cursordata.aicur, cursordata.cicur * sizeof(DWORD), 1);
1581 RtlCopyMemory(aicur,
1582 cursordata.aicur,
1583 cursordata.cicur * sizeof(DWORD));
1584
1585 /* Probe and copy ajifRate */
1586 ProbeForRead(cursordata.ajifRate, cursordata.cicur * sizeof(INT), 1);
1587 RtlCopyMemory(ajifRate,
1588 cursordata.ajifRate,
1589 cursordata.cicur * sizeof(INT));
1590
1591 /* Set the new pointers */
1592 cursordata.aspcur = aspcur;
1593 cursordata.aicur = aicur;
1594 cursordata.ajifRate = ajifRate;
1595 }
1596 else
1597 {
1598 /* This is a standard cursor, we don't use the pointers */
1599 cursordata.aspcur = NULL;
1600 cursordata.aicur = NULL;
1601 cursordata.ajifRate = NULL;
1602 }
1603 }
1605 {
1607 goto Exit;
1608 }
1609 _SEH2_END
1610
1611 /* Check if we got a module name */
1612 if (pustrModule != NULL)
1613 {
1614 /* Capture the name */
1615 status = ProbeAndCaptureUnicodeString(&ustrModule, UserMode, pustrModule);
1616 if (!NT_SUCCESS(status))
1617 {
1618 ERR("Failed to copy pustrModule: status 0x%08lx\n", status);
1619 goto Exit;
1620 }
1621 }
1622
1623 /* Check if we got a resource name */
1624 if (pustrRsrc != NULL)
1625 {
1626 /* We use this function, because INTRESOURCEs and ATOMs are the same */
1627 status = ProbeAndCaptureUnicodeStringOrAtom(&ustrRsrc, pustrRsrc);
1628 if (!NT_SUCCESS(status))
1629 {
1630 ERR("Failed to copy pustrRsrc: status 0x%08lx\n", status);
1631 goto Exit;
1632 }
1633 }
1634
1635 /* Make sure the caller doesn't give us invalid flags */
1636 if (cursordata.CURSORF_flags & ~CURSORF_USER_MASK)
1637 {
1638 ERR("Invalid cursor flags: 0x%08lx\n", cursordata.CURSORF_flags);
1639 goto Exit;
1640 }
1641
1642 /* Acquire the global user lock */
1644
1645 /* Call the internal function */
1646 bResult = UserSetCursorIconData(hcursor,
1647 pustrModule ? &ustrModule : NULL,
1648 pustrRsrc ? &ustrRsrc : NULL,
1649 &cursordata);
1650
1651 /* Release the global user lock */
1652 UserLeave();
1653
1654Exit:
1655
1656 /* Free the captured module name */
1657 if ((ustrModule.Buffer != NULL) && !IS_INTRESOURCE(ustrModule.Buffer))
1658 {
1660 }
1661
1662 if (pvBuffer != NULL)
1663 {
1665 }
1666
1667 /* Additional cleanup on failure */
1668 if (bResult == FALSE)
1669 {
1670 if ((ustrRsrc.Buffer != NULL) &&
1671 !IS_INTRESOURCE(ustrRsrc.Buffer))
1672 {
1674 }
1675 }
1676
1677 TRACE("Leave NtUserSetCursorIconData, bResult = %i\n", bResult);
1678
1679 return bResult;
1680}
1681
1682/* Mostly inspired from wine code.
1683 * We use low level functions because:
1684 * - at this point, the icon bitmap could have a different bit depth than the DC,
1685 * making it thus impossible to use NtCreateCompatibleDC and selecting the bitmap.
1686 * This happens after a mode setting change.
1687 * - it avoids massive GDI objects locking when only the destination surface needs it.
1688 * - It makes (small) performance gains.
1689 */
1690BOOL
1692 HDC hDc,
1693 INT xLeft,
1694 INT yTop,
1695 PCURICON_OBJECT pIcon,
1696 INT cxWidth,
1697 INT cyHeight,
1698 UINT istepIfAniCur,
1699 HBRUSH hbrFlickerFreeDraw,
1700 UINT diFlags)
1701{
1702 PSURFACE psurfDest, psurfMask, psurfColor; //, psurfOffScreen = NULL;
1703 PDC pdc = NULL;
1704 BOOL Ret = FALSE;
1705 HBITMAP hbmMask, hbmColor, hbmAlpha;
1706 BOOL bOffScreen;
1707 RECTL rcDest, rcSrc;
1708 CLIPOBJ* pdcClipObj = NULL;
1709 EXLATEOBJ exlo;
1710
1711 /* Stupid case */
1712 if ((diFlags & DI_NORMAL) == 0)
1713 {
1714 ERR("DrawIconEx called without mask or color bitmap to draw.\n");
1715 return FALSE;
1716 }
1717
1718 if (pIcon->CURSORF_flags & CURSORF_ACON)
1719 {
1720 ACON* pAcon = (ACON*)pIcon;
1721 if (istepIfAniCur >= pAcon->cicur)
1722 {
1723 ERR("NtUserDrawIconEx: istepIfAniCur too big!\n");
1724 return FALSE;
1725 }
1726 pIcon = pAcon->aspcur[pAcon->aicur[istepIfAniCur]];
1727 }
1728
1729 hbmMask = pIcon->hbmMask;
1730 hbmColor = pIcon->hbmColor;
1731 hbmAlpha = pIcon->hbmAlpha;
1732
1733 /*
1734 * Get our objects.
1735 * Shared locks are enough, we are only reading those bitmaps
1736 */
1737 psurfMask = SURFACE_ShareLockSurface(hbmMask);
1738 if (psurfMask == NULL)
1739 {
1740 ERR("Unable to lock the mask surface.\n");
1741 return FALSE;
1742 }
1743
1744 /* Color bitmap is not mandatory */
1745 if (hbmColor == NULL)
1746 {
1747 /* But then the mask bitmap must have the information in it's bottom half */
1748 ASSERT(psurfMask->SurfObj.sizlBitmap.cy == 2*pIcon->cy);
1749 psurfColor = NULL;
1750 }
1751 else if ((psurfColor = SURFACE_ShareLockSurface(hbmColor)) == NULL)
1752 {
1753 ERR("Unable to lock the color bitmap.\n");
1754 SURFACE_ShareUnlockSurface(psurfMask);
1755 return FALSE;
1756 }
1757
1758 pdc = DC_LockDc(hDc);
1759 if (!pdc)
1760 {
1761 ERR("Could not lock the destination DC.\n");
1762 SURFACE_ShareUnlockSurface(psurfMask);
1763 if (psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
1764 return FALSE;
1765 }
1766
1767 /* Fix width parameter, if needed */
1768 if (!cxWidth)
1769 {
1770 if (diFlags & DI_DEFAULTSIZE)
1771 cxWidth = is_icon(pIcon) ?
1773 else
1774 cxWidth = pIcon->cx;
1775 }
1776
1777 /* Fix height parameter, if needed */
1778 if (!cyHeight)
1779 {
1780 if (diFlags & DI_DEFAULTSIZE)
1781 cyHeight = is_icon(pIcon) ?
1783 else
1784 cyHeight = pIcon->cy;
1785 }
1786
1787 /* Calculate destination rectangle */
1788 RECTL_vSetRect(&rcDest, xLeft, yTop, xLeft + cxWidth, yTop + cyHeight);
1789 IntLPtoDP(pdc, (LPPOINT)&rcDest, 2);
1790 RECTL_vOffsetRect(&rcDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
1791
1792 /* Prepare the underlying surface */
1793 DC_vPrepareDCsForBlit(pdc, &rcDest, NULL, NULL);
1794
1795 /* We now have our destination surface and rectangle */
1796 psurfDest = pdc->dclevel.pSurface;
1797
1798 if (psurfDest == NULL)
1799 {
1800 /* Empty DC */
1801 DC_vFinishBlit(pdc, NULL);
1802 DC_UnlockDc(pdc);
1803 SURFACE_ShareUnlockSurface(psurfMask);
1804 if (psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
1805 return FALSE;
1806 }
1807
1808 /* Set source rect */
1809 RECTL_vSetRect(&rcSrc, 0, 0, pIcon->cx, pIcon->cy);
1810
1811 /* Should we render off-screen? */
1812 bOffScreen = hbrFlickerFreeDraw &&
1813 (GDI_HANDLE_GET_TYPE(hbrFlickerFreeDraw) == GDI_OBJECT_TYPE_BRUSH);
1814
1815 if (bOffScreen)
1816 {
1817 /* Yes: Allocate and paint the offscreen surface */
1818 EBRUSHOBJ eboFill;
1819 PBRUSH pbrush = BRUSH_ShareLockBrush(hbrFlickerFreeDraw);
1820
1821 TRACE("Performing off-screen rendering.\n");
1822
1823 if (!pbrush)
1824 {
1825 ERR("Failed to get brush object.\n");
1826 goto Cleanup;
1827 }
1828
1829#if 0 //We lock the hdc surface during the whole function it makes no sense to use an offscreen surface for "flicker free" drawing
1830 psurfOffScreen = SURFACE_AllocSurface(STYPE_BITMAP,
1831 cxWidth, cyHeight, psurfDest->SurfObj.iBitmapFormat,
1832 0, 0, NULL);
1833 if (!psurfOffScreen)
1834 {
1835 ERR("Failed to allocate the off-screen surface.\n");
1836 BRUSH_ShareUnlockBrush(pbrush);
1837 goto Cleanup;
1838 }
1839
1840 /* Paint the brush */
1841 EBRUSHOBJ_vInit(&eboFill, pbrush, psurfOffScreen, 0x00FFFFFF, 0, NULL);
1842 RECTL_vSetRect(&rcDest, 0, 0, cxWidth, cyHeight);
1843
1844 Ret = IntEngBitBlt(&psurfOffScreen->SurfObj,
1845 NULL,
1846 NULL,
1847 NULL,
1848 NULL,
1849 &rcDest,
1850 NULL,
1851 NULL,
1852 &eboFill.BrushObject,
1853 &pbrush->ptOrigin,
1854 ROP4_PATCOPY);
1855
1856 /* Clean up everything */
1857 EBRUSHOBJ_vCleanup(&eboFill);
1858 BRUSH_ShareUnlockBrush(pbrush);
1859
1860 if (!Ret)
1861 {
1862 ERR("Failed to paint the off-screen surface.\n");
1863 goto Cleanup;
1864 }
1865
1866 /* We now have our destination surface */
1867 psurfDest = psurfOffScreen;
1868#else
1869 pdcClipObj = (CLIPOBJ *)&pdc->co;
1870 /* Paint the brush */
1871 EBRUSHOBJ_vInit(&eboFill, pbrush, psurfDest, 0x00FFFFFF, 0, NULL);
1872
1873 Ret = IntEngBitBlt(&psurfDest->SurfObj,
1874 NULL,
1875 NULL,
1876 pdcClipObj,
1877 NULL,
1878 &rcDest,
1879 NULL,
1880 NULL,
1881 &eboFill.BrushObject,
1882 &pbrush->ptOrigin,
1883 ROP4_PATCOPY);
1884
1885 /* Clean up everything */
1886 EBRUSHOBJ_vCleanup(&eboFill);
1887 BRUSH_ShareUnlockBrush(pbrush);
1888
1889 if (!Ret)
1890 {
1891 ERR("Failed to paint the off-screen surface.\n");
1892 goto Cleanup;
1893 }
1894#endif
1895 }
1896 else
1897 {
1898 /* We directly draw to the DC */
1899 TRACE("Performing on screen rendering.\n");
1900 pdcClipObj = (CLIPOBJ *)&pdc->co;
1901 // psurfOffScreen = NULL;
1902 }
1903
1904 /* Now do the rendering */
1905 if (hbmAlpha && ((diFlags & DI_NORMAL) == DI_NORMAL))
1906 {
1907 BLENDOBJ blendobj = { {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA } };
1908 PSURFACE psurf = NULL;
1909
1910 psurf = SURFACE_ShareLockSurface(hbmAlpha);
1911 if (!psurf)
1912 {
1913 ERR("SURFACE_LockSurface failed!\n");
1914 goto NoAlpha;
1915 }
1916
1917 /* Initialize color translation object */
1918 EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0xFFFFFFFF, 0xFFFFFFFF, 0);
1919
1920 /* Now do it */
1921 Ret = IntEngAlphaBlend(&psurfDest->SurfObj,
1922 &psurf->SurfObj,
1923 pdcClipObj,
1924 &exlo.xlo,
1925 &rcDest,
1926 &rcSrc,
1927 &blendobj);
1928
1929 EXLATEOBJ_vCleanup(&exlo);
1931 if (Ret) goto done;
1932 ERR("NtGdiAlphaBlend failed!\n");
1933 }
1934NoAlpha:
1935 if (diFlags & DI_MASK)
1936 {
1937 DWORD rop4 = (diFlags & DI_IMAGE) ? ROP4_SRCAND : ROP4_SRCCOPY;
1938
1939 EXLATEOBJ_vInitSrcMonoXlate(&exlo, psurfDest->ppal, 0x00FFFFFF, 0);
1940
1941 Ret = IntEngStretchBlt(&psurfDest->SurfObj,
1942 &psurfMask->SurfObj,
1943 NULL,
1944 pdcClipObj,
1945 &exlo.xlo,
1946 NULL,
1947 &rcDest,
1948 &rcSrc,
1949 NULL,
1950 NULL,
1951 NULL,
1952 rop4);
1953
1954 EXLATEOBJ_vCleanup(&exlo);
1955
1956 if (!Ret)
1957 {
1958 ERR("Failed to mask the bitmap data.\n");
1959 goto Cleanup;
1960 }
1961 }
1962
1963 if (diFlags & DI_IMAGE)
1964 {
1965 if (psurfColor)
1966 {
1967 DWORD rop4 = (diFlags & DI_MASK) ? ROP4_SRCINVERT : ROP4_SRCCOPY ;
1968
1969 EXLATEOBJ_vInitialize(&exlo, psurfColor->ppal, psurfDest->ppal, 0x00FFFFFF, 0x00FFFFFF, 0);
1970
1971 Ret = IntEngStretchBlt(&psurfDest->SurfObj,
1972 &psurfColor->SurfObj,
1973 NULL,
1974 pdcClipObj,
1975 &exlo.xlo,
1976 NULL,
1977 &rcDest,
1978 &rcSrc,
1979 NULL,
1980 NULL,
1981 NULL,
1982 rop4);
1983
1984 EXLATEOBJ_vCleanup(&exlo);
1985
1986 if (!Ret)
1987 {
1988 ERR("Failed to render the icon bitmap.\n");
1989 goto Cleanup;
1990 }
1991 }
1992 else
1993 {
1994 /* Mask bitmap holds the information in its bottom half */
1995 DWORD rop4 = (diFlags & DI_MASK) ? ROP4_SRCINVERT : ROP4_SRCCOPY;
1996 RECTL_vOffsetRect(&rcSrc, 0, pIcon->cy);
1997
1998 EXLATEOBJ_vInitSrcMonoXlate(&exlo, psurfDest->ppal, 0x00FFFFFF, 0);
1999
2000 Ret = IntEngStretchBlt(&psurfDest->SurfObj,
2001 &psurfMask->SurfObj,
2002 NULL,
2003 pdcClipObj,
2004 &exlo.xlo,
2005 NULL,
2006 &rcDest,
2007 &rcSrc,
2008 NULL,
2009 NULL,
2010 NULL,
2011 rop4);
2012
2013 EXLATEOBJ_vCleanup(&exlo);
2014
2015 if (!Ret)
2016 {
2017 ERR("Failed to render the icon bitmap.\n");
2018 goto Cleanup;
2019 }
2020 }
2021 }
2022
2023done:
2024#if 0
2025 /* We're done. Was it a double buffered draw ? */
2026 if (bOffScreen)
2027 {
2028 /* Yes. Draw it back to our DC */
2029 POINTL ptSrc = {0, 0};
2030
2031 /* Calculate destination rectangle */
2032 RECTL_vSetRect(&rcDest, xLeft, yTop, xLeft + cxWidth, yTop + cyHeight);
2033 IntLPtoDP(pdc, (LPPOINT)&rcDest, 2);
2034 RECTL_vOffsetRect(&rcDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
2035
2036 /* Get the clip object */
2037 pdcClipObj = pdc->rosdc.CombinedClip;
2038
2039 /* We now have our destination surface and rectangle */
2040 psurfDest = pdc->dclevel.pSurface;
2041
2042 /* Color translation */
2043 EXLATEOBJ_vInitialize(&exlo, psurfOffScreen->ppal, psurfDest->ppal, 0x00FFFFFF, 0x00FFFFFF, 0);
2044
2045 /* Blt it! */
2046 Ret = IntEngBitBlt(&psurfDest->SurfObj,
2047 &psurfOffScreen->SurfObj,
2048 NULL,
2049 pdcClipObj,
2050 &exlo.xlo,
2051 &rcDest,
2052 &ptSrc,
2053 NULL,
2054 NULL,
2055 NULL,
2056 ROP4_SRCCOPY);
2057
2058 EXLATEOBJ_vCleanup(&exlo);
2059 }
2060#endif
2061Cleanup:
2062 if (pdc)
2063 {
2064 DC_vFinishBlit(pdc, NULL);
2065 DC_UnlockDc(pdc);
2066 }
2067
2068#if 0
2069 /* Delete off screen rendering surface */
2070 if (psurfOffScreen)
2071 GDIOBJ_vDeleteObject(&psurfOffScreen->BaseObject);
2072#endif
2073
2074 /* Unlock other surfaces */
2075 SURFACE_ShareUnlockSurface(psurfMask);
2076 if (psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
2077
2078 return Ret;
2079}
2080
2081/*
2082 * @implemented
2083 */
2084BOOL
2087 HDC hdc,
2088 int xLeft,
2089 int yTop,
2090 HICON hIcon,
2091 int cxWidth,
2092 int cyHeight,
2093 UINT istepIfAniCur,
2094 HBRUSH hbrFlickerFreeDraw,
2095 UINT diFlags,
2096 BOOL bMetaHDC, // When TRUE, GDI functions need to be handled in User32!
2097 PVOID pDIXData)
2098{
2099 PCURICON_OBJECT pIcon;
2100 BOOL Ret;
2101
2102 TRACE("Enter NtUserDrawIconEx\n");
2104
2105 if (!(pIcon = UserGetCurIconObject(hIcon)))
2106 {
2107 ERR("UserGetCurIconObject(0x%p) failed!\n", hIcon);
2108 UserLeave();
2109 return FALSE;
2110 }
2111
2112 Ret = UserDrawIconEx(hdc,
2113 xLeft,
2114 yTop,
2115 pIcon,
2116 cxWidth,
2117 cyHeight,
2118 istepIfAniCur,
2119 hbrFlickerFreeDraw,
2120 diFlags);
2121
2122 UserDereferenceObject(pIcon);
2123
2124 UserLeave();
2125 return Ret;
2126}
2127
2128/*
2129 * @unimplemented
2130 */
2131HCURSOR
2132NTAPI
2134 HCURSOR hCursor,
2135 DWORD istep,
2136 INT* rate_jiffies,
2137 DWORD* num_steps)
2138{
2139 PCURICON_OBJECT CurIcon;
2140 HCURSOR ret;
2141 INT jiffies = 0;
2142 DWORD steps = 1;
2144
2145 TRACE("Enter NtUserGetCursorFrameInfo\n");
2147
2148 if (!(CurIcon = UserGetCurIconObject(hCursor)))
2149 {
2150 UserLeave();
2151 return NULL;
2152 }
2153
2154 ret = UserHMGetHandle(CurIcon);
2155
2156 if (CurIcon->CURSORF_flags & CURSORF_ACON)
2157 {
2158 PACON AniCurIcon = (PACON)CurIcon;
2159 if (istep >= AniCurIcon->cicur)
2160 {
2161 UserDereferenceObject(CurIcon);
2162 UserLeave();
2163 return NULL;
2164 }
2165 jiffies = AniCurIcon->ajifRate[istep];
2166 steps = AniCurIcon->cicur;
2167 ret = UserHMGetHandle(AniCurIcon->aspcur[AniCurIcon->aicur[istep]]);
2168 }
2169
2170 _SEH2_TRY
2171 {
2172 ProbeForWrite(rate_jiffies, sizeof(INT), 1);
2173 ProbeForWrite(num_steps, sizeof(DWORD), 1);
2174 *rate_jiffies = jiffies;
2175 *num_steps = steps;
2176 }
2178 {
2180 }
2181 _SEH2_END
2182
2183 if (!NT_SUCCESS(Status))
2184 {
2185 WARN("Status: 0x%08lx\n", Status);
2187 ret = NULL;
2188 }
2189
2190 UserDereferenceObject(CurIcon);
2191 UserLeave();
2192
2193 TRACE("Leaving NtUserGetCursorFrameInfo, ret = 0x%p\n", ret);
2194
2195 return ret;
2196}
2197
2198/*
2199 * @implemented
2200 */
2201BOOL
2204 HCURSOR hcur,
2205 DWORD id)
2206{
2207 PCURICON_OBJECT pcur, pcurOrig = NULL;
2208 int i;
2209 PPROCESSINFO ppi;
2210 BOOL Ret = FALSE;
2212
2214 {
2215 goto Exit;
2216 }
2217
2218 if (hcur)
2219 {
2220 pcur = UserGetCurIconObject(hcur);
2221 if (!pcur)
2222 {
2224 goto Exit;
2225 }
2226
2228
2229 for (i = 0 ; i < 16; i++)
2230 {
2231 if (gasyscur[i].type == id)
2232 {
2233 pcurOrig = gasyscur[i].handle;
2234
2235 if (pcurOrig) break;
2236
2237 if (ppi->W32PF_flags & W32PF_CREATEDWINORDC)
2238 {
2239 gasyscur[i].handle = pcur;
2241 pcur->head.ppi = NULL;
2243 Ret = TRUE;
2244 }
2245 break;
2246 }
2247 }
2248 if (pcurOrig)
2249 {
2250 FIXME("Need to copy cursor data or do something! pcurOrig %p new pcur %p\n",pcurOrig,pcur);
2251 }
2252 }
2253Exit:
2254 UserLeave();
2255 return Ret;
2256}
2257
2258/* EOF */
unsigned char BOOLEAN
LONG NTSTATUS
Definition: precomp.h:26
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
HBITMAP FASTCALL BITMAP_CopyBitmap(HBITMAP hBitmap)
Definition: bitmaps.c:714
BOOL NTAPI GreSetBitmapOwner(_In_ HBITMAP hbmp, _In_ ULONG ulOwner)
Definition: bitmaps.c:17
#define DBG_DEFAULT_CHANNEL(ch)
Definition: debug.h:106
#define leave
Definition: btrfs_drv.h:138
struct @1779 Msg[]
static BOOLEAN IntLPtoDP(DC *pdc, PPOINTL ppt, UINT count)
Definition: coord.h:182
struct tagACON * PACON
#define OIC_INTERNAL_WINSMALL
Definition: cursoricon.h:112
struct _CURICON_OBJECT * PCURICON_OBJECT
#define CURSORF_USER_MASK
Definition: cursoricon.h:6
VOID FASTCALL DC_vPrepareDCsForBlit(PDC pdcDest, const RECT *rcDest, PDC pdcSrc, const RECT *rcSrc)
Definition: dclife.c:505
VOID FASTCALL DC_vFinishBlit(PDC pdc1, PDC pdc2)
Definition: dclife.c:614
FORCEINLINE VOID DC_UnlockDc(PDC pdc)
Definition: dc.h:238
FORCEINLINE PDC DC_LockDc(HDC hdc)
Definition: dc.h:220
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
WORD ATOM
Definition: dimm.idl:113
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define NT_SUCCESS(StatCode)
Definition: apphelp.c:33
#define APIENTRY
Definition: api.h:79
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
static void cleanup(void)
Definition: main.c:1335
#define IS_INTRESOURCE(x)
Definition: loader.c:613
static const WCHAR Cleanup[]
Definition: register.c:80
#define pt(x, y)
Definition: drawing.c:79
return ret
Definition: mutex.c:146
VOID NTAPI EBRUSHOBJ_vCleanup(EBRUSHOBJ *pebo)
Definition: engbrush.c:153
VOID NTAPI EBRUSHOBJ_vInit(EBRUSHOBJ *pebo, PBRUSH pbrush, PSURFACE psurf, COLORREF crBackgroundClr, COLORREF crForegroundClr, PPALETTE ppalDC)
Definition: engbrush.c:52
#define ExAllocatePoolWithTag(hernya, size, tag)
Definition: env_spec_w32.h:350
ULONG RtlCompareUnicodeString(PUNICODE_STRING s1, PUNICODE_STRING s2, BOOLEAN UpCase)
Definition: string_lib.cpp:31
#define PagedPool
Definition: env_spec_w32.h:308
VOID NTAPI ProbeForRead(IN CONST VOID *Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:102
VOID NTAPI ProbeForWrite(IN PVOID Address, IN SIZE_T Length, IN ULONG Alignment)
Definition: exintrin.c:143
#define BufLen
Definition: fatfs.h:167
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
#define BRUSH_ShareLockBrush(hBrush)
Definition: brush.h:117
#define BRUSH_ShareUnlockBrush(pBrush)
Definition: brush.h:118
#define GDI_OBJECT_TYPE_BRUSH
Definition: gdi.h:52
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
Status
Definition: gdiplustypes.h:25
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLbitfield flags
Definition: glext.h:7161
GLfloat param
Definition: glext.h:5796
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
PSERVERINFO gpsi
Definition: imm.c:18
#define CURSORF_LRSHARED
Definition: ntuser.h:1201
#define UserHMGetHandle(obj)
Definition: ntuser.h:230
_Out_opt_ PICONINFO _Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING _Out_opt_ LPDWORD _In_ BOOL bInternal
Definition: ntuser.h:2314
struct _THREADINFO * GetW32ThreadInfo(VOID)
Definition: misc.c:807
#define CURSORF_CURRENT
Definition: ntuser.h:1207
_Out_opt_ PICONINFO IconInfo
Definition: ntuser.h:2310
#define CURSORF_LINKED
Definition: ntuser.h:1206
@ TYPE_CURSOR
Definition: ntuser.h:43
struct tagCURSORDATA CURSORDATA
#define CURSORF_GLOBAL
Definition: ntuser.h:1200
#define CURSORF_ACONFRAME
Definition: ntuser.h:1204
_Out_opt_ PICONINFO _Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING lpResName
Definition: ntuser.h:2312
_Out_opt_ PICONINFO _Inout_opt_ PUNICODE_STRING _Inout_opt_ PUNICODE_STRING _Out_opt_ LPDWORD pbpp
Definition: ntuser.h:2313
#define CURSORF_ACON
Definition: ntuser.h:1202
#define EXCEPTION_EXECUTE_HANDLER
Definition: excpt.h:90
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)
int * PINT
Definition: minwindef.h:150
#define MmCopyToCaller(x, y, z)
Definition: mmcopy.h:19
#define ASSERT(a)
Definition: mode.c:44
#define jiffies
Definition: module.h:1085
#define ExFreePoolWithTag(_P, _T)
Definition: module.h:1109
#define for
Definition: utility.h:88
#define AC_SRC_ALPHA
Definition: alphablend.c:9
HDC hdc
Definition: main.c:9
static HBITMAP
Definition: button.c:44
static HDC
Definition: imagelist.c:88
static HICON
Definition: imagelist.c:80
unsigned short RTL_ATOM
Definition: atom.c:42
static DWORD DWORD DWORD DWORD * steps
Definition: cursoricon.c:1638
static DWORD DWORD istep
Definition: cursoricon.c:1638
#define min(a, b)
Definition: monoChain.cc:55
HICON hIcon
Definition: msconfig.c:44
VOID FASTCALL co_MsqInsertMouseMessage(MSG *Msg, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: msgqueue.c:580
PCURICON_OBJECT FASTCALL UserSetCursor(PCURICON_OBJECT NewCursor, BOOL ForceChange)
Definition: msgqueue.c:93
unsigned int UINT
Definition: ndis.h:50
#define UserMode
Definition: asm.h:39
NTSYSAPI NTSTATUS NTAPI RtlAddAtomToAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ PWSTR AtomName, _Out_ PRTL_ATOM Atom)
NTSYSAPI NTSTATUS NTAPI RtlLookupAtomInAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ PWSTR AtomName, _Out_ PRTL_ATOM Atom)
NTSYSAPI NTSTATUS NTAPI RtlDeleteAtomFromAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom)
NTSYSAPI NTSTATUS NTAPI RtlQueryAtomInAtomTable(_In_ PRTL_ATOM_TABLE AtomTable, _In_ RTL_ATOM Atom, _Out_opt_ PULONG RefCount, _Out_opt_ PULONG PinCount, _Out_opt_z_bytecap_(*NameLength) PWSTR AtomName, _Inout_opt_ PULONG NameLength)
#define _Out_opt_
Definition: no_sal2.h:214
#define _Inout_
Definition: no_sal2.h:162
#define _Success_(c)
Definition: no_sal2.h:84
#define _Inout_opt_
Definition: no_sal2.h:216
#define _In_
Definition: no_sal2.h:158
#define _In_opt_
Definition: no_sal2.h:212
#define FASTCALL
Definition: nt_native.h:50
#define DWORD
Definition: nt_native.h:44
#define GDI_OBJ_HMGR_POWNED
Definition: ntgdihdl.h:117
#define GDI_OBJ_HMGR_PUBLIC
Definition: ntgdihdl.h:116
ULONG MmUserProbeAddress
Definition: init.c:50
PVOID NTAPI PsGetCurrentProcessWin32Process(VOID)
Definition: process.c:1183
BOOL FASTCALL CheckWinstaAttributeAccess(ACCESS_MASK DesiredAccess)
Definition: winsta.c:388
VOID FASTCALL UserLeave(VOID)
Definition: ntuser.c:258
VOID FASTCALL UserEnterShared(VOID)
Definition: ntuser.c:242
VOID FASTCALL UserEnterExclusive(VOID)
Definition: ntuser.c:249
#define MAKEINTRESOURCE(i)
Definition: ntverrsrc.c:25
#define TAG_STRING
Definition: oslist.h:22
#define RT_ICON
Definition: pedump.c:365
long LONG
Definition: pedump.c:60
#define INT
Definition: polytest.cpp:20
#define _SEH2_GetExceptionCode()
Definition: pseh2_64.h:181
#define _SEH2_EXCEPT(...)
Definition: pseh2_64.h:82
#define _SEH2_VOLATILE
Definition: pseh2_64.h:185
#define _SEH2_END
Definition: pseh2_64.h:171
#define _SEH2_TRY
Definition: pseh2_64.h:71
#define _SEH2_YIELD(__stmt)
Definition: pseh2_64.h:184
static __inline NTSTATUS ProbeAndCaptureUnicodeString(OUT PUNICODE_STRING Dest, IN KPROCESSOR_MODE CurrentMode, IN const UNICODE_STRING *UnsafeSrc)
Definition: probe.h:142
static __inline VOID ReleaseCapturedUnicodeString(IN PUNICODE_STRING CapturedString, IN KPROCESSOR_MODE CurrentMode)
Definition: probe.h:239
#define STATUS_SUCCESS
Definition: shellext.h:65
static void Exit(void)
Definition: sock.c:1330
#define TRACE(s)
Definition: solgame.cpp:4
#define __kernel_entry
Definition: specstrings.h:355
Definition: polytest.cpp:41
CLIPOBJ CombinedClip
Definition: polytest.cpp:42
Implementation of the Explorer desktop window.
Definition: desktop.h:52
long bottom
Definition: polytest.cpp:53
long right
Definition: polytest.cpp:53
long top
Definition: polytest.cpp:53
long left
Definition: polytest.cpp:53
PCURICON_OBJECT handle
Definition: cursoricon.h:99
Definition: types.h:101
struct _CURICON_OBJECT * pcurNext
Definition: cursoricon.h:12
HBITMAP hbmColor
Definition: cursoricon.h:20
HBITMAP hbmMask
Definition: cursoricon.h:19
UNICODE_STRING strName
Definition: cursoricon.h:13
USHORT atomModName
Definition: cursoricon.h:14
PROCMARKHEAD head
Definition: cursoricon.h:11
ULONG CURSORF_flags
Definition: cursoricon.h:16
HBITMAP hbmAlpha
Definition: cursoricon.h:21
BRUSHOBJ BrushObject
Definition: brush.h:71
XLATEOBJ xlo
Definition: xlateobj.h:21
DWORD yHotspot
Definition: winuser.h:3227
BOOL fIcon
Definition: winuser.h:3225
DWORD xHotspot
Definition: winuser.h:3226
HBITMAP hbmColor
Definition: winuser.h:3229
HBITMAP hbmMask
Definition: winuser.h:3228
struct _CURICON_OBJECT * pCursorCache
Definition: win32.h:273
struct _PROCESSINFO * ppi
Definition: ntuser.h:227
LONG cy
Definition: kdterminal.h:28
SURFOBJ SurfObj
Definition: surface.h:8
struct _PALETTE *const ppal
Definition: surface.h:11
SIZEL sizlBitmap
Definition: winddi.h:1209
ULONG iBitmapFormat
Definition: winddi.h:1215
PCURICON_OBJECT CurrentCursorObject
Definition: cursoricon.h:74
USHORT MaximumLength
Definition: env_spec_w32.h:370
Definition: ntuser.h:694
Definition: ps.c:97
UINT cpcur
Definition: cursoricon.h:37
UINT cicur
Definition: cursoricon.h:38
DWORD * aicur
Definition: cursoricon.h:40
PCURICON_OBJECT * aspcur
Definition: cursoricon.h:39
INT * ajifRate
Definition: cursoricon.h:41
DWORD * aicur
Definition: ntuser.h:1193
INT * ajifRate
Definition: ntuser.h:1194
ULONG CURSORF_flags
Definition: ntuser.h:1179
UINT cpcur
Definition: ntuser.h:1190
UINT cicur
Definition: ntuser.h:1191
struct tagCURSORDATA * aspcur
Definition: ntuser.h:1192
DWORD flags
Definition: winuser.h:3822
DWORD cbSize
Definition: winuser.h:3821
HCURSOR hCursor
Definition: winuser.h:3823
POINT ptScreenPos
Definition: winuser.h:3824
Definition: windef.h:99
#define __WARNING_READ_OVERRUN
Definition: suppress.h:142
#define _PRAGMA_WARNING_SUPPRESS(x)
Definition: suppress.h:28
#define max(a, b)
Definition: svc.c:63
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define NTAPI
Definition: typedefs.h:36
uint32_t * LPDWORD
Definition: typedefs.h:59
int32_t INT
Definition: typedefs.h:58
#define RtlCopyMemory(Destination, Source, Length)
Definition: typedefs.h:263
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG_PTR
Definition: typedefs.h:65
int32_t * PLONG
Definition: typedefs.h:58
uint32_t ULONG
Definition: typedefs.h:59
_Must_inspect_result_ _In_ WDFCOLLECTION _In_ WDFOBJECT Object
#define FORCEINLINE
Definition: wdftypes.h:67
#define W32PF_CREATEDWINORDC
Definition: win32.h:34
#define ROP4_SRCCOPY
Definition: dib.h:13
#define ROP4_PATCOPY
Definition: dib.h:15
#define ROP4_SRCINVERT
Definition: dib.h:9
#define ROP4_SRCAND
Definition: dib.h:10
BOOL APIENTRY IntEngAlphaBlend(_Inout_ SURFOBJ *psoDest, _In_ SURFOBJ *psoSource, _In_opt_ CLIPOBJ *pco, _In_opt_ XLATEOBJ *pxlo, _In_ RECTL *prclDest, _In_ RECTL *prclSrc, _In_ BLENDOBJ *pBlendObj)
Definition: alphablend.c:198
BOOL APIENTRY IntEngBitBlt(SURFOBJ *psoTrg, SURFOBJ *psoSrc, SURFOBJ *psoMask, CLIPOBJ *pco, XLATEOBJ *pxlo, RECTL *prclTrg, POINTL *pptlSrc, POINTL *pptlMask, BRUSHOBJ *pbo, POINTL *pptlBrush, ROP4 Rop4)
Definition: bitblt.c:656
VOID FASTCALL SetLastNtError(_In_ NTSTATUS Status)
Definition: error.c:31
PSURFACE NTAPI SURFACE_AllocSurface(_In_ USHORT iType, _In_ ULONG cx, _In_ ULONG cy, _In_ ULONG iFormat, _In_ ULONG fjBitmap, _In_opt_ ULONG cjWidth, _In_opt_ ULONG cjBufSize, _In_opt_ PVOID pvBits)
Definition: surface.c:116
#define SURFACE_ShareUnlockSurface(pBMObj)
Definition: surface.h:102
#define SURFACE_ShareLockSurface(hBMObj)
Definition: surface.h:91
BOOL NTAPI GreSetObjectOwner(HGDIOBJ hobj, ULONG ulOwner)
Definition: gdiobj.c:1268
BOOL NTAPI GreDeleteObject(HGDIOBJ hobj)
Definition: gdiobj.c:1165
VOID NTAPI GDIOBJ_vDeleteObject(POBJ pobj)
Definition: gdiobj.c:1118
FORCEINLINE VOID RECTL_vSetRect(_Out_ RECTL *prcl, _In_ LONG left, _In_ LONG top, _In_ LONG right, _In_ LONG bottom)
Definition: rect.h:5
FORCEINLINE VOID RECTL_vOffsetRect(_Inout_ RECTL *prcl, _In_ INT cx, _In_ INT cy)
Definition: rect.h:31
_Must_inspect_result_ NTSTATUS NTAPI ProbeAndCaptureUnicodeStringOrAtom(_Out_ _When_(return >=0, _At_(pustrOut->Buffer, _Post_ _Notnull_)) PUNICODE_STRING pustrOut, __in_data_source(USER_MODE) _In_ PUNICODE_STRING pustrUnsafe)
Definition: class.c:152
BOOL APIENTRY NtUserGetClipCursor(RECTL *lpRect)
Definition: cursoricon.c:998
VOID FreeCurIconObject(_In_ PVOID Object)
Definition: cursoricon.c:336
static VOID IntInsertCursorIntoList(_Inout_ PCURICON_OBJECT pcur)
Definition: cursoricon.c:80
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: cursoricon.c:2086
HANDLE IntCreateCurIconHandle(BOOLEAN Animated)
Definition: cursoricon.c:285
BOOL APIENTRY UserSetCursorIconData(_In_ HCURSOR hcursor, _In_opt_ PUNICODE_STRING pustrModule, _In_opt_ PUNICODE_STRING pustrRsrc, _In_ PCURSORDATA pcursordata)
Definition: cursoricon.c:1421
static BOOL IntSetCursorData(_Inout_ PCURICON_OBJECT pcur, _In_opt_ PUNICODE_STRING pustrName, _In_ ATOM atomModName, _In_ const CURSORDATA *pcursordata)
Definition: cursoricon.c:1132
SYSTEMCURICO gasyscur[]
Definition: cursoricon.c:32
BOOL APIENTRY NtUserGetIconSize(HANDLE hCurIcon, UINT istepIfAniCur, PLONG plcx, PLONG plcy)
Definition: cursoricon.c:590
HICON NTAPI NtUserFindExistingCursorIcon(_In_ PUNICODE_STRING pustrModule, _In_ PUNICODE_STRING pustrRsrc, _In_ FINDEXISTINGCURICONPARAM *param)
Definition: cursoricon.c:863
BOOL APIENTRY NtUserSetCursorContents(HANDLE hCurIcon, PICONINFO UnsafeIconInfo)
Definition: cursoricon.c:1121
BOOL InitCursorImpl(VOID)
Definition: cursoricon.c:64
BOOL APIENTRY NtUserClipCursor(RECTL *prcl)
Definition: cursoricon.c:755
BOOL UserSetCursorPos(INT x, INT y, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
Definition: cursoricon.c:238
BOOL APIENTRY NtUserDestroyCursor(_In_ HANDLE hCurIcon, _In_ BOOL bForce)
Definition: cursoricon.c:795
__kernel_entry BOOL APIENTRY NtUserSetCursorIconData(_In_ HCURSOR hcursor, _In_opt_ PUNICODE_STRING pustrModule, _In_opt_ PUNICODE_STRING pustrRsrc, _In_ const CURSORDATA *pCursorData)
Definition: cursoricon.c:1512
VOID IntLoadSystenIcons(HICON hcur, DWORD id)
Definition: cursoricon.c:137
PCURICON_OBJECT IntSystemSetCursor(PCURICON_OBJECT pcurNew)
Definition: cursoricon.c:230
PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID)
Definition: cursoricon.c:187
BOOL APIENTRY NtUserSetSystemCursor(HCURSOR hcur, DWORD id)
Definition: cursoricon.c:2203
BOOL APIENTRY NtUserGetCursorInfo(PCURSORINFO pci)
Definition: cursoricon.c:649
FORCEINLINE BOOL is_icon(PCURICON_OBJECT object)
Definition: cursoricon.c:194
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
Definition: cursoricon.c:200
BOOL APIENTRY UserClipCursor(RECTL *prcl)
Definition: cursoricon.c:702
BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth, INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags)
Definition: cursoricon.c:1691
HCURSOR APIENTRY NtUserSetCursor(HCURSOR hCursor)
Definition: cursoricon.c:1051
static BOOL IntSetAconData(_Inout_ PACON pacon, _In_opt_ PUNICODE_STRING pustrName, _In_ ATOM atomModName, _In_ const CURSORDATA *pcursordata)
Definition: cursoricon.c:1240
VOID FASTCALL IntCleanupCurIconCache(PPROCESSINFO Win32Process)
Definition: cursoricon.c:395
SYSTEM_CURSORINFO gSysCursorInfo
Definition: cursoricon.c:25
PCURICON_OBJECT gcurFirst
Definition: cursoricon.c:27
HCURSOR NTAPI NtUserGetCursorFrameInfo(HCURSOR hCursor, DWORD istep, INT *rate_jiffies, DWORD *num_steps)
Definition: cursoricon.c:2133
SYSTEMCURICO gasysico[]
Definition: cursoricon.c:54
BOOLEAN IntDestroyCurIconObject(_In_ PVOID Object)
Definition: cursoricon.c:317
static VOID IntRemoveCursorFromList(_Inout_ PCURICON_OBJECT pcur)
Definition: cursoricon.c:101
PWND FASTCALL UserGetDesktopWindow(VOID)
Definition: desktop.c:1403
WORD FASTCALL UserGetMouseButtonsState(VOID)
Definition: mouse.c:22
LONG NTAPI UserGetSystemMetrics(ULONG Index)
Definition: metric.c:210
BOOL FASTCALL UserDereferenceObject(PVOID Object)
Definition: object.c:644
PVOID FASTCALL UserReferenceObjectByHandle(HANDLE handle, HANDLE_TYPE type)
Definition: object.c:741
BOOL FASTCALL UserDeleteObject(HANDLE h, HANDLE_TYPE type)
Definition: object.c:717
PUSER_HANDLE_TABLE gHandleTable
Definition: object.c:13
BOOL FASTCALL UserObjectInDestroy(HANDLE h)
Definition: object.c:703
void FreeProcMarkObject(_In_ PVOID Object)
Definition: object.c:175
PVOID FASTCALL UserCreateObject(PUSER_HANDLE_TABLE ht, PDESKTOP pDesktop, PTHREADINFO pti, HANDLE *h, HANDLE_TYPE type, ULONG size)
Definition: object.c:568
PVOID UserGetObjectNoErr(PUSER_HANDLE_TABLE ht, HANDLE handle, HANDLE_TYPE type)
Definition: object.c:481
VOID FASTCALL UserReferenceObject(PVOID obj)
Definition: object.c:731
PRTL_ATOM_TABLE gAtomTable
Definition: session.c:13
#define USERTAG_CURSOR
Definition: tags.h:209
#define STYPE_BITMAP
Definition: winddi.h:1175
_In_opt_ SURFOBJ _In_opt_ SURFOBJ _In_ CLIPOBJ _In_opt_ XLATEOBJ _In_ RECTL _In_opt_ POINTL _In_opt_ POINTL _In_opt_ BRUSHOBJ _In_opt_ POINTL _In_ ROP4 rop4
Definition: winddi.h:3442
_In_ ULONG _In_ CLIPOBJ _In_ RECTL * prcl
Definition: winddi.h:3531
ENGAPI VOID APIENTRY EngSetLastError(_In_ ULONG iError)
Definition: error.c:22
_In_ ULONG cjSize
Definition: winddi.h:3634
HICON HCURSOR
Definition: windef.h:93
#define ERROR_INVALID_CURSOR_HANDLE
Definition: winerror.h:1228
#define AC_SRC_OVER
Definition: wingdi.h:1369
#define DI_NORMAL
Definition: wingdi.h:72
#define DI_IMAGE
Definition: wingdi.h:70
#define DI_MASK
Definition: wingdi.h:71
#define DI_DEFAULTSIZE
Definition: wingdi.h:69
#define MAKELPARAM(l, h)
Definition: winuser.h:4110
#define SM_CYSCREEN
Definition: winuser.h:971
#define CURSOR_SHOWING
Definition: winuser.h:2700
#define WM_MOUSEMOVE
Definition: winuser.h:1803
#define WINSTA_READATTRIBUTES
Definition: winuser.h:414
#define SM_CYICON
Definition: winuser.h:984
#define SM_CXSCREEN
Definition: winuser.h:970
#define WINSTA_WRITEATTRIBUTES
Definition: winuser.h:416
#define SM_CYCURSOR
Definition: winuser.h:986
#define SM_CXICON
Definition: winuser.h:983
#define SM_CXCURSOR
Definition: winuser.h:985
#define NT_ASSERT
Definition: rtlfuncs.h:3327
#define NT_VERIFY(exp)
Definition: rtlfuncs.h:3304
VOID NTAPI EXLATEOBJ_vInitialize(_Out_ PEXLATEOBJ pexlo, _In_opt_ PALETTE *ppalSrc, _In_opt_ PALETTE *ppalDst, _In_ COLORREF crSrcBackColor, _In_ COLORREF crDstBackColor, _In_ COLORREF crDstForeColor)
Definition: xlateobj.c:358
VOID NTAPI EXLATEOBJ_vCleanup(_Inout_ PEXLATEOBJ pexlo)
Definition: xlateobj.c:649
VOID NTAPI EXLATEOBJ_vInitSrcMonoXlate(PEXLATEOBJ pexlo, PPALETTE ppalDst, COLORREF crBackgroundClr, COLORREF crForegroundClr)
Definition: xlateobj.c:632
__wchar_t WCHAR
Definition: xmlstorage.h:180