1 #undef WIN32_LEAN_AND_MEAN
3 #include <ddk/ntddmou.h>
4 #include <win32k/win32k.h>
7 #include <win32k/cursoricon.h>
8 #include <win32k/bitmaps.h>
9 #include <include/winsta.h>
10 #include <include/error.h>
11 #include <include/mouse.h>
12 #include <include/window.h>
13 #include <internal/safe.h>
16 #include <win32k/debug1.h>
18 BOOL FASTCALL IconCursor_InternalDelete( PICONCURSOROBJ pIconCursor )
20 ASSERT( pIconCursor );
21 if( pIconCursor->ANDBitmap.bmBits )
22 ExFreePool(pIconCursor->ANDBitmap.bmBits);
23 if( pIconCursor->XORBitmap.bmBits )
24 ExFreePool(pIconCursor->XORBitmap.bmBits);
34 NtGdiCreateIcon(BOOL fIcon,
47 Planes = (BYTE) Planes;
48 BitsPerPel = (BYTE) BitsPerPel;
50 /* Check parameters */
51 if (!Height || !Width)
61 /* Create the ICONCURSOROBJ object*/
62 hIcon = ICONCURSOROBJ_AllocIconCursor ();
65 DPRINT("NtGdiCreateIcon: ICONCURSOROBJ_AllocIconCursor(hIcon == 0x%x) returned 0\n", hIcon);
69 icon = ICONCURSOROBJ_LockIconCursor(hIcon);
71 /* Set up the basic icon stuff */
73 icon->xHotspot = xHotspot;
74 icon->yHotspot = yHotspot;
76 /* Setup the icon mask and icon color bitmaps */
77 icon->ANDBitmap.bmType = 0;
78 icon->ANDBitmap.bmWidth = Width;
79 icon->ANDBitmap.bmHeight = Height;
80 icon->ANDBitmap.bmPlanes = 1;
81 icon->ANDBitmap.bmBitsPixel = 1;
82 icon->ANDBitmap.bmWidthBytes = BITMAPOBJ_GetWidthBytes (Width, 1);
83 icon->ANDBitmap.bmBits = NULL;
85 icon->XORBitmap.bmType = 0;
86 icon->XORBitmap.bmWidth = Width;
87 icon->XORBitmap.bmHeight = Height;
88 icon->XORBitmap.bmPlanes = Planes;
89 icon->XORBitmap.bmBitsPixel = BitsPerPel;
90 icon->XORBitmap.bmWidthBytes = BITMAPOBJ_GetWidthBytes (Width, BitsPerPel);
91 icon->XORBitmap.bmBits = NULL;
93 /* allocate memory for the icon mask and icon color bitmaps,
94 this will be freed in IconCursor_InternalDelete */
95 icon->ANDBitmap.bmBits = ExAllocatePool(PagedPool, Height * icon->ANDBitmap.bmWidthBytes);
96 icon->XORBitmap.bmBits = ExAllocatePool(PagedPool, Height * icon->XORBitmap.bmWidthBytes);
98 /* set the bits of the mask and color bitmaps */
101 memcpy(icon->ANDBitmap.bmBits, (PVOID)ANDBits, Height * icon->ANDBitmap.bmWidthBytes);
106 memcpy(icon->XORBitmap.bmBits, (PVOID)XORBits, Height * icon->XORBitmap.bmWidthBytes);
109 ICONCURSOROBJ_UnlockIconCursor( hIcon );
130 icon = ICONCURSOROBJ_LockIconCursor(hIcon);
134 DPRINT1("NtUserGetIconInfo: ICONCURSOROBJ_LockIconCursor(hIcon == 0x%x) returned 0\n", hIcon);
138 *fIcon = icon->fIcon ;
139 *xHotspot = icon->xHotspot;
140 *yHotspot = icon->yHotspot;
142 *hbmMask = NtGdiCreateBitmap(icon->ANDBitmap.bmWidth,
143 icon->ANDBitmap.bmHeight,
144 icon->ANDBitmap.bmPlanes,
145 icon->ANDBitmap.bmBitsPixel,
146 icon->ANDBitmap.bmBits);
148 *hbmColor = NtGdiCreateBitmap(icon->XORBitmap.bmWidth,
149 icon->XORBitmap.bmHeight,
150 icon->XORBitmap.bmPlanes,
151 icon->XORBitmap.bmBitsPixel,
152 icon->XORBitmap.bmBits);
154 ICONCURSOROBJ_UnlockIconCursor(hIcon);
156 if (!*hbmMask || !*hbmColor)
176 if (!hIcon || !Width || !Width)
179 icon = ICONCURSOROBJ_LockIconCursor(hIcon);
183 DPRINT1("NtUserGetIconInfo: ICONCURSOROBJ_LockIconCursor() returned 0\n");
187 if(fIcon) *fIcon = icon->fIcon;
188 *Width = icon->ANDBitmap.bmWidth;
189 *Width = icon->ANDBitmap.bmHeight;
191 ICONCURSOROBJ_UnlockIconCursor(hIcon);
202 NtUserGetCursorFrameInfo(
236 /* FIXME - check if process has WINSTA_WRITEATTRIBUTES */
238 PWINSTATION_OBJECT WinStaObject;
239 PSYSTEM_CURSORINFO CurInfo;
240 PWINDOW_OBJECT DesktopWindow;
243 NTSTATUS Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
247 if (!NT_SUCCESS(Status))
249 DPRINT1("Validation of window station handle (0x%X) failed\n",
250 PROCESS_WINDOW_STATION());
251 SetLastWin32Error(Status);
255 if (NULL != UnsafeRect && ! NT_SUCCESS(MmCopyFromCaller(&Rect, UnsafeRect, sizeof(RECT))))
257 ObDereferenceObject(WinStaObject);
258 SetLastWin32Error(ERROR_INVALID_PARAMETER);
262 CurInfo = &WinStaObject->SystemCursor;
265 if((Rect.right >= Rect.left) &&
266 (Rect.bottom >= Rect.top))
268 DesktopWindow = IntGetWindowObject(WinStaObject->ActiveDesktop->DesktopWindow);
269 CurInfo->CursorClipInfo.IsClipped = TRUE;
270 CurInfo->CursorClipInfo.Left = max(Rect.left, DesktopWindow->WindowRect.left);
271 CurInfo->CursorClipInfo.Top = max(Rect.top, DesktopWindow->WindowRect.top);
272 CurInfo->CursorClipInfo.Right = min(Rect.right, DesktopWindow->WindowRect.right);
273 CurInfo->CursorClipInfo.Bottom = min(Rect.bottom, DesktopWindow->WindowRect.bottom);
274 IntReleaseWindowObject(DesktopWindow);
276 MouseMoveCursor(CurInfo->x, CurInfo->y);
280 WinStaObject->SystemCursor.CursorClipInfo.IsClipped = FALSE;
282 ObDereferenceObject(WinStaObject);
308 NtUserFindExistingCursorIcon(
327 /* FIXME - check if process has WINSTA_READATTRIBUTES */
329 PWINSTATION_OBJECT WinStaObject;
334 NTSTATUS Status = ValidateWindowStationHandle(PROCESS_WINDOW_STATION(),
338 if (!NT_SUCCESS(Status))
340 DPRINT("Validation of window station handle (0x%X) failed\n",
341 PROCESS_WINDOW_STATION());
342 SetLastWin32Error(Status);
346 if(WinStaObject->SystemCursor.CursorClipInfo.IsClipped)
348 lpRect->left = WinStaObject->SystemCursor.CursorClipInfo.Left;
349 lpRect->top = WinStaObject->SystemCursor.CursorClipInfo.Top;
350 lpRect->right = WinStaObject->SystemCursor.CursorClipInfo.Right;
351 lpRect->bottom = WinStaObject->SystemCursor.CursorClipInfo.Bottom;
357 lpRect->right = NtUserGetSystemMetrics(SM_CXSCREEN);
358 lpRect->bottom = NtUserGetSystemMetrics(SM_CYSCREEN);
361 ObDereferenceObject(WinStaObject);
386 NtUserSetCursorContents(
401 NtUserSetCursorIconData(
418 NtUserSetSystemCursor(