2 * ReactOS W32 Subsystem
3 * Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 ReactOS Team
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 * We handle two types of cursors/icons:
23 * Loaded without LR_SHARED flag
24 * Private to a process
25 * Can be deleted by calling NtDestroyCursorIcon()
26 * CurIcon->hModule, CurIcon->hRsrc and CurIcon->hGroupRsrc set to NULL
28 * Loaded with LR_SHARED flag
29 * Possibly shared by multiple processes
30 * Immune to NtDestroyCursorIcon()
31 * CurIcon->hModule, CurIcon->hRsrc and CurIcon->hGroupRsrc are valid
32 * There's a M:N relationship between processes and (shared) cursor/icons.
33 * A process can have multiple cursor/icons and a cursor/icon can be used
34 * by multiple processes. To keep track of this we keep a list of all
35 * cursor/icons (CurIconList) and per cursor/icon we keep a list of
36 * CURICON_PROCESS structs starting at CurIcon->ProcessList.
44 static PAGED_LOOKASIDE_LIST gProcessLookasideList
;
45 static LIST_ENTRY gCurIconList
;
47 /* Look up the location of the cursor in the GDIDEVICE structure
48 * when all we know is the window station object
49 * Actually doesn't use the window station, but should... */
51 IntGetCursorLocation(PWINSTATION_OBJECT WinSta
, POINT
*loc
)
58 /* FIXME - get the screen dc from the window station or desktop */
59 if (!(hDC
= IntGetScreenDC()))
63 if (!(dc
= DC_LockDc(hDC
)))
65 GDIDevice
= (GDIDEVICE
*)dc
->pPDev
;
68 loc
->x
= GDIDevice
->Pointer
.Pos
.x
;
69 loc
->y
= GDIDevice
->Pointer
.Pos
.y
;
74 /* This function creates a reference for the object! */
75 PCURICON_OBJECT FASTCALL
UserGetCurIconObject(HCURSOR hCurIcon
)
77 PCURICON_OBJECT CurIcon
;
81 SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE
);
85 CurIcon
= (PCURICON_OBJECT
)UserReferenceObjectByHandle(hCurIcon
, otCursorIcon
);
88 /* we never set ERROR_INVALID_ICON_HANDLE. lets hope noone ever checks for it */
89 SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE
);
93 ASSERT(USER_BODY_TO_HEADER(CurIcon
)->RefCount
>= 1);
98 #define COLORCURSORS_ALLOWED FALSE
100 IntSetCursor(PWINSTATION_OBJECT WinSta
, PCURICON_OBJECT NewCursor
,
103 BITMAPOBJ
*BitmapObj
;
106 PBITMAPOBJ MaskBmpObj
= NULL
;
107 PSYSTEM_CURSORINFO CurInfo
;
108 PCURICON_OBJECT OldCursor
;
109 HCURSOR Ret
= (HCURSOR
)0;
112 SURFOBJ
*soMask
= NULL
, *soColor
= NULL
;
113 XLATEOBJ
*XlateObj
= NULL
;
117 CurInfo
= IntGetSysCursorInfo(WinSta
);
118 OldCursor
= CurInfo
->CurrentCursorObject
;
121 Ret
= (HCURSOR
)OldCursor
->Self
;
124 if (!ForceChange
&& OldCursor
== NewCursor
)
129 if(!(Screen
= IntGetScreenDC()))
133 /* FIXME use the desktop's HDC instead of using ScreenDeviceContext */
134 dc
= DC_LockDc(Screen
);
140 dcbmp
= dc
->w
.hBitmap
;
141 DevInfo
= (PDEVINFO
)&((GDIDEVICE
*)dc
->pPDev
)->DevInfo
;
144 BitmapObj
= BITMAPOBJ_LockBitmap(dcbmp
);
147 SurfObj
= &BitmapObj
->SurfObj
;
151 if (CurInfo
->CurrentCursorObject
|| ForceChange
)
153 if (CurInfo
->CurrentCursorObject
)
155 UserDereferenceObject(CurInfo
->CurrentCursorObject
);
156 if (CurInfo
->ShowingCursor
)
158 DPRINT1("Removing pointer!\n");
159 /* Remove the cursor if it was displayed */
160 IntEngMovePointer(SurfObj
, -1, -1, &GDIDEV(SurfObj
)->Pointer
.Exclude
);
164 GDIDEV(SurfObj
)->Pointer
.Status
= SPS_ACCEPT_NOEXCLUDE
;
166 CurInfo
->CurrentCursorObject
= NewCursor
; /* i.e. CurrentCursorObject = NULL */
167 CurInfo
->ShowingCursor
= 0;
170 BITMAPOBJ_UnlockBitmap(BitmapObj
);
174 /* TODO: Fixme. Logic is screwed above */
176 MaskBmpObj
= BITMAPOBJ_LockBitmap(NewCursor
->IconInfo
.hbmMask
);
179 const int maskBpp
= BitsPerFormat(MaskBmpObj
->SurfObj
.iBitmapFormat
);
180 BITMAPOBJ_UnlockBitmap(MaskBmpObj
);
183 DPRINT1("SetCursor: The Mask bitmap must have 1BPP!\n");
184 BITMAPOBJ_UnlockBitmap(BitmapObj
);
188 if ((DevInfo
->flGraphicsCaps2
& GCAPS2_ALPHACURSOR
) &&
189 SurfObj
->iBitmapFormat
>= BMF_16BPP
&&
190 SurfObj
->iBitmapFormat
<= BMF_32BPP
&&
191 NewCursor
->Shadow
&& COLORCURSORS_ALLOWED
)
193 /* FIXME - Create a color pointer, only 32bit bitmap, set alpha bits!
194 Do not pass a mask bitmap to DrvSetPointerShape()!
195 Create a XLATEOBJ that describes the colors of the bitmap. */
196 DPRINT1("SetCursor: (Colored) alpha cursors are not supported!\n");
200 if(NewCursor
->IconInfo
.hbmColor
201 && COLORCURSORS_ALLOWED
)
203 /* FIXME - Create a color pointer, create only one 32bit bitmap!
204 Do not pass a mask bitmap to DrvSetPointerShape()!
205 Create a XLATEOBJ that describes the colors of the bitmap.
206 (16bit bitmaps are propably allowed) */
207 DPRINT1("SetCursor: Cursors with colors are not supported!\n");
211 MaskBmpObj
= BITMAPOBJ_LockBitmap(NewCursor
->IconInfo
.hbmMask
);
214 RECTL DestRect
= {0, 0, MaskBmpObj
->SurfObj
.sizlBitmap
.cx
, MaskBmpObj
->SurfObj
.sizlBitmap
.cy
};
215 POINTL SourcePoint
= {0, 0};
218 * NOTE: For now we create the cursor in top-down bitmap,
219 * because VMware driver rejects it otherwise. This should
222 hMask
= EngCreateBitmap(
223 MaskBmpObj
->SurfObj
.sizlBitmap
, abs(MaskBmpObj
->SurfObj
.lDelta
),
224 MaskBmpObj
->SurfObj
.iBitmapFormat
, BMF_TOPDOWN
,
228 BITMAPOBJ_UnlockBitmap(MaskBmpObj
);
229 BITMAPOBJ_UnlockBitmap(BitmapObj
);
232 soMask
= EngLockSurface((HSURF
)hMask
);
233 EngCopyBits(soMask
, &MaskBmpObj
->SurfObj
, NULL
, NULL
,
234 &DestRect
, &SourcePoint
);
235 BITMAPOBJ_UnlockBitmap(MaskBmpObj
);
239 CurInfo
->ShowingCursor
= CURSOR_SHOWING
;
240 CurInfo
->CurrentCursorObject
= NewCursor
;
241 UserReferenceObject(NewCursor
);
245 CurInfo
->ShowingCursor
= 0;
246 CurInfo
->CurrentCursorObject
= NULL
;
249 /* OldCursor is not in use anymore */
252 UserDereferenceObject(OldCursor
);
255 if (GDIDEVFUNCS(SurfObj
).SetPointerShape
)
257 GDIDEV(SurfObj
)->Pointer
.Status
=
258 GDIDEVFUNCS(SurfObj
).SetPointerShape(
259 SurfObj
, soMask
, soColor
, XlateObj
,
260 NewCursor
->IconInfo
.xHotspot
,
261 NewCursor
->IconInfo
.yHotspot
,
262 GDIDEV(SurfObj
)->Pointer
.Pos
.x
,
263 GDIDEV(SurfObj
)->Pointer
.Pos
.y
,
264 &(GDIDEV(SurfObj
)->Pointer
.Exclude
),
266 DPRINT("SetCursor: DrvSetPointerShape() returned %x\n",
267 GDIDEV(SurfObj
)->Pointer
.Status
);
271 GDIDEV(SurfObj
)->Pointer
.Status
= SPS_DECLINE
;
274 if(GDIDEV(SurfObj
)->Pointer
.Status
== SPS_DECLINE
)
276 GDIDEV(SurfObj
)->Pointer
.Status
= EngSetPointerShape(
277 SurfObj
, soMask
, soColor
, XlateObj
,
278 NewCursor
->IconInfo
.xHotspot
,
279 NewCursor
->IconInfo
.yHotspot
,
280 GDIDEV(SurfObj
)->Pointer
.Pos
.x
,
281 GDIDEV(SurfObj
)->Pointer
.Pos
.y
,
282 &(GDIDEV(SurfObj
)->Pointer
.Exclude
),
284 GDIDEV(SurfObj
)->Pointer
.MovePointer
= NULL
;
288 GDIDEV(SurfObj
)->Pointer
.MovePointer
= GDIDEVFUNCS(SurfObj
).MovePointer
;
291 BITMAPOBJ_UnlockBitmap(BitmapObj
);
294 EngUnlockSurface(soMask
);
295 EngDeleteSurface((HSURF
)hMask
);
299 EngDeleteXlate(XlateObj
);
302 if(GDIDEV(SurfObj
)->Pointer
.Status
== SPS_ERROR
)
303 DPRINT1("SetCursor: DrvSetPointerShape() returned SPS_ERROR\n");
309 IntSetupCurIconHandles(PWINSTATION_OBJECT WinSta
)
311 ExInitializePagedLookasideList(&gProcessLookasideList
,
315 sizeof(CURICON_PROCESS
),
318 InitializeListHead(&gCurIconList
);
324 * We have to register that this object is in use by the current
325 * process. The only way to do that seems to be to walk the list
326 * of cursor/icon objects starting at W32Process->CursorIconListHead.
327 * If the object is already present in the list, we don't have to do
328 * anything, if it's not present we add it and inc the ProcessCount
329 * in the object. Having to walk the list kind of sucks, but that's
332 static BOOLEAN FASTCALL
333 ReferenceCurIconByProcess(PCURICON_OBJECT CurIcon
)
335 PW32PROCESS Win32Process
;
336 PCURICON_PROCESS Current
;
338 Win32Process
= PsGetCurrentProcessWin32Process();
340 LIST_FOR_EACH(Current
, &CurIcon
->ProcessList
, CURICON_PROCESS
, ListEntry
)
342 if (Current
->Process
== Win32Process
)
344 /* Already registered for this process */
349 /* Not registered yet */
350 Current
= ExAllocateFromPagedLookasideList(&gProcessLookasideList
);
355 InsertHeadList(&CurIcon
->ProcessList
, &Current
->ListEntry
);
356 Current
->Process
= Win32Process
;
361 PCURICON_OBJECT FASTCALL
362 IntFindExistingCurIconObject(PWINSTATION_OBJECT WinSta
, HMODULE hModule
,
363 HRSRC hRsrc
, LONG cx
, LONG cy
)
365 PCURICON_OBJECT CurIcon
;
367 LIST_FOR_EACH(CurIcon
, &gCurIconList
, CURICON_OBJECT
, ListEntry
)
370 // if(NT_SUCCESS(UserReferenceObjectByPointer(Object, otCursorIcon))) //<- huh????
371 // UserReferenceObject( CurIcon);
373 if((CurIcon
->hModule
== hModule
) && (CurIcon
->hRsrc
== hRsrc
))
375 if(cx
&& ((cx
!= CurIcon
->Size
.cx
) || (cy
!= CurIcon
->Size
.cy
)))
377 // UserDereferenceObject(CurIcon);
380 if (! ReferenceCurIconByProcess(CurIcon
))
388 // UserDereferenceObject(CurIcon);
395 PCURICON_OBJECT FASTCALL
396 IntCreateCurIconHandle(PWINSTATION_OBJECT WinSta
)
398 PCURICON_OBJECT CurIcon
;
401 CurIcon
= UserCreateObject(gHandleTable
, &hCurIcon
, otCursorIcon
, sizeof(CURICON_OBJECT
));
405 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
409 CurIcon
->Self
= hCurIcon
;
410 InitializeListHead(&CurIcon
->ProcessList
);
412 if (! ReferenceCurIconByProcess(CurIcon
))
414 DPRINT1("Failed to add process\n");
415 UserDeleteObject(hCurIcon
, otCursorIcon
);
416 UserDereferenceObject(CurIcon
);
420 InsertHeadList(&gCurIconList
, &CurIcon
->ListEntry
);
426 IntDestroyCurIconObject(PWINSTATION_OBJECT WinSta
, PCURICON_OBJECT CurIcon
, BOOL ProcessCleanup
)
428 PSYSTEM_CURSORINFO CurInfo
;
429 HBITMAP bmpMask
, bmpColor
;
431 PCURICON_PROCESS Current
= NULL
;
432 PW32PROCESS W32Process
= PsGetCurrentProcessWin32Process();
434 /* Private objects can only be destroyed by their own process */
435 if (NULL
== CurIcon
->hModule
)
437 ASSERT(CurIcon
->ProcessList
.Flink
->Flink
== &CurIcon
->ProcessList
);
438 Current
= CONTAINING_RECORD(CurIcon
->ProcessList
.Flink
, CURICON_PROCESS
, ListEntry
);
439 if (Current
->Process
!= W32Process
)
441 DPRINT1("Trying to destroy private icon/cursor of another process\n");
445 else if (! ProcessCleanup
)
447 DPRINT("Trying to destroy shared icon/cursor\n");
451 /* Now find this process in the list of processes referencing this object and
452 remove it from that list */
453 LIST_FOR_EACH(Current
, &CurIcon
->ProcessList
, CURICON_PROCESS
, ListEntry
)
455 if (Current
->Process
== W32Process
)
457 RemoveEntryList(&Current
->ListEntry
);
462 ExFreeToPagedLookasideList(&gProcessLookasideList
, Current
);
464 /* If there are still processes referencing this object we can't destroy it yet */
465 if (! IsListEmpty(&CurIcon
->ProcessList
))
471 if (! ProcessCleanup
)
473 RemoveEntryList(&CurIcon
->ListEntry
);
476 CurInfo
= IntGetSysCursorInfo(WinSta
);
478 if (CurInfo
->CurrentCursorObject
== CurIcon
)
480 /* Hide the cursor if we're destroying the current cursor */
481 IntSetCursor(WinSta
, NULL
, TRUE
);
484 bmpMask
= CurIcon
->IconInfo
.hbmMask
;
485 bmpColor
= CurIcon
->IconInfo
.hbmColor
;
490 GDIOBJ_SetOwnership(bmpMask
, PsGetCurrentProcess());
491 NtGdiDeleteObject(bmpMask
);
492 CurIcon
->IconInfo
.hbmMask
= NULL
;
496 GDIOBJ_SetOwnership(bmpColor
, PsGetCurrentProcess());
497 NtGdiDeleteObject(bmpColor
);
498 CurIcon
->IconInfo
.hbmColor
= NULL
;
501 /* We were given a pointer, no need to keep the reference anylonger! */
502 UserDereferenceObject(CurIcon
);
503 Ret
= UserDeleteObject(CurIcon
->Self
, otCursorIcon
);
509 IntCleanupCurIcons(struct _EPROCESS
*Process
, PW32PROCESS Win32Process
)
511 PWINSTATION_OBJECT WinSta
;
512 PCURICON_OBJECT CurIcon
, tmp
;
513 PCURICON_PROCESS ProcessData
;
515 WinSta
= IntGetWinStaObj();
521 LIST_FOR_EACH_SAFE(CurIcon
, tmp
, &gCurIconList
, CURICON_OBJECT
, ListEntry
)
523 UserReferenceObject(CurIcon
);
524 // if(NT_SUCCESS(UserReferenceObjectByPointer(Object, otCursorIcon)))
526 LIST_FOR_EACH(ProcessData
, &CurIcon
->ProcessList
, CURICON_PROCESS
, ListEntry
)
528 if (Win32Process
== ProcessData
->Process
)
530 RemoveEntryList(&CurIcon
->ListEntry
);
531 IntDestroyCurIconObject(WinSta
, CurIcon
, TRUE
);
537 // UserDereferenceObject(Object);
542 UserDereferenceObject(CurIcon
);
546 ObDereferenceObject(WinSta
);
554 NtUserCreateCursorIconHandle(PICONINFO IconInfo OPTIONAL
, BOOL Indirect
)
556 PCURICON_OBJECT CurIcon
;
557 PWINSTATION_OBJECT WinSta
;
561 DECLARE_RETURN(HANDLE
);
563 DPRINT("Enter NtUserCreateCursorIconHandle\n");
564 UserEnterExclusive();
566 WinSta
= IntGetWinStaObj();
572 if (!(CurIcon
= IntCreateCurIconHandle(WinSta
)))
574 SetLastWin32Error(ERROR_NOT_ENOUGH_MEMORY
);
575 ObDereferenceObject(WinSta
);
583 Status
= MmCopyFromCaller(&CurIcon
->IconInfo
, IconInfo
, sizeof(ICONINFO
));
584 if(NT_SUCCESS(Status
))
588 CurIcon
->IconInfo
.hbmMask
= BITMAPOBJ_CopyBitmap(CurIcon
->IconInfo
.hbmMask
);
589 CurIcon
->IconInfo
.hbmColor
= BITMAPOBJ_CopyBitmap(CurIcon
->IconInfo
.hbmColor
);
591 if(CurIcon
->IconInfo
.hbmColor
&&
592 (bmp
= BITMAPOBJ_LockBitmap(CurIcon
->IconInfo
.hbmColor
)))
594 CurIcon
->Size
.cx
= bmp
->SurfObj
.sizlBitmap
.cx
;
595 CurIcon
->Size
.cy
= bmp
->SurfObj
.sizlBitmap
.cy
;
596 BITMAPOBJ_UnlockBitmap(bmp
);
597 GDIOBJ_SetOwnership(CurIcon
->IconInfo
.hbmColor
, NULL
);
599 if(CurIcon
->IconInfo
.hbmMask
&&
600 (bmp
= BITMAPOBJ_LockBitmap(CurIcon
->IconInfo
.hbmMask
)))
602 if (CurIcon
->IconInfo
.hbmColor
== NULL
)
604 CurIcon
->Size
.cx
= bmp
->SurfObj
.sizlBitmap
.cx
;
605 CurIcon
->Size
.cy
= bmp
->SurfObj
.sizlBitmap
.cy
/ 2;
607 BITMAPOBJ_UnlockBitmap(bmp
);
608 GDIOBJ_SetOwnership(CurIcon
->IconInfo
.hbmMask
, NULL
);
613 SetLastNtError(Status
);
614 /* FIXME - Don't exit here */
618 UserDereferenceObject(CurIcon
);
619 ObDereferenceObject(WinSta
);
623 DPRINT("Leave NtUserCreateCursorIconHandle, ret=%i\n",_ret_
);
636 PUNICODE_STRING lpInstName
, // optional
637 PUNICODE_STRING lpResName
, // optional
638 LPDWORD pbpp
, // optional
642 PCURICON_OBJECT CurIcon
;
643 PWINSTATION_OBJECT WinSta
;
644 NTSTATUS Status
= STATUS_SUCCESS
;
646 DECLARE_RETURN(BOOL
);
648 DPRINT("Enter NtUserGetIconInfo\n");
649 UserEnterExclusive();
653 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
657 WinSta
= IntGetWinStaObj();
663 if (!(CurIcon
= UserGetCurIconObject(hCurIcon
)))
665 ObDereferenceObject(WinSta
);
669 RtlCopyMemory(&ii
, &CurIcon
->IconInfo
, sizeof(ICONINFO
));
672 ii
.hbmMask
= BITMAPOBJ_CopyBitmap(CurIcon
->IconInfo
.hbmMask
);
673 ii
.hbmColor
= BITMAPOBJ_CopyBitmap(CurIcon
->IconInfo
.hbmColor
);
678 ProbeForWrite(IconInfo
, sizeof(ICONINFO
), 1);
679 RtlCopyMemory(IconInfo
, &ii
, sizeof(ICONINFO
));
686 ProbeForWrite(pbpp
, sizeof(DWORD
), 1);
688 bmp
= BITMAPOBJ_LockBitmap(CurIcon
->IconInfo
.hbmColor
);
691 colorBpp
= BitsPerFormat(bmp
->SurfObj
.iBitmapFormat
);
692 BITMAPOBJ_UnlockBitmap(bmp
);
695 RtlCopyMemory(pbpp
, &colorBpp
, sizeof(DWORD
));
701 Status
= _SEH_GetExceptionCode();
705 if (NT_SUCCESS(Status
))
708 SetLastNtError(Status
);
710 UserDereferenceObject(CurIcon
);
711 ObDereferenceObject(WinSta
);
715 DPRINT("Leave NtUserGetIconInfo, ret=%i\n",_ret_
);
729 PLONG plcx
, // &size.cx
730 PLONG plcy
) // &size.cy
732 PCURICON_OBJECT CurIcon
;
733 NTSTATUS Status
= STATUS_SUCCESS
;
736 DPRINT("Enter NtUserGetIconSize\n");
737 UserEnterExclusive();
739 if (!(CurIcon
= UserGetCurIconObject(hCurIcon
)))
746 ProbeForWrite(plcx
, sizeof(LONG
), 1);
747 RtlCopyMemory(plcx
, &CurIcon
->Size
.cx
, sizeof(LONG
));
748 ProbeForWrite(plcy
, sizeof(LONG
), 1);
749 RtlCopyMemory(plcy
, &CurIcon
->Size
.cy
, sizeof(LONG
));
753 Status
= _SEH_GetExceptionCode();
757 if(NT_SUCCESS(Status
))
760 SetLastNtError(Status
); // maybe not, test this
762 UserDereferenceObject(CurIcon
);
765 DPRINT("Leave NtUserGetIconSize, ret=%i\n", bRet
);
776 NtUserGetCursorFrameInfo(
797 PSYSTEM_CURSORINFO CurInfo
;
798 PWINSTATION_OBJECT WinSta
;
800 PCURICON_OBJECT CurIcon
;
802 DECLARE_RETURN(BOOL
);
804 DPRINT("Enter NtUserGetCursorInfo\n");
805 UserEnterExclusive();
810 /* FIXME - get the screen dc from the window station or desktop */
811 if (!(hDC
= IntGetScreenDC()))
817 Status
= MmCopyFromCaller(&SafeCi
.cbSize
, pci
, sizeof(DWORD
));
818 if(!NT_SUCCESS(Status
))
820 SetLastNtError(Status
);
824 if(SafeCi
.cbSize
!= sizeof(CURSORINFO
))
826 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
830 WinSta
= IntGetWinStaObj();
836 CurInfo
= IntGetSysCursorInfo(WinSta
);
837 CurIcon
= (PCURICON_OBJECT
)CurInfo
->CurrentCursorObject
;
839 SafeCi
.flags
= ((CurInfo
->ShowingCursor
&& CurIcon
) ? CURSOR_SHOWING
: 0);
840 SafeCi
.hCursor
= (CurIcon
? (HCURSOR
)CurIcon
->Self
: (HCURSOR
)0);
842 IntGetCursorLocation(WinSta
, &SafeCi
.ptScreenPos
);
844 Status
= MmCopyToCaller(pci
, &SafeCi
, sizeof(CURSORINFO
));
845 if(!NT_SUCCESS(Status
))
847 ObDereferenceObject(WinSta
);
848 SetLastNtError(Status
);
852 ObDereferenceObject(WinSta
);
856 DPRINT("Leave NtUserGetCursorInfo, ret=%i\n",_ret_
);
870 /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
872 PWINSTATION_OBJECT WinSta
;
873 PSYSTEM_CURSORINFO CurInfo
;
875 PWINDOW_OBJECT DesktopWindow
= NULL
;
876 POINT MousePos
= {0};
877 DECLARE_RETURN(BOOL
);
879 DPRINT("Enter NtUserClipCursor\n");
880 UserEnterExclusive();
882 WinSta
= IntGetWinStaObj();
888 if (NULL
!= UnsafeRect
&& ! NT_SUCCESS(MmCopyFromCaller(&Rect
, UnsafeRect
, sizeof(RECT
))))
890 ObDereferenceObject(WinSta
);
891 SetLastWin32Error(ERROR_INVALID_PARAMETER
);
895 CurInfo
= IntGetSysCursorInfo(WinSta
);
896 IntGetCursorLocation(WinSta
, &MousePos
);
898 if(WinSta
->ActiveDesktop
)
899 DesktopWindow
= UserGetWindowObject(WinSta
->ActiveDesktop
->DesktopWindow
);
901 if((Rect
.right
> Rect
.left
) && (Rect
.bottom
> Rect
.top
)
902 && DesktopWindow
&& UnsafeRect
!= NULL
)
906 CurInfo
->CursorClipInfo
.IsClipped
= TRUE
;
907 CurInfo
->CursorClipInfo
.Left
= max(Rect
.left
, DesktopWindow
->Wnd
->WindowRect
.left
);
908 CurInfo
->CursorClipInfo
.Top
= max(Rect
.top
, DesktopWindow
->Wnd
->WindowRect
.top
);
909 CurInfo
->CursorClipInfo
.Right
= min(Rect
.right
- 1, DesktopWindow
->Wnd
->WindowRect
.right
- 1);
910 CurInfo
->CursorClipInfo
.Bottom
= min(Rect
.bottom
- 1, DesktopWindow
->Wnd
->WindowRect
.bottom
- 1);
915 mi
.dwFlags
= MOUSEEVENTF_ABSOLUTE
| MOUSEEVENTF_MOVE
;
923 CurInfo
->CursorClipInfo
.IsClipped
= FALSE
;
924 ObDereferenceObject(WinSta
);
929 DPRINT("Leave NtUserClipCursor, ret=%i\n",_ret_
);
944 PWINSTATION_OBJECT WinSta
;
945 PCURICON_OBJECT CurIcon
;
947 DECLARE_RETURN(BOOL
);
949 DPRINT("Enter NtUserDestroyCursorIcon\n");
950 UserEnterExclusive();
952 WinSta
= IntGetWinStaObj();
958 if (!(CurIcon
= UserGetCurIconObject(hCurIcon
)))
960 ObDereferenceObject(WinSta
);
964 ret
= IntDestroyCurIconObject(WinSta
, CurIcon
, FALSE
);
965 /* Note: IntDestroyCurIconObject will remove our reference for us! */
967 ObDereferenceObject(WinSta
);
971 DPRINT("Leave NtUserDestroyCursorIcon, ret=%i\n",_ret_
);
982 NtUserFindExistingCursorIcon(
988 PCURICON_OBJECT CurIcon
;
989 PWINSTATION_OBJECT WinSta
;
990 HANDLE Ret
= (HANDLE
)0;
991 DECLARE_RETURN(HICON
);
993 DPRINT("Enter NtUserFindExistingCursorIcon\n");
994 UserEnterExclusive();
996 WinSta
= IntGetWinStaObj();
1002 CurIcon
= IntFindExistingCurIconObject(WinSta
, hModule
, hRsrc
, cx
, cy
);
1005 Ret
= CurIcon
->Self
;
1007 // IntReleaseCurIconObject(CurIcon);//faxme: is this correct? does IntFindExistingCurIconObject add a ref?
1008 ObDereferenceObject(WinSta
);
1012 SetLastWin32Error(ERROR_INVALID_CURSOR_HANDLE
);
1013 ObDereferenceObject(WinSta
);
1017 DPRINT("Leave NtUserFindExistingCursorIcon, ret=%i\n",_ret_
);
1028 NtUserGetClipCursor(
1031 /* FIXME - check if process has WINSTA_READATTRIBUTES */
1032 PSYSTEM_CURSORINFO CurInfo
;
1033 PWINSTATION_OBJECT WinSta
;
1036 DECLARE_RETURN(BOOL
);
1038 DPRINT("Enter NtUserGetClipCursor\n");
1039 UserEnterExclusive();
1044 WinSta
= IntGetWinStaObj();
1050 CurInfo
= IntGetSysCursorInfo(WinSta
);
1051 if(CurInfo
->CursorClipInfo
.IsClipped
)
1053 Rect
.left
= CurInfo
->CursorClipInfo
.Left
;
1054 Rect
.top
= CurInfo
->CursorClipInfo
.Top
;
1055 Rect
.right
= CurInfo
->CursorClipInfo
.Right
;
1056 Rect
.bottom
= CurInfo
->CursorClipInfo
.Bottom
;
1062 Rect
.right
= UserGetSystemMetrics(SM_CXSCREEN
);
1063 Rect
.bottom
= UserGetSystemMetrics(SM_CYSCREEN
);
1066 Status
= MmCopyToCaller((PRECT
)lpRect
, &Rect
, sizeof(RECT
));
1067 if(!NT_SUCCESS(Status
))
1069 ObDereferenceObject(WinSta
);
1070 SetLastNtError(Status
);
1074 ObDereferenceObject(WinSta
);
1079 DPRINT("Leave NtUserGetClipCursor, ret=%i\n",_ret_
);
1093 PCURICON_OBJECT CurIcon
;
1095 PWINSTATION_OBJECT WinSta
;
1096 DECLARE_RETURN(HCURSOR
);
1098 DPRINT("Enter NtUserSetCursor\n");
1099 UserEnterExclusive();
1101 WinSta
= IntGetWinStaObj();
1109 if(!(CurIcon
= UserGetCurIconObject(hCursor
)))
1111 ObDereferenceObject(WinSta
);
1120 OldCursor
= IntSetCursor(WinSta
, CurIcon
, FALSE
);
1124 UserDereferenceObject(CurIcon
);
1126 ObDereferenceObject(WinSta
);
1131 DPRINT("Leave NtUserSetCursor, ret=%i\n",_ret_
);
1142 NtUserSetCursorContents(
1144 PICONINFO UnsafeIconInfo
)
1146 PCURICON_OBJECT CurIcon
;
1149 PWINSTATION_OBJECT WinSta
;
1152 DECLARE_RETURN(BOOL
);
1154 DPRINT("Enter NtUserSetCursorContents\n");
1155 UserEnterExclusive();
1157 WinSta
= IntGetWinStaObj();
1163 if (!(CurIcon
= UserGetCurIconObject(hCurIcon
)))
1165 ObDereferenceObject(WinSta
);
1170 Status
= MmCopyFromCaller(&IconInfo
, UnsafeIconInfo
, sizeof(ICONINFO
));
1171 if(!NT_SUCCESS(Status
))
1173 SetLastNtError(Status
);
1177 /* Delete old bitmaps */
1178 if (CurIcon
->IconInfo
.hbmColor
!= IconInfo
.hbmColor
)
1180 NtGdiDeleteObject(CurIcon
->IconInfo
.hbmColor
);
1182 if (CurIcon
->IconInfo
.hbmMask
!= IconInfo
.hbmMask
)
1184 NtGdiDeleteObject(CurIcon
->IconInfo
.hbmMask
);
1187 /* Copy new IconInfo field */
1188 CurIcon
->IconInfo
= IconInfo
;
1190 bmp
= BITMAPOBJ_LockBitmap(CurIcon
->IconInfo
.hbmColor
);
1193 CurIcon
->Size
.cx
= bmp
->SurfObj
.sizlBitmap
.cx
;
1194 CurIcon
->Size
.cy
= bmp
->SurfObj
.sizlBitmap
.cy
;
1195 BITMAPOBJ_UnlockBitmap(bmp
);
1196 GDIOBJ_SetOwnership(CurIcon
->IconInfo
.hbmColor
, NULL
);
1200 bmp
= BITMAPOBJ_LockBitmap(CurIcon
->IconInfo
.hbmMask
);
1204 CurIcon
->Size
.cx
= bmp
->SurfObj
.sizlBitmap
.cx
;
1205 CurIcon
->Size
.cy
= bmp
->SurfObj
.sizlBitmap
.cy
/ 2;
1207 BITMAPOBJ_UnlockBitmap(bmp
);
1208 GDIOBJ_SetOwnership(CurIcon
->IconInfo
.hbmMask
, NULL
);
1217 UserDereferenceObject(CurIcon
);
1219 ObDereferenceObject(WinSta
);
1223 DPRINT("Leave NtUserSetCursorContents, ret=%i\n",_ret_
);
1235 NtUserSetCursorIconData(
1238 PUNICODE_STRING pstrResName
,
1239 PICONINFO pIconInfo
)
1241 PCURICON_OBJECT CurIcon
;
1242 PWINSTATION_OBJECT WinSta
;
1244 NTSTATUS Status
= STATUS_SUCCESS
;
1246 DECLARE_RETURN(BOOL
);
1248 DPRINT("Enter NtUserSetCursorIconData\n");
1249 UserEnterExclusive();
1251 WinSta
= IntGetWinStaObj();
1257 if(!(CurIcon
= UserGetCurIconObject(Handle
)))
1259 ObDereferenceObject(WinSta
);
1263 CurIcon
->hModule
= hModule
;
1264 CurIcon
->hRsrc
= NULL
; //hRsrc;
1265 CurIcon
->hGroupRsrc
= NULL
; //hGroupRsrc;
1269 ProbeForRead(pIconInfo
, sizeof(ICONINFO
), 1);
1270 RtlCopyMemory(&CurIcon
->IconInfo
, pIconInfo
, sizeof(ICONINFO
));
1272 CurIcon
->IconInfo
.hbmMask
= BITMAPOBJ_CopyBitmap(pIconInfo
->hbmMask
);
1273 CurIcon
->IconInfo
.hbmColor
= BITMAPOBJ_CopyBitmap(pIconInfo
->hbmColor
);
1275 if (CurIcon
->IconInfo
.hbmColor
)
1277 if ((pBmpObj
= BITMAPOBJ_LockBitmap(CurIcon
->IconInfo
.hbmColor
)))
1279 CurIcon
->Size
.cx
= pBmpObj
->SurfObj
.sizlBitmap
.cx
;
1280 CurIcon
->Size
.cy
= pBmpObj
->SurfObj
.sizlBitmap
.cy
;
1281 BITMAPOBJ_UnlockBitmap(pBmpObj
);
1282 GDIOBJ_SetOwnership(GdiHandleTable
, CurIcon
->IconInfo
.hbmMask
, NULL
);
1285 if (CurIcon
->IconInfo
.hbmMask
)
1287 if (CurIcon
->IconInfo
.hbmColor
== NULL
)
1289 if ((pBmpObj
= BITMAPOBJ_LockBitmap(CurIcon
->IconInfo
.hbmMask
)))
1291 CurIcon
->Size
.cx
= pBmpObj
->SurfObj
.sizlBitmap
.cx
;
1292 CurIcon
->Size
.cy
= pBmpObj
->SurfObj
.sizlBitmap
.cy
;
1293 BITMAPOBJ_UnlockBitmap(pBmpObj
);
1296 GDIOBJ_SetOwnership(GdiHandleTable
, CurIcon
->IconInfo
.hbmMask
, NULL
);
1301 Status
= _SEH_GetExceptionCode();
1305 if(!NT_SUCCESS(Status
))
1306 SetLastNtError(Status
);
1310 UserDereferenceObject(CurIcon
);
1311 ObDereferenceObject(WinSta
);
1315 DPRINT("Leave NtUserSetCursorIconData, ret=%i\n",_ret_
);
1322 NtUserSetCursorIconData(
1330 PCURICON_OBJECT CurIcon
;
1331 PWINSTATION_OBJECT WinSta
;
1335 DECLARE_RETURN(BOOL
);
1337 DPRINT("Enter NtUserSetCursorIconData\n");
1338 UserEnterExclusive();
1340 WinSta
= IntGetWinStaObj();
1346 if(!(CurIcon
= UserGetCurIconObject(hCurIcon
)))
1348 ObDereferenceObject(WinSta
);
1352 CurIcon
->hModule
= hModule
;
1353 CurIcon
->hRsrc
= hRsrc
;
1354 CurIcon
->hGroupRsrc
= hGroupRsrc
;
1359 Status
= MmCopyFromCaller(&CurIcon
->IconInfo
.fIcon
, fIcon
, sizeof(BOOL
));
1360 if(!NT_SUCCESS(Status
))
1362 SetLastNtError(Status
);
1374 Status
= MmCopyFromCaller(&SafeHotspot
, Hotspot
, sizeof(POINT
));
1375 if(NT_SUCCESS(Status
))
1377 CurIcon
->IconInfo
.xHotspot
= SafeHotspot
.x
;
1378 CurIcon
->IconInfo
.yHotspot
= SafeHotspot
.y
;
1383 SetLastNtError(Status
);
1386 if(!fIcon
&& !Hotspot
)
1392 UserDereferenceObject(CurIcon
);
1393 ObDereferenceObject(WinSta
);
1398 DPRINT("Leave NtUserSetCursorIconData, ret=%i\n",_ret_
);
1409 NtUserSetSystemCursor(
1417 #define STRETCH_CAN_SRCCOPY_ONLY
1419 #ifdef STRETCH_CAN_SRCCOPY_ONLY
1422 DoStretchBlt(HDC DcDest
, int XDest
, int YDest
, int WidthDest
, int HeightDest
,
1423 HDC DcSrc
, int XSrc
, int YSrc
, int WidthSrc
, int HeightSrc
,
1424 DWORD Rop3
, BOOL Color
)
1427 HBITMAP BitmapStretched
;
1430 if (WidthDest
== WidthSrc
&& HeightDest
== HeightSrc
)
1432 NtGdiBitBlt(DcDest
, XDest
, YDest
, WidthDest
, HeightDest
,
1433 DcSrc
, XSrc
, YSrc
, Rop3
, 0, 0);
1435 else if (SRCCOPY
== Rop3
)
1437 NtGdiStretchBlt(DcDest
, XDest
, YDest
, WidthDest
, HeightDest
,
1438 DcSrc
, XSrc
, YSrc
, WidthSrc
, HeightSrc
,
1443 DcStretched
= NtGdiCreateCompatibleDC(DcSrc
);
1444 if (NULL
== DcStretched
)
1446 DPRINT1("Failed to create compatible DC\n");
1451 BitmapStretched
= NtGdiCreateCompatibleBitmap(DcDest
, WidthDest
,
1456 BitmapStretched
= IntGdiCreateBitmap(WidthDest
, HeightDest
, 1, 1, NULL
);
1458 if (NULL
== BitmapStretched
)
1460 NtGdiDeleteObjectApp(DcStretched
);
1461 DPRINT1("Failed to create temporary bitmap\n");
1464 OldBitmap
= NtGdiSelectBitmap(DcStretched
, BitmapStretched
);
1465 if (NULL
== OldBitmap
)
1467 NtGdiDeleteObject(BitmapStretched
);
1468 NtGdiDeleteObjectApp(DcStretched
);
1469 DPRINT1("Failed to create temporary bitmap\n");
1472 if (! NtGdiStretchBlt(DcStretched
, 0, 0, WidthDest
, HeightDest
,
1473 DcSrc
, XSrc
, YSrc
, WidthSrc
, HeightSrc
,
1475 ! NtGdiBitBlt(DcDest
, XDest
, YDest
, WidthDest
, HeightDest
,
1476 DcStretched
, 0, 0, Rop3
, 0, 0))
1478 DPRINT1("Failed to blt\n");
1480 NtGdiSelectBitmap(DcStretched
, OldBitmap
);
1481 NtGdiDeleteObject(BitmapStretched
);
1482 NtGdiDeleteObjectApp(DcStretched
);
1486 #define DoStretchBlt(DcDest, XDest, YDest, WidthDest, HeightDest, \
1487 DcSrc, XSrc, YSrc, WidthSrc, HeightSrc, Rop3, Color) \
1488 NtGdiStretchBlt((DcDest), (XDest), (YDest), (WidthDest), (HeightDest), \
1489 (DcSrc), (XSrc), (YSrc), (WidthSrc), (HeightSrc), \
1491 #endif /* STRETCH_CAN_SRCCOPY_ONLY */
1498 PCURICON_OBJECT pIcon
,
1502 HBRUSH hbrFlickerFreeDraw
,
1506 HBITMAP hbmMask
, hbmColor
;
1507 BITMAP bmpMask
, bmpColor
;
1508 COLORREF oldFg
, oldBg
;
1514 HGDIOBJ hOldOffBrush
= 0;
1515 HGDIOBJ hOldOffBmp
= 0;
1519 BOOL bAlpha
= FALSE
;
1521 hbmMask
= pIcon
->IconInfo
.hbmMask
;
1522 hbmColor
= pIcon
->IconInfo
.hbmColor
;
1525 DPRINT1("NtUserDrawIconEx: istepIfAniCur is not supported!\n");
1527 if (!hbmMask
|| !IntGdiGetObject(hbmMask
, sizeof(BITMAP
), (PVOID
)&bmpMask
))
1532 if (hbmColor
&& !IntGdiGetObject(hbmColor
, sizeof(BITMAP
), (PVOID
)&bmpColor
))
1539 IconSize
.cx
= bmpColor
.bmWidth
;
1540 IconSize
.cy
= bmpColor
.bmHeight
;
1544 IconSize
.cx
= bmpMask
.bmWidth
;
1545 IconSize
.cy
= bmpMask
.bmHeight
/ 2;
1548 /* NtGdiCreateCompatibleBitmap will create a monochrome bitmap
1549 when cxWidth or cyHeight is 0 */
1550 if ((bmpColor
.bmBitsPixel
== 32) && (cxWidth
!= 0) && (cyHeight
!= 0))
1556 diFlags
= DI_NORMAL
;
1559 cxWidth
= ((diFlags
& DI_DEFAULTSIZE
) ?
1560 UserGetSystemMetrics(SM_CXICON
) : IconSize
.cx
);
1563 cyHeight
= ((diFlags
& DI_DEFAULTSIZE
) ?
1564 UserGetSystemMetrics(SM_CYICON
) : IconSize
.cy
);
1566 DoFlickerFree
= (hbrFlickerFreeDraw
&&
1567 (GDI_HANDLE_GET_TYPE(hbrFlickerFreeDraw
) == GDI_OBJECT_TYPE_BRUSH
));
1569 if (DoFlickerFree
|| bAlpha
)
1573 BITMAPOBJ
*BitmapObj
= NULL
;
1576 r
.bottom
= cyHeight
;
1578 hdcOff
= NtGdiCreateCompatibleDC(hDc
);
1581 DPRINT1("NtGdiCreateCompatibleDC() failed!\n");
1585 hbmOff
= NtGdiCreateCompatibleBitmap(hDc
, cxWidth
, cyHeight
);
1588 DPRINT1("NtGdiCreateCompatibleBitmap() failed!\n");
1592 /* make sure we have a 32 bit offscreen bitmap
1593 otherwise we can't do alpha blending */
1594 BitmapObj
= BITMAPOBJ_LockBitmap(hbmOff
);
1595 if (BitmapObj
== NULL
)
1597 DPRINT1("GDIOBJ_LockObj() failed!\n");
1600 BITMAP_GetObject(BitmapObj
, sizeof(BITMAP
), (PVOID
)&bm
);
1602 if (bm
.bmBitsPixel
!= 32)
1605 BITMAPOBJ_UnlockBitmap(BitmapObj
);
1607 hOldOffBmp
= NtGdiSelectBitmap(hdcOff
, hbmOff
);
1610 DPRINT1("NtGdiSelectBitmap() failed!\n");
1616 hOldOffBrush
= NtGdiSelectBrush(hdcOff
, hbrFlickerFreeDraw
);
1619 DPRINT1("NtGdiSelectBitmap() failed!\n");
1623 NtGdiPatBlt(hdcOff
, 0, 0, r
.right
, r
.bottom
, PATCOPY
);
1629 hdcMem
= NtGdiCreateCompatibleDC(hDc
);
1632 DPRINT1("NtGdiCreateCompatibleDC() failed!\n");
1636 nStretchMode
= IntGdiSetStretchBltMode(hdcOff
, STRETCH_DELETESCANS
);
1638 oldFg
= IntGdiSetTextColor(hdcOff
, RGB(0, 0, 0));
1639 oldBg
= IntGdiSetBkColor(hdcOff
, RGB(255, 255, 255));
1641 if (diFlags
& DI_MASK
)
1643 hOldMem
= NtGdiSelectBitmap(hdcMem
, hbmMask
);
1646 DPRINT("NtGdiSelectBitmap() failed!\n");
1650 DoStretchBlt(hdcOff
, (DoFlickerFree
? 0 : xLeft
),
1651 (DoFlickerFree
? 0 : yTop
), cxWidth
, cyHeight
, hdcMem
,
1652 0, 0, IconSize
.cx
, IconSize
.cy
,
1653 ((diFlags
& DI_IMAGE
) ? SRCAND
: SRCCOPY
), FALSE
);
1655 if (!hbmColor
&& (bmpMask
.bmHeight
== 2 * bmpMask
.bmWidth
)
1656 && (diFlags
& DI_IMAGE
))
1658 DoStretchBlt(hdcOff
, (DoFlickerFree
? 0 : xLeft
),
1659 (DoFlickerFree
? 0 : yTop
), cxWidth
, cyHeight
, hdcMem
,
1660 0, IconSize
.cy
, IconSize
.cx
, IconSize
.cy
, SRCINVERT
,
1663 diFlags
&= ~DI_IMAGE
;
1666 NtGdiSelectBitmap(hdcMem
, hOldMem
);
1669 if(diFlags
& DI_IMAGE
)
1671 hOldMem
= NtGdiSelectBitmap(hdcMem
, (hbmColor
? hbmColor
: hbmMask
));
1673 DoStretchBlt(hdcOff
, (DoFlickerFree
? 0 : xLeft
),
1674 (DoFlickerFree
? 0 : yTop
), cxWidth
, cyHeight
, hdcMem
,
1675 0, (hbmColor
? 0 : IconSize
.cy
), IconSize
.cx
, IconSize
.cy
,
1676 ((diFlags
& DI_MASK
) ? SRCINVERT
: SRCCOPY
),
1679 NtGdiSelectBitmap(hdcMem
, hOldMem
);
1685 BITMAPOBJ
*BitmapObj
= NULL
;
1687 BLENDFUNCTION BlendFunc
;
1689 BYTE Red
, Green
, Blue
, Alpha
;
1693 BitmapObj
= BITMAPOBJ_LockBitmap(hbmOff
);
1694 if (BitmapObj
== NULL
)
1696 DPRINT1("GDIOBJ_LockObj() failed!\n");
1699 BITMAP_GetObject(BitmapObj
, sizeof(BITMAP
), (PVOID
)&bm
);
1701 pBits
= ExAllocatePoolWithTag(PagedPool
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), TAG_BITMAP
);
1704 DPRINT1("ExAllocatePoolWithTag() failed!\n");
1705 BITMAPOBJ_UnlockBitmap(BitmapObj
);
1710 IntGetBitmapBits(BitmapObj
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), pBits
);
1712 /* premultiply with the alpha channel value */
1713 for (i
= 0; i
< cyHeight
; i
++)
1715 for (j
= 0; j
< cxWidth
; j
++)
1717 Pixel
= *(DWORD
*)(pBits
+ Count
);
1719 Alpha
= ((BYTE
)(Pixel
>> 24) & 0xff);
1721 Red
= (((BYTE
)(Pixel
>> 0)) * Alpha
) / 0xff;
1722 Green
= (((BYTE
)(Pixel
>> 8)) * Alpha
) / 0xff;
1723 Blue
= (((BYTE
)(Pixel
>> 16)) * Alpha
) / 0xff;
1725 *(DWORD
*)(pBits
+ Count
) = (DWORD
)(Red
| (Green
<< 8) | (Blue
<< 16) | (Alpha
<< 24));
1727 Count
+= sizeof (DWORD
);
1732 IntSetBitmapBits(BitmapObj
, bm
.bmWidthBytes
* abs(bm
.bmHeight
), pBits
);
1733 ExFreePoolWithTag(pBits
, TAG_BITMAP
);
1735 BITMAPOBJ_UnlockBitmap(BitmapObj
);
1737 BlendFunc
.BlendOp
= AC_SRC_OVER
;
1738 BlendFunc
.BlendFlags
= 0;
1739 BlendFunc
.SourceConstantAlpha
= 255;
1740 BlendFunc
.AlphaFormat
= AC_SRC_ALPHA
;
1742 NtGdiAlphaBlend(hDc
, xLeft
, yTop
, cxWidth
, cyHeight
,
1743 hdcOff
, 0, 0, cxWidth
, cyHeight
, BlendFunc
, 0);
1745 else if (DoFlickerFree
)
1747 NtGdiBitBlt(hDc
, xLeft
, yTop
, cxWidth
,
1748 cyHeight
, hdcOff
, 0, 0, SRCCOPY
, 0, 0);
1751 IntGdiSetTextColor(hdcOff
, oldFg
);
1752 IntGdiSetBkColor(hdcOff
, oldBg
);
1753 IntGdiSetStretchBltMode(hdcOff
, nStretchMode
);
1758 if(DoFlickerFree
|| bAlpha
)
1760 if(hOldOffBmp
) NtGdiSelectBitmap(hdcOff
, hOldOffBmp
);
1761 if(hOldOffBrush
) NtGdiSelectBrush(hdcOff
, hOldOffBrush
);
1762 if(hbmOff
) NtGdiDeleteObject(hbmOff
);
1763 if(hdcOff
) NtGdiDeleteObjectApp(hdcOff
);
1766 if(hdcMem
) NtGdiDeleteObjectApp(hdcMem
);
1783 HBRUSH hbrFlickerFreeDraw
,
1788 PCURICON_OBJECT pIcon
;
1791 DPRINT("Enter NtUserDrawIconEx\n");
1792 UserEnterExclusive();
1794 if(!(pIcon
= UserGetCurIconObject(hIcon
)))
1796 DPRINT1("UserGetCurIconObject() failed!\n");
1801 Ret
= UserDrawIconEx(hdc
,
1811 UserDereferenceObject(pIcon
);
1817 /* Called from NtUserCallOneParam with Routine ONEPARAM_ROUTINE_SHOWCURSOR
1818 * User32 macro NtUserShowCursor */
1821 UserShowCursor(BOOL bShow
)
1823 PTHREADINFO pti
= PsGetCurrentThreadWin32Thread();
1824 PWINSTATION_OBJECT WinSta
= pti
->Desktop
->WindowStation
;
1825 PSYSTEM_CURSORINFO CurInfo
;
1831 BITMAPOBJ
*BitmapObj
;
1836 if(!(Screen
= IntGetScreenDC()))
1838 return showpointer
; /* No mouse */
1841 dc
= DC_LockDc(Screen
);
1845 return showpointer
; /* No mouse */
1848 dcbmp
= dc
->w
.hBitmap
;
1851 BitmapObj
= BITMAPOBJ_LockBitmap(dcbmp
);
1854 return showpointer
; /* No Mouse */
1857 SurfObj
= &BitmapObj
->SurfObj
;
1858 if (SurfObj
== NULL
)
1860 BITMAPOBJ_UnlockBitmap(BitmapObj
);
1861 return showpointer
; /* No mouse */
1864 ppdev
= GDIDEV(SurfObj
);
1868 BITMAPOBJ_UnlockBitmap(BitmapObj
);
1869 return showpointer
; /* No mouse */
1872 pgp
= &ppdev
->Pointer
;
1874 CurInfo
= IntGetSysCursorInfo(WinSta
);
1879 showpointer
= pgp
->ShowPointer
;
1881 if (showpointer
>= 0)
1883 //ppdev->SafetyRemoveCount = 1;
1884 //ppdev->SafetyRemoveLevel = 1;
1885 EngMovePointer(SurfObj
,-1,-1,NULL
);
1886 CurInfo
->ShowingCursor
= 0;
1893 showpointer
= pgp
->ShowPointer
;
1896 if (showpointer
< 0)
1898 //ppdev->SafetyRemoveCount = 0;
1899 //ppdev->SafetyRemoveLevel = 0;
1900 EngMovePointer(SurfObj
,-1,-1,NULL
);
1901 CurInfo
->ShowingCursor
= CURSOR_SHOWING
;
1905 BITMAPOBJ_UnlockBitmap(BitmapObj
);