ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
October 2012
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
14 participants
211 discussions
Start a n
N
ew thread
[gadamopoulos] 57651: [user32_apitest] - Add a test for LR_SHARED flag for LoadImage
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Tue Oct 30 13:29:11 2012 New Revision: 57651 URL:
http://svn.reactos.org/svn/reactos?rev=57651&view=rev
Log: [user32_apitest] - Add a test for LR_SHARED flag for LoadImage Added: trunk/rostests/apitests/user32/LoadImage.c (with props) Modified: trunk/rostests/apitests/user32/CMakeLists.txt trunk/rostests/apitests/user32/testlist.c Modified: trunk/rostests/apitests/user32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/CMakeList…
============================================================================== --- trunk/rostests/apitests/user32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/user32/CMakeLists.txt [iso-8859-1] Tue Oct 30 13:29:11 2012 @@ -10,6 +10,7 @@ GetPeekMessage.c GetSystemMetrics.c InitializeLpkHooks.c + LoadImage.c RealGetWindowClass.c ScrollDC.c ScrollWindowEx.c Added: trunk/rostests/apitests/user32/LoadImage.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/LoadImage…
============================================================================== --- trunk/rostests/apitests/user32/LoadImage.c (added) +++ trunk/rostests/apitests/user32/LoadImage.c [iso-8859-1] Tue Oct 30 13:29:11 2012 @@ -1,0 +1,38 @@ + +#include <stdio.h> +#include <wine/test.h> +#include <windows.h> +#include "resource.h" + +START_TEST(LoadImage) +{ + char path[MAX_PATH]; + PROCESS_INFORMATION pi; + STARTUPINFO si; + HANDLE handle; + + char **test_argv; + int argc = winetest_get_mainargs( &test_argv ); + + /* Now check its behaviour regarding Shared icons/cursors */ + handle = LoadImageW( GetModuleHandle(NULL), L"TESTCURSOR", IMAGE_CURSOR, 0, 0, LR_SHARED | LR_DEFAULTSIZE ); + ok(handle != 0, "\n"); + + if (argc >= 3) + { + HANDLE arg; + + sscanf (test_argv[2], "%lu", (ULONG_PTR*) &arg); + + ok(handle != arg, "Got same handles\n"); + + return; + } + + /* Start child process */ + sprintf( path, "%s LoadImage %lu", test_argv[0], (ULONG_PTR)handle ); + memset( &si, 0, sizeof(si) ); + si.cb = sizeof(si); + CreateProcessA( NULL, path, NULL, NULL, TRUE, 0, NULL, NULL, &si, &pi ); + WaitForSingleObject (pi.hProcess, INFINITE); +} Propchange: trunk/rostests/apitests/user32/LoadImage.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/rostests/apitests/user32/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/testlist.…
============================================================================== --- trunk/rostests/apitests/user32/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/user32/testlist.c [iso-8859-1] Tue Oct 30 13:29:11 2012 @@ -14,6 +14,7 @@ extern void func_GetPeekMessage(void); extern void func_GetSystemMetrics(void); extern void func_InitializeLpkHooks(void); +extern void func_LoadImage(void); extern void func_RealGetWindowClass(void); extern void func_ScrollDC(void); extern void func_ScrollWindowEx(void); @@ -35,6 +36,7 @@ { "GetPeekMessage", func_GetPeekMessage }, { "GetSystemMetrics", func_GetSystemMetrics }, { "InitializeLpkHooks", func_InitializeLpkHooks }, + { "LoadImage", func_LoadImage }, { "RealGetWindowClass", func_RealGetWindowClass }, { "ScrollDC", func_ScrollDC }, { "ScrollWindowEx", func_ScrollWindowEx },
12 years, 1 month
1
0
0
0
[jgardou] 57650: [W32K_APITEST] - Better test for NtUserGetIconInfo
by jgardou@svn.reactos.org
Author: jgardou Date: Tue Oct 30 02:05:52 2012 New Revision: 57650 URL:
http://svn.reactos.org/svn/reactos?rev=57650&view=rev
Log: [W32K_APITEST] - Better test for NtUserGetIconInfo Modified: trunk/rostests/apitests/w32knapi/ntuser/NtUserGetIconInfo.c Modified: trunk/rostests/apitests/w32knapi/ntuser/NtUserGetIconInfo.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/w32knapi/ntuser/…
============================================================================== --- trunk/rostests/apitests/w32knapi/ntuser/NtUserGetIconInfo.c [iso-8859-1] (original) +++ trunk/rostests/apitests/w32knapi/ntuser/NtUserGetIconInfo.c [iso-8859-1] Tue Oct 30 02:05:52 2012 @@ -109,7 +109,9 @@ TEST(hIcon != NULL); - RtlInitUnicodeString(&hInstStr, NULL); + hInstStr.Buffer = HeapAlloc(GetProcessHeap(), 0, MAX_PATH * sizeof(WCHAR)); + hInstStr.MaximumLength = MAX_PATH; + hInstStr.Length = 0; RtlInitUnicodeString(&ResourceStr, NULL); TEST(NtUserGetIconInfo(hIcon, @@ -119,15 +121,16 @@ &bpp, FALSE) == TRUE); - TESTX(hInstStr.Buffer == NULL, "hInstStr.buffer : %p\n", hInstStr.Buffer); - TEST(hInstStr.Length == 0); - TEST(hInstStr.MaximumLength == 0); + TEST(hInstStr.Length != 0); + hInstStr.Buffer[hInstStr.Length] = 0; + printf("%s,%i: hInstStr.buffer : %S\n", __FUNCTION__, __LINE__, hInstStr.Buffer); TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(293)); TEST(ResourceStr.Length == 0); TEST(ResourceStr.MaximumLength == 0); TEST(bpp == 32); - RtlInitUnicodeString(&hInstStr, NULL); + ZeroMemory(hInstStr.Buffer, MAX_PATH*sizeof(WCHAR)); + hInstStr.Length = 0; RtlInitUnicodeString(&ResourceStr, NULL); TEST(NtUserGetIconInfo(hIcon, @@ -137,9 +140,9 @@ &bpp, TRUE) == TRUE); - TESTX(hInstStr.Buffer == NULL, "hInstStr.buffer : %p\n", hInstStr.Buffer); - TEST(hInstStr.Length == 0); - TEST(hInstStr.MaximumLength == 0); + TEST(hInstStr.Length != 0); + hInstStr.Buffer[hInstStr.Length] = 0; + printf("%s,%i: hInstStr.buffer : %S\n", __FUNCTION__, __LINE__, hInstStr.Buffer); TEST((LPCTSTR)ResourceStr.Buffer == MAKEINTRESOURCE(293)); TEST(bpp == 32);
12 years, 1 month
1
0
0
0
[jgardou] 57649: [USER32_APITEST] - Commit forgotten file
by jgardou@svn.reactos.org
Author: jgardou Date: Tue Oct 30 01:39:28 2012 New Revision: 57649 URL:
http://svn.reactos.org/svn/reactos?rev=57649&view=rev
Log: [USER32_APITEST] - Commit forgotten file Modified: trunk/rostests/apitests/user32/testlist.c Modified: trunk/rostests/apitests/user32/testlist.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/testlist.…
============================================================================== --- trunk/rostests/apitests/user32/testlist.c [iso-8859-1] (original) +++ trunk/rostests/apitests/user32/testlist.c [iso-8859-1] Tue Oct 30 01:39:28 2012 @@ -7,6 +7,7 @@ extern void func_AttachThreadInput(void); extern void func_DeferWindowPos(void); +extern void func_DestroyCursorIcon(void); extern void func_desktop(void); extern void func_GetIconInfo(void); extern void func_GetKeyState(void); @@ -28,6 +29,7 @@ { "AttachThreadInput", func_AttachThreadInput }, { "desktop", func_desktop }, { "DeferWindowPos", func_DeferWindowPos }, + { "DestroyCursorIcon", func_DestroyCursorIcon }, { "GetIconInfo", func_GetIconInfo }, { "GetKeyState", func_GetKeyState }, { "GetPeekMessage", func_GetPeekMessage },
12 years, 1 month
1
0
0
0
[jgardou] 57648: [USER32_APITEST] - More thorough test for what really happens after the "destruction" of a shared cursor.
by jgardou@svn.reactos.org
Author: jgardou Date: Mon Oct 29 16:14:54 2012 New Revision: 57648 URL:
http://svn.reactos.org/svn/reactos?rev=57648&view=rev
Log: [USER32_APITEST] - More thorough test for what really happens after the "destruction" of a shared cursor. Modified: trunk/rostests/apitests/user32/DestroyCursorIcon.c Modified: trunk/rostests/apitests/user32/DestroyCursorIcon.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/DestroyCu…
============================================================================== --- trunk/rostests/apitests/user32/DestroyCursorIcon.c [iso-8859-1] (original) +++ trunk/rostests/apitests/user32/DestroyCursorIcon.c [iso-8859-1] Mon Oct 29 16:14:54 2012 @@ -41,7 +41,11 @@ ok(DestroyCursor(hcursor), "\n"); /* In fact, it's still there */ + ZeroMemory(&iconinfo, sizeof(iconinfo)); ok(GetIconInfo(hcursor, &iconinfo), "\n"); + ok(iconinfo.hbmMask != NULL, "\n"); + ok(iconinfo.hbmColor != NULL, "\n"); + ok(!iconinfo.fIcon, "\n"); /* clean up */ DeleteObject(iconinfo.hbmMask);
12 years, 1 month
1
0
0
0
[jgardou] 57647: [USER32_APITESTS] - Add some test for DestroyCursor/DestroyIcon
by jgardou@svn.reactos.org
Author: jgardou Date: Mon Oct 29 16:12:49 2012 New Revision: 57647 URL:
http://svn.reactos.org/svn/reactos?rev=57647&view=rev
Log: [USER32_APITESTS] - Add some test for DestroyCursor/DestroyIcon Added: trunk/rostests/apitests/user32/DestroyCursorIcon.c (with props) Modified: trunk/rostests/apitests/user32/CMakeLists.txt Modified: trunk/rostests/apitests/user32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/CMakeList…
============================================================================== --- trunk/rostests/apitests/user32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/rostests/apitests/user32/CMakeLists.txt [iso-8859-1] Mon Oct 29 16:12:49 2012 @@ -3,6 +3,7 @@ AttachThreadInput.c helper.c DeferWindowPos.c + DestroyCursorIcon.c desktop.c GetIconInfo.c GetKeyState.c Added: trunk/rostests/apitests/user32/DestroyCursorIcon.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/user32/DestroyCu…
============================================================================== --- trunk/rostests/apitests/user32/DestroyCursorIcon.c (added) +++ trunk/rostests/apitests/user32/DestroyCursorIcon.c [iso-8859-1] Mon Oct 29 16:12:49 2012 @@ -1,0 +1,49 @@ +#include <stdio.h> +#include <wine/test.h> +#include <windows.h> +#include "resource.h" + +START_TEST(DestroyCursorIcon) +{ + HICON hicon; + HCURSOR hcursor; + ICONINFO iconinfo; + + ZeroMemory(&iconinfo, sizeof(iconinfo)); + + iconinfo.hbmMask = CreateBitmap(8, 16, 1, 1, NULL); + ok(iconinfo.hbmMask != NULL, "\n"); + + /* + * Test if DestroyCursor can destroy an icon, and vice-versa . + * It can. + */ + iconinfo.fIcon = TRUE; + hicon = CreateIconIndirect(&iconinfo); + ok(hicon != 0, "should not fail\n"); + ok(DestroyCursor(hicon), "\n"); + ok(!DestroyIcon(hicon), "\n"); + + iconinfo.fIcon = FALSE; + hcursor = CreateIconIndirect(&iconinfo); + ok(hcursor != 0, "should not fail\n"); + ok(DestroyIcon(hcursor), "\n"); + ok(!DestroyCursor(hcursor), "\n"); + + /* Clean up */ + DeleteObject(iconinfo.hbmMask); + + /* Now check its behaviour regarding Shared icons/cursors */ + hcursor = LoadCursor(GetModuleHandle(NULL), "TESTCURSOR"); + ok(hcursor != 0, "\n"); + + /* MSDN says we shouldn't do that, but it still succeeds */ + ok(DestroyCursor(hcursor), "\n"); + + /* In fact, it's still there */ + ok(GetIconInfo(hcursor, &iconinfo), "\n"); + + /* clean up */ + DeleteObject(iconinfo.hbmMask); + DeleteObject(iconinfo.hbmColor); +} Propchange: trunk/rostests/apitests/user32/DestroyCursorIcon.c ------------------------------------------------------------------------------ svn:eol-style = native
12 years, 1 month
1
0
0
0
[jgardou] 57646: [WIN32K] - put changes for the new cursor/icons implementation in a separate file
by jgardou@svn.reactos.org
Author: jgardou Date: Mon Oct 29 15:50:20 2012 New Revision: 57646 URL:
http://svn.reactos.org/svn/reactos?rev=57646&view=rev
Log: [WIN32K] - put changes for the new cursor/icons implementation in a separate file Added: trunk/reactos/win32ss/user/ntuser/cursoricon_new.c (with props) Modified: trunk/reactos/win32ss/CMakeLists.txt trunk/reactos/win32ss/user/ntuser/cursoricon.c trunk/reactos/win32ss/user/ntuser/cursoricon.h trunk/reactos/win32ss/user/ntuser/msgqueue.c Modified: trunk/reactos/win32ss/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/CMakeLists.txt?rev…
============================================================================== --- trunk/reactos/win32ss/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/win32ss/CMakeLists.txt [iso-8859-1] Mon Oct 29 15:50:20 2012 @@ -9,10 +9,6 @@ if(USE_DIBLIB) add_subdirectory(gdi/diblib) -endif() - -if(USE_NEW_CURSORICON) - add_definitions(-DNEW_CURSORICON) endif() add_subdirectory(gdi/gdi32) @@ -107,7 +103,6 @@ user/ntuser/class.c user/ntuser/clipboard.c user/ntuser/csr.c - user/ntuser/cursoricon.c user/ntuser/defwnd.c user/ntuser/desktop.c user/ntuser/display.c @@ -194,6 +189,13 @@ ${GENDIB_FILES}) endif() +if(USE_NEW_CURSORICON) + add_definitions(-DNEW_CURSORICON) + list(APPEND SOURCE user/ntuser/cursoricon_new.c) +else() + list(APPEND SOURCE user/ntuser/cursoricon.c) +endif() + if(ARCH STREQUAL "i386") list(APPEND SOURCE gdi/dib/i386/dib24bpp_hline.s Modified: trunk/reactos/win32ss/user/ntuser/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/cursor…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/cursoricon.c [iso-8859-1] Mon Oct 29 15:50:20 2012 @@ -237,7 +237,7 @@ IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, PPROCESSINFO ppi) { PSYSTEM_CURSORINFO CurInfo; - HBITMAP bmpMask, bmpColor, bmpAlpha; + HBITMAP bmpMask, bmpColor; BOOLEAN Ret, bListEmpty, bFound = FALSE; PCURICON_PROCESS Current = NULL; @@ -291,28 +291,21 @@ UserSetCursor(NULL, TRUE); } - bmpMask = CurIcon->aFrame[0].hbmMask; - bmpColor = CurIcon->aFrame[0].hbmColor; - bmpAlpha = CurIcon->aFrame[0].hbmAlpha; + bmpMask = CurIcon->IconInfo.hbmMask; + bmpColor = CurIcon->IconInfo.hbmColor; /* Delete bitmaps */ if (bmpMask) { GreSetObjectOwner(bmpMask, GDI_OBJ_HMGR_POWNED); GreDeleteObject(bmpMask); - CurIcon->aFrame[0].hbmMask = NULL; + CurIcon->IconInfo.hbmMask = NULL; } if (bmpColor) { GreSetObjectOwner(bmpColor, GDI_OBJ_HMGR_POWNED); GreDeleteObject(bmpColor); - CurIcon->aFrame[0].hbmColor = NULL; - } - if (bmpAlpha) - { - GreSetObjectOwner(bmpAlpha, GDI_OBJ_HMGR_POWNED); - GreDeleteObject(bmpAlpha); - CurIcon->aFrame[0].hbmAlpha = NULL; + CurIcon->IconInfo.hbmColor = NULL; } /* We were given a pointer, no need to keep the reference anylonger! */ @@ -368,21 +361,18 @@ { goto leave; } - - /* Fill data */ - ii.fIcon = CurIcon->bIcon; - ii.xHotspot = CurIcon->ptlHotspot.x; - ii.yHotspot = CurIcon->ptlHotspot.y; + + RtlCopyMemory(&ii, &CurIcon->IconInfo, sizeof(ICONINFO)); /* Copy bitmaps */ - ii.hbmMask = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmMask); - ii.hbmColor = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmColor); + ii.hbmMask = BITMAP_CopyBitmap(CurIcon->IconInfo.hbmMask); + ii.hbmColor = BITMAP_CopyBitmap(CurIcon->IconInfo.hbmColor); if (pbpp) { PSURFACE psurfBmp; - psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmColor); + psurfBmp = SURFACE_ShareLockSurface(CurIcon->IconInfo.hbmColor); if (psurfBmp) { colorBpp = BitsPerFormat(psurfBmp->SurfObj.iBitmapFormat); @@ -809,103 +799,35 @@ goto done; } -#if 0 - /* Check if we get valid information */ - if(IconInfo.fIcon != CurInfo->bIcon) - { - EngSetLastError(ERROR_INVALID_PARAMETER); - goto done; - } -#endif - /* Delete old bitmaps */ - if (CurIcon->aFrame[0].hbmColor) - GreDeleteObject(CurIcon->aFrame[0].hbmColor); - if (CurIcon->aFrame[0].hbmMask) - GreDeleteObject(CurIcon->aFrame[0].hbmMask); - if(CurIcon->aFrame[0].hbmAlpha) - GreDeleteObject(CurIcon->aFrame[0].hbmAlpha); - - /* Set fields */ - CurIcon->bIcon = IconInfo.fIcon; - CurIcon->ptlHotspot.x = IconInfo.xHotspot; - CurIcon->ptlHotspot.y = IconInfo.yHotspot; - CurIcon->aFrame[0].hbmMask = IconInfo.hbmMask; - CurIcon->aFrame[0].hbmColor = IconInfo.hbmColor; - CurIcon->aFrame[0].hbmAlpha = NULL; - - if (IconInfo.hbmColor) - { - BOOLEAN bAlpha = FALSE; - psurfBmp = SURFACE_ShareLockSurface(IconInfo.hbmColor); + if ((CurIcon->IconInfo.hbmColor) + && (CurIcon->IconInfo.hbmColor != IconInfo.hbmColor)) + { + GreDeleteObject(CurIcon->IconInfo.hbmColor); + } + if ((CurIcon->IconInfo.hbmMask) + && CurIcon->IconInfo.hbmMask != IconInfo.hbmMask) + { + GreDeleteObject(CurIcon->IconInfo.hbmMask); + } + + /* Copy new IconInfo field */ + CurIcon->IconInfo = IconInfo; + + if (CurIcon->IconInfo.hbmColor) + { + psurfBmp = SURFACE_ShareLockSurface(CurIcon->IconInfo.hbmColor); if (!psurfBmp) goto done; + CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; - - /* 32bpp bitmap is likely to have an alpha channel */ - if(psurfBmp->SurfObj.iBitmapFormat == BMF_32BPP) - { - PFN_DIB_GetPixel fn_GetPixel = DibFunctionsForBitmapFormat[BMF_32BPP].DIB_GetPixel; - INT i, j; - - fn_GetPixel = DibFunctionsForBitmapFormat[BMF_32BPP].DIB_GetPixel; - for (i = 0; i < psurfBmp->SurfObj.sizlBitmap.cx; i++) - { - for (j = 0; j < psurfBmp->SurfObj.sizlBitmap.cy; j++) - { - bAlpha = ((BYTE)(fn_GetPixel(&psurfBmp->SurfObj, i, j) >> 24)) != 0; - if (bAlpha) - break; - } - if (bAlpha) - break; - } - } - /* We're done with this one */ SURFACE_ShareUnlockSurface(psurfBmp); - GreSetObjectOwner(IconInfo.hbmColor, GDI_OBJ_HMGR_PUBLIC); - - if(bAlpha) - { - UCHAR Alpha; - PUCHAR ptr; - INT i, j; - /* Copy the bitmap */ - CurIcon->aFrame[0].hbmAlpha = BITMAP_CopyBitmap(IconInfo.hbmColor); - if(!CurIcon->aFrame[0].hbmAlpha) - { - ERR("BITMAP_CopyBitmap failed!"); - goto done; - } - - psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmAlpha); - if(!psurfBmp) - { - ERR("SURFACE_LockSurface failed!\n"); - goto done; - } - - /* Premultiply with the alpha channel value */ - for (i = 0; i < psurfBmp->SurfObj.sizlBitmap.cy; i++) - { - ptr = (PBYTE)psurfBmp->SurfObj.pvScan0 + i*psurfBmp->SurfObj.lDelta; - for (j = 0; j < psurfBmp->SurfObj.sizlBitmap.cx; j++) - { - Alpha = ptr[3]; - ptr[0] = (ptr[0] * Alpha) / 0xff; - ptr[1] = (ptr[1] * Alpha) / 0xff; - ptr[2] = (ptr[2] * Alpha) / 0xff; - ptr += 4; - } - } - SURFACE_ShareUnlockSurface(psurfBmp); - GreSetObjectOwner(CurIcon->aFrame[0].hbmAlpha, GDI_OBJ_HMGR_PUBLIC); - } + GreSetObjectOwner(CurIcon->IconInfo.hbmColor, GDI_OBJ_HMGR_PUBLIC); } else { - psurfBmp = SURFACE_ShareLockSurface(IconInfo.hbmMask); + psurfBmp = SURFACE_ShareLockSurface(CurIcon->IconInfo.hbmMask); if (!psurfBmp) goto done; @@ -914,17 +836,11 @@ SURFACE_ShareUnlockSurface(psurfBmp); } - GreSetObjectOwner(IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); + GreSetObjectOwner(CurIcon->IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); Ret = TRUE; done: - - if(!Ret) - { - IntDestroyCurIconObject(CurIcon, PsGetCurrentProcessWin32Process()); - CurIcon = NULL; - } if (CurIcon) { @@ -942,21 +858,20 @@ /* * @implemented */ -#ifdef NEW_CURSORICON +#if 0 BOOL APIENTRY NtUserSetCursorIconData( - _In_ HCURSOR Handle, - _In_ HINSTANCE hinst, - _In_ HRSRC hrsrc, - _In_ PICONINFO pIconInfo) + HANDLE Handle, + HMODULE hModule, + PUNICODE_STRING pstrResName, + PICONINFO pIconInfo) { PCURICON_OBJECT CurIcon; PSURFACE psurfBmp; NTSTATUS Status = STATUS_SUCCESS; BOOL Ret = FALSE; DECLARE_RETURN(BOOL); - ICONINFO ii; TRACE("Enter NtUserSetCursorIconData\n"); UserEnterExclusive(); @@ -966,96 +881,54 @@ RETURN(FALSE); } - CurIcon->hModule = hinst; - CurIcon->hRsrc =hrsrc; + CurIcon->hModule = hModule; + CurIcon->hRsrc = NULL; //hRsrc; + CurIcon->hGroupRsrc = NULL; //hGroupRsrc; _SEH2_TRY { ProbeForRead(pIconInfo, sizeof(ICONINFO), 1); - ii = *pIconInfo; + RtlCopyMemory(&CurIcon->IconInfo, pIconInfo, sizeof(ICONINFO)); + + CurIcon->IconInfo.hbmMask = BITMAP_CopyBitmap(pIconInfo->hbmMask); + CurIcon->IconInfo.hbmColor = BITMAP_CopyBitmap(pIconInfo->hbmColor); + + if (CurIcon->IconInfo.hbmColor) + { + if ((psurfBmp = SURFACE_LockSurface(CurIcon->IconInfo.hbmColor))) + { + CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; + CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; + SURFACE_UnlockSurface(psurfBmp); + GreSetObjectOwner(CurIcon->IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); + } + } + if (CurIcon->IconInfo.hbmMask) + { + if (CurIcon->IconInfo.hbmColor == NULL) + { + if ((psurfBmp = SURFACE_LockSurface(CurIcon->IconInfo.hbmMask))) + { + CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; + CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; + SURFACE_UnlockSurface(psurfBmp); + } + } + GreSetObjectOwner(CurIcon->IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); + } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END - + if (!NT_SUCCESS(Status)) - { SetLastNtError(Status); - goto done; - } - - /* This is probably not what windows does, but consistency checks can't hurt */ - if(CurIcon->bIcon != ii.fIcon) - { - EngSetLastError(ERROR_INVALID_PARAMETER); - goto done; - } - CurIcon->ptlHotspot.x = ii.xHotspot; - CurIcon->ptlHotspot.y = ii.yHotspot; - - if(!ii.hbmMask) - { - EngSetLastError(ERROR_INVALID_PARAMETER); - goto done; - } - - CurIcon->aFrame[0].hbmMask = BITMAP_CopyBitmap(ii.hbmMask); - if(!CurIcon->aFrame[0].hbmMask) - goto done; - - if(ii.hbmColor) - { - CurIcon->aFrame[0].hbmColor = BITMAP_CopyBitmap(ii.hbmColor); - if(!CurIcon->aFrame[0].hbmColor) - goto done; - } - - if (CurIcon->aFrame[0].hbmColor) - { - if ((psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmColor))) - { - CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; - CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; - SURFACE_ShareUnlockSurface(psurfBmp); - GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); - } - else - goto done; - } else - { - if ((psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmMask))) - { - CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; - CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy/2; - SURFACE_ShareUnlockSurface(psurfBmp); - } - else - goto done; - } - GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); - - Ret = TRUE; - -done: + Ret = TRUE; + UserDereferenceObject(CurIcon); - if(!Ret) - { - if (CurIcon->aFrame[0].hbmMask) - { - GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_POWNED); - GreDeleteObject(CurIcon->aFrame[0].hbmMask); - CurIcon->aFrame[0].hbmMask = NULL; - } - if (CurIcon->aFrame[0].hbmColor) - { - GreSetObjectOwner(CurIcon->aFrame[0].hbmColor, GDI_OBJ_HMGR_POWNED); - GreDeleteObject(CurIcon->aFrame[0].hbmColor); - CurIcon->aFrame[0].hbmColor = NULL; - } - } RETURN(Ret); CLEANUP: @@ -1076,6 +949,7 @@ { PCURICON_OBJECT CurIcon; NTSTATUS Status; + POINT SafeHotspot; BOOL Ret = FALSE; DECLARE_RETURN(BOOL); @@ -1094,7 +968,7 @@ /* Copy fields */ if (fIcon) { - Status = MmCopyFromCaller(&CurIcon->bIcon, fIcon, sizeof(BOOL)); + Status = MmCopyFromCaller(&CurIcon->IconInfo.fIcon, fIcon, sizeof(BOOL)); if (!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -1109,12 +983,16 @@ if (Hotspot) { - Status = MmCopyFromCaller(&CurIcon->ptlHotspot, Hotspot, sizeof(POINT)); - if (!NT_SUCCESS(Status)) - { + 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); - goto done; - } } if (!fIcon && !Hotspot) @@ -1126,14 +1004,10 @@ if(Ret) { /* This icon is shared now */ - GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); - if(CurIcon->aFrame[0].hbmColor) + GreSetObjectOwner(CurIcon->IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); + if(CurIcon->IconInfo.hbmColor) { - GreSetObjectOwner(CurIcon->aFrame[0].hbmColor, GDI_OBJ_HMGR_PUBLIC); - } - if(CurIcon->aFrame[0].hbmAlpha) - { - GreSetObjectOwner(CurIcon->aFrame[0].hbmAlpha, GDI_OBJ_HMGR_PUBLIC); + GreSetObjectOwner(CurIcon->IconInfo.hbmColor, GDI_OBJ_HMGR_PUBLIC); } } UserDereferenceObject(CurIcon); @@ -1170,8 +1044,8 @@ PSURFACE psurfDest, psurfMask, psurfColor, psurfOffScreen; PDC pdc = NULL; BOOL Ret = FALSE; - HBITMAP hbmMask, hbmColor, hbmAlpha; - BOOL bOffScreen; + HBITMAP hbmMask, hbmColor; + BOOL bOffScreen, bAlpha = FALSE; RECTL rcDest, rcSrc; CLIPOBJ* pdcClipObj = NULL; EXLATEOBJ exlo; @@ -1183,9 +1057,8 @@ return FALSE; } - hbmMask = pIcon->aFrame[0].hbmMask; - hbmColor = pIcon->aFrame[0].hbmColor; - hbmAlpha = pIcon->aFrame[0].hbmAlpha; + hbmMask = pIcon->IconInfo.hbmMask; + hbmColor = pIcon->IconInfo.hbmColor; if (istepIfAniCur) ERR("NtUserDrawIconEx: istepIfAniCur is not supported!\n"); @@ -1218,11 +1091,35 @@ /* Set source rect */ RECTL_vSetRect(&rcSrc, 0, 0, pIcon->Size.cx, pIcon->Size.cy); + /* Check for alpha */ + if (psurfColor && + (psurfColor->SurfObj.iBitmapFormat == BMF_32BPP) && + (diFlags & DI_IMAGE)) + { + PFN_DIB_GetPixel fnSource_GetPixel = NULL; + INT i, j; + + /* In order to correctly display 32 bit icons Windows first scans the image, + because information about transparency is not stored in any image's headers */ + fnSource_GetPixel = DibFunctionsForBitmapFormat[BMF_32BPP].DIB_GetPixel; + for (i = 0; i < psurfColor->SurfObj.sizlBitmap.cx; i++) + { + for (j = 0; j < psurfColor->SurfObj.sizlBitmap.cy; j++) + { + bAlpha = ((BYTE)(fnSource_GetPixel(&psurfColor->SurfObj, i, j) >> 24) & 0xff); + if (bAlpha) + break; + } + if (bAlpha) + break; + } + } + /* Fix width parameter, if needed */ if (!cxWidth) { if(diFlags & DI_DEFAULTSIZE) - cxWidth = pIcon->bIcon ? + cxWidth = pIcon->IconInfo.fIcon ? UserGetSystemMetrics(SM_CXICON) : UserGetSystemMetrics(SM_CXCURSOR); else cxWidth = pIcon->Size.cx; @@ -1232,7 +1129,7 @@ if (!cyHeight) { if(diFlags & DI_DEFAULTSIZE) - cyHeight = pIcon->bIcon ? + cyHeight = pIcon->IconInfo.fIcon ? UserGetSystemMetrics(SM_CYICON) : UserGetSystemMetrics(SM_CYCURSOR); else cyHeight = pIcon->Size.cy; @@ -1341,16 +1238,42 @@ } /* Now do the rendering */ - if(hbmAlpha && (diFlags & DI_IMAGE)) + if(bAlpha && (diFlags & DI_IMAGE)) { BLENDOBJ blendobj = { {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA } }; + BYTE Alpha; + INT i, j; PSURFACE psurf = NULL; - - psurf = SURFACE_ShareLockSurface(hbmAlpha); + PBYTE ptr ; + HBITMAP hsurfCopy = NULL; + + hsurfCopy = BITMAP_CopyBitmap(hbmColor); + if(!hsurfCopy) + { + ERR("BITMAP_CopyBitmap failed!"); + goto CleanupAlpha; + } + + psurf = SURFACE_ShareLockSurface(hsurfCopy); if(!psurf) { ERR("SURFACE_LockSurface failed!\n"); - goto NoAlpha; + goto CleanupAlpha; + } + + /* Premultiply with the alpha channel value */ + for (i = 0; i < psurf->SurfObj.sizlBitmap.cy; i++) + { + ptr = (PBYTE)psurf->SurfObj.pvScan0 + i*psurf->SurfObj.lDelta; + for (j = 0; j < psurf->SurfObj.sizlBitmap.cx; j++) + { + Alpha = ptr[3]; + ptr[0] = (ptr[0] * Alpha) / 0xff; + ptr[1] = (ptr[1] * Alpha) / 0xff; + ptr[2] = (ptr[2] * Alpha) / 0xff; + + ptr += 4; + } } /* Initialize color translation object */ @@ -1366,11 +1289,14 @@ &blendobj); EXLATEOBJ_vCleanup(&exlo); - SURFACE_ShareUnlockSurface(psurf); - if(Ret) goto done; + + CleanupAlpha: + if(psurf) SURFACE_ShareUnlockSurface(psurf); + if(hsurfCopy) NtGdiDeleteObjectApp(hsurfCopy); + if(Ret) goto done; ERR("NtGdiAlphaBlend failed!\n"); } -NoAlpha: + if (diFlags & DI_MASK) { DWORD rop4 = (diFlags & DI_IMAGE) ? ROP4_SRCAND : ROP4_SRCCOPY; Modified: trunk/reactos/win32ss/user/ntuser/cursoricon.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/cursor…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/cursoricon.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/cursoricon.h [iso-8859-1] Mon Oct 29 15:50:20 2012 @@ -8,6 +8,7 @@ PPROCESSINFO Process; } CURICON_PROCESS, *PCURICON_PROCESS; +#ifdef NEW_CURSORICON typedef struct _CURICON_FRAME { HBITMAP hbmMask; @@ -23,15 +24,29 @@ LIST_ENTRY ProcessList; HMODULE hModule; HRSRC hRsrc; -#ifndef NEW_CURSORICON - HRSRC hGroupRsrc; -#endif SIZE Size; BYTE Shadow; BOOL bIcon; POINTL ptlHotspot; CURICON_FRAME aFrame[1]; } CURICON_OBJECT, *PCURICON_OBJECT; + +#else + +typedef struct _CURICON_OBJECT +{ + PROCMARKHEAD head; + LIST_ENTRY ListEntry; + HANDLE Self; + LIST_ENTRY ProcessList; + HMODULE hModule; + HRSRC hRsrc; + HRSRC hGroupRsrc; + SIZE Size; + BYTE Shadow; + ICONINFO IconInfo; +} CURICON_OBJECT, *PCURICON_OBJECT; +#endif typedef struct _CURSORACCELERATION_INFO { Added: trunk/reactos/win32ss/user/ntuser/cursoricon_new.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/cursor…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/cursoricon_new.c (added) +++ trunk/reactos/win32ss/user/ntuser/cursoricon_new.c [iso-8859-1] Mon Oct 29 15:50:20 2012 @@ -1,0 +1,1578 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS Win32k subsystem + * PURPOSE: Cursor and icon functions + * FILE: subsystems/win32/win32k/ntuser/cursoricon.c + * 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 + * There's a M:N relationship between processes and (shared) cursor/icons. + * A process can have multiple cursor/icons and a cursor/icon can be used + * by multiple processes. To keep track of this we keep a list of all + * cursor/icons (CurIconList) and per cursor/icon we keep a list of + * CURICON_PROCESS structs starting at CurIcon->ProcessList. + */ + +#include <win32k.h> +DBG_DEFAULT_CHANNEL(UserIcon); + +static PPAGED_LOOKASIDE_LIST pgProcessLookasideList; +static LIST_ENTRY gCurIconList; + +SYSTEM_CURSORINFO gSysCursorInfo; + +BOOL +InitCursorImpl() +{ + pgProcessLookasideList = ExAllocatePool(NonPagedPool, sizeof(PAGED_LOOKASIDE_LIST)); + if(!pgProcessLookasideList) + return FALSE; + + ExInitializePagedLookasideList(pgProcessLookasideList, + NULL, + NULL, + 0, + sizeof(CURICON_PROCESS), + TAG_DIB, + 128); + InitializeListHead(&gCurIconList); + + gSysCursorInfo.Enabled = FALSE; + gSysCursorInfo.ButtonsDown = 0; + gSysCursorInfo.bClipped = FALSE; + gSysCursorInfo.LastBtnDown = 0; + gSysCursorInfo.CurrentCursorObject = NULL; + gSysCursorInfo.ShowingCursor = -1; + gSysCursorInfo.ClickLockActive = FALSE; + gSysCursorInfo.ClickLockTime = 0; + + return TRUE; +} + +PSYSTEM_CURSORINFO +IntGetSysCursorInfo() +{ + return &gSysCursorInfo; +} + +/* 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; + } + + CurIcon = (PCURICON_OBJECT)UserReferenceObjectByHandle(hCurIcon, otCursorIcon); + 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; +} + +/* + * We have to register that this object is in use by the current + * process. The only way to do that seems to be to walk the list + * of cursor/icon objects starting at W32Process->CursorIconListHead. + * If the object is already present in the list, we don't have to do + * anything, if it's not present we add it and inc the ProcessCount + * in the object. Having to walk the list kind of sucks, but that's + * life... + */ +static BOOLEAN FASTCALL +ReferenceCurIconByProcess(PCURICON_OBJECT CurIcon) +{ + PPROCESSINFO Win32Process; + PCURICON_PROCESS Current; + + Win32Process = PsGetCurrentProcessWin32Process(); + + LIST_FOR_EACH(Current, &CurIcon->ProcessList, CURICON_PROCESS, ListEntry) + { + if (Current->Process == Win32Process) + { + /* Already registered for this process */ + return TRUE; + } + } + + /* Not registered yet */ + Current = ExAllocateFromPagedLookasideList(pgProcessLookasideList); + if (NULL == Current) + { + return FALSE; + } + InsertHeadList(&CurIcon->ProcessList, &Current->ListEntry); + Current->Process = Win32Process; + + return TRUE; +} + +PCURICON_OBJECT FASTCALL +IntFindExistingCurIconObject(HMODULE hModule, + HRSRC hRsrc, LONG cx, LONG cy) +{ + PCURICON_OBJECT CurIcon; + + LIST_FOR_EACH(CurIcon, &gCurIconList, CURICON_OBJECT, ListEntry) + { + + // if (NT_SUCCESS(UserReferenceObjectByPointer(Object, otCursorIcon))) // <- huh???? +// UserReferenceObject( CurIcon); +// { + if ((CurIcon->hModule == hModule) && (CurIcon->hRsrc == hRsrc)) + { + if (cx && ((cx != CurIcon->Size.cx) || (cy != CurIcon->Size.cy))) + { +// UserDereferenceObject(CurIcon); + continue; + } + if (! ReferenceCurIconByProcess(CurIcon)) + { + return NULL; + } + + return CurIcon; + } +// } +// UserDereferenceObject(CurIcon); + + } + + return NULL; +} + +PCURICON_OBJECT +IntCreateCurIconHandle() +{ + PCURICON_OBJECT CurIcon; + HANDLE hCurIcon; + + CurIcon = UserCreateObject(gHandleTable, NULL, NULL, &hCurIcon, otCursorIcon, sizeof(CURICON_OBJECT)); + + if (!CurIcon) + { + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + CurIcon->Self = hCurIcon; + InitializeListHead(&CurIcon->ProcessList); + + if (! ReferenceCurIconByProcess(CurIcon)) + { + ERR("Failed to add process\n"); + UserDeleteObject(hCurIcon, otCursorIcon); + UserDereferenceObject(CurIcon); + return NULL; + } + + InsertHeadList(&gCurIconList, &CurIcon->ListEntry); + + return CurIcon; +} + +BOOLEAN FASTCALL +IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, PPROCESSINFO ppi) +{ + PSYSTEM_CURSORINFO CurInfo; + HBITMAP bmpMask, bmpColor, bmpAlpha; + BOOLEAN Ret, bListEmpty, bFound = FALSE; + PCURICON_PROCESS Current = NULL; + + /* For handles created without any data (error handling) */ + if(IsListEmpty(&CurIcon->ProcessList)) + goto emptyList; + + /* Now find this process in the list of processes referencing this object and + remove it from that list */ + LIST_FOR_EACH(Current, &CurIcon->ProcessList, CURICON_PROCESS, ListEntry) + { + if (Current->Process == ppi) + { + bFound = TRUE; + bListEmpty = RemoveEntryList(&Current->ListEntry); + break; + } + } + + if(!bFound) + { + /* This object doesn't belong to this process */ + EngSetLastError(ERROR_INVALID_HANDLE); + return FALSE; + } + + ExFreeToPagedLookasideList(pgProcessLookasideList, Current); + + /* If there are still processes referencing this object we can't destroy it yet */ + if (!bListEmpty) + { + if(CurIcon->head.ppi == ppi) + { + /* Set the first process of the list as owner */ + Current = CONTAINING_RECORD(CurIcon->ProcessList.Flink, CURICON_PROCESS, ListEntry); + UserSetObjectOwner(CurIcon, otCursorIcon, Current->Process); + } + UserDereferenceObject(CurIcon); + return TRUE; + } + +emptyList: + /* Remove it from the list */ + RemoveEntryList(&CurIcon->ListEntry); + + CurInfo = IntGetSysCursorInfo(); + + if (CurInfo->CurrentCursorObject == CurIcon) + { + /* Hide the cursor if we're destroying the current cursor */ + UserSetCursor(NULL, TRUE); + } + + bmpMask = CurIcon->aFrame[0].hbmMask; + bmpColor = CurIcon->aFrame[0].hbmColor; + bmpAlpha = CurIcon->aFrame[0].hbmAlpha; + + /* Delete bitmaps */ + if (bmpMask) + { + GreSetObjectOwner(bmpMask, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(bmpMask); + CurIcon->aFrame[0].hbmMask = NULL; + } + if (bmpColor) + { + GreSetObjectOwner(bmpColor, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(bmpColor); + CurIcon->aFrame[0].hbmColor = NULL; + } + if (bmpAlpha) + { + GreSetObjectOwner(bmpAlpha, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(bmpAlpha); + CurIcon->aFrame[0].hbmAlpha = NULL; + } + + /* We were given a pointer, no need to keep the reference anylonger! */ + UserDereferenceObject(CurIcon); + Ret = UserDeleteObject(CurIcon->Self, otCursorIcon); + + return Ret; +} + +VOID FASTCALL +IntCleanupCurIcons(struct _EPROCESS *Process, PPROCESSINFO Win32Process) +{ + PCURICON_OBJECT CurIcon, tmp; + + /* Run through the list of icon objects */ + LIST_FOR_EACH_SAFE(CurIcon, tmp, &gCurIconList, CURICON_OBJECT, ListEntry) + { + UserReferenceObject(CurIcon); + IntDestroyCurIconObject(CurIcon, Win32Process); + } +} + + +/* + * @implemented + */ +BOOL +APIENTRY +NtUserGetIconInfo( + HANDLE hCurIcon, + PICONINFO IconInfo, + PUNICODE_STRING lpInstName, // Optional + PUNICODE_STRING lpResName, // Optional + LPDWORD pbpp, // Optional + BOOL bInternal) +{ + ICONINFO ii; + PCURICON_OBJECT CurIcon; + NTSTATUS Status = STATUS_SUCCESS; + BOOL Ret = FALSE; + DWORD colorBpp = 0; + + TRACE("Enter NtUserGetIconInfo\n"); + UserEnterExclusive(); + + if (!IconInfo) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + goto leave; + } + + if (!(CurIcon = UserGetCurIconObject(hCurIcon))) + { + goto leave; + } + + /* Fill data */ + ii.fIcon = CurIcon->bIcon; + ii.xHotspot = CurIcon->ptlHotspot.x; + ii.yHotspot = CurIcon->ptlHotspot.y; + + /* Copy bitmaps */ + ii.hbmMask = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmMask); + ii.hbmColor = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmColor); + + if (pbpp) + { + PSURFACE psurfBmp; + + psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmColor); + if (psurfBmp) + { + colorBpp = BitsPerFormat(psurfBmp->SurfObj.iBitmapFormat); + SURFACE_ShareUnlockSurface(psurfBmp); + } + } + + /* Copy fields */ + _SEH2_TRY + { + 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(); + } + _SEH2_END + + if (NT_SUCCESS(Status)) + Ret = TRUE; + else + SetLastNtError(Status); + + UserDereferenceObject(CurIcon); + +leave: + 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; + } + + _SEH2_TRY + { + ProbeForWrite(plcx, sizeof(LONG), 1); + RtlCopyMemory(plcx, &CurIcon->Size.cx, sizeof(LONG)); + ProbeForWrite(plcy, sizeof(LONG), 1); + RtlCopyMemory(plcy, &CurIcon->Size.cy, sizeof(LONG)); + } + _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); + SafeCi.hCursor = (CurIcon ? (HCURSOR)CurIcon->Self : (HCURSOR)0); + + 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; + } + + UserEnterExclusive(); + + /* Call the internal function */ + bResult = UserClipCursor(prcl); + + UserLeave(); + + return bResult; +} + + +/* + * @implemented + */ +BOOL +APIENTRY +NtUserDestroyCursor( + HANDLE hCurIcon, + DWORD Unknown) +{ + PCURICON_OBJECT CurIcon; + BOOL ret; + DECLARE_RETURN(BOOL); + + TRACE("Enter NtUserDestroyCursorIcon\n"); + UserEnterExclusive(); + + if (!(CurIcon = UserGetCurIconObject(hCurIcon))) + { + RETURN(FALSE); + } + + ret = IntDestroyCurIconObject(CurIcon, PsGetCurrentProcessWin32Process()); + /* Note: IntDestroyCurIconObject will remove our reference for us! */ + + RETURN(ret); + +CLEANUP: + TRACE("Leave NtUserDestroyCursorIcon, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + +/* + * @implemented + */ +HICON +APIENTRY +NtUserFindExistingCursorIcon( + HMODULE hModule, + HRSRC hRsrc, + LONG cx, + LONG cy) +{ + PCURICON_OBJECT CurIcon; + HANDLE Ret = (HANDLE)0; + DECLARE_RETURN(HICON); + + TRACE("Enter NtUserFindExistingCursorIcon\n"); + UserEnterExclusive(); + + CurIcon = IntFindExistingCurIconObject(hModule, hRsrc, cx, cy); + if (CurIcon) + { + Ret = CurIcon->Self; + +// IntReleaseCurIconObject(CurIcon); // FIXME: Is this correct? Does IntFindExistingCurIconObject add a ref? + RETURN(Ret); + } + + EngSetLastError(ERROR_INVALID_CURSOR_HANDLE); + RETURN((HANDLE)0); + +CLEANUP: + TRACE("Leave NtUserFindExistingCursorIcon, ret=%p\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + +/* + * @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; + + TRACE("Enter NtUserSetCursor\n"); + UserEnterExclusive(); + + if (hCursor) + { + pcurNew = UserGetCurIconObject(hCursor); + if (!pcurNew) + { + EngSetLastError(ERROR_INVALID_CURSOR_HANDLE); + goto leave; + } + } + else + { + pcurNew = NULL; + } + + pcurOld = UserSetCursor(pcurNew, FALSE); + if (pcurOld) + { + hOldCursor = (HCURSOR)pcurOld->Self; + UserDereferenceObject(pcurOld); + } + +leave: + UserLeave(); + return hOldCursor; +} + + +/* + * @implemented + */ +BOOL +APIENTRY +NtUserSetCursorContents( + HANDLE hCurIcon, + PICONINFO UnsafeIconInfo) +{ + PCURICON_OBJECT CurIcon; + ICONINFO IconInfo; + PSURFACE psurfBmp; + NTSTATUS Status; + BOOL Ret = FALSE; + DECLARE_RETURN(BOOL); + + TRACE("Enter NtUserSetCursorContents\n"); + UserEnterExclusive(); + + if (!(CurIcon = UserGetCurIconObject(hCurIcon))) + { + RETURN(FALSE); + } + + /* Copy fields */ + Status = MmCopyFromCaller(&IconInfo, UnsafeIconInfo, sizeof(ICONINFO)); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + goto done; + } + +#if 0 + /* Check if we get valid information */ + if(IconInfo.fIcon != CurInfo->bIcon) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + goto done; + } +#endif + + /* Delete old bitmaps */ + if (CurIcon->aFrame[0].hbmColor) + GreDeleteObject(CurIcon->aFrame[0].hbmColor); + if (CurIcon->aFrame[0].hbmMask) + GreDeleteObject(CurIcon->aFrame[0].hbmMask); + if(CurIcon->aFrame[0].hbmAlpha) + GreDeleteObject(CurIcon->aFrame[0].hbmAlpha); + + /* Set fields */ + CurIcon->bIcon = IconInfo.fIcon; + CurIcon->ptlHotspot.x = IconInfo.xHotspot; + CurIcon->ptlHotspot.y = IconInfo.yHotspot; + CurIcon->aFrame[0].hbmMask = IconInfo.hbmMask; + CurIcon->aFrame[0].hbmColor = IconInfo.hbmColor; + CurIcon->aFrame[0].hbmAlpha = NULL; + + if (IconInfo.hbmColor) + { + BOOLEAN bAlpha = FALSE; + psurfBmp = SURFACE_ShareLockSurface(IconInfo.hbmColor); + if (!psurfBmp) + goto done; + CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; + CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; + + /* 32bpp bitmap is likely to have an alpha channel */ + if(psurfBmp->SurfObj.iBitmapFormat == BMF_32BPP) + { + PFN_DIB_GetPixel fn_GetPixel = DibFunctionsForBitmapFormat[BMF_32BPP].DIB_GetPixel; + INT i, j; + + fn_GetPixel = DibFunctionsForBitmapFormat[BMF_32BPP].DIB_GetPixel; + for (i = 0; i < psurfBmp->SurfObj.sizlBitmap.cx; i++) + { + for (j = 0; j < psurfBmp->SurfObj.sizlBitmap.cy; j++) + { + bAlpha = ((BYTE)(fn_GetPixel(&psurfBmp->SurfObj, i, j) >> 24)) != 0; + if (bAlpha) + break; + } + if (bAlpha) + break; + } + } + /* We're done with this one */ + SURFACE_ShareUnlockSurface(psurfBmp); + GreSetObjectOwner(IconInfo.hbmColor, GDI_OBJ_HMGR_PUBLIC); + + if(bAlpha) + { + UCHAR Alpha; + PUCHAR ptr; + INT i, j; + /* Copy the bitmap */ + CurIcon->aFrame[0].hbmAlpha = BITMAP_CopyBitmap(IconInfo.hbmColor); + if(!CurIcon->aFrame[0].hbmAlpha) + { + ERR("BITMAP_CopyBitmap failed!"); + goto done; + } + + psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmAlpha); + if(!psurfBmp) + { + ERR("SURFACE_LockSurface failed!\n"); + goto done; + } + + /* Premultiply with the alpha channel value */ + for (i = 0; i < psurfBmp->SurfObj.sizlBitmap.cy; i++) + { + ptr = (PBYTE)psurfBmp->SurfObj.pvScan0 + i*psurfBmp->SurfObj.lDelta; + for (j = 0; j < psurfBmp->SurfObj.sizlBitmap.cx; j++) + { + Alpha = ptr[3]; + ptr[0] = (ptr[0] * Alpha) / 0xff; + ptr[1] = (ptr[1] * Alpha) / 0xff; + ptr[2] = (ptr[2] * Alpha) / 0xff; + ptr += 4; + } + } + SURFACE_ShareUnlockSurface(psurfBmp); + GreSetObjectOwner(CurIcon->aFrame[0].hbmAlpha, GDI_OBJ_HMGR_PUBLIC); + } + } + else + { + psurfBmp = SURFACE_ShareLockSurface(IconInfo.hbmMask); + if (!psurfBmp) + goto done; + + CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; + CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy / 2; + + SURFACE_ShareUnlockSurface(psurfBmp); + } + GreSetObjectOwner(IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); + + Ret = TRUE; + +done: + + if(!Ret) + { + IntDestroyCurIconObject(CurIcon, PsGetCurrentProcessWin32Process()); + CurIcon = NULL; + } + + if (CurIcon) + { + UserDereferenceObject(CurIcon); + } + RETURN(Ret); + +CLEANUP: + TRACE("Leave NtUserSetCursorContents, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} + + +/* + * @implemented + */ +#ifdef NEW_CURSORICON +BOOL +APIENTRY +NtUserSetCursorIconData( + _In_ HCURSOR Handle, + _In_ HINSTANCE hinst, + _In_ HRSRC hrsrc, + _In_ PICONINFO pIconInfo) +{ + PCURICON_OBJECT CurIcon; + PSURFACE psurfBmp; + NTSTATUS Status = STATUS_SUCCESS; + BOOL Ret = FALSE; + DECLARE_RETURN(BOOL); + ICONINFO ii; + + TRACE("Enter NtUserSetCursorIconData\n"); + UserEnterExclusive(); + + if (!(CurIcon = UserGetCurIconObject(Handle))) + { + RETURN(FALSE); + } + + CurIcon->hModule = hinst; + CurIcon->hRsrc =hrsrc; + + _SEH2_TRY + { + ProbeForRead(pIconInfo, sizeof(ICONINFO), 1); + ii = *pIconInfo; + } + _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) + { + Status = _SEH2_GetExceptionCode(); + } + _SEH2_END + + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + goto done; + } + + /* This is probably not what windows does, but consistency checks can't hurt */ + if(CurIcon->bIcon != ii.fIcon) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + goto done; + } + CurIcon->ptlHotspot.x = ii.xHotspot; + CurIcon->ptlHotspot.y = ii.yHotspot; + + if(!ii.hbmMask) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + goto done; + } + + CurIcon->aFrame[0].hbmMask = BITMAP_CopyBitmap(ii.hbmMask); + if(!CurIcon->aFrame[0].hbmMask) + goto done; + + if(ii.hbmColor) + { + CurIcon->aFrame[0].hbmColor = BITMAP_CopyBitmap(ii.hbmColor); + if(!CurIcon->aFrame[0].hbmColor) + goto done; + } + + if (CurIcon->aFrame[0].hbmColor) + { + if ((psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmColor))) + { + CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; + CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; + SURFACE_ShareUnlockSurface(psurfBmp); + GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); + } + else + goto done; + } + else + { + if ((psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmMask))) + { + CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; + CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy/2; + SURFACE_ShareUnlockSurface(psurfBmp); + } + else + goto done; + } + GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); + + Ret = TRUE; + +done: + UserDereferenceObject(CurIcon); + if(!Ret) + { + if (CurIcon->aFrame[0].hbmMask) + { + GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(CurIcon->aFrame[0].hbmMask); + CurIcon->aFrame[0].hbmMask = NULL; + } + if (CurIcon->aFrame[0].hbmColor) + { + GreSetObjectOwner(CurIcon->aFrame[0].hbmColor, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(CurIcon->aFrame[0].hbmColor); + CurIcon->aFrame[0].hbmColor = NULL; + } + } + RETURN(Ret); + +CLEANUP: + TRACE("Leave NtUserSetCursorIconData, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} +#else +BOOL +APIENTRY +NtUserSetCursorIconData( + HANDLE hCurIcon, + PBOOL fIcon, + POINT *Hotspot, + HMODULE hModule, + HRSRC hRsrc, + HRSRC hGroupRsrc) +{ + PCURICON_OBJECT CurIcon; + NTSTATUS Status; + BOOL Ret = FALSE; + DECLARE_RETURN(BOOL); + + TRACE("Enter NtUserSetCursorIconData\n"); + UserEnterExclusive(); + + if (!(CurIcon = UserGetCurIconObject(hCurIcon))) + { + RETURN(FALSE); + } + + CurIcon->hModule = hModule; + CurIcon->hRsrc = hRsrc; + CurIcon->hGroupRsrc = hGroupRsrc; + + /* Copy fields */ + if (fIcon) + { + Status = MmCopyFromCaller(&CurIcon->bIcon, fIcon, sizeof(BOOL)); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + goto done; + } + } + else + { + if (!Hotspot) + Ret = TRUE; + } + + if (Hotspot) + { + Status = MmCopyFromCaller(&CurIcon->ptlHotspot, Hotspot, sizeof(POINT)); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + goto done; + } + } + + if (!fIcon && !Hotspot) + { + Ret = TRUE; + } + +done: + if(Ret) + { + /* This icon is shared now */ + GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); + if(CurIcon->aFrame[0].hbmColor) + { + GreSetObjectOwner(CurIcon->aFrame[0].hbmColor, GDI_OBJ_HMGR_PUBLIC); + } + if(CurIcon->aFrame[0].hbmAlpha) + { + GreSetObjectOwner(CurIcon->aFrame[0].hbmAlpha, GDI_OBJ_HMGR_PUBLIC); + } + } + UserDereferenceObject(CurIcon); + RETURN(Ret); + + +CLEANUP: + TRACE("Leave NtUserSetCursorIconData, ret=%i\n",_ret_); + UserLeave(); + END_CLEANUP; +} +#endif + +/* 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) +{ + PSURFACE psurfDest, psurfMask, psurfColor, psurfOffScreen; + 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; + } + + hbmMask = pIcon->aFrame[0].hbmMask; + hbmColor = pIcon->aFrame[0].hbmColor; + hbmAlpha = pIcon->aFrame[0].hbmAlpha; + + if (istepIfAniCur) + ERR("NtUserDrawIconEx: istepIfAniCur is not supported!\n"); + + /* + * 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 */ + ASSERT(psurfMask->SurfObj.sizlBitmap.cy == 2*pIcon->Size.cy); + psurfColor = NULL; + } + else if ((psurfColor = SURFACE_ShareLockSurface(hbmColor)) == NULL) + { + ERR("Unable to lock the color bitmap.\n"); + SURFACE_ShareUnlockSurface(psurfMask); + return FALSE; + } + + /* Set source rect */ + RECTL_vSetRect(&rcSrc, 0, 0, pIcon->Size.cx, pIcon->Size.cy); + + /* Fix width parameter, if needed */ + if (!cxWidth) + { + if(diFlags & DI_DEFAULTSIZE) + cxWidth = pIcon->bIcon ? + UserGetSystemMetrics(SM_CXICON) : UserGetSystemMetrics(SM_CXCURSOR); + else + cxWidth = pIcon->Size.cx; + } + + /* Fix height parameter, if needed */ + if (!cyHeight) + { + if(diFlags & DI_DEFAULTSIZE) + cyHeight = pIcon->bIcon ? + UserGetSystemMetrics(SM_CYICON) : UserGetSystemMetrics(SM_CYCURSOR); + else + cyHeight = pIcon->Size.cy; + } + + /* Should we render off-screen? */ + bOffScreen = hbrFlickerFreeDraw && (GDI_HANDLE_GET_TYPE(hbrFlickerFreeDraw) == GDI_OBJECT_TYPE_BRUSH); + + 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"); + SURFACE_ShareUnlockSurface(psurfMask); + if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor); + return FALSE; + } + + psurfOffScreen = SURFACE_AllocSurface(STYPE_BITMAP, + cxWidth, cyHeight, psurfColor->SurfObj.iBitmapFormat, + 0, 0, NULL); + if(!psurfOffScreen) + { + ERR("Failed to allocate the off-screen surface.\n"); + SURFACE_ShareUnlockSurface(psurfMask); + if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor); + BRUSH_ShareUnlockBrush(pbrush); + return FALSE; + } + + /* 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"); + SURFACE_ShareUnlockSurface(psurfMask); + if(psurfColor) SURFACE_ShareUnlockSurface(psurfColor); + GDIOBJ_vDeleteObject(&psurfOffScreen->BaseObject); + return FALSE; + } + + /* We now have our destination surface */ + psurfDest = psurfOffScreen; + } + else + { + /* We directly draw to the DC */ + TRACE("Performing on screen rendering.\n"); + + psurfOffScreen = NULL; + 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 */ + DC_vPrepareDCsForBlit(pdc, rcDest, NULL, rcDest); + + /* Get the clip object */ + pdcClipObj = pdc->rosdc.CombinedClip; + + /* 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; + } + } + + /* Now do the rendering */ + if(hbmAlpha && (diFlags & DI_IMAGE)) + { + BLENDOBJ blendobj = { {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA } }; + 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; + ERR("NtGdiAlphaBlend failed!\n"); + } +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) + { + if (psurfColor) + { + 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; + RECTL_vOffsetRect(&rcSrc, 0, pIcon->Size.cy); + + 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: + /* We're done. Was it a double buffered draw ? */ + if(bOffScreen) + { + /* Yes. Draw it back to our DC */ + POINTL ptSrc = {0, 0}; + pdc = DC_LockDc(hDc); + if(!pdc) + { + ERR("Could not lock the destination DC.\n"); + 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 */ + DC_vPrepareDCsForBlit(pdc, rcDest, NULL, rcDest); + + /* Get the clip object */ + pdcClipObj = pdc->rosdc.CombinedClip; + + /* We now have our destination surface and rectangle */ + psurfDest = pdc->dclevel.pSurface; + if(!psurfDest) + { + /* So, you did all of this for an empty DC. */ + DC_UnlockDc(pdc); + goto Cleanup2; + } + + /* 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); + } +Cleanup: + if(pdc) + { + DC_vFinishBlit(pdc, NULL); + DC_UnlockDc(pdc); + } + +Cleanup2: + /* Delete off screen rendering surface */ + if(psurfOffScreen) + GDIOBJ_vDeleteObject(&psurfOffScreen->BaseObject); + + /* 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))) + { + ERR("UserGetCurIconObject() failed!\n"); + UserLeave(); + return FALSE; + } + + Ret = UserDrawIconEx(hdc, + xLeft, + yTop, + pIcon, + cxWidth, + cyHeight, + istepIfAniCur, + hbrFlickerFreeDraw, + diFlags); + + UserDereferenceObject(pIcon); + + UserLeave(); + return Ret; +} + +/* EOF */ Propchange: trunk/reactos/win32ss/user/ntuser/cursoricon_new.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/win32ss/user/ntuser/msgqueue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/msgque…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/msgqueue.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/msgqueue.c [iso-8859-1] Mon Oct 29 15:50:20 2012 @@ -145,6 +145,7 @@ if (NewCursor) { /* Call GDI to set the new screen cursor */ +#ifdef NEW_CURSORICON GreSetPointerShape(hdcScreen, NewCursor->aFrame[0].hbmMask, NewCursor->aFrame[0].hbmColor, @@ -152,6 +153,15 @@ NewCursor->ptlHotspot.y, gpsi->ptCursor.x, gpsi->ptCursor.y); +#else + GreSetPointerShape(hdcScreen, + NewCursor->IconInfo.hbmMask, + NewCursor->IconInfo.hbmColor, + NewCursor->IconInfo.xHotspot, + NewCursor->IconInfo.yHotspot, + gpsi->ptCursor.x, + gpsi->ptCursor.y); +#endif } else /* Note: OldCursor != NewCursor so we have to hide cursor */ { @@ -571,6 +581,7 @@ if(CurInfo->CurrentCursorObject != MessageQueue->CursorObject) { /* Call GDI to set the new screen cursor */ +#ifdef NEW_CURSORICON GreSetPointerShape(hdcScreen, MessageQueue->CursorObject->aFrame[0].hbmMask, MessageQueue->CursorObject->aFrame[0].hbmColor, @@ -578,6 +589,15 @@ MessageQueue->CursorObject->ptlHotspot.y, gpsi->ptCursor.x, gpsi->ptCursor.y); +#else + GreSetPointerShape(hdcScreen, + MessageQueue->CursorObject->IconInfo.hbmMask, + MessageQueue->CursorObject->IconInfo.hbmColor, + MessageQueue->CursorObject->IconInfo.xHotspot, + MessageQueue->CursorObject->IconInfo.yHotspot, + gpsi->ptCursor.x, + gpsi->ptCursor.y); +#endif } else GreMovePointer(hdcScreen, Msg->pt.x, Msg->pt.y); }
12 years, 1 month
1
0
0
0
[jimtabor] 57645: [Win32k] - Move away from thread pointer when using hooks.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Mon Oct 29 04:47:55 2012 New Revision: 57645 URL:
http://svn.reactos.org/svn/reactos?rev=57645&view=rev
Log: [Win32k] - Move away from thread pointer when using hooks. Modified: trunk/reactos/win32ss/include/ntuser.h trunk/reactos/win32ss/user/ntuser/hook.c Modified: trunk/reactos/win32ss/include/ntuser.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/include/ntuser.h?r…
============================================================================== --- trunk/reactos/win32ss/include/ntuser.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/include/ntuser.h [iso-8859-1] Mon Oct 29 04:47:55 2012 @@ -200,7 +200,6 @@ struct _DESKTOP *rpdesk; /* ReactOS */ LIST_ENTRY Chain; /* Hook chain entry */ - struct _ETHREAD* Thread; /* Thread owning the hook */ HOOKPROC Proc; /* Hook function */ BOOLEAN Ansi; /* Is it an Ansi hook? */ UNICODE_STRING ModuleName; /* Module name for global hooks */ Modified: trunk/reactos/win32ss/user/ntuser/hook.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/hook.c…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/hook.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/hook.c [iso-8859-1] Mon Oct 29 04:47:55 2012 @@ -250,8 +250,8 @@ BOOL Block = FALSE; ULONG_PTR uResult = 0; - if (Hook->Thread) - pti = Hook->Thread->Tcb.Win32Thread; + if (Hook->ptiHooked) + pti = Hook->ptiHooked; else pti = Hook->head.pti; @@ -990,9 +990,9 @@ PLIST_ENTRY pLastHead, pElem; PTHREADINFO pti; - if (Hook->Thread) - { - pti = ((PTHREADINFO)Hook->Thread->Tcb.Win32Thread); + if (Hook->ptiHooked) + { + pti = Hook->ptiHooked; pLastHead = &pti->aphkStart[HOOKID_TO_INDEX(HookId)]; } else @@ -1035,9 +1035,9 @@ HookId = Hook->HookId; - if (Hook->Thread) // Local - { - pti = ((PTHREADINFO)Hook->Thread->Tcb.Win32Thread); + if (Hook->ptiHooked) // Local + { + pti = Hook->ptiHooked; IntFreeHook( Hook); @@ -1496,8 +1496,6 @@ ptiHook = Thread->Tcb.Win32Thread; - ObDereferenceObject(Thread); - if ( ptiHook->rpdesk != pti->rpdesk) // gptiCurrent->rpdesk) { ERR("Local hook wrong desktop HookId: %d\n",HookId); @@ -1577,7 +1575,6 @@ } Hook->ihmod = (INT)Mod; // Module Index from atom table, Do this for now. - Hook->Thread = Thread; /* Set Thread, Null is Global. */ Hook->HookId = HookId; Hook->rpdesk = ptiHook->rpdesk; Hook->phkNext = NULL; /* Dont use as a chain! Use link lists for chaining. */ @@ -1684,6 +1681,7 @@ CLEANUP: TRACE("Leave NtUserSetWindowsHookEx, ret=%i\n",_ret_); + if (Thread) ObDereferenceObject(Thread); UserLeave(); END_CLEANUP; }
12 years, 1 month
1
0
0
0
[jgardou] 57644: [WIN32SS/USER] - Begin a rewrite of our cursor/Icons implementation. The current one is too close to wine's.
by jgardou@svn.reactos.org
Author: jgardou Date: Mon Oct 29 01:43:38 2012 New Revision: 57644 URL:
http://svn.reactos.org/svn/reactos?rev=57644&view=rev
Log: [WIN32SS/USER] - Begin a rewrite of our cursor/Icons implementation. The current one is too close to wine's. Added: trunk/reactos/win32ss/user/user32/windows/cursoricon_new.c (with props) Modified: trunk/reactos/win32ss/CMakeLists.txt trunk/reactos/win32ss/include/ntuser.h trunk/reactos/win32ss/user/ntuser/cursoricon.c trunk/reactos/win32ss/user/ntuser/cursoricon.h trunk/reactos/win32ss/user/ntuser/msgqueue.c trunk/reactos/win32ss/user/user32/CMakeLists.txt trunk/reactos/win32ss/user/user32/misc/exticon.c trunk/reactos/win32ss/w32ksvc.h Modified: trunk/reactos/win32ss/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/CMakeLists.txt?rev…
============================================================================== --- trunk/reactos/win32ss/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/win32ss/CMakeLists.txt [iso-8859-1] Mon Oct 29 01:43:38 2012 @@ -1,5 +1,6 @@ set(USE_DIBLIB FALSE) +set(USE_NEW_CURSORICON FALSE) # Give WIN32 subsystem its own project. PROJECT(WIN32SS) @@ -8,6 +9,10 @@ if(USE_DIBLIB) add_subdirectory(gdi/diblib) +endif() + +if(USE_NEW_CURSORICON) + add_definitions(-DNEW_CURSORICON) endif() add_subdirectory(gdi/gdi32) Modified: trunk/reactos/win32ss/include/ntuser.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/include/ntuser.h?r…
============================================================================== --- trunk/reactos/win32ss/include/ntuser.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/include/ntuser.h [iso-8859-1] Mon Oct 29 01:43:38 2012 @@ -2739,14 +2739,24 @@ HANDLE Handle, PICONINFO IconInfo); -#if 0 // Correct type. +#ifdef NEW_CURSORICON BOOL NTAPI NtUserSetCursorIconData( - HCURSOR hCursor, - PUNICODE_STRING ModuleName, - PUNICODE_STRING ResourceName, - PCURSORDATA pCursorData); + _In_ HCURSOR hCursor, + _In_ HINSTANCE hinst, + _In_ HRSRC hrsrc, + _In_ PICONINFO pii); +#else +BOOL +NTAPI +NtUserSetCursorIconData( + HANDLE Handle, + PBOOL fIcon, + POINT *Hotspot, + HMODULE hModule, + HRSRC hRsrc, + HRSRC hGroupRsrc); #endif DWORD @@ -3361,16 +3371,6 @@ IN HWND hWnd, IN DWORD dwFlags); -BOOL -NTAPI -NtUserSetCursorIconData( - HANDLE Handle, - PBOOL fIcon, - POINT *Hotspot, - HMODULE hModule, - HRSRC hRsrc, - HRSRC hGroupRsrc); - typedef struct _SETSCROLLBARINFO { int nTrackPos; Modified: trunk/reactos/win32ss/user/ntuser/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/cursor…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/cursoricon.c [iso-8859-1] Mon Oct 29 01:43:38 2012 @@ -237,7 +237,7 @@ IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, PPROCESSINFO ppi) { PSYSTEM_CURSORINFO CurInfo; - HBITMAP bmpMask, bmpColor; + HBITMAP bmpMask, bmpColor, bmpAlpha; BOOLEAN Ret, bListEmpty, bFound = FALSE; PCURICON_PROCESS Current = NULL; @@ -291,21 +291,28 @@ UserSetCursor(NULL, TRUE); } - bmpMask = CurIcon->IconInfo.hbmMask; - bmpColor = CurIcon->IconInfo.hbmColor; + bmpMask = CurIcon->aFrame[0].hbmMask; + bmpColor = CurIcon->aFrame[0].hbmColor; + bmpAlpha = CurIcon->aFrame[0].hbmAlpha; /* Delete bitmaps */ if (bmpMask) { GreSetObjectOwner(bmpMask, GDI_OBJ_HMGR_POWNED); GreDeleteObject(bmpMask); - CurIcon->IconInfo.hbmMask = NULL; + CurIcon->aFrame[0].hbmMask = NULL; } if (bmpColor) { GreSetObjectOwner(bmpColor, GDI_OBJ_HMGR_POWNED); GreDeleteObject(bmpColor); - CurIcon->IconInfo.hbmColor = NULL; + CurIcon->aFrame[0].hbmColor = NULL; + } + if (bmpAlpha) + { + GreSetObjectOwner(bmpAlpha, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(bmpAlpha); + CurIcon->aFrame[0].hbmAlpha = NULL; } /* We were given a pointer, no need to keep the reference anylonger! */ @@ -361,18 +368,21 @@ { goto leave; } - - RtlCopyMemory(&ii, &CurIcon->IconInfo, sizeof(ICONINFO)); + + /* Fill data */ + ii.fIcon = CurIcon->bIcon; + ii.xHotspot = CurIcon->ptlHotspot.x; + ii.yHotspot = CurIcon->ptlHotspot.y; /* Copy bitmaps */ - ii.hbmMask = BITMAP_CopyBitmap(CurIcon->IconInfo.hbmMask); - ii.hbmColor = BITMAP_CopyBitmap(CurIcon->IconInfo.hbmColor); + ii.hbmMask = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmMask); + ii.hbmColor = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmColor); if (pbpp) { PSURFACE psurfBmp; - psurfBmp = SURFACE_ShareLockSurface(CurIcon->IconInfo.hbmColor); + psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmColor); if (psurfBmp) { colorBpp = BitsPerFormat(psurfBmp->SurfObj.iBitmapFormat); @@ -799,35 +809,103 @@ goto done; } +#if 0 + /* Check if we get valid information */ + if(IconInfo.fIcon != CurInfo->bIcon) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + goto done; + } +#endif + /* Delete old bitmaps */ - if ((CurIcon->IconInfo.hbmColor) - && (CurIcon->IconInfo.hbmColor != IconInfo.hbmColor)) - { - GreDeleteObject(CurIcon->IconInfo.hbmColor); - } - if ((CurIcon->IconInfo.hbmMask) - && CurIcon->IconInfo.hbmMask != IconInfo.hbmMask) - { - GreDeleteObject(CurIcon->IconInfo.hbmMask); - } - - /* Copy new IconInfo field */ - CurIcon->IconInfo = IconInfo; - - if (CurIcon->IconInfo.hbmColor) - { - psurfBmp = SURFACE_ShareLockSurface(CurIcon->IconInfo.hbmColor); + if (CurIcon->aFrame[0].hbmColor) + GreDeleteObject(CurIcon->aFrame[0].hbmColor); + if (CurIcon->aFrame[0].hbmMask) + GreDeleteObject(CurIcon->aFrame[0].hbmMask); + if(CurIcon->aFrame[0].hbmAlpha) + GreDeleteObject(CurIcon->aFrame[0].hbmAlpha); + + /* Set fields */ + CurIcon->bIcon = IconInfo.fIcon; + CurIcon->ptlHotspot.x = IconInfo.xHotspot; + CurIcon->ptlHotspot.y = IconInfo.yHotspot; + CurIcon->aFrame[0].hbmMask = IconInfo.hbmMask; + CurIcon->aFrame[0].hbmColor = IconInfo.hbmColor; + CurIcon->aFrame[0].hbmAlpha = NULL; + + if (IconInfo.hbmColor) + { + BOOLEAN bAlpha = FALSE; + psurfBmp = SURFACE_ShareLockSurface(IconInfo.hbmColor); if (!psurfBmp) goto done; - CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; + + /* 32bpp bitmap is likely to have an alpha channel */ + if(psurfBmp->SurfObj.iBitmapFormat == BMF_32BPP) + { + PFN_DIB_GetPixel fn_GetPixel = DibFunctionsForBitmapFormat[BMF_32BPP].DIB_GetPixel; + INT i, j; + + fn_GetPixel = DibFunctionsForBitmapFormat[BMF_32BPP].DIB_GetPixel; + for (i = 0; i < psurfBmp->SurfObj.sizlBitmap.cx; i++) + { + for (j = 0; j < psurfBmp->SurfObj.sizlBitmap.cy; j++) + { + bAlpha = ((BYTE)(fn_GetPixel(&psurfBmp->SurfObj, i, j) >> 24)) != 0; + if (bAlpha) + break; + } + if (bAlpha) + break; + } + } + /* We're done with this one */ SURFACE_ShareUnlockSurface(psurfBmp); - GreSetObjectOwner(CurIcon->IconInfo.hbmColor, GDI_OBJ_HMGR_PUBLIC); + GreSetObjectOwner(IconInfo.hbmColor, GDI_OBJ_HMGR_PUBLIC); + + if(bAlpha) + { + UCHAR Alpha; + PUCHAR ptr; + INT i, j; + /* Copy the bitmap */ + CurIcon->aFrame[0].hbmAlpha = BITMAP_CopyBitmap(IconInfo.hbmColor); + if(!CurIcon->aFrame[0].hbmAlpha) + { + ERR("BITMAP_CopyBitmap failed!"); + goto done; + } + + psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmAlpha); + if(!psurfBmp) + { + ERR("SURFACE_LockSurface failed!\n"); + goto done; + } + + /* Premultiply with the alpha channel value */ + for (i = 0; i < psurfBmp->SurfObj.sizlBitmap.cy; i++) + { + ptr = (PBYTE)psurfBmp->SurfObj.pvScan0 + i*psurfBmp->SurfObj.lDelta; + for (j = 0; j < psurfBmp->SurfObj.sizlBitmap.cx; j++) + { + Alpha = ptr[3]; + ptr[0] = (ptr[0] * Alpha) / 0xff; + ptr[1] = (ptr[1] * Alpha) / 0xff; + ptr[2] = (ptr[2] * Alpha) / 0xff; + ptr += 4; + } + } + SURFACE_ShareUnlockSurface(psurfBmp); + GreSetObjectOwner(CurIcon->aFrame[0].hbmAlpha, GDI_OBJ_HMGR_PUBLIC); + } } else { - psurfBmp = SURFACE_ShareLockSurface(CurIcon->IconInfo.hbmMask); + psurfBmp = SURFACE_ShareLockSurface(IconInfo.hbmMask); if (!psurfBmp) goto done; @@ -836,11 +914,17 @@ SURFACE_ShareUnlockSurface(psurfBmp); } - GreSetObjectOwner(CurIcon->IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); + GreSetObjectOwner(IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); Ret = TRUE; done: + + if(!Ret) + { + IntDestroyCurIconObject(CurIcon, PsGetCurrentProcessWin32Process()); + CurIcon = NULL; + } if (CurIcon) { @@ -858,20 +942,21 @@ /* * @implemented */ -#if 0 +#ifdef NEW_CURSORICON BOOL APIENTRY NtUserSetCursorIconData( - HANDLE Handle, - HMODULE hModule, - PUNICODE_STRING pstrResName, - PICONINFO pIconInfo) + _In_ HCURSOR Handle, + _In_ HINSTANCE hinst, + _In_ HRSRC hrsrc, + _In_ PICONINFO pIconInfo) { PCURICON_OBJECT CurIcon; PSURFACE psurfBmp; NTSTATUS Status = STATUS_SUCCESS; BOOL Ret = FALSE; DECLARE_RETURN(BOOL); + ICONINFO ii; TRACE("Enter NtUserSetCursorIconData\n"); UserEnterExclusive(); @@ -881,54 +966,96 @@ RETURN(FALSE); } - CurIcon->hModule = hModule; - CurIcon->hRsrc = NULL; //hRsrc; - CurIcon->hGroupRsrc = NULL; //hGroupRsrc; + CurIcon->hModule = hinst; + CurIcon->hRsrc =hrsrc; _SEH2_TRY { ProbeForRead(pIconInfo, sizeof(ICONINFO), 1); - RtlCopyMemory(&CurIcon->IconInfo, pIconInfo, sizeof(ICONINFO)); - - CurIcon->IconInfo.hbmMask = BITMAP_CopyBitmap(pIconInfo->hbmMask); - CurIcon->IconInfo.hbmColor = BITMAP_CopyBitmap(pIconInfo->hbmColor); - - if (CurIcon->IconInfo.hbmColor) - { - if ((psurfBmp = SURFACE_LockSurface(CurIcon->IconInfo.hbmColor))) - { - CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; - CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; - SURFACE_UnlockSurface(psurfBmp); - GreSetObjectOwner(CurIcon->IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); - } - } - if (CurIcon->IconInfo.hbmMask) - { - if (CurIcon->IconInfo.hbmColor == NULL) - { - if ((psurfBmp = SURFACE_LockSurface(CurIcon->IconInfo.hbmMask))) - { - CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; - CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; - SURFACE_UnlockSurface(psurfBmp); - } - } - GreSetObjectOwner(CurIcon->IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); - } + ii = *pIconInfo; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { Status = _SEH2_GetExceptionCode(); } _SEH2_END - + if (!NT_SUCCESS(Status)) + { SetLastNtError(Status); + goto done; + } + + /* This is probably not what windows does, but consistency checks can't hurt */ + if(CurIcon->bIcon != ii.fIcon) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + goto done; + } + CurIcon->ptlHotspot.x = ii.xHotspot; + CurIcon->ptlHotspot.y = ii.yHotspot; + + if(!ii.hbmMask) + { + EngSetLastError(ERROR_INVALID_PARAMETER); + goto done; + } + + CurIcon->aFrame[0].hbmMask = BITMAP_CopyBitmap(ii.hbmMask); + if(!CurIcon->aFrame[0].hbmMask) + goto done; + + if(ii.hbmColor) + { + CurIcon->aFrame[0].hbmColor = BITMAP_CopyBitmap(ii.hbmColor); + if(!CurIcon->aFrame[0].hbmColor) + goto done; + } + + if (CurIcon->aFrame[0].hbmColor) + { + if ((psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmColor))) + { + CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; + CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; + SURFACE_ShareUnlockSurface(psurfBmp); + GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); + } + else + goto done; + } else - Ret = TRUE; - + { + if ((psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmMask))) + { + CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; + CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy/2; + SURFACE_ShareUnlockSurface(psurfBmp); + } + else + goto done; + } + GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); + + Ret = TRUE; + +done: UserDereferenceObject(CurIcon); + if(!Ret) + { + if (CurIcon->aFrame[0].hbmMask) + { + GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(CurIcon->aFrame[0].hbmMask); + CurIcon->aFrame[0].hbmMask = NULL; + } + if (CurIcon->aFrame[0].hbmColor) + { + GreSetObjectOwner(CurIcon->aFrame[0].hbmColor, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(CurIcon->aFrame[0].hbmColor); + CurIcon->aFrame[0].hbmColor = NULL; + } + } RETURN(Ret); CLEANUP: @@ -949,7 +1076,6 @@ { PCURICON_OBJECT CurIcon; NTSTATUS Status; - POINT SafeHotspot; BOOL Ret = FALSE; DECLARE_RETURN(BOOL); @@ -968,7 +1094,7 @@ /* Copy fields */ if (fIcon) { - Status = MmCopyFromCaller(&CurIcon->IconInfo.fIcon, fIcon, sizeof(BOOL)); + Status = MmCopyFromCaller(&CurIcon->bIcon, fIcon, sizeof(BOOL)); if (!NT_SUCCESS(Status)) { SetLastNtError(Status); @@ -983,16 +1109,12 @@ 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 + Status = MmCopyFromCaller(&CurIcon->ptlHotspot, Hotspot, sizeof(POINT)); + if (!NT_SUCCESS(Status)) + { SetLastNtError(Status); + goto done; + } } if (!fIcon && !Hotspot) @@ -1004,10 +1126,14 @@ if(Ret) { /* This icon is shared now */ - GreSetObjectOwner(CurIcon->IconInfo.hbmMask, GDI_OBJ_HMGR_PUBLIC); - if(CurIcon->IconInfo.hbmColor) + GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); + if(CurIcon->aFrame[0].hbmColor) { - GreSetObjectOwner(CurIcon->IconInfo.hbmColor, GDI_OBJ_HMGR_PUBLIC); + GreSetObjectOwner(CurIcon->aFrame[0].hbmColor, GDI_OBJ_HMGR_PUBLIC); + } + if(CurIcon->aFrame[0].hbmAlpha) + { + GreSetObjectOwner(CurIcon->aFrame[0].hbmAlpha, GDI_OBJ_HMGR_PUBLIC); } } UserDereferenceObject(CurIcon); @@ -1044,8 +1170,8 @@ PSURFACE psurfDest, psurfMask, psurfColor, psurfOffScreen; PDC pdc = NULL; BOOL Ret = FALSE; - HBITMAP hbmMask, hbmColor; - BOOL bOffScreen, bAlpha = FALSE; + HBITMAP hbmMask, hbmColor, hbmAlpha; + BOOL bOffScreen; RECTL rcDest, rcSrc; CLIPOBJ* pdcClipObj = NULL; EXLATEOBJ exlo; @@ -1057,8 +1183,9 @@ return FALSE; } - hbmMask = pIcon->IconInfo.hbmMask; - hbmColor = pIcon->IconInfo.hbmColor; + hbmMask = pIcon->aFrame[0].hbmMask; + hbmColor = pIcon->aFrame[0].hbmColor; + hbmAlpha = pIcon->aFrame[0].hbmAlpha; if (istepIfAniCur) ERR("NtUserDrawIconEx: istepIfAniCur is not supported!\n"); @@ -1091,35 +1218,11 @@ /* Set source rect */ RECTL_vSetRect(&rcSrc, 0, 0, pIcon->Size.cx, pIcon->Size.cy); - /* Check for alpha */ - if (psurfColor && - (psurfColor->SurfObj.iBitmapFormat == BMF_32BPP) && - (diFlags & DI_IMAGE)) - { - PFN_DIB_GetPixel fnSource_GetPixel = NULL; - INT i, j; - - /* In order to correctly display 32 bit icons Windows first scans the image, - because information about transparency is not stored in any image's headers */ - fnSource_GetPixel = DibFunctionsForBitmapFormat[BMF_32BPP].DIB_GetPixel; - for (i = 0; i < psurfColor->SurfObj.sizlBitmap.cx; i++) - { - for (j = 0; j < psurfColor->SurfObj.sizlBitmap.cy; j++) - { - bAlpha = ((BYTE)(fnSource_GetPixel(&psurfColor->SurfObj, i, j) >> 24) & 0xff); - if (bAlpha) - break; - } - if (bAlpha) - break; - } - } - /* Fix width parameter, if needed */ if (!cxWidth) { if(diFlags & DI_DEFAULTSIZE) - cxWidth = pIcon->IconInfo.fIcon ? + cxWidth = pIcon->bIcon ? UserGetSystemMetrics(SM_CXICON) : UserGetSystemMetrics(SM_CXCURSOR); else cxWidth = pIcon->Size.cx; @@ -1129,7 +1232,7 @@ if (!cyHeight) { if(diFlags & DI_DEFAULTSIZE) - cyHeight = pIcon->IconInfo.fIcon ? + cyHeight = pIcon->bIcon ? UserGetSystemMetrics(SM_CYICON) : UserGetSystemMetrics(SM_CYCURSOR); else cyHeight = pIcon->Size.cy; @@ -1238,42 +1341,16 @@ } /* Now do the rendering */ - if(bAlpha && (diFlags & DI_IMAGE)) + if(hbmAlpha && (diFlags & DI_IMAGE)) { BLENDOBJ blendobj = { {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA } }; - BYTE Alpha; - INT i, j; PSURFACE psurf = NULL; - PBYTE ptr ; - HBITMAP hsurfCopy = NULL; - - hsurfCopy = BITMAP_CopyBitmap(hbmColor); - if(!hsurfCopy) - { - ERR("BITMAP_CopyBitmap failed!"); - goto CleanupAlpha; - } - - psurf = SURFACE_ShareLockSurface(hsurfCopy); + + psurf = SURFACE_ShareLockSurface(hbmAlpha); if(!psurf) { ERR("SURFACE_LockSurface failed!\n"); - goto CleanupAlpha; - } - - /* Premultiply with the alpha channel value */ - for (i = 0; i < psurf->SurfObj.sizlBitmap.cy; i++) - { - ptr = (PBYTE)psurf->SurfObj.pvScan0 + i*psurf->SurfObj.lDelta; - for (j = 0; j < psurf->SurfObj.sizlBitmap.cx; j++) - { - Alpha = ptr[3]; - ptr[0] = (ptr[0] * Alpha) / 0xff; - ptr[1] = (ptr[1] * Alpha) / 0xff; - ptr[2] = (ptr[2] * Alpha) / 0xff; - - ptr += 4; - } + goto NoAlpha; } /* Initialize color translation object */ @@ -1289,14 +1366,11 @@ &blendobj); EXLATEOBJ_vCleanup(&exlo); - - CleanupAlpha: - if(psurf) SURFACE_ShareUnlockSurface(psurf); - if(hsurfCopy) NtGdiDeleteObjectApp(hsurfCopy); - if(Ret) goto done; + SURFACE_ShareUnlockSurface(psurf); + if(Ret) goto done; ERR("NtGdiAlphaBlend failed!\n"); } - +NoAlpha: if (diFlags & DI_MASK) { DWORD rop4 = (diFlags & DI_IMAGE) ? ROP4_SRCAND : ROP4_SRCCOPY; Modified: trunk/reactos/win32ss/user/ntuser/cursoricon.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/cursor…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/cursoricon.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/cursoricon.h [iso-8859-1] Mon Oct 29 01:43:38 2012 @@ -8,6 +8,13 @@ PPROCESSINFO Process; } CURICON_PROCESS, *PCURICON_PROCESS; +typedef struct _CURICON_FRAME +{ + HBITMAP hbmMask; + HBITMAP hbmColor; + HBITMAP hbmAlpha; +} CURICON_FRAME, *PCURICON_FRAME; + typedef struct _CURICON_OBJECT { PROCMARKHEAD head; @@ -16,10 +23,14 @@ LIST_ENTRY ProcessList; HMODULE hModule; HRSRC hRsrc; +#ifndef NEW_CURSORICON HRSRC hGroupRsrc; +#endif SIZE Size; BYTE Shadow; - ICONINFO IconInfo; + BOOL bIcon; + POINTL ptlHotspot; + CURICON_FRAME aFrame[1]; } CURICON_OBJECT, *PCURICON_OBJECT; typedef struct _CURSORACCELERATION_INFO Modified: trunk/reactos/win32ss/user/ntuser/msgqueue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/msgque…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/msgqueue.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/msgqueue.c [iso-8859-1] Mon Oct 29 01:43:38 2012 @@ -146,10 +146,10 @@ { /* Call GDI to set the new screen cursor */ GreSetPointerShape(hdcScreen, - NewCursor->IconInfo.hbmMask, - NewCursor->IconInfo.hbmColor, - NewCursor->IconInfo.xHotspot, - NewCursor->IconInfo.yHotspot, + NewCursor->aFrame[0].hbmMask, + NewCursor->aFrame[0].hbmColor, + NewCursor->ptlHotspot.x, + NewCursor->ptlHotspot.y, gpsi->ptCursor.x, gpsi->ptCursor.y); } @@ -572,10 +572,10 @@ { /* Call GDI to set the new screen cursor */ GreSetPointerShape(hdcScreen, - MessageQueue->CursorObject->IconInfo.hbmMask, - MessageQueue->CursorObject->IconInfo.hbmColor, - MessageQueue->CursorObject->IconInfo.xHotspot, - MessageQueue->CursorObject->IconInfo.yHotspot, + MessageQueue->CursorObject->aFrame[0].hbmMask, + MessageQueue->CursorObject->aFrame[0].hbmColor, + MessageQueue->CursorObject->ptlHotspot.x, + MessageQueue->CursorObject->ptlHotspot.y, gpsi->ptCursor.x, gpsi->ptCursor.y); } else Modified: trunk/reactos/win32ss/user/user32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/CMakeL…
============================================================================== --- trunk/reactos/win32ss/user/user32/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/CMakeLists.txt [iso-8859-1] Mon Oct 29 01:43:38 2012 @@ -41,7 +41,7 @@ windows/caret.c windows/class.c windows/clipboard.c - windows/cursoricon.c +# windows/cursoricon.c windows/dc.c windows/defwnd.c windows/dialog.c @@ -64,6 +64,12 @@ user32.rc ${CMAKE_CURRENT_BINARY_DIR}/user32.def) +if(USE_NEW_CURSORICON) + list(APPEND SOURCE windows/cursoricon_new.c) +else() + list(APPEND SOURCE windows/cursoricon.c) +endif() + add_library(user32 SHARED ${SOURCE}) set_module_type(user32 win32dll UNICODE) Modified: trunk/reactos/win32ss/user/user32/misc/exticon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/misc/e…
============================================================================== --- trunk/reactos/win32ss/user/user32/misc/exticon.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/misc/exticon.c [iso-8859-1] Mon Oct 29 01:43:38 2012 @@ -29,30 +29,6 @@ /* Start of Hack section */ WINE_DEFAULT_DEBUG_CHANNEL(icon); - -#include "pshpack1.h" - -typedef struct -{ - BYTE bWidth; /* Width, in pixels, of the image */ - BYTE bHeight; /* Height, in pixels, of the image */ - BYTE bColorCount; /* Number of colors in image (0 if >=8bpp) */ - BYTE bReserved; /* Reserved ( must be 0) */ - WORD wPlanes; /* Color Planes */ - WORD wBitCount; /* Bits per pixel */ - DWORD dwBytesInRes; /* How many bytes in this resource? */ - DWORD dwImageOffset; /* Where in the file is this image? */ -} icoICONDIRENTRY, *LPicoICONDIRENTRY; - -typedef struct -{ - WORD idReserved; /* Reserved (must be 0) */ - WORD idType; /* Resource Type (RES_ICON or RES_CURSOR) */ - WORD idCount; /* How many images */ - icoICONDIRENTRY idEntries[1]; /* An entry for each image (idCount of 'em) */ -} icoICONDIR, *LPicoICONDIR; - -#include "poppack.h" #if 0 static void dumpIcoDirEnty ( LPicoICONDIRENTRY entry ) Added: trunk/reactos/win32ss/user/user32/windows/cursoricon_new.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/window…
============================================================================== --- trunk/reactos/win32ss/user/user32/windows/cursoricon_new.c (added) +++ trunk/reactos/win32ss/user/user32/windows/cursoricon_new.c [iso-8859-1] Mon Oct 29 01:43:38 2012 @@ -1,0 +1,756 @@ +/* + * PROJECT: ReactOS user32.dll + * COPYRIGHT: GPL - See COPYING in the top level directory + * FILE: dll/win32/user32/windows/class.c + * PURPOSE: Window classes + * PROGRAMMER: Jérôme Gardou (jerome.gardou(a)reactos.org) + */ + +#include <user32.h> + +#include <wine/debug.h> + +WINE_DEFAULT_DEBUG_CHANNEL(cursor); +//WINE_DECLARE_DEBUG_CHANNEL(icon); +//WINE_DECLARE_DEBUG_CHANNEL(resource); + +/************* USER32 INTERNAL FUNCTIONS **********/ + +/* This callback routine is called directly after switching to gui mode */ +NTSTATUS +WINAPI +User32SetupDefaultCursors(PVOID Arguments, + ULONG ArgumentLength) +{ + BOOL *DefaultCursor = (BOOL*)Arguments; + HCURSOR hCursor; + + if(*DefaultCursor) + { + /* set default cursor */ + hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW); + SetCursor(hCursor); + } + else + { + /* FIXME load system cursor scheme */ + SetCursor(0); + hCursor = LoadCursorW(0, (LPCWSTR)IDC_ARROW); + SetCursor(hCursor); + } + + return(ZwCallbackReturn(&hCursor, sizeof(HCURSOR), STATUS_SUCCESS)); +} + +BOOL get_icon_size(HICON hIcon, SIZE *size) +{ + return NtUserGetIconSize(hIcon, 0, &size->cx, &size->cy); +} + +HCURSOR CursorIconToCursor(HICON hIcon, BOOL SemiTransparent) +{ + UNIMPLEMENTED; + return NULL; +} + +/************* IMPLEMENTATION HELPERS ******************/ + +static int get_dib_image_size( int width, int height, int depth ) +{ + return (((width * depth + 31) / 8) & ~3) * abs( height ); +} + +static BOOL is_dib_monochrome( const BITMAPINFO* info ) +{ + if (info->bmiHeader.biBitCount != 1) return FALSE; + + if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) + { + const RGBTRIPLE *rgb = ((const BITMAPCOREINFO*)info)->bmciColors; + + /* Check if the first color is black */ + if ((rgb->rgbtRed == 0) && (rgb->rgbtGreen == 0) && (rgb->rgbtBlue == 0)) + { + rgb++; + + /* Check if the second color is white */ + return ((rgb->rgbtRed == 0xff) && (rgb->rgbtGreen == 0xff) + && (rgb->rgbtBlue == 0xff)); + } + else return FALSE; + } + else /* assume BITMAPINFOHEADER */ + { + const RGBQUAD *rgb = info->bmiColors; + + /* Check if the first color is black */ + if ((rgb->rgbRed == 0) && (rgb->rgbGreen == 0) && + (rgb->rgbBlue == 0) && (rgb->rgbReserved == 0)) + { + rgb++; + + /* Check if the second color is white */ + return ((rgb->rgbRed == 0xff) && (rgb->rgbGreen == 0xff) + && (rgb->rgbBlue == 0xff) && (rgb->rgbReserved == 0)); + } + else return FALSE; + } +} + +static int bitmap_info_size( const BITMAPINFO * info, WORD coloruse ) +{ + unsigned int colors, size, masks = 0; + + if (info->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) + { + const BITMAPCOREHEADER *core = (const BITMAPCOREHEADER *)info; + colors = (core->bcBitCount <= 8) ? 1 << core->bcBitCount : 0; + return sizeof(BITMAPCOREHEADER) + colors * + ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBTRIPLE) : sizeof(WORD)); + } + else /* assume BITMAPINFOHEADER */ + { + colors = info->bmiHeader.biClrUsed; + if (colors > 256) /* buffer overflow otherwise */ + colors = 256; + if (!colors && (info->bmiHeader.biBitCount <= 8)) + colors = 1 << info->bmiHeader.biBitCount; + if (info->bmiHeader.biCompression == BI_BITFIELDS) masks = 3; + size = max( info->bmiHeader.biSize, sizeof(BITMAPINFOHEADER) + masks * sizeof(DWORD) ); + return size + colors * ((coloruse == DIB_RGB_COLORS) ? sizeof(RGBQUAD) : sizeof(WORD)); + } +} + +/************* IMPLEMENTATION CORE ****************/ + +static BOOL CURSORICON_GetIconInfoFromBMI( + _Inout_ ICONINFO* pii, + _In_ const BITMAPINFO *pbmi, + _In_ int cxDesired, + _In_ int cyDesired +) +{ + UINT ubmiSize = bitmap_info_size(pbmi, DIB_RGB_COLORS); + BOOL monochrome = is_dib_monochrome(pbmi); + HDC hdc, hdcScreen; + BITMAPINFO* pbmiCopy; + HBITMAP hbmpOld = NULL; + BOOL bResult = FALSE; + const VOID *pvColor, *pvMask; + + /* Check for invalid data */ + if ( (pbmi->bmiHeader.biSize != sizeof(BITMAPCOREHEADER) && + pbmi->bmiHeader.biSize != sizeof(BITMAPINFOHEADER)) || + pbmi->bmiHeader.biCompression != BI_RGB ) + { + WARN("Invalid resource bitmap header.\n"); + return FALSE; + } + + /* Fix the hotspot coords */ + if(cxDesired != pbmi->bmiHeader.biWidth) + pii->xHotspot = (pii->xHotspot * cxDesired) / pbmi->bmiHeader.biWidth; + if(cxDesired != (pbmi->bmiHeader.biHeight/2)) + pii->yHotspot = (pii->yHotspot * cyDesired * 2) / pbmi->bmiHeader.biHeight; + + hdcScreen = CreateDCW(L"DISPLAY", NULL, NULL, NULL); + if(!hdcScreen) + return FALSE; + hdc = CreateCompatibleDC(hdcScreen); + if(!hdc) + { + DeleteDC(hdcScreen); + return FALSE; + } + + pbmiCopy = HeapAlloc(GetProcessHeap(), 0, max(ubmiSize, FIELD_OFFSET(BITMAPINFO, bmiColors[3]))); + if(!pbmiCopy) + goto done; + RtlCopyMemory(pbmiCopy, pbmi, ubmiSize); + pbmiCopy->bmiHeader.biHeight /= 2; + + pvColor = (const char*)pbmi + ubmiSize; + pvMask = (const char*)pvColor + + get_dib_image_size(pbmi->bmiHeader.biWidth, pbmiCopy->bmiHeader.biHeight, pbmi->bmiHeader.biBitCount ); + + /* Set XOR bits */ + if(monochrome) + { + /* Create the 1bpp bitmap which will contain everything */ + pii->hbmColor = NULL; + pii->hbmMask = CreateCompatibleBitmap(hdc, cxDesired, cyDesired * 2); + if(!pii->hbmMask) + goto done; + hbmpOld = SelectObject(hdc, pii->hbmMask); + if(!hbmpOld) + goto done; + + if(!StretchDIBits(hdc, 0, cyDesired, cxDesired, cyDesired, + 0, 0, pbmiCopy->bmiHeader.biWidth, pbmiCopy->bmiHeader.biHeight, + pvColor, pbmiCopy, DIB_RGB_COLORS, SRCCOPY)) + goto done; + } + else + { + /* Create the bitmap. It has to be compatible with the screen surface */ + pii->hbmColor = CreateCompatibleBitmap(hdcScreen, cxDesired, cyDesired); + if(!pii->hbmColor) + goto done; + /* Create the 1bpp mask bitmap */ + pii->hbmMask = CreateCompatibleBitmap(hdc, cxDesired, cyDesired); + if(!pii->hbmMask) + goto done; + hbmpOld = SelectObject(hdc, pii->hbmColor); + if(!hbmpOld) + goto done; + if(!StretchDIBits(hdc, 0, 0, cxDesired, cyDesired, + 0, 0, pbmiCopy->bmiHeader.biWidth, pbmiCopy->bmiHeader.biHeight, + pvColor, pbmiCopy, DIB_RGB_COLORS, SRCCOPY)) + goto done; + + /* Now convert the info to monochrome for the mask bits */ + pbmiCopy->bmiHeader.biBitCount = 1; + /* Handle the CORE/INFO difference */ + if (pbmiCopy->bmiHeader.biSize != sizeof(BITMAPCOREHEADER)) + { + RGBQUAD *rgb = pbmiCopy->bmiColors; + + pbmiCopy->bmiHeader.biClrUsed = pbmiCopy->bmiHeader.biClrImportant = 2; + rgb[0].rgbBlue = rgb[0].rgbGreen = rgb[0].rgbRed = 0x00; + rgb[1].rgbBlue = rgb[1].rgbGreen = rgb[1].rgbRed = 0xff; + rgb[0].rgbReserved = rgb[1].rgbReserved = 0; + } + else + { + RGBTRIPLE *rgb = (RGBTRIPLE *)(((BITMAPCOREHEADER *)pbmiCopy) + 1); + + rgb[0].rgbtBlue = rgb[0].rgbtGreen = rgb[0].rgbtRed = 0x00; + rgb[1].rgbtBlue = rgb[1].rgbtGreen = rgb[1].rgbtRed = 0xff; + } + } + /* Set the mask bits */ + if(!SelectObject(hdc, pii->hbmMask)) + goto done; + bResult = StretchDIBits(hdc, 0, 0, cxDesired, cyDesired, + 0, 0, pbmiCopy->bmiHeader.biWidth, pbmiCopy->bmiHeader.biHeight, + pvMask, pbmiCopy, DIB_RGB_COLORS, SRCCOPY) != 0; + +done: + DeleteDC(hdcScreen); + if(hbmpOld) SelectObject(hdc, hbmpOld); + DeleteDC(hdc); + if(pbmiCopy) HeapFree(GetProcessHeap(), 0, pbmiCopy); + /* Clean up in case of failure */ + if(!bResult) + { + if(pii->hbmMask) DeleteObject(pii->hbmMask); + if(pii->hbmColor) DeleteObject(pii->hbmColor); + } + return bResult; +} + +static +HANDLE +BITMAP_LoadImageW( + _In_opt_ HINSTANCE hinst, + _In_ LPCWSTR lpszName, + _In_ int cxDesired, + _In_ int cyDesired, + _In_ UINT fuLoad +) +{ + UNIMPLEMENTED; + return NULL; +} + +static +HANDLE +CURSORICON_LoadImageW( + _In_opt_ HINSTANCE hinst, + _In_ LPCWSTR lpszName, + _In_ int cxDesired, + _In_ int cyDesired, + _In_ UINT fuLoad, + _In_ BOOL bIcon +) +{ + HRSRC hrsrc, hrsrc2; + HANDLE handle, hCurIcon; + CURSORICONDIR* dir; + WORD wResId; + LPBYTE bits; + ICONINFO ii; + BOOL bStatus; + + if(fuLoad & LR_LOADFROMFILE) + { + UNIMPLEMENTED; + return NULL; + } + + /* Check if caller wants OEM icons */ + if(!hinst) + hinst = User32Instance; + + /* Find resource ID */ + hrsrc = FindResourceW( + hinst, + lpszName, + (LPWSTR)(bIcon ? RT_GROUP_ICON : RT_GROUP_CURSOR)); + + /* We let FindResource, LoadResource, etc. call SetLastError */ + if(!hrsrc) + return NULL; + + /* Fix width/height */ + if(fuLoad & LR_DEFAULTSIZE) + { + if(!cxDesired) cxDesired = GetSystemMetrics(bIcon ? SM_CXICON : SM_CXCURSOR); + if(!cyDesired) cyDesired = GetSystemMetrics(bIcon ? SM_CYICON : SM_CYCURSOR); + } + + /* If LR_SHARED is set, we must check for the cache */ + hCurIcon = NtUserFindExistingCursorIcon(hinst, hrsrc, cxDesired, cyDesired); + if(hCurIcon) + return hCurIcon; + + handle = LoadResource(hinst, hrsrc); + if(!handle) + return NULL; + + dir = LockResource(handle); + if(!dir) return NULL; + + /* For now, take the first entry */ + wResId = dir->idEntries[0].wResId; + FreeResource(handle); + + /* Get the relevant resource pointer */ + hrsrc2 = FindResourceW( + hinst, + MAKEINTRESOURCEW(wResId), + (LPWSTR)(bIcon ? RT_ICON : RT_CURSOR)); + if(!hrsrc2) + return NULL; + + handle = LoadResource(hinst, hrsrc2); + if(!handle) + return NULL; + + bits = LockResource(handle); + if(!bits) + { + FreeResource(handle); + return NULL; + } + + /* Get the hospot */ + if(bIcon) + { + ii.xHotspot = cxDesired/2; + ii.yHotspot = cyDesired/2; + } + else + { + SHORT* ptr = (SHORT*)bits; + ii.xHotspot = ptr[0]; + ii.yHotspot = ptr[1]; + bits += 2*sizeof(SHORT); + } + ii.fIcon = bIcon; + + /* Get the bitmaps */ + bStatus = CURSORICON_GetIconInfoFromBMI( + &ii, + (BITMAPINFO*)bits, + cxDesired, + cyDesired); + + FreeResource( handle ); + + if(!bStatus) + return NULL; + + /* Create the handle */ + hCurIcon = NtUserxCreateEmptyCurObject(bIcon ? 0 : 1); + if(!hCurIcon) + return NULL; + + /* Tell win32k */ + if(fuLoad & LR_SHARED) + bStatus = NtUserSetCursorIconData(hCurIcon, hinst, hrsrc, &ii); + else + bStatus = NtUserSetCursorIconData(hCurIcon, NULL, NULL, &ii); + + if(!bStatus) + { + NtUserDestroyCursor(hCurIcon, TRUE); + hCurIcon = NULL; + } + + DeleteObject(ii.hbmMask); + DeleteObject(ii.hbmColor); + + return hCurIcon; +} + +/************* PUBLIC FUNCTIONS *******************/ + +HANDLE WINAPI CopyImage( + _In_ HANDLE hImage, + _In_ UINT uType, + _In_ int cxDesired, + _In_ int cyDesired, + _In_ UINT fuFlags +) +{ + UNIMPLEMENTED; + return NULL; +} + +HICON WINAPI CopyIcon( + _In_ HICON hIcon +) +{ + UNIMPLEMENTED; + return NULL; +} + +BOOL WINAPI DrawIcon( + _In_ HDC hDC, + _In_ int X, + _In_ int Y, + _In_ HICON hIcon +) +{ + return DrawIconEx(hDC, X, Y, hIcon, 0, 0, 0, NULL, DI_NORMAL | DI_COMPAT | DI_DEFAULTSIZE); +} + +BOOL WINAPI DrawIconEx( + _In_ HDC hdc, + _In_ int xLeft, + _In_ int yTop, + _In_ HICON hIcon, + _In_ int cxWidth, + _In_ int cyWidth, + _In_ UINT istepIfAniCur, + _In_opt_ HBRUSH hbrFlickerFreeDraw, + _In_ UINT diFlags +) +{ + UNIMPLEMENTED; + return FALSE; +} + +BOOL WINAPI GetIconInfo( + _In_ HICON hIcon, + _Out_ PICONINFO piconinfo +) +{ + UNIMPLEMENTED; + return FALSE; +} + +BOOL WINAPI DestroyIcon( + _In_ HICON hIcon +) +{ + UNIMPLEMENTED; + return FALSE; +} + +HICON WINAPI LoadIconA( + _In_opt_ HINSTANCE hInstance, + _In_ LPCSTR lpIconName +) +{ + TRACE("%p, %s\n", hInstance, debugstr_a(lpIconName)); + + return LoadImageA(hInstance, + lpIconName, + IMAGE_ICON, + 0, + 0, + LR_SHARED | LR_DEFAULTSIZE ); +} + +HICON WINAPI LoadIconW( + _In_opt_ HINSTANCE hInstance, + _In_ LPCWSTR lpIconName +) +{ + TRACE("%p, %s\n", hInstance, debugstr_w(lpIconName)); + + return LoadImageW(hInstance, + lpIconName, + IMAGE_ICON, + 0, + 0, + LR_SHARED | LR_DEFAULTSIZE ); +} + +HCURSOR WINAPI LoadCursorA( + _In_opt_ HINSTANCE hInstance, + _In_ LPCSTR lpCursorName +) +{ + TRACE("%p, %s\n", hInstance, debugstr_a(lpCursorName)); + + return LoadImageA(hInstance, + lpCursorName, + IMAGE_CURSOR, + 0, + 0, + LR_SHARED | LR_DEFAULTSIZE ); +} + +HCURSOR WINAPI LoadCursorW( + _In_opt_ HINSTANCE hInstance, + _In_ LPCWSTR lpCursorName +) +{ + TRACE("%p, %s\n", hInstance, debugstr_w(lpCursorName)); + + return LoadImageW(hInstance, + lpCursorName, + IMAGE_CURSOR, + 0, + 0, + LR_SHARED | LR_DEFAULTSIZE ); +} + +HCURSOR WINAPI LoadCursorFromFileA( + _In_ LPCSTR lpFileName +) +{ + TRACE("%s\n", debugstr_a(lpFileName)); + + return LoadImageA(NULL, + lpFileName, + IMAGE_CURSOR, + 0, + 0, + LR_LOADFROMFILE | LR_DEFAULTSIZE ); +} + +HCURSOR WINAPI LoadCursorFromFileW( + _In_ LPCWSTR lpFileName +) +{ + TRACE("%s\n", debugstr_w(lpFileName)); + + return LoadImageW(NULL, + lpFileName, + IMAGE_CURSOR, + 0, + 0, + LR_LOADFROMFILE | LR_DEFAULTSIZE ); +} + +HBITMAP WINAPI LoadBitmapA( + _In_opt_ HINSTANCE hInstance, + _In_ LPCSTR lpBitmapName +) +{ + TRACE("%p, %s\n", hInstance, debugstr_a(lpBitmapName)); + + return LoadImageA(hInstance, + lpBitmapName, + IMAGE_BITMAP, + 0, + 0, + 0); +} + +HBITMAP WINAPI LoadBitmapW( + _In_opt_ HINSTANCE hInstance, + _In_ LPCWSTR lpBitmapName +) +{ + TRACE("%p, %s\n", hInstance, debugstr_w(lpBitmapName)); + + return LoadImageW(hInstance, + lpBitmapName, + IMAGE_BITMAP, + 0, + 0, + 0); +} + +HANDLE WINAPI LoadImageA( + _In_opt_ HINSTANCE hinst, + _In_ LPCSTR lpszName, + _In_ UINT uType, + _In_ int cxDesired, + _In_ int cyDesired, + _In_ UINT fuLoad +) +{ + HANDLE res; + LPWSTR u_name; + DWORD len; + + if (IS_INTRESOURCE(lpszName)) + return LoadImageW(hinst, (LPCWSTR)lpszName, uType, cxDesired, cyDesired, fuLoad); + + len = MultiByteToWideChar( CP_ACP, 0, lpszName, -1, NULL, 0 ); + u_name = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) ); + MultiByteToWideChar( CP_ACP, 0, lpszName, -1, u_name, len ); + + res = LoadImageW(hinst, u_name, uType, cxDesired, cyDesired, fuLoad); + HeapFree(GetProcessHeap(), 0, u_name); + return res; +} + +HANDLE WINAPI LoadImageW( + _In_opt_ HINSTANCE hinst, + _In_ LPCWSTR lpszName, + _In_ UINT uType, + _In_ int cxDesired, + _In_ int cyDesired, + _In_ UINT fuLoad +) +{ + /* Redirect to each implementation */ + switch(uType) + { + case IMAGE_BITMAP: + return BITMAP_LoadImageW(hinst, lpszName, cxDesired, cyDesired, fuLoad); + case IMAGE_CURSOR: + case IMAGE_ICON: + return CURSORICON_LoadImageW(hinst, lpszName, cxDesired, cyDesired, fuLoad, uType == IMAGE_ICON); + default: + SetLastError(ERROR_INVALID_PARAMETER); + break; + } + return NULL; +} + +int WINAPI LookupIconIdFromDirectory( + _In_ PBYTE presbits, + _In_ BOOL fIcon +) +{ + UNIMPLEMENTED; + return 0; +} + +int WINAPI LookupIconIdFromDirectoryEx( + _In_ PBYTE presbits, + _In_ BOOL fIcon, + _In_ int cxDesired, + _In_ int cyDesired, + _In_ UINT Flags +) +{ + UNIMPLEMENTED; + return 0; +} + +HICON WINAPI CreateIcon( + _In_opt_ HINSTANCE hInstance, + _In_ int nWidth, + _In_ int nHeight, + _In_ BYTE cPlanes, + _In_ BYTE cBitsPixel, + _In_ const BYTE *lpbANDbits, + _In_ const BYTE *lpbXORbits +) +{ + UNIMPLEMENTED; + return NULL; +} + +HICON WINAPI CreateIconFromResource( + _In_ PBYTE presbits, + _In_ DWORD dwResSize, + _In_ BOOL fIcon, + _In_ DWORD dwVer +) +{ + return CreateIconFromResourceEx( presbits, dwResSize, fIcon, dwVer, 0,0,0); +} + +HICON WINAPI CreateIconFromResourceEx( + _In_ PBYTE pbIconBits, + _In_ DWORD cbIconBits, + _In_ BOOL fIcon, + _In_ DWORD dwVersion, + _In_ int cxDesired, + _In_ int cyDesired, + _In_ UINT uFlags +) +{ + UNIMPLEMENTED; + return NULL; +} + +HICON WINAPI CreateIconIndirect( + _In_ PICONINFO piconinfo +) +{ + UNIMPLEMENTED; + return NULL; +} + +HCURSOR WINAPI CreateCursor( + _In_opt_ HINSTANCE hInst, + _In_ int xHotSpot, + _In_ int yHotSpot, + _In_ int nWidth, + _In_ int nHeight, + _In_ const VOID *pvANDPlane, + _In_ const VOID *pvXORPlane +) +{ + UNIMPLEMENTED; + return NULL; +} + +BOOL WINAPI SetSystemCursor( + _In_ HCURSOR hcur, + _In_ DWORD id +) +{ + UNIMPLEMENTED; + return FALSE; +} + +BOOL WINAPI SetCursorPos( + _In_ int X, + _In_ int Y +) +{ + UNIMPLEMENTED; + return FALSE; +} + +BOOL WINAPI GetCursorPos( + _Out_ LPPOINT lpPoint +) +{ + UNIMPLEMENTED; + return FALSE; +} + +int WINAPI ShowCursor( + _In_ BOOL bShow +) +{ + UNIMPLEMENTED; + return -1; +} + +HCURSOR WINAPI GetCursor(void) +{ + UNIMPLEMENTED; + return NULL; +} + +BOOL WINAPI DestroyCursor( + _In_ HCURSOR hCursor +) +{ + UNIMPLEMENTED; + return FALSE; +} Propchange: trunk/reactos/win32ss/user/user32/windows/cursoricon_new.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: trunk/reactos/win32ss/w32ksvc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/w32ksvc.h?rev=5764…
============================================================================== --- trunk/reactos/win32ss/w32ksvc.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/w32ksvc.h [iso-8859-1] Mon Oct 29 01:43:38 2012 @@ -517,7 +517,11 @@ SVC_(UserSetConsoleReserveKeys, 2) SVC_(UserSetCursor, 1) SVC_(UserSetCursorContents, 2) +#ifdef NEW_CURSORICON +SVC_(UserSetCursorIconData, 4) +#else SVC_(UserSetCursorIconData, 6) +#endif SVC_(UserSetDbgTag, 2) SVC_(UserSetFocus, 1) SVC_(UserSetImeHotKey, 5)
12 years, 1 month
1
0
0
0
[hbelusca] 57643: [NTDLL/CSR/SM] - Clean some headers. - Code formatting.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sun Oct 28 22:56:13 2012 New Revision: 57643 URL:
http://svn.reactos.org/svn/reactos?rev=57643&view=rev
Log: [NTDLL/CSR/SM] - Clean some headers. - Code formatting. Removed: branches/ros-csrss/include/reactos/subsys/csr/csrss.h Modified: branches/ros-csrss/ (props changed) branches/ros-csrss/dll/ntdll/include/ntdll.h branches/ros-csrss/include/reactos/subsys/csr/csrmsg.h branches/ros-csrss/include/reactos/subsys/csr/csrsrv.h branches/ros-csrss/include/reactos/subsys/sm/api.h (props changed) branches/ros-csrss/include/reactos/subsys/sm/helper.h (contents, props changed) branches/ros-csrss/include/reactos/subsys/sm/ns.h (contents, props changed) branches/ros-csrss/include/reactos/subsys/win/base.h Propchange: branches/ros-csrss/ ------------------------------------------------------------------------------ --- svn:mergeinfo (original) +++ svn:mergeinfo Sun Oct 28 22:56:13 2012 @@ -13,4 +13,4 @@ /branches/usb-bringup:51335,51337,51341-51343,51348,51350,51353,51355,51365-51369,51372,51384-54388,54396-54398,54736-54737,54752-54754,54756-54760,54762,54764-54765,54767-54768,54772,54774-54777,54781,54787,54790-54792,54797-54798,54806,54808,54834-54838,54843,54850,54852,54856,54858-54859 /branches/usb-bringup-trunk:55019-55543,55548-55554,55556-55567 /branches/wlan-bringup:54809-54998 -/trunk/reactos:57561-57634 +/trunk/reactos:57561-57641 Modified: branches/ros-csrss/dll/ntdll/include/ntdll.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/ntdll/include/ntd…
============================================================================== --- branches/ros-csrss/dll/ntdll/include/ntdll.h [iso-8859-1] (original) +++ branches/ros-csrss/dll/ntdll/include/ntdll.h [iso-8859-1] Sun Oct 28 22:56:13 2012 @@ -41,7 +41,8 @@ /* Internal NTDLL */ #include "ntdllp.h" -/* CSRSS Header */ +/* CSRSS Headers */ +#include <csr/csrsrv.h> #include <csr/csr.h> /* PSEH */ Modified: branches/ros-csrss/include/reactos/subsys/csr/csrmsg.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/csr/csrmsg.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/csr/csrmsg.h [iso-8859-1] Sun Oct 28 22:56:13 2012 @@ -97,9 +97,6 @@ ULONG_PTR PointerArray[1]; } CSR_CAPTURE_BUFFER, *PCSR_CAPTURE_BUFFER; - -#include "csrss.h" // remove it when the data structures are not used anymore. - /* Keep in sync with definition below. */ // #define CSRSS_HEADER_SIZE (sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(NTSTATUS)) @@ -118,17 +115,8 @@ union { CSR_CLIENT_CONNECT CsrClientConnect; - CSR_SET_PRIORITY_CLASS SetPriorityClass; CSR_IDENTIFY_ALTERTABLE_THREAD IdentifyAlertableThread; - - /*** win32csr thingies to remove. ***/ -#if 1 - CSRSS_CREATE_DESKTOP CreateDesktopRequest; - CSRSS_SHOW_DESKTOP ShowDesktopRequest; - CSRSS_HIDE_DESKTOP HideDesktopRequest; -#endif - /************************************/ } Data; }; }; Modified: branches/ros-csrss/include/reactos/subsys/csr/csrsrv.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/csr/csrsrv.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/csr/csrsrv.h [iso-8859-1] Sun Oct 28 22:56:13 2012 @@ -22,6 +22,9 @@ #include "csrmsg.h" /* TYPES **********************************************************************/ + +// Used in ntdll/csr/connect.c +#define CSR_CSRSS_SECTION_SIZE (65536) typedef struct _CSR_NT_SESSION { Removed: branches/ros-csrss/include/reactos/subsys/csr/csrss.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/csr/csrss.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/csr/csrss.h (removed) @@ -1,33 +1,0 @@ -/***************************** CSRSS Data ***********************************/ - -#ifndef __INCLUDE_CSRSS_CSRSS_H -#define __INCLUDE_CSRSS_CSRSS_H - -// Used in ntdll/csr/connect.c -#define CSR_CSRSS_SECTION_SIZE (65536) - - -/*** win32csr thingies to remove. ***/ -#if 1 - -typedef struct -{ - HDESK DesktopHandle; -} CSRSS_CREATE_DESKTOP, *PCSRSS_CREATE_DESKTOP; - -typedef struct -{ - HWND DesktopWindow; - ULONG Width; - ULONG Height; -} CSRSS_SHOW_DESKTOP, *PCSRSS_SHOW_DESKTOP; - -typedef struct -{ - HWND DesktopWindow; -} CSRSS_HIDE_DESKTOP, *PCSRSS_HIDE_DESKTOP; - -#endif -/************************************/ - -#endif /* __INCLUDE_CSRSS_CSRSS_H */ Propchange: branches/ros-csrss/include/reactos/subsys/sm/api.h ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords (removed) @@ -1,1 +1,0 @@ -author date id revision Modified: branches/ros-csrss/include/reactos/subsys/sm/helper.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/sm/helper.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/sm/helper.h [iso-8859-1] Sun Oct 28 22:56:13 2012 @@ -5,36 +5,33 @@ #include <sm/api.h> #endif -/* $Id$ */ - /* smlib/connect.c */ NTSTATUS WINAPI -SmConnectApiPort (IN PUNICODE_STRING pSbApiPortName OPTIONAL, - IN HANDLE hSbApiPort OPTIONAL, - IN WORD wSubsystem OPTIONAL, /* pe.h */ - IN OUT PHANDLE phSmApiPort); +SmConnectApiPort(IN PUNICODE_STRING pSbApiPortName OPTIONAL, + IN HANDLE hSbApiPort OPTIONAL, + IN WORD wSubsystem OPTIONAL, /* pe.h */ + IN OUT PHANDLE phSmApiPort); /* smlib/compses.c */ NTSTATUS WINAPI -SmCompleteSession (IN HANDLE hSmApiPort, - IN HANDLE hSbApiPort, - IN HANDLE hApiPort); +SmCompleteSession(IN HANDLE hSmApiPort, + IN HANDLE hSbApiPort, + IN HANDLE hApiPort); /* smlib/execpgm.c */ NTSTATUS WINAPI -SmExecuteProgram (IN HANDLE hSmApiPort, - IN PUNICODE_STRING Pgm - ); +SmExecuteProgram(IN HANDLE hSmApiPort, + IN PUNICODE_STRING Pgm); /* smdll/query.c */ NTSTATUS WINAPI -SmQueryInformation (IN HANDLE SmApiPort, - IN SM_INFORMATION_CLASS SmInformationClass, - IN OUT PVOID Data, - IN ULONG DataLength, - IN OUT PULONG ReturnedDataLength OPTIONAL); +SmQueryInformation(IN HANDLE SmApiPort, + IN SM_INFORMATION_CLASS SmInformationClass, + IN OUT PVOID Data, + IN ULONG DataLength, + IN OUT PULONG ReturnedDataLength OPTIONAL); /* smlib/lookupss.c */ NTSTATUS WINAPI -SmLookupSubsystem (IN PWSTR Name, - IN OUT PWSTR Data, - IN OUT PULONG DataLength, - IN OUT PULONG DataType, - IN PVOID Environment OPTIONAL); +SmLookupSubsystem(IN PWSTR Name, + IN OUT PWSTR Data, + IN OUT PULONG DataLength, + IN OUT PULONG DataType, + IN PVOID Environment OPTIONAL); #endif /* ndef INCLUDE_SM_HELPER_H */ Propchange: branches/ros-csrss/include/reactos/subsys/sm/helper.h ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords (removed) @@ -1,1 +1,0 @@ -author date id revision Modified: branches/ros-csrss/include/reactos/subsys/sm/ns.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/sm/ns.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/sm/ns.h [iso-8859-1] Sun Oct 28 22:56:13 2012 @@ -1,9 +1,7 @@ #if !defined(INCLUDE_SM_NS_H) #define INCLUDE_SM_NS_H -/* $Id$ */ - -#define SM_REGISTRY_ROOT_NAME L"\\Session Manager" +#define SM_REGISTRY_ROOT_NAME L"\\Session Manager" #define SM_REGISTRY_SUBSYSTEMS_NAME L"SubSystems" #define SM_API_PORT_NAME L"\\SmApiPort" Propchange: branches/ros-csrss/include/reactos/subsys/sm/ns.h ------------------------------------------------------------------------------ --- svn:keywords (original) +++ svn:keywords (removed) @@ -1,1 +1,0 @@ -id author date revision Modified: branches/ros-csrss/include/reactos/subsys/win/base.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/win/base.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/win/base.h [iso-8859-1] Sun Oct 28 22:56:13 2012 @@ -13,7 +13,7 @@ typedef VOID (CALLBACK * BASE_PROCESS_CREATE_NOTIFY_ROUTINE)(PVOID); -NTSTATUS WINAPI BaseSetProcessCreateNotify (BASE_PROCESS_CREATE_NOTIFY_ROUTINE); +NTSTATUS WINAPI BaseSetProcessCreateNotify(BASE_PROCESS_CREATE_NOTIFY_ROUTINE); // CSR_SERVER_DLL_INIT(ServerDllInitialization); typedef struct _NLS_USER_INFO
12 years, 1 month
1
0
0
0
[gadamopoulos] 57642: [win32k] - Plug some object leaks in callproc and clipboard code
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Sun Oct 28 17:31:33 2012 New Revision: 57642 URL:
http://svn.reactos.org/svn/reactos?rev=57642&view=rev
Log: [win32k] - Plug some object leaks in callproc and clipboard code Modified: trunk/reactos/win32ss/user/ntuser/callproc.c trunk/reactos/win32ss/user/ntuser/clipboard.c Modified: trunk/reactos/win32ss/user/ntuser/callproc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/callpr…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/callproc.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/callproc.c [iso-8859-1] Sun Oct 28 17:31:33 2012 @@ -45,6 +45,9 @@ NewCallProc->wType |= Unicode ? UserGetCPDA2U : UserGetCPDU2A ; NewCallProc->spcpdNext = NULL; } + + /* Release the extra reference (UserCreateObject added 2 references) */ + UserDereferenceObject(NewCallProc); return NewCallProc; } Modified: trunk/reactos/win32ss/user/ntuser/clipboard.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/clipbo…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/clipboard.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/clipboard.c [iso-8859-1] Sun Oct 28 17:31:33 2012 @@ -211,6 +211,9 @@ /* Add the clipboard data */ IntAddFormatedData(pWinStaObj, CF_DIB, hMem, TRUE, TRUE); + /* Release the extra reference (UserCreateObject added 2 references) */ + UserDereferenceObject(pClipboardData); + cleanup: UserReleaseDC(NULL, hdc, FALSE); } @@ -302,6 +305,9 @@ *((LCID*)pMemObj->Data) = NtCurrentTeb()->CurrentLocale; IntAddFormatedData(pWinStaObj, CF_LOCALE, hMem, TRUE, TRUE); } + + /* Release the extra reference (UserCreateObject added 2 references) */ + UserDereferenceObject(pMemObj); } /* Add CF_TEXT. Note: it is synthesized in user32.dll */ @@ -1099,6 +1105,9 @@ } _SEH2_END; + /* Release the extra reference (UserCreateObject added 2 references) */ + UserDereferenceObject(pMemObj); + /* If we failed to copy data, remove handle */ if (!pMemObj) {
12 years, 1 month
1
0
0
0
← Newer
1
2
3
4
5
...
22
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
Results per page:
10
25
50
100
200