From 1300cdce17e63e0230ed83117dfb3d97c78e357e Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Wed, 9 Jan 2008 16:04:34 +0000 Subject: [PATCH] - Fall back onto some of the previous win32k icon handling code, and fix user32 to suit. - This fixes the handle problem we were seeing which was caused by a failing NtUserFindExistingCursorIcon call in user32. It was incompatible with the new code and thus, creating a new icon for all LR_SHARED resources. - The new code is correct, and will be re-enabled once I've finished the cursoricon object rewrite (which will make it compatible with windows) - You'll probably need to 'make win32k_clean' before building svn path=/trunk/; revision=31687 --- reactos/dll/win32/user32/windows/bitmap.c | 11 ++- reactos/include/reactos/win32k/ntuser.h | 6 +- .../win32/win32k/ntuser/cursoricon.c | 83 +++++++++++++++++++ .../subsystems/win32/win32k/ntuser/object.c | 2 + reactos/subsystems/win32/win32k/w32ksvc.db | 2 +- 5 files changed, 97 insertions(+), 7 deletions(-) diff --git a/reactos/dll/win32/user32/windows/bitmap.c b/reactos/dll/win32/user32/windows/bitmap.c index 139a2c85886..f8a8d45ded8 100644 --- a/reactos/dll/win32/user32/windows/bitmap.c +++ b/reactos/dll/win32/user32/windows/bitmap.c @@ -268,7 +268,7 @@ LoadCursorIconImage( if (hIcon && 0 != (fuLoad & LR_SHARED)) { -#if 0 +#if 1 NtUserSetCursorIconData((HICON)hIcon, NULL, NULL, hinst, hResInfo, (HRSRC)NULL); #else @@ -762,7 +762,7 @@ GetIconCurBpp(PICONINFO pIconInfo) return pbi->bmiHeader.biBitCount; } - +#if 0 static BOOL SetCursorIconData( HANDLE Handle, @@ -770,6 +770,7 @@ SetCursorIconData( LPWSTR lpResName, PICONINFO pIconInfo) { + UNICODE_STRING Res; if (!Handle || !pIconInfo) @@ -778,6 +779,7 @@ SetCursorIconData( RtlInitUnicodeString(&Res, lpResName); return NtUserSetCursorIconData(Handle, hMod, &Res, pIconInfo); + } @@ -840,7 +842,7 @@ CopyIcoCur(HANDLE hIconCur, return hNewIcon; } - +#endif /* * @unimplemented @@ -873,7 +875,8 @@ CopyImage( return CopyBmp(hnd, type, desiredx, desiredy, flags); case IMAGE_ICON: - return CopyIcoCur(hnd, type, desiredx, desiredy, flags); + //return CopyIcoCur(hnd, type, desiredx, desiredy, flags); + return CopyIcon(hnd); case IMAGE_CURSOR: { diff --git a/reactos/include/reactos/win32k/ntuser.h b/reactos/include/reactos/win32k/ntuser.h index 751c720b57a..c072e37b894 100644 --- a/reactos/include/reactos/win32k/ntuser.h +++ b/reactos/include/reactos/win32k/ntuser.h @@ -2067,9 +2067,11 @@ BOOL NTAPI NtUserSetCursorIconData( HANDLE Handle, + PBOOL fIcon, + POINT *Hotspot, HMODULE hModule, - PUNICODE_STRING pstrResName, - PICONINFO pIconInfo); + HRSRC hRsrc, + HRSRC hGroupRsrc); DWORD NTAPI diff --git a/reactos/subsystems/win32/win32k/ntuser/cursoricon.c b/reactos/subsystems/win32/win32k/ntuser/cursoricon.c index 1abba52339f..3c03623527f 100644 --- a/reactos/subsystems/win32/win32k/ntuser/cursoricon.c +++ b/reactos/subsystems/win32/win32k/ntuser/cursoricon.c @@ -1187,6 +1187,7 @@ CLEANUP: /* * @implemented */ +#if 0 BOOL NTAPI NtUserSetCursorIconData( @@ -1272,7 +1273,89 @@ CLEANUP: UserLeave(); END_CLEANUP; } +#else +BOOL +STDCALL +NtUserSetCursorIconData( + HANDLE hCurIcon, + PBOOL fIcon, + POINT *Hotspot, + HMODULE hModule, + HRSRC hRsrc, + HRSRC hGroupRsrc) +{ + PCURICON_OBJECT CurIcon; + PWINSTATION_OBJECT WinSta; + NTSTATUS Status; + POINT SafeHotspot; + BOOL Ret = FALSE; + DECLARE_RETURN(BOOL); + DPRINT("Enter NtUserSetCursorIconData\n"); + UserEnterExclusive(); + + WinSta = IntGetWinStaObj(); + if(WinSta == NULL) + { + RETURN( FALSE); + } + + if(!(CurIcon = UserGetCurIconObject(hCurIcon))) + { + ObDereferenceObject(WinSta); + RETURN(FALSE); + } + + CurIcon->hModule = hModule; + CurIcon->hRsrc = hRsrc; + CurIcon->hGroupRsrc = hGroupRsrc; + + /* Copy fields */ + if(fIcon) + { + Status = MmCopyFromCaller(&CurIcon->IconInfo.fIcon, fIcon, sizeof(BOOL)); + if(!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + goto done; + } + } + else + { + if(!Hotspot) + Ret = TRUE; + } + + if(Hotspot) + { + Status = MmCopyFromCaller(&SafeHotspot, Hotspot, sizeof(POINT)); + if(NT_SUCCESS(Status)) + { + CurIcon->IconInfo.xHotspot = SafeHotspot.x; + CurIcon->IconInfo.yHotspot = SafeHotspot.y; + + Ret = TRUE; + } + else + SetLastNtError(Status); + } + + if(!fIcon && !Hotspot) + { + Ret = TRUE; + } + +done: + ObDereferenceObject(WinSta); + RETURN( Ret); + + +CLEANUP: + DPRINT("Leave NtUserSetCursorIconData, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} +#endif /* * @unimplemented diff --git a/reactos/subsystems/win32/win32k/ntuser/object.c b/reactos/subsystems/win32/win32k/ntuser/object.c index cc4b6ebbae5..ea4858bbac5 100644 --- a/reactos/subsystems/win32/win32k/ntuser/object.c +++ b/reactos/subsystems/win32/win32k/ntuser/object.c @@ -108,6 +108,8 @@ __inline static PUSER_HANDLE_ENTRY alloc_user_entry(PUSER_HANDLE_TABLE ht) } DPRINT1("Handle Count by Type:\n Free = %d Window = %d Menu = %d CursorIcon = %d Hook = %d\n CallProc = %d Accel = %d Monitor = %d\n", iFree, iWindow, iMenu, iCursorIcon, iHook, iCallProc, iAccel, iMonitor ); + + ASSERT(FALSE); //#endif return NULL; #if 0 diff --git a/reactos/subsystems/win32/win32k/w32ksvc.db b/reactos/subsystems/win32/win32k/w32ksvc.db index aafae7a7fa7..e5d44d2cbc0 100644 --- a/reactos/subsystems/win32/win32k/w32ksvc.db +++ b/reactos/subsystems/win32/win32k/w32ksvc.db @@ -519,7 +519,7 @@ NtUserSetClipboardViewer 1 NtUserSetConsoleReserveKeys 2 NtUserSetCursor 1 NtUserSetCursorContents 2 -NtUserSetCursorIconData 4 +NtUserSetCursorIconData 6 #4 NtUserSetDbgTag 2 NtUserSetFocus 1 NtUserSetImeHotKey 5