2012-10-29 15:50:20 +00:00
|
|
|
/*
|
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Win32k subsystem
|
|
|
|
* PURPOSE: Cursor and icon functions
|
2014-08-08 16:14:38 +00:00
|
|
|
* FILE: win32ss/user/ntuser/cursoricon.c
|
2012-10-29 15:50:20 +00:00
|
|
|
* PROGRAMER: ReactOS Team
|
|
|
|
*/
|
|
|
|
/*
|
|
|
|
* We handle two types of cursors/icons:
|
|
|
|
* - Private
|
|
|
|
* Loaded without LR_SHARED flag
|
|
|
|
* Private to a process
|
|
|
|
* Can be deleted by calling NtDestroyCursorIcon()
|
|
|
|
* CurIcon->hModule, CurIcon->hRsrc and CurIcon->hGroupRsrc set to NULL
|
|
|
|
* - Shared
|
|
|
|
* Loaded with LR_SHARED flag
|
|
|
|
* Possibly shared by multiple processes
|
|
|
|
* Immune to NtDestroyCursorIcon()
|
|
|
|
* CurIcon->hModule, CurIcon->hRsrc and CurIcon->hGroupRsrc are valid
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <win32k.h>
|
|
|
|
DBG_DEFAULT_CHANNEL(UserIcon);
|
|
|
|
|
|
|
|
SYSTEM_CURSORINFO gSysCursorInfo;
|
|
|
|
|
|
|
|
BOOL
|
2013-11-15 17:34:13 +00:00
|
|
|
InitCursorImpl(VOID)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2012-11-08 12:51:24 +00:00
|
|
|
gSysCursorInfo.Enabled = FALSE;
|
|
|
|
gSysCursorInfo.ButtonsDown = 0;
|
|
|
|
gSysCursorInfo.bClipped = FALSE;
|
|
|
|
gSysCursorInfo.LastBtnDown = 0;
|
|
|
|
gSysCursorInfo.CurrentCursorObject = NULL;
|
|
|
|
gSysCursorInfo.ShowingCursor = -1;
|
|
|
|
gSysCursorInfo.ClickLockActive = FALSE;
|
|
|
|
gSysCursorInfo.ClickLockTime = 0;
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
PSYSTEM_CURSORINFO
|
|
|
|
IntGetSysCursorInfo()
|
|
|
|
{
|
|
|
|
return &gSysCursorInfo;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:51:24 +00:00
|
|
|
FORCEINLINE
|
|
|
|
BOOL
|
|
|
|
is_icon(PCURICON_OBJECT object)
|
|
|
|
{
|
|
|
|
return MAKEINTRESOURCE(object->rt) == RT_ICON;
|
|
|
|
}
|
|
|
|
|
2012-10-29 15:50:20 +00:00
|
|
|
/* This function creates a reference for the object! */
|
|
|
|
PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon)
|
|
|
|
{
|
|
|
|
PCURICON_OBJECT CurIcon;
|
|
|
|
|
|
|
|
if (!hCurIcon)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_CURSOR_HANDLE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2014-10-23 09:32:39 +00:00
|
|
|
if (UserObjectInDestroy(hCurIcon))
|
2013-11-13 20:06:01 +00:00
|
|
|
{
|
2014-10-23 09:32:39 +00:00
|
|
|
WARN("Requesting invalid/destroyed cursor.\n");
|
2013-11-13 20:06:01 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_CURSOR_HANDLE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2012-12-29 19:14:30 +00:00
|
|
|
CurIcon = (PCURICON_OBJECT)UserReferenceObjectByHandle(hCurIcon, TYPE_CURSOR);
|
2012-10-29 15:50:20 +00:00
|
|
|
if (!CurIcon)
|
|
|
|
{
|
|
|
|
/* We never set ERROR_INVALID_ICON_HANDLE. lets hope noone ever checks for it */
|
|
|
|
EngSetLastError(ERROR_INVALID_CURSOR_HANDLE);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ASSERT(CurIcon->head.cLockObj >= 1);
|
|
|
|
return CurIcon;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL UserSetCursorPos( INT x, INT y, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook)
|
|
|
|
{
|
|
|
|
PWND DesktopWindow;
|
|
|
|
PSYSTEM_CURSORINFO CurInfo;
|
|
|
|
MSG Msg;
|
|
|
|
RECTL rcClip;
|
|
|
|
POINT pt;
|
|
|
|
|
|
|
|
if(!(DesktopWindow = UserGetDesktopWindow()))
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CurInfo = IntGetSysCursorInfo();
|
|
|
|
|
|
|
|
/* Clip cursor position */
|
|
|
|
if (!CurInfo->bClipped)
|
|
|
|
rcClip = DesktopWindow->rcClient;
|
|
|
|
else
|
|
|
|
rcClip = CurInfo->rcClip;
|
|
|
|
|
|
|
|
if(x >= rcClip.right) x = rcClip.right - 1;
|
|
|
|
if(x < rcClip.left) x = rcClip.left;
|
|
|
|
if(y >= rcClip.bottom) y = rcClip.bottom - 1;
|
|
|
|
if(y < rcClip.top) y = rcClip.top;
|
|
|
|
|
|
|
|
pt.x = x;
|
|
|
|
pt.y = y;
|
|
|
|
|
|
|
|
/* 1. Generate a mouse move message, this sets the htEx and Track Window too. */
|
|
|
|
Msg.message = WM_MOUSEMOVE;
|
|
|
|
Msg.wParam = UserGetMouseButtonsState();
|
|
|
|
Msg.lParam = MAKELPARAM(x, y);
|
|
|
|
Msg.pt = pt;
|
|
|
|
co_MsqInsertMouseMessage(&Msg, flags, dwExtraInfo, Hook);
|
|
|
|
|
|
|
|
/* 2. Store the new cursor position */
|
|
|
|
gpsi->ptCursor = pt;
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
HANDLE
|
|
|
|
IntCreateCurIconHandle(BOOLEAN Animated)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
|
|
|
PCURICON_OBJECT CurIcon;
|
|
|
|
HANDLE hCurIcon;
|
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
CurIcon = UserCreateObject(
|
|
|
|
gHandleTable,
|
|
|
|
NULL,
|
2014-10-21 18:59:44 +00:00
|
|
|
GetW32ThreadInfo(),
|
2013-11-13 20:06:01 +00:00
|
|
|
&hCurIcon,
|
|
|
|
TYPE_CURSOR,
|
|
|
|
Animated ? sizeof(ACON) : sizeof(CURICON_OBJECT));
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
if (!CurIcon)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
UserDereferenceObject(CurIcon);
|
2012-10-29 15:50:20 +00:00
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
return hCurIcon;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 18:59:44 +00:00
|
|
|
BOOLEAN
|
2014-10-21 19:57:03 +00:00
|
|
|
IntDestroyCurIconObject(
|
|
|
|
_In_ PVOID Object)
|
|
|
|
{
|
|
|
|
PCURICON_OBJECT CurIcon = Object;
|
|
|
|
|
2014-10-23 09:32:39 +00:00
|
|
|
/* Try finding it in its process cache */
|
|
|
|
if (CurIcon->CURSORF_flags & CURSORF_LRSHARED)
|
|
|
|
{
|
|
|
|
PPROCESSINFO ppi;
|
|
|
|
|
|
|
|
ppi = CurIcon->head.ppi;
|
|
|
|
if (ppi->pCursorCache == CurIcon)
|
|
|
|
{
|
|
|
|
ppi->pCursorCache = CurIcon->pcurNext;
|
|
|
|
UserDereferenceObject(CurIcon);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PCURICON_OBJECT CacheCurIcon = ppi->pCursorCache;
|
|
|
|
while (CacheCurIcon)
|
|
|
|
{
|
|
|
|
if (CacheCurIcon->pcurNext == CurIcon)
|
|
|
|
{
|
|
|
|
CacheCurIcon->pcurNext = CurIcon->pcurNext;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
CacheCurIcon = CacheCurIcon->pcurNext;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* We must have found it! */
|
|
|
|
ASSERT(CacheCurIcon != NULL);
|
|
|
|
UserDereferenceObject(CurIcon);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-10-21 19:57:03 +00:00
|
|
|
/* We just mark the handle as being destroyed.
|
|
|
|
* Deleting all the stuff will be deferred to the actual struct free. */
|
2014-10-23 19:41:42 +00:00
|
|
|
UserDeleteObject(CurIcon->head.h, TYPE_CURSOR);
|
|
|
|
return TRUE;
|
2014-10-21 19:57:03 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
FreeCurIconObject(
|
|
|
|
_In_ PVOID Object)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2014-10-21 18:59:44 +00:00
|
|
|
PCURICON_OBJECT CurIcon = Object;
|
2012-11-04 12:56:44 +00:00
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
if(!(CurIcon->CURSORF_flags & CURSORF_ACON))
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2013-11-13 20:06:01 +00:00
|
|
|
HBITMAP bmpMask = CurIcon->hbmMask;
|
|
|
|
HBITMAP bmpColor = CurIcon->hbmColor;
|
|
|
|
HBITMAP bmpAlpha = CurIcon->hbmAlpha;
|
|
|
|
|
|
|
|
/* Delete bitmaps */
|
|
|
|
if (bmpMask)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2013-11-13 20:06:01 +00:00
|
|
|
GreSetObjectOwner(bmpMask, GDI_OBJ_HMGR_POWNED);
|
|
|
|
GreDeleteObject(bmpMask);
|
|
|
|
CurIcon->hbmMask = NULL;
|
|
|
|
}
|
|
|
|
if (bmpColor)
|
|
|
|
{
|
|
|
|
GreSetObjectOwner(bmpColor, GDI_OBJ_HMGR_POWNED);
|
|
|
|
GreDeleteObject(bmpColor);
|
|
|
|
CurIcon->hbmColor = NULL;
|
|
|
|
}
|
|
|
|
if (bmpAlpha)
|
|
|
|
{
|
|
|
|
GreSetObjectOwner(bmpAlpha, GDI_OBJ_HMGR_POWNED);
|
|
|
|
GreDeleteObject(bmpAlpha);
|
|
|
|
CurIcon->hbmAlpha = NULL;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
}
|
2013-11-13 20:06:01 +00:00
|
|
|
else
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2013-11-13 20:06:01 +00:00
|
|
|
PACON AniCurIcon = (PACON)CurIcon;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
for(i = 0; i < AniCurIcon->cpcur; i++)
|
2014-10-25 19:46:12 +00:00
|
|
|
{
|
|
|
|
UserDereferenceObject(AniCurIcon->aspcur[i]);
|
2014-10-21 18:59:44 +00:00
|
|
|
IntDestroyCurIconObject(AniCurIcon->aspcur[i]);
|
2014-10-25 19:46:12 +00:00
|
|
|
}
|
2013-11-13 20:06:01 +00:00
|
|
|
ExFreePoolWithTag(AniCurIcon->aspcur, USERTAG_CURSOR);
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
2013-11-13 20:06:01 +00:00
|
|
|
|
|
|
|
if (CurIcon->CURSORF_flags & CURSORF_LRSHARED)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2013-11-13 20:06:01 +00:00
|
|
|
if (!IS_INTRESOURCE(CurIcon->strName.Buffer))
|
|
|
|
ExFreePoolWithTag(CurIcon->strName.Buffer, TAG_STRING);
|
|
|
|
if (CurIcon->atomModName)
|
|
|
|
RtlDeleteAtomFromAtomTable(gAtomTable, CurIcon->atomModName);
|
|
|
|
CurIcon->strName.Buffer = NULL;
|
|
|
|
CurIcon->atomModName = 0;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
2014-10-21 19:57:03 +00:00
|
|
|
/* Finally free the thing */
|
|
|
|
FreeProcMarkObject(CurIcon);
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
VOID FASTCALL
|
2014-10-21 18:59:44 +00:00
|
|
|
IntCleanupCurIconCache(PPROCESSINFO Win32Process)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2013-11-13 20:06:01 +00:00
|
|
|
PCURICON_OBJECT CurIcon;
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
/* Run through the list of icon objects */
|
2014-10-21 18:59:44 +00:00
|
|
|
while (Win32Process->pCursorCache)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2013-11-13 20:06:01 +00:00
|
|
|
CurIcon = Win32Process->pCursorCache;
|
|
|
|
Win32Process->pCursorCache = CurIcon->pcurNext;
|
2014-10-21 18:59:44 +00:00
|
|
|
UserDereferenceObject(CurIcon);
|
2014-04-13 23:53:34 +00:00
|
|
|
}
|
|
|
|
}
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserGetIconInfo(
|
2012-11-04 12:56:44 +00:00
|
|
|
_In_ HANDLE hCurIcon,
|
|
|
|
_Out_opt_ PICONINFO IconInfo,
|
|
|
|
_Out_opt_ PUNICODE_STRING lpModule, // Optional
|
|
|
|
_Out_opt_ PUNICODE_STRING lpResName, // Optional
|
|
|
|
_Out_opt_ LPDWORD pbpp, // Optional
|
|
|
|
_In_ BOOL bInternal)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
|
|
|
ICONINFO ii;
|
|
|
|
PCURICON_OBJECT CurIcon;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
BOOL Ret = FALSE;
|
|
|
|
DWORD colorBpp = 0;
|
|
|
|
|
|
|
|
TRACE("Enter NtUserGetIconInfo\n");
|
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
/* Check if something was actually asked */
|
|
|
|
if (!IconInfo && !lpModule && !lpResName)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2012-11-04 12:56:44 +00:00
|
|
|
WARN("Nothing to fill.\n");
|
2012-10-29 15:50:20 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
2012-11-04 12:56:44 +00:00
|
|
|
return FALSE;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
2012-11-04 12:56:44 +00:00
|
|
|
|
|
|
|
UserEnterExclusive();
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
|
|
|
|
{
|
2012-11-04 12:56:44 +00:00
|
|
|
WARN("UserGetIconObject(0x%08x) Failed.\n", hCurIcon);
|
|
|
|
UserLeave();
|
|
|
|
return FALSE;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
/* Give back the icon information */
|
|
|
|
if(IconInfo)
|
|
|
|
{
|
2013-11-13 20:06:01 +00:00
|
|
|
PCURICON_OBJECT FrameCurIcon = CurIcon;
|
|
|
|
if(CurIcon->CURSORF_flags & CURSORF_ACON)
|
|
|
|
{
|
|
|
|
/* Get information from first frame. */
|
|
|
|
FrameCurIcon = ((PACON)CurIcon)->aspcur[0];
|
|
|
|
}
|
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
/* Fill data */
|
2013-11-13 20:06:01 +00:00
|
|
|
ii.fIcon = is_icon(FrameCurIcon);
|
|
|
|
ii.xHotspot = FrameCurIcon->xHotspot;
|
|
|
|
ii.yHotspot = FrameCurIcon->yHotspot;
|
2012-10-29 15:50:20 +00:00
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
/* Copy bitmaps */
|
2013-11-13 20:06:01 +00:00
|
|
|
ii.hbmMask = BITMAP_CopyBitmap(FrameCurIcon->hbmMask);
|
2012-11-04 12:56:44 +00:00
|
|
|
GreSetObjectOwner(ii.hbmMask, GDI_OBJ_HMGR_POWNED);
|
2013-11-13 20:06:01 +00:00
|
|
|
ii.hbmColor = BITMAP_CopyBitmap(FrameCurIcon->hbmColor);
|
2012-11-04 12:56:44 +00:00
|
|
|
GreSetObjectOwner(ii.hbmColor, GDI_OBJ_HMGR_POWNED);
|
2013-11-13 20:06:01 +00:00
|
|
|
colorBpp = FrameCurIcon->bpp;
|
2012-11-04 12:56:44 +00:00
|
|
|
|
|
|
|
/* Copy fields */
|
|
|
|
_SEH2_TRY
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2012-11-04 12:56:44 +00:00
|
|
|
ProbeForWrite(IconInfo, sizeof(ICONINFO), 1);
|
|
|
|
RtlCopyMemory(IconInfo, &ii, sizeof(ICONINFO));
|
|
|
|
|
|
|
|
if (pbpp)
|
|
|
|
{
|
|
|
|
ProbeForWrite(pbpp, sizeof(DWORD), 1);
|
|
|
|
*pbpp = colorBpp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
2012-11-04 12:56:44 +00:00
|
|
|
_SEH2_END
|
2012-10-29 15:50:20 +00:00
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
WARN("Status: 0x%08x.\n", Status);
|
|
|
|
SetLastNtError(Status);
|
|
|
|
goto leave;
|
|
|
|
}
|
2012-11-04 12:56:44 +00:00
|
|
|
}
|
2012-10-29 15:50:20 +00:00
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
/* Give back the module name */
|
|
|
|
if(lpModule)
|
|
|
|
{
|
2013-11-13 20:06:01 +00:00
|
|
|
ULONG BufLen = 0;
|
|
|
|
if (!CurIcon->atomModName)
|
2012-11-04 12:56:44 +00:00
|
|
|
goto leave;
|
2013-11-13 20:06:01 +00:00
|
|
|
|
|
|
|
RtlQueryAtomInAtomTable(gAtomTable, CurIcon->atomModName, NULL, NULL, NULL, &BufLen);
|
|
|
|
/* Get the module name from the atom table */
|
2012-11-04 12:56:44 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2014-10-23 19:41:42 +00:00
|
|
|
BufLen += sizeof(WCHAR);
|
|
|
|
if (BufLen > (lpModule->MaximumLength))
|
2013-11-13 20:06:01 +00:00
|
|
|
{
|
|
|
|
lpModule->Length = 0;
|
2014-10-23 19:41:42 +00:00
|
|
|
lpModule->MaximumLength = BufLen;
|
2013-11-13 20:06:01 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ProbeForWrite(lpModule->Buffer, lpModule->MaximumLength, 1);
|
2014-10-23 19:41:42 +00:00
|
|
|
BufLen = lpModule->MaximumLength;
|
2013-11-13 20:06:01 +00:00
|
|
|
RtlQueryAtomInAtomTable(gAtomTable, CurIcon->atomModName, NULL, NULL, lpModule->Buffer, &BufLen);
|
2014-10-23 19:41:42 +00:00
|
|
|
lpModule->Length = BufLen;
|
2013-11-13 20:06:01 +00:00
|
|
|
}
|
2012-11-04 12:56:44 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
goto leave;
|
|
|
|
}
|
2012-11-04 12:56:44 +00:00
|
|
|
}
|
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
if (lpResName)
|
2012-11-04 12:56:44 +00:00
|
|
|
{
|
2013-11-13 20:06:01 +00:00
|
|
|
if (!CurIcon->strName.Buffer)
|
2012-11-04 12:56:44 +00:00
|
|
|
goto leave;
|
2013-11-13 20:06:01 +00:00
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
/* Copy it */
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(lpResName, sizeof(UNICODE_STRING), 1);
|
2013-11-13 20:06:01 +00:00
|
|
|
if (IS_INTRESOURCE(CurIcon->strName.Buffer))
|
2012-11-04 12:56:44 +00:00
|
|
|
{
|
2012-11-08 12:51:24 +00:00
|
|
|
lpResName->Buffer = CurIcon->strName.Buffer;
|
2012-11-04 12:56:44 +00:00
|
|
|
lpResName->Length = 0;
|
2014-10-23 19:41:42 +00:00
|
|
|
lpResName->MaximumLength = 0;
|
2012-11-04 12:56:44 +00:00
|
|
|
}
|
2014-10-23 19:41:42 +00:00
|
|
|
else if (lpResName->MaximumLength < CurIcon->strName.MaximumLength)
|
2013-11-13 20:06:01 +00:00
|
|
|
{
|
|
|
|
lpResName->Length = 0;
|
2014-10-23 19:41:42 +00:00
|
|
|
lpResName->MaximumLength = CurIcon->strName.MaximumLength;
|
2013-11-13 20:06:01 +00:00
|
|
|
}
|
2012-11-04 12:56:44 +00:00
|
|
|
else
|
|
|
|
{
|
2014-10-23 19:41:42 +00:00
|
|
|
ProbeForWrite(lpResName->Buffer, lpResName->MaximumLength, 1);
|
|
|
|
RtlCopyMemory(lpResName->Buffer, CurIcon->strName.Buffer, CurIcon->strName.Length);
|
|
|
|
lpResName->Length = CurIcon->strName.Length;
|
2012-11-04 12:56:44 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
2012-10-29 15:50:20 +00:00
|
|
|
SetLastNtError(Status);
|
2012-11-04 12:56:44 +00:00
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ret = TRUE;
|
2012-10-29 15:50:20 +00:00
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
leave:
|
2012-10-29 15:50:20 +00:00
|
|
|
UserDereferenceObject(CurIcon);
|
|
|
|
|
|
|
|
TRACE("Leave NtUserGetIconInfo, ret=%i\n", Ret);
|
|
|
|
UserLeave();
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserGetIconSize(
|
|
|
|
HANDLE hCurIcon,
|
|
|
|
UINT istepIfAniCur,
|
|
|
|
PLONG plcx, // &size.cx
|
|
|
|
PLONG plcy) // &size.cy
|
|
|
|
{
|
|
|
|
PCURICON_OBJECT CurIcon;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
BOOL bRet = FALSE;
|
|
|
|
|
|
|
|
TRACE("Enter NtUserGetIconSize\n");
|
|
|
|
UserEnterExclusive();
|
|
|
|
|
|
|
|
if (!(CurIcon = UserGetCurIconObject(hCurIcon)))
|
|
|
|
{
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
if(CurIcon->CURSORF_flags & CURSORF_ACON)
|
|
|
|
{
|
|
|
|
/* Use first frame for animated cursors */
|
|
|
|
PACON AniCurIcon = (PACON)CurIcon;
|
|
|
|
CurIcon = AniCurIcon->aspcur[0];
|
|
|
|
UserDereferenceObject(AniCurIcon);
|
|
|
|
UserReferenceObject(CurIcon);
|
|
|
|
}
|
|
|
|
|
2012-10-29 15:50:20 +00:00
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(plcx, sizeof(LONG), 1);
|
2012-11-08 12:51:24 +00:00
|
|
|
*plcx = CurIcon->cx;
|
2012-10-29 15:50:20 +00:00
|
|
|
ProbeForWrite(plcy, sizeof(LONG), 1);
|
2012-11-08 12:51:24 +00:00
|
|
|
*plcy = CurIcon->cy;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
bRet = TRUE;
|
|
|
|
else
|
|
|
|
SetLastNtError(Status); // Maybe not, test this
|
|
|
|
|
|
|
|
UserDereferenceObject(CurIcon);
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
TRACE("Leave NtUserGetIconSize, ret=%i\n", bRet);
|
|
|
|
UserLeave();
|
|
|
|
return bRet;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserGetCursorInfo(
|
|
|
|
PCURSORINFO pci)
|
|
|
|
{
|
|
|
|
CURSORINFO SafeCi;
|
|
|
|
PSYSTEM_CURSORINFO CurInfo;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
PCURICON_OBJECT CurIcon;
|
|
|
|
BOOL Ret = FALSE;
|
|
|
|
DECLARE_RETURN(BOOL);
|
|
|
|
|
|
|
|
TRACE("Enter NtUserGetCursorInfo\n");
|
|
|
|
UserEnterExclusive();
|
|
|
|
|
|
|
|
CurInfo = IntGetSysCursorInfo();
|
|
|
|
CurIcon = (PCURICON_OBJECT)CurInfo->CurrentCursorObject;
|
|
|
|
|
|
|
|
SafeCi.cbSize = sizeof(CURSORINFO);
|
|
|
|
SafeCi.flags = ((CurIcon && CurInfo->ShowingCursor >= 0) ? CURSOR_SHOWING : 0);
|
2013-11-13 20:06:01 +00:00
|
|
|
SafeCi.hCursor = (CurIcon ? CurIcon->head.h : NULL);
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
SafeCi.ptScreenPos = gpsi->ptCursor;
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
if (pci->cbSize == sizeof(CURSORINFO))
|
|
|
|
{
|
|
|
|
ProbeForWrite(pci, sizeof(CURSORINFO), 1);
|
|
|
|
RtlCopyMemory(pci, &SafeCi, sizeof(CURSORINFO));
|
|
|
|
Ret = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END;
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN(Ret);
|
|
|
|
|
|
|
|
CLEANUP:
|
|
|
|
TRACE("Leave NtUserGetCursorInfo, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
UserClipCursor(
|
|
|
|
RECTL *prcl)
|
|
|
|
{
|
|
|
|
/* FIXME: Check if process has WINSTA_WRITEATTRIBUTES */
|
|
|
|
PSYSTEM_CURSORINFO CurInfo;
|
|
|
|
PWND DesktopWindow = NULL;
|
|
|
|
|
|
|
|
CurInfo = IntGetSysCursorInfo();
|
|
|
|
|
|
|
|
DesktopWindow = UserGetDesktopWindow();
|
|
|
|
|
|
|
|
if (prcl != NULL && DesktopWindow != NULL)
|
|
|
|
{
|
|
|
|
if (prcl->right < prcl->left || prcl->bottom < prcl->top)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
CurInfo->bClipped = TRUE;
|
|
|
|
|
|
|
|
/* Set nw cliping region. Note: we can't use RECTL_bIntersectRect because
|
|
|
|
it sets rect to 0 0 0 0 when it's empty. For more info see monitor winetest */
|
|
|
|
CurInfo->rcClip.left = max(prcl->left, DesktopWindow->rcWindow.left);
|
|
|
|
CurInfo->rcClip.right = min(prcl->right, DesktopWindow->rcWindow.right);
|
|
|
|
if (CurInfo->rcClip.right < CurInfo->rcClip.left)
|
|
|
|
CurInfo->rcClip.right = CurInfo->rcClip.left;
|
|
|
|
|
|
|
|
CurInfo->rcClip.top = max(prcl->top, DesktopWindow->rcWindow.top);
|
|
|
|
CurInfo->rcClip.bottom = min(prcl->bottom, DesktopWindow->rcWindow.bottom);
|
|
|
|
if (CurInfo->rcClip.bottom < CurInfo->rcClip.top)
|
|
|
|
CurInfo->rcClip.bottom = CurInfo->rcClip.top;
|
|
|
|
|
|
|
|
/* Make sure cursor is in clipping region */
|
|
|
|
UserSetCursorPos(gpsi->ptCursor.x, gpsi->ptCursor.y, 0, 0, FALSE);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CurInfo->bClipped = FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserClipCursor(
|
|
|
|
RECTL *prcl)
|
|
|
|
{
|
|
|
|
RECTL rclLocal;
|
|
|
|
BOOL bResult;
|
|
|
|
|
|
|
|
if (prcl)
|
|
|
|
{
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
/* Probe and copy rect */
|
|
|
|
ProbeForRead(prcl, sizeof(RECTL), 1);
|
|
|
|
rclLocal = *prcl;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
_SEH2_YIELD(return FALSE;)
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
|
|
|
prcl = &rclLocal;
|
|
|
|
}
|
|
|
|
|
2014-08-08 16:04:08 +00:00
|
|
|
UserEnterExclusive();
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
/* Call the internal function */
|
|
|
|
bResult = UserClipCursor(prcl);
|
|
|
|
|
|
|
|
UserLeave();
|
|
|
|
|
|
|
|
return bResult;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserDestroyCursor(
|
2012-11-04 12:56:44 +00:00
|
|
|
_In_ HANDLE hCurIcon,
|
|
|
|
_In_ BOOL bForce)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
|
|
|
BOOL ret;
|
2014-10-23 09:52:57 +00:00
|
|
|
PCURICON_OBJECT CurIcon = NULL;
|
2012-10-29 15:50:20 +00:00
|
|
|
|
2014-10-23 09:32:39 +00:00
|
|
|
TRACE("Enter NtUserDestroyCursorIcon (%p, %u)\n", hCurIcon, bForce);
|
2012-10-29 15:50:20 +00:00
|
|
|
UserEnterExclusive();
|
|
|
|
|
2014-10-23 09:52:57 +00:00
|
|
|
CurIcon = UserGetCurIconObject(hCurIcon);
|
|
|
|
if (!CurIcon)
|
|
|
|
{
|
|
|
|
ret = FALSE;
|
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
|
2014-10-21 18:59:44 +00:00
|
|
|
if (!bForce)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2014-10-21 18:59:44 +00:00
|
|
|
/* Maybe we have good reasons not to destroy this object */
|
|
|
|
if (CurIcon->head.ppi != PsGetCurrentProcessWin32Process())
|
|
|
|
{
|
|
|
|
/* No way, you're not touching my cursor */
|
|
|
|
ret = FALSE;
|
|
|
|
goto leave;
|
|
|
|
}
|
2012-10-29 15:50:20 +00:00
|
|
|
|
2014-10-23 09:52:57 +00:00
|
|
|
if (CurIcon->CURSORF_flags & CURSORF_CURRENT)
|
2014-10-21 18:59:44 +00:00
|
|
|
{
|
|
|
|
WARN("Trying to delete current cursor!\n");
|
|
|
|
ret = FALSE;
|
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
|
2014-10-23 09:52:57 +00:00
|
|
|
if (CurIcon->CURSORF_flags & CURSORF_LRSHARED)
|
2014-10-21 18:59:44 +00:00
|
|
|
{
|
|
|
|
WARN("Trying to delete shared cursor.\n");
|
|
|
|
/* This one is not an error */
|
|
|
|
ret = TRUE;
|
|
|
|
goto leave;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Destroy the handle */
|
2014-10-23 09:52:57 +00:00
|
|
|
ret = IntDestroyCurIconObject(CurIcon);
|
2014-10-21 18:59:44 +00:00
|
|
|
|
|
|
|
leave:
|
2014-10-23 09:52:57 +00:00
|
|
|
if (CurIcon)
|
|
|
|
UserDereferenceObject(CurIcon);
|
2014-10-21 18:59:44 +00:00
|
|
|
TRACE("Leave NtUserDestroyCursorIcon, ret=%i\n", ret);
|
2012-10-29 15:50:20 +00:00
|
|
|
UserLeave();
|
2014-10-21 18:59:44 +00:00
|
|
|
return ret;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HICON
|
2012-11-04 12:56:44 +00:00
|
|
|
NTAPI
|
2012-10-29 15:50:20 +00:00
|
|
|
NtUserFindExistingCursorIcon(
|
2012-11-04 12:56:44 +00:00
|
|
|
_In_ PUNICODE_STRING pustrModule,
|
|
|
|
_In_ PUNICODE_STRING pustrRsrc,
|
2012-11-05 20:23:01 +00:00
|
|
|
_In_ FINDEXISTINGCURICONPARAM* param)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
|
|
|
PCURICON_OBJECT CurIcon;
|
2012-11-04 12:56:44 +00:00
|
|
|
HICON Ret = NULL;
|
|
|
|
UNICODE_STRING ustrModuleSafe, ustrRsrcSafe;
|
2012-11-05 20:23:01 +00:00
|
|
|
FINDEXISTINGCURICONPARAM paramSafe;
|
2012-11-04 12:56:44 +00:00
|
|
|
NTSTATUS Status;
|
2013-11-13 20:06:01 +00:00
|
|
|
PPROCESSINFO pProcInfo = PsGetCurrentProcessWin32Process();
|
|
|
|
RTL_ATOM atomModName;
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
TRACE("Enter NtUserFindExistingCursorIcon\n");
|
2012-11-04 12:56:44 +00:00
|
|
|
|
2012-11-05 20:23:01 +00:00
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForRead(param, sizeof(*param), 1);
|
2012-11-08 12:51:24 +00:00
|
|
|
RtlCopyMemory(¶mSafe, param, sizeof(paramSafe));
|
2012-11-05 20:23:01 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END
|
2012-10-29 15:50:20 +00:00
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
/* Capture resource name (it can be an INTRESOURCE == ATOM) */
|
|
|
|
Status = ProbeAndCaptureUnicodeStringOrAtom(&ustrRsrcSafe, pustrRsrc);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
return NULL;
|
|
|
|
Status = ProbeAndCaptureUnicodeString(&ustrModuleSafe, UserMode, pustrModule);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
goto done;
|
|
|
|
Status = RtlLookupAtomInAtomTable(gAtomTable, ustrModuleSafe.Buffer, &atomModName);
|
|
|
|
ReleaseCapturedUnicodeString(&ustrModuleSafe, UserMode);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
/* The module is not in the atom table. No chance to find the cursor */
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
UserEnterExclusive();
|
2013-11-13 20:06:01 +00:00
|
|
|
CurIcon = pProcInfo->pCursorCache;
|
|
|
|
while(CurIcon)
|
|
|
|
{
|
|
|
|
/* Icon/cursor */
|
|
|
|
if (paramSafe.bIcon != is_icon(CurIcon))
|
|
|
|
{
|
|
|
|
CurIcon = CurIcon->pcurNext;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
/* See if module names match */
|
|
|
|
if (atomModName == CurIcon->atomModName)
|
|
|
|
{
|
|
|
|
/* They do. Now see if this is the same resource */
|
|
|
|
if (IS_INTRESOURCE(CurIcon->strName.Buffer) != IS_INTRESOURCE(ustrRsrcSafe.Buffer))
|
|
|
|
{
|
|
|
|
/* One is an INT resource and the other is not -> no match */
|
|
|
|
CurIcon = CurIcon->pcurNext;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IS_INTRESOURCE(CurIcon->strName.Buffer))
|
|
|
|
{
|
|
|
|
if (CurIcon->strName.Buffer == ustrRsrcSafe.Buffer)
|
|
|
|
{
|
|
|
|
/* INT resources match */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (RtlCompareUnicodeString(&ustrRsrcSafe, &CurIcon->strName, TRUE) == 0)
|
|
|
|
{
|
|
|
|
/* Resource name strings match */
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
CurIcon = CurIcon->pcurNext;
|
|
|
|
}
|
|
|
|
if(CurIcon)
|
|
|
|
Ret = CurIcon->head.h;
|
2012-10-29 15:50:20 +00:00
|
|
|
UserLeave();
|
2012-11-04 12:56:44 +00:00
|
|
|
|
|
|
|
done:
|
|
|
|
if(!IS_INTRESOURCE(ustrRsrcSafe.Buffer))
|
|
|
|
ExFreePoolWithTag(ustrRsrcSafe.Buffer, TAG_STRING);
|
|
|
|
|
|
|
|
return Ret;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserGetClipCursor(
|
|
|
|
RECTL *lpRect)
|
|
|
|
{
|
|
|
|
/* FIXME: Check if process has WINSTA_READATTRIBUTES */
|
|
|
|
PSYSTEM_CURSORINFO CurInfo;
|
|
|
|
RECTL Rect;
|
|
|
|
NTSTATUS Status;
|
|
|
|
DECLARE_RETURN(BOOL);
|
|
|
|
|
|
|
|
TRACE("Enter NtUserGetClipCursor\n");
|
|
|
|
UserEnterExclusive();
|
|
|
|
|
|
|
|
if (!lpRect)
|
|
|
|
RETURN(FALSE);
|
|
|
|
|
|
|
|
CurInfo = IntGetSysCursorInfo();
|
|
|
|
if (CurInfo->bClipped)
|
|
|
|
{
|
|
|
|
Rect = CurInfo->rcClip;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Rect.left = 0;
|
|
|
|
Rect.top = 0;
|
|
|
|
Rect.right = UserGetSystemMetrics(SM_CXSCREEN);
|
|
|
|
Rect.bottom = UserGetSystemMetrics(SM_CYSCREEN);
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = MmCopyToCaller(lpRect, &Rect, sizeof(RECT));
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
RETURN(FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
RETURN(TRUE);
|
|
|
|
|
|
|
|
CLEANUP:
|
|
|
|
TRACE("Leave NtUserGetClipCursor, ret=%i\n",_ret_);
|
|
|
|
UserLeave();
|
|
|
|
END_CLEANUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HCURSOR
|
|
|
|
APIENTRY
|
|
|
|
NtUserSetCursor(
|
|
|
|
HCURSOR hCursor)
|
|
|
|
{
|
|
|
|
PCURICON_OBJECT pcurOld, pcurNew;
|
|
|
|
HCURSOR hOldCursor = NULL;
|
|
|
|
|
2014-10-23 09:32:39 +00:00
|
|
|
TRACE("Enter NtUserSetCursor: %p\n", hCursor);
|
2012-10-29 15:50:20 +00:00
|
|
|
UserEnterExclusive();
|
|
|
|
|
|
|
|
if (hCursor)
|
|
|
|
{
|
|
|
|
pcurNew = UserGetCurIconObject(hCursor);
|
|
|
|
if (!pcurNew)
|
|
|
|
{
|
|
|
|
EngSetLastError(ERROR_INVALID_CURSOR_HANDLE);
|
|
|
|
goto leave;
|
|
|
|
}
|
2012-11-08 12:51:24 +00:00
|
|
|
pcurNew->CURSORF_flags |= CURSORF_CURRENT;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
pcurNew = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
pcurOld = UserSetCursor(pcurNew, FALSE);
|
|
|
|
if (pcurOld)
|
|
|
|
{
|
2014-10-23 09:32:39 +00:00
|
|
|
hOldCursor = pcurOld->head.h;
|
|
|
|
/* See if it was destroyed in the meantime */
|
|
|
|
if (UserObjectInDestroy(hOldCursor))
|
|
|
|
hOldCursor = NULL;
|
2012-11-08 12:51:24 +00:00
|
|
|
pcurOld->CURSORF_flags &= ~CURSORF_CURRENT;
|
2014-10-21 18:59:44 +00:00
|
|
|
UserDereferenceObject(pcurOld);
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
leave:
|
|
|
|
UserLeave();
|
|
|
|
return hOldCursor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2012-11-08 12:51:24 +00:00
|
|
|
* @unimplemented
|
2012-10-29 15:50:20 +00:00
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserSetCursorContents(
|
|
|
|
HANDLE hCurIcon,
|
|
|
|
PICONINFO UnsafeIconInfo)
|
|
|
|
{
|
2012-11-08 12:51:24 +00:00
|
|
|
FIXME(" is UNIMPLEMENTED.\n");
|
|
|
|
return FALSE;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserSetCursorIconData(
|
2012-11-04 12:56:44 +00:00
|
|
|
_In_ HCURSOR Handle,
|
|
|
|
_In_opt_ PUNICODE_STRING pustrModule,
|
|
|
|
_In_opt_ PUNICODE_STRING pustrRsrc,
|
2013-11-13 20:06:01 +00:00
|
|
|
_In_ const CURSORDATA* pCursorData)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
|
|
|
PCURICON_OBJECT CurIcon;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
2013-11-13 20:06:01 +00:00
|
|
|
BOOLEAN Ret = FALSE;
|
|
|
|
BOOLEAN IsShared = FALSE, IsAnim = FALSE;
|
|
|
|
DWORD numFrames;
|
|
|
|
UINT i = 0;
|
2012-11-04 12:56:44 +00:00
|
|
|
|
2012-10-29 15:50:20 +00:00
|
|
|
TRACE("Enter NtUserSetCursorIconData\n");
|
2012-11-04 12:56:44 +00:00
|
|
|
|
2012-10-29 15:50:20 +00:00
|
|
|
UserEnterExclusive();
|
|
|
|
|
|
|
|
if (!(CurIcon = UserGetCurIconObject(Handle)))
|
|
|
|
{
|
2012-11-04 12:56:44 +00:00
|
|
|
UserLeave();
|
|
|
|
EngSetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
return FALSE;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
2012-11-08 12:51:24 +00:00
|
|
|
ProbeForRead(pCursorData, sizeof(*pCursorData), 1);
|
2013-11-13 20:06:01 +00:00
|
|
|
if(pCursorData->CURSORF_flags & CURSORF_ACON)
|
|
|
|
{
|
|
|
|
/* This is an animated cursor */
|
|
|
|
PACON AniCurIcon = (PACON)CurIcon;
|
|
|
|
DWORD numSteps;
|
|
|
|
|
|
|
|
numFrames = AniCurIcon->cpcur = pCursorData->cpcur;
|
|
|
|
numSteps = AniCurIcon->cicur = pCursorData->cicur;
|
|
|
|
AniCurIcon->iicur = pCursorData->iicur;
|
|
|
|
AniCurIcon->rt = pCursorData->rt;
|
|
|
|
|
|
|
|
/* Calculate size: one cursor object for each frame, and a frame index and jiffies for each "step" */
|
|
|
|
AniCurIcon->aspcur = ExAllocatePoolWithTag(PagedPool | POOL_RAISE_IF_ALLOCATION_FAILURE, /* Let SEH catch allocation failures */
|
|
|
|
numFrames * sizeof(CURICON_OBJECT*) + numSteps * (sizeof(DWORD) + sizeof(INT)),
|
|
|
|
USERTAG_CURSOR);
|
|
|
|
AniCurIcon->aicur = (DWORD*)(AniCurIcon->aspcur + numFrames);
|
|
|
|
AniCurIcon->ajifRate = (INT*)(AniCurIcon->aicur + numSteps);
|
|
|
|
|
|
|
|
RtlZeroMemory(AniCurIcon->aspcur, numFrames * sizeof(CURICON_OBJECT*));
|
|
|
|
|
|
|
|
ProbeForRead(pCursorData->aicur, numSteps * sizeof(DWORD), 1);
|
|
|
|
RtlCopyMemory(AniCurIcon->aicur, pCursorData->aicur, numSteps * sizeof(DWORD));
|
|
|
|
ProbeForRead(pCursorData->ajifRate, numSteps * sizeof(INT), 1);
|
|
|
|
RtlCopyMemory(AniCurIcon->ajifRate, pCursorData->ajifRate, numSteps * sizeof(INT));
|
|
|
|
|
|
|
|
AniCurIcon->CURSORF_flags = pCursorData->CURSORF_flags;
|
|
|
|
pCursorData = pCursorData->aspcur;
|
|
|
|
|
|
|
|
IsAnim = TRUE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
CurIcon->xHotspot = pCursorData->xHotspot;
|
|
|
|
CurIcon->yHotspot = pCursorData->yHotspot;
|
|
|
|
CurIcon->cx = pCursorData->cx;
|
|
|
|
CurIcon->cy = pCursorData->cy;
|
|
|
|
CurIcon->rt = pCursorData->rt;
|
|
|
|
CurIcon->bpp = pCursorData->bpp;
|
|
|
|
CurIcon->hbmMask = pCursorData->hbmMask;
|
|
|
|
CurIcon->hbmColor = pCursorData->hbmColor;
|
|
|
|
CurIcon->hbmAlpha = pCursorData->hbmAlpha;
|
|
|
|
CurIcon->CURSORF_flags = pCursorData->CURSORF_flags;
|
|
|
|
}
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
SetLastNtError(Status);
|
|
|
|
goto done;
|
|
|
|
}
|
2013-11-13 20:06:01 +00:00
|
|
|
|
|
|
|
if(IsAnim)
|
|
|
|
{
|
|
|
|
PACON AniCurIcon = (PACON)CurIcon;
|
|
|
|
/* This is an animated cursor. Create a cursor object for each frame and set up the data */
|
|
|
|
for(i = 0; i < numFrames; i++)
|
|
|
|
{
|
|
|
|
HANDLE hCurFrame = IntCreateCurIconHandle(FALSE);
|
|
|
|
if(!NtUserSetCursorIconData(hCurFrame, NULL, NULL, pCursorData))
|
|
|
|
goto done;
|
|
|
|
AniCurIcon->aspcur[i] = UserGetCurIconObject(hCurFrame);
|
|
|
|
if(!AniCurIcon->aspcur[i])
|
|
|
|
goto done;
|
|
|
|
pCursorData++;
|
|
|
|
}
|
|
|
|
}
|
2012-10-29 15:50:20 +00:00
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
if(CurIcon->CURSORF_flags & CURSORF_LRSHARED)
|
2012-11-10 15:56:42 +00:00
|
|
|
{
|
2013-11-13 20:06:01 +00:00
|
|
|
IsShared = TRUE;
|
|
|
|
if(pustrRsrc && pustrModule)
|
|
|
|
{
|
|
|
|
UNICODE_STRING ustrModuleSafe;
|
|
|
|
/* We use this convenient function, because INTRESOURCEs and ATOMs are the same */
|
|
|
|
Status = ProbeAndCaptureUnicodeStringOrAtom(&CurIcon->strName, pustrRsrc);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
goto done;
|
|
|
|
Status = ProbeAndCaptureUnicodeString(&ustrModuleSafe, UserMode, pustrModule);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
goto done;
|
|
|
|
Status = RtlAddAtomToAtomTable(gAtomTable, ustrModuleSafe.Buffer, &CurIcon->atomModName);
|
|
|
|
ReleaseCapturedUnicodeString(&ustrModuleSafe, UserMode);
|
|
|
|
if(!NT_SUCCESS(Status))
|
|
|
|
goto done;
|
|
|
|
}
|
2012-11-10 15:56:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if(!CurIcon->hbmMask)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2012-11-08 12:51:24 +00:00
|
|
|
ERR("NtUserSetCursorIconData was got no hbmMask.\n");
|
2012-10-29 15:50:20 +00:00
|
|
|
EngSetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
goto done;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:51:24 +00:00
|
|
|
GreSetObjectOwner(CurIcon->hbmMask, GDI_OBJ_HMGR_PUBLIC);
|
2012-10-29 15:50:20 +00:00
|
|
|
|
2012-11-10 15:56:42 +00:00
|
|
|
if(CurIcon->hbmColor)
|
2012-11-08 12:51:24 +00:00
|
|
|
GreSetObjectOwner(CurIcon->hbmColor, GDI_OBJ_HMGR_PUBLIC);
|
|
|
|
|
2012-11-10 15:56:42 +00:00
|
|
|
if(CurIcon->hbmAlpha)
|
2012-11-08 12:51:24 +00:00
|
|
|
GreSetObjectOwner(CurIcon->hbmAlpha, GDI_OBJ_HMGR_PUBLIC);
|
2013-11-13 20:06:01 +00:00
|
|
|
|
|
|
|
if(IsShared)
|
|
|
|
{
|
|
|
|
/* Update process cache in case of shared cursor */
|
|
|
|
PPROCESSINFO ppi = CurIcon->head.ppi;
|
2013-11-15 17:34:13 +00:00
|
|
|
UserReferenceObject(CurIcon);
|
2013-11-13 20:06:01 +00:00
|
|
|
CurIcon->pcurNext = ppi->pCursorCache;
|
|
|
|
ppi->pCursorCache = CurIcon;
|
|
|
|
}
|
2012-11-04 12:56:44 +00:00
|
|
|
|
2012-10-29 15:50:20 +00:00
|
|
|
Ret = TRUE;
|
|
|
|
|
|
|
|
done:
|
2013-11-13 20:06:01 +00:00
|
|
|
if(!Ret && IsShared)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
2012-11-08 12:51:24 +00:00
|
|
|
if(!IS_INTRESOURCE(CurIcon->strName.Buffer))
|
|
|
|
ExFreePoolWithTag(CurIcon->strName.Buffer, TAG_STRING);
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
2013-11-13 20:06:01 +00:00
|
|
|
|
|
|
|
if(!Ret && IsAnim)
|
|
|
|
{
|
|
|
|
PACON AniCurIcon = (PACON)CurIcon;
|
|
|
|
for(i = 0; i < numFrames; i++)
|
|
|
|
{
|
|
|
|
if(AniCurIcon->aspcur[i])
|
2014-10-25 19:46:12 +00:00
|
|
|
{
|
|
|
|
UserDereferenceObject(AniCurIcon->aspcur[i]);
|
2014-10-21 18:59:44 +00:00
|
|
|
IntDestroyCurIconObject(AniCurIcon->aspcur[i]);
|
2014-10-25 19:46:12 +00:00
|
|
|
}
|
2013-11-13 20:06:01 +00:00
|
|
|
}
|
|
|
|
AniCurIcon->cicur = 0;
|
|
|
|
AniCurIcon->cpcur = 0;
|
|
|
|
ExFreePoolWithTag(AniCurIcon->aspcur, USERTAG_CURSOR);
|
|
|
|
AniCurIcon->aspcur = NULL;
|
|
|
|
AniCurIcon->aicur = NULL;
|
|
|
|
AniCurIcon->ajifRate = NULL;
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:51:24 +00:00
|
|
|
UserDereferenceObject(CurIcon);
|
2012-11-04 12:56:44 +00:00
|
|
|
TRACE("Leave NtUserSetCursorIconData, ret=%i\n",Ret);
|
2012-10-29 15:50:20 +00:00
|
|
|
UserLeave();
|
2013-11-15 17:34:13 +00:00
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
return Ret;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Mostly inspired from wine code.
|
|
|
|
* We use low level functions because:
|
|
|
|
* - at this point, the icon bitmap could have a different bit depth than the DC,
|
|
|
|
* making it thus impossible to use NtCreateCompatibleDC and selecting the bitmap.
|
|
|
|
* This happens after a mode setting change.
|
|
|
|
* - it avoids massive GDI objects locking when only the destination surface needs it.
|
|
|
|
* - It makes (small) performance gains.
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
UserDrawIconEx(
|
|
|
|
HDC hDc,
|
|
|
|
INT xLeft,
|
|
|
|
INT yTop,
|
|
|
|
PCURICON_OBJECT pIcon,
|
|
|
|
INT cxWidth,
|
|
|
|
INT cyHeight,
|
|
|
|
UINT istepIfAniCur,
|
|
|
|
HBRUSH hbrFlickerFreeDraw,
|
|
|
|
UINT diFlags)
|
|
|
|
{
|
2012-11-04 12:56:44 +00:00
|
|
|
PSURFACE psurfDest, psurfMask, psurfColor; //, psurfOffScreen = NULL;
|
2012-10-29 15:50:20 +00:00
|
|
|
PDC pdc = NULL;
|
|
|
|
BOOL Ret = FALSE;
|
|
|
|
HBITMAP hbmMask, hbmColor, hbmAlpha;
|
|
|
|
BOOL bOffScreen;
|
|
|
|
RECTL rcDest, rcSrc;
|
|
|
|
CLIPOBJ* pdcClipObj = NULL;
|
|
|
|
EXLATEOBJ exlo;
|
|
|
|
|
|
|
|
/* Stupid case */
|
|
|
|
if((diFlags & DI_NORMAL) == 0)
|
|
|
|
{
|
|
|
|
ERR("DrawIconEx called without mask or color bitmap to draw.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
if (pIcon->CURSORF_flags & CURSORF_ACON)
|
|
|
|
{
|
|
|
|
ACON* pAcon = (ACON*)pIcon;
|
|
|
|
if(istepIfAniCur >= pAcon->cicur)
|
|
|
|
{
|
|
|
|
ERR("NtUserDrawIconEx: istepIfAniCur too big!\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pIcon = pAcon->aspcur[pAcon->aicur[istepIfAniCur]];
|
|
|
|
}
|
|
|
|
|
2012-11-08 12:51:24 +00:00
|
|
|
hbmMask = pIcon->hbmMask;
|
|
|
|
hbmColor = pIcon->hbmColor;
|
|
|
|
hbmAlpha = pIcon->hbmAlpha;
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Get our objects.
|
|
|
|
* Shared locks are enough, we are only reading those bitmaps
|
|
|
|
*/
|
|
|
|
psurfMask = SURFACE_ShareLockSurface(hbmMask);
|
|
|
|
if(psurfMask == NULL)
|
|
|
|
{
|
|
|
|
ERR("Unable to lock the mask surface.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Color bitmap is not mandatory */
|
|
|
|
if(hbmColor == NULL)
|
|
|
|
{
|
|
|
|
/* But then the mask bitmap must have the information in it's bottom half */
|
2012-11-08 12:51:24 +00:00
|
|
|
ASSERT(psurfMask->SurfObj.sizlBitmap.cy == 2*pIcon->cy);
|
2012-10-29 15:50:20 +00:00
|
|
|
psurfColor = NULL;
|
|
|
|
}
|
|
|
|
else if ((psurfColor = SURFACE_ShareLockSurface(hbmColor)) == NULL)
|
|
|
|
{
|
|
|
|
ERR("Unable to lock the color bitmap.\n");
|
|
|
|
SURFACE_ShareUnlockSurface(psurfMask);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
pdc = DC_LockDc(hDc);
|
|
|
|
if(!pdc)
|
|
|
|
{
|
|
|
|
ERR("Could not lock the destination DC.\n");
|
|
|
|
SURFACE_ShareUnlockSurface(psurfMask);
|
|
|
|
if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
/* Calculate destination rectangle */
|
|
|
|
RECTL_vSetRect(&rcDest, xLeft, yTop, xLeft + cxWidth, yTop + cyHeight);
|
|
|
|
IntLPtoDP(pdc, (LPPOINT)&rcDest, 2);
|
|
|
|
RECTL_vOffsetRect(&rcDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
|
|
|
|
|
|
|
|
/* Prepare the underlying surface */
|
2014-07-23 16:05:47 +00:00
|
|
|
DC_vPrepareDCsForBlit(pdc, &rcDest, NULL, NULL);
|
2012-11-04 12:56:44 +00:00
|
|
|
|
|
|
|
/* We now have our destination surface and rectangle */
|
|
|
|
psurfDest = pdc->dclevel.pSurface;
|
|
|
|
|
|
|
|
if(psurfDest == NULL)
|
|
|
|
{
|
|
|
|
/* Empty DC */
|
|
|
|
DC_vFinishBlit(pdc, NULL);
|
|
|
|
DC_UnlockDc(pdc);
|
|
|
|
SURFACE_ShareUnlockSurface(psurfMask);
|
|
|
|
if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2012-10-29 15:50:20 +00:00
|
|
|
/* Set source rect */
|
2012-11-08 12:51:24 +00:00
|
|
|
RECTL_vSetRect(&rcSrc, 0, 0, pIcon->cx, pIcon->cy);
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
/* Fix width parameter, if needed */
|
|
|
|
if (!cxWidth)
|
|
|
|
{
|
|
|
|
if(diFlags & DI_DEFAULTSIZE)
|
2012-11-08 12:51:24 +00:00
|
|
|
cxWidth = is_icon(pIcon) ?
|
2012-10-29 15:50:20 +00:00
|
|
|
UserGetSystemMetrics(SM_CXICON) : UserGetSystemMetrics(SM_CXCURSOR);
|
|
|
|
else
|
2012-11-08 12:51:24 +00:00
|
|
|
cxWidth = pIcon->cx;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Fix height parameter, if needed */
|
|
|
|
if (!cyHeight)
|
|
|
|
{
|
|
|
|
if(diFlags & DI_DEFAULTSIZE)
|
2012-11-08 12:51:24 +00:00
|
|
|
cyHeight = is_icon(pIcon) ?
|
2012-10-29 15:50:20 +00:00
|
|
|
UserGetSystemMetrics(SM_CYICON) : UserGetSystemMetrics(SM_CYCURSOR);
|
|
|
|
else
|
2012-11-08 12:51:24 +00:00
|
|
|
cyHeight = pIcon->cy;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Should we render off-screen? */
|
2012-11-04 12:56:44 +00:00
|
|
|
bOffScreen = hbrFlickerFreeDraw &&
|
|
|
|
(GDI_HANDLE_GET_TYPE(hbrFlickerFreeDraw) == GDI_OBJECT_TYPE_BRUSH);
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
if (bOffScreen)
|
|
|
|
{
|
|
|
|
/* Yes: Allocate and paint the offscreen surface */
|
|
|
|
EBRUSHOBJ eboFill;
|
|
|
|
PBRUSH pbrush = BRUSH_ShareLockBrush(hbrFlickerFreeDraw);
|
|
|
|
|
|
|
|
TRACE("Performing off-screen rendering.\n");
|
|
|
|
|
|
|
|
if(!pbrush)
|
|
|
|
{
|
|
|
|
ERR("Failed to get brush object.\n");
|
2012-11-04 12:56:44 +00:00
|
|
|
goto Cleanup;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
2012-11-04 12:56:44 +00:00
|
|
|
#if 0 //We lock the hdc surface during the whole function it makes no sense to use an offscreen surface for "flicker free" drawing
|
2012-10-29 15:50:20 +00:00
|
|
|
psurfOffScreen = SURFACE_AllocSurface(STYPE_BITMAP,
|
2012-11-04 12:56:44 +00:00
|
|
|
cxWidth, cyHeight, psurfDest->SurfObj.iBitmapFormat,
|
2012-10-29 15:50:20 +00:00
|
|
|
0, 0, NULL);
|
|
|
|
if(!psurfOffScreen)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate the off-screen surface.\n");
|
|
|
|
BRUSH_ShareUnlockBrush(pbrush);
|
2012-11-04 12:56:44 +00:00
|
|
|
goto Cleanup;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Paint the brush */
|
|
|
|
EBRUSHOBJ_vInit(&eboFill, pbrush, psurfOffScreen, 0x00FFFFFF, 0, NULL);
|
|
|
|
RECTL_vSetRect(&rcDest, 0, 0, cxWidth, cyHeight);
|
|
|
|
|
|
|
|
Ret = IntEngBitBlt(&psurfOffScreen->SurfObj,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&rcDest,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&eboFill.BrushObject,
|
|
|
|
&pbrush->ptOrigin,
|
|
|
|
ROP4_PATCOPY);
|
|
|
|
|
|
|
|
/* Clean up everything */
|
|
|
|
EBRUSHOBJ_vCleanup(&eboFill);
|
|
|
|
BRUSH_ShareUnlockBrush(pbrush);
|
|
|
|
|
|
|
|
if(!Ret)
|
|
|
|
{
|
|
|
|
ERR("Failed to paint the off-screen surface.\n");
|
2012-11-04 12:56:44 +00:00
|
|
|
goto Cleanup;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* We now have our destination surface */
|
|
|
|
psurfDest = psurfOffScreen;
|
2012-11-04 12:56:44 +00:00
|
|
|
#else
|
2014-08-08 16:14:38 +00:00
|
|
|
pdcClipObj = &pdc->co.ClipObj;
|
2012-11-04 12:56:44 +00:00
|
|
|
/* Paint the brush */
|
|
|
|
EBRUSHOBJ_vInit(&eboFill, pbrush, psurfDest, 0x00FFFFFF, 0, NULL);
|
|
|
|
|
|
|
|
Ret = IntEngBitBlt(&psurfDest->SurfObj,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
pdcClipObj,
|
|
|
|
NULL,
|
|
|
|
&rcDest,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&eboFill.BrushObject,
|
|
|
|
&pbrush->ptOrigin,
|
|
|
|
ROP4_PATCOPY);
|
|
|
|
|
|
|
|
/* Clean up everything */
|
|
|
|
EBRUSHOBJ_vCleanup(&eboFill);
|
|
|
|
BRUSH_ShareUnlockBrush(pbrush);
|
|
|
|
|
|
|
|
if(!Ret)
|
|
|
|
{
|
|
|
|
ERR("Failed to paint the off-screen surface.\n");
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
#endif
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* We directly draw to the DC */
|
|
|
|
TRACE("Performing on screen rendering.\n");
|
2014-08-08 16:14:38 +00:00
|
|
|
pdcClipObj = &pdc->co.ClipObj;
|
2012-11-04 12:56:44 +00:00
|
|
|
// psurfOffScreen = NULL;
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Now do the rendering */
|
2014-08-08 16:04:08 +00:00
|
|
|
if(hbmAlpha && ((diFlags & DI_NORMAL) == DI_NORMAL))
|
|
|
|
{
|
|
|
|
BLENDOBJ blendobj = { {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA } };
|
2012-10-29 15:50:20 +00:00
|
|
|
PSURFACE psurf = NULL;
|
|
|
|
|
|
|
|
psurf = SURFACE_ShareLockSurface(hbmAlpha);
|
|
|
|
if(!psurf)
|
|
|
|
{
|
|
|
|
ERR("SURFACE_LockSurface failed!\n");
|
|
|
|
goto NoAlpha;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Initialize color translation object */
|
|
|
|
EXLATEOBJ_vInitialize(&exlo, psurf->ppal, psurfDest->ppal, 0xFFFFFFFF, 0xFFFFFFFF, 0);
|
|
|
|
|
|
|
|
/* Now do it */
|
|
|
|
Ret = IntEngAlphaBlend(&psurfDest->SurfObj,
|
|
|
|
&psurf->SurfObj,
|
|
|
|
pdcClipObj,
|
|
|
|
&exlo.xlo,
|
|
|
|
&rcDest,
|
|
|
|
&rcSrc,
|
|
|
|
&blendobj);
|
|
|
|
|
|
|
|
EXLATEOBJ_vCleanup(&exlo);
|
|
|
|
SURFACE_ShareUnlockSurface(psurf);
|
|
|
|
if(Ret) goto done;
|
2014-08-08 16:04:08 +00:00
|
|
|
ERR("NtGdiAlphaBlend failed!\n");
|
2012-10-29 15:50:20 +00:00
|
|
|
}
|
|
|
|
NoAlpha:
|
|
|
|
if (diFlags & DI_MASK)
|
|
|
|
{
|
|
|
|
DWORD rop4 = (diFlags & DI_IMAGE) ? ROP4_SRCAND : ROP4_SRCCOPY;
|
|
|
|
|
|
|
|
EXLATEOBJ_vInitSrcMonoXlate(&exlo, psurfDest->ppal, 0x00FFFFFF, 0);
|
|
|
|
|
|
|
|
Ret = IntEngStretchBlt(&psurfDest->SurfObj,
|
|
|
|
&psurfMask->SurfObj,
|
|
|
|
NULL,
|
|
|
|
pdcClipObj,
|
|
|
|
&exlo.xlo,
|
|
|
|
NULL,
|
|
|
|
&rcDest,
|
|
|
|
&rcSrc,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
rop4);
|
|
|
|
|
|
|
|
EXLATEOBJ_vCleanup(&exlo);
|
|
|
|
|
|
|
|
if(!Ret)
|
|
|
|
{
|
|
|
|
ERR("Failed to mask the bitmap data.\n");
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if(diFlags & DI_IMAGE)
|
|
|
|
{
|
2014-08-08 16:04:08 +00:00
|
|
|
if (psurfColor)
|
2012-10-29 15:50:20 +00:00
|
|
|
{
|
|
|
|
DWORD rop4 = (diFlags & DI_MASK) ? ROP4_SRCINVERT : ROP4_SRCCOPY ;
|
|
|
|
|
|
|
|
EXLATEOBJ_vInitialize(&exlo, psurfColor->ppal, psurfDest->ppal, 0x00FFFFFF, 0x00FFFFFF, 0);
|
|
|
|
|
|
|
|
Ret = IntEngStretchBlt(&psurfDest->SurfObj,
|
|
|
|
&psurfColor->SurfObj,
|
|
|
|
NULL,
|
|
|
|
pdcClipObj,
|
|
|
|
&exlo.xlo,
|
|
|
|
NULL,
|
|
|
|
&rcDest,
|
|
|
|
&rcSrc,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
rop4);
|
|
|
|
|
|
|
|
EXLATEOBJ_vCleanup(&exlo);
|
|
|
|
|
|
|
|
if(!Ret)
|
|
|
|
{
|
|
|
|
ERR("Failed to render the icon bitmap.\n");
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Mask bitmap holds the information in its bottom half */
|
|
|
|
DWORD rop4 = (diFlags & DI_MASK) ? ROP4_SRCINVERT : ROP4_SRCCOPY;
|
2012-11-08 12:51:24 +00:00
|
|
|
RECTL_vOffsetRect(&rcSrc, 0, pIcon->cy);
|
2012-10-29 15:50:20 +00:00
|
|
|
|
|
|
|
EXLATEOBJ_vInitSrcMonoXlate(&exlo, psurfDest->ppal, 0x00FFFFFF, 0);
|
|
|
|
|
|
|
|
Ret = IntEngStretchBlt(&psurfDest->SurfObj,
|
|
|
|
&psurfMask->SurfObj,
|
|
|
|
NULL,
|
|
|
|
pdcClipObj,
|
|
|
|
&exlo.xlo,
|
|
|
|
NULL,
|
|
|
|
&rcDest,
|
|
|
|
&rcSrc,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
rop4);
|
|
|
|
|
|
|
|
EXLATEOBJ_vCleanup(&exlo);
|
|
|
|
|
|
|
|
if(!Ret)
|
|
|
|
{
|
|
|
|
ERR("Failed to render the icon bitmap.\n");
|
|
|
|
goto Cleanup;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
done:
|
2012-11-04 12:56:44 +00:00
|
|
|
#if 0
|
2012-10-29 15:50:20 +00:00
|
|
|
/* We're done. Was it a double buffered draw ? */
|
|
|
|
if(bOffScreen)
|
|
|
|
{
|
|
|
|
/* Yes. Draw it back to our DC */
|
|
|
|
POINTL ptSrc = {0, 0};
|
2012-11-04 12:56:44 +00:00
|
|
|
|
2012-10-29 15:50:20 +00:00
|
|
|
/* Calculate destination rectangle */
|
|
|
|
RECTL_vSetRect(&rcDest, xLeft, yTop, xLeft + cxWidth, yTop + cyHeight);
|
|
|
|
IntLPtoDP(pdc, (LPPOINT)&rcDest, 2);
|
|
|
|
RECTL_vOffsetRect(&rcDest, pdc->ptlDCOrig.x, pdc->ptlDCOrig.y);
|
|
|
|
|
|
|
|
/* Get the clip object */
|
|
|
|
pdcClipObj = pdc->rosdc.CombinedClip;
|
|
|
|
|
|
|
|
/* We now have our destination surface and rectangle */
|
|
|
|
psurfDest = pdc->dclevel.pSurface;
|
|
|
|
|
|
|
|
/* Color translation */
|
|
|
|
EXLATEOBJ_vInitialize(&exlo, psurfOffScreen->ppal, psurfDest->ppal, 0x00FFFFFF, 0x00FFFFFF, 0);
|
|
|
|
|
|
|
|
/* Blt it! */
|
|
|
|
Ret = IntEngBitBlt(&psurfDest->SurfObj,
|
|
|
|
&psurfOffScreen->SurfObj,
|
|
|
|
NULL,
|
|
|
|
pdcClipObj,
|
|
|
|
&exlo.xlo,
|
|
|
|
&rcDest,
|
|
|
|
&ptSrc,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
ROP4_SRCCOPY);
|
|
|
|
|
|
|
|
EXLATEOBJ_vCleanup(&exlo);
|
|
|
|
}
|
2012-11-04 12:56:44 +00:00
|
|
|
#endif
|
2012-10-29 15:50:20 +00:00
|
|
|
Cleanup:
|
|
|
|
if(pdc)
|
|
|
|
{
|
|
|
|
DC_vFinishBlit(pdc, NULL);
|
|
|
|
DC_UnlockDc(pdc);
|
|
|
|
}
|
2012-11-04 12:56:44 +00:00
|
|
|
|
|
|
|
#if 0
|
2012-10-29 15:50:20 +00:00
|
|
|
/* Delete off screen rendering surface */
|
|
|
|
if(psurfOffScreen)
|
|
|
|
GDIOBJ_vDeleteObject(&psurfOffScreen->BaseObject);
|
2012-11-04 12:56:44 +00:00
|
|
|
#endif
|
|
|
|
|
2012-10-29 15:50:20 +00:00
|
|
|
/* Unlock other surfaces */
|
|
|
|
SURFACE_ShareUnlockSurface(psurfMask);
|
|
|
|
if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor);
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
BOOL
|
|
|
|
APIENTRY
|
|
|
|
NtUserDrawIconEx(
|
|
|
|
HDC hdc,
|
|
|
|
int xLeft,
|
|
|
|
int yTop,
|
|
|
|
HICON hIcon,
|
|
|
|
int cxWidth,
|
|
|
|
int cyHeight,
|
|
|
|
UINT istepIfAniCur,
|
|
|
|
HBRUSH hbrFlickerFreeDraw,
|
|
|
|
UINT diFlags,
|
|
|
|
BOOL bMetaHDC, // When TRUE, GDI functions need to be handled in User32!
|
|
|
|
PVOID pDIXData)
|
|
|
|
{
|
|
|
|
PCURICON_OBJECT pIcon;
|
|
|
|
BOOL Ret;
|
|
|
|
|
|
|
|
TRACE("Enter NtUserDrawIconEx\n");
|
|
|
|
UserEnterExclusive();
|
|
|
|
|
|
|
|
if (!(pIcon = UserGetCurIconObject(hIcon)))
|
|
|
|
{
|
2012-11-04 12:56:44 +00:00
|
|
|
ERR("UserGetCurIconObject(0x%08x) failed!\n", hIcon);
|
2012-10-29 15:50:20 +00:00
|
|
|
UserLeave();
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
Ret = UserDrawIconEx(hdc,
|
|
|
|
xLeft,
|
|
|
|
yTop,
|
|
|
|
pIcon,
|
|
|
|
cxWidth,
|
|
|
|
cyHeight,
|
|
|
|
istepIfAniCur,
|
|
|
|
hbrFlickerFreeDraw,
|
|
|
|
diFlags);
|
|
|
|
|
|
|
|
UserDereferenceObject(pIcon);
|
|
|
|
|
|
|
|
UserLeave();
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
2013-11-13 20:06:01 +00:00
|
|
|
/*
|
|
|
|
* @unimplemented
|
|
|
|
*/
|
|
|
|
HCURSOR
|
|
|
|
NTAPI
|
|
|
|
NtUserGetCursorFrameInfo(
|
|
|
|
HCURSOR hCursor,
|
|
|
|
DWORD istep,
|
|
|
|
INT* rate_jiffies,
|
|
|
|
DWORD* num_steps)
|
|
|
|
{
|
|
|
|
PCURICON_OBJECT CurIcon;
|
|
|
|
HCURSOR ret;
|
|
|
|
INT jiffies = 0;
|
|
|
|
DWORD steps = 1;
|
|
|
|
NTSTATUS Status = STATUS_SUCCESS;
|
|
|
|
|
|
|
|
TRACE("Enter NtUserGetCursorFrameInfo\n");
|
|
|
|
UserEnterExclusive();
|
|
|
|
|
|
|
|
if (!(CurIcon = UserGetCurIconObject(hCursor)))
|
|
|
|
{
|
|
|
|
UserLeave();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
ret = CurIcon->head.h;
|
|
|
|
|
|
|
|
if(CurIcon->CURSORF_flags & CURSORF_ACON)
|
|
|
|
{
|
|
|
|
PACON AniCurIcon = (PACON)CurIcon;
|
|
|
|
if(istep >= AniCurIcon->cicur)
|
|
|
|
{
|
|
|
|
UserDereferenceObject(CurIcon);
|
|
|
|
UserLeave();
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
jiffies = AniCurIcon->ajifRate[istep];
|
|
|
|
steps = AniCurIcon->cicur;
|
|
|
|
ret = AniCurIcon->aspcur[AniCurIcon->aicur[istep]]->head.h;
|
|
|
|
}
|
|
|
|
|
|
|
|
_SEH2_TRY
|
|
|
|
{
|
|
|
|
ProbeForWrite(rate_jiffies, sizeof(INT), 1);
|
|
|
|
ProbeForWrite(num_steps, sizeof(DWORD), 1);
|
|
|
|
*rate_jiffies = jiffies;
|
|
|
|
*num_steps = steps;
|
|
|
|
}
|
|
|
|
_SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
|
|
|
|
{
|
|
|
|
Status = _SEH2_GetExceptionCode();
|
|
|
|
}
|
|
|
|
_SEH2_END
|
|
|
|
|
|
|
|
if (!NT_SUCCESS(Status))
|
|
|
|
{
|
|
|
|
WARN("Status: 0x%08x.\n", Status);
|
|
|
|
SetLastNtError(Status);
|
|
|
|
ret = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
UserDereferenceObject(CurIcon);
|
|
|
|
UserLeave();
|
|
|
|
|
|
|
|
TRACE("Leaving NtUserGetCursorFrameInfo, ret = 0x%08x\n", ret);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2012-10-29 15:50:20 +00:00
|
|
|
/* EOF */
|