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
November 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
11 participants
124 discussions
Start a n
N
ew thread
[jgardou] 57695: [WIN32K] - Implement usage of alpha cursors (does not work yet due to a bug in windres) - Directly use bitmaps passed to NtUserSetCursorIconData instead of copying them
by jgardou@svn.reactos.org
Author: jgardou Date: Sat Nov 10 15:56:42 2012 New Revision: 57695 URL:
http://svn.reactos.org/svn/reactos?rev=57695&view=rev
Log: [WIN32K] - Implement usage of alpha cursors (does not work yet due to a bug in windres) - Directly use bitmaps passed to NtUserSetCursorIconData instead of copying them Modified: trunk/reactos/win32ss/gdi/eng/mouse.c trunk/reactos/win32ss/gdi/eng/mouse.h trunk/reactos/win32ss/gdi/eng/pdevobj.h trunk/reactos/win32ss/user/ntuser/cursoricon_new.c trunk/reactos/win32ss/user/ntuser/msgqueue.c trunk/reactos/win32ss/user/user32/windows/cursoricon_new.c Modified: trunk/reactos/win32ss/gdi/eng/mouse.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/mouse.c?re…
============================================================================== --- trunk/reactos/win32ss/gdi/eng/mouse.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/eng/mouse.c [iso-8859-1] Sat Nov 10 15:56:42 2012 @@ -232,29 +232,51 @@ /* Blt the pointer on the screen. */ if (pgp->psurfColor) { - IntEngBitBlt(psoDest, - &pgp->psurfMask->SurfObj, - NULL, - NULL, - NULL, - &rclSurf, - (POINTL*)&rclPointer, - NULL, - NULL, - NULL, - ROP4_FROM_INDEX(R3_OPINDEX_SRCAND)); - - IntEngBitBlt(psoDest, - &pgp->psurfColor->SurfObj, - NULL, - NULL, - NULL, - &rclSurf, - (POINTL*)&rclPointer, - NULL, - NULL, - NULL, - ROP4_FROM_INDEX(R3_OPINDEX_SRCINVERT)); + if(!(pgp->flags & SPS_ALPHA)) + { + IntEngBitBlt(psoDest, + &pgp->psurfMask->SurfObj, + NULL, + NULL, + NULL, + &rclSurf, + (POINTL*)&rclPointer, + NULL, + NULL, + NULL, + ROP4_SRCAND); + + IntEngBitBlt(psoDest, + &pgp->psurfColor->SurfObj, + NULL, + NULL, + NULL, + &rclSurf, + (POINTL*)&rclPointer, + NULL, + NULL, + NULL, + ROP4_SRCINVERT); + } + else + { + BLENDOBJ blendobj = { {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA } }; + EXLATEOBJ exlo; + EXLATEOBJ_vInitialize(&exlo, + pgp->psurfColor->ppal, + ppdev->ppalSurf, + 0xFFFFFFFF, + 0xFFFFFFFF, + 0); + IntEngAlphaBlend(psoDest, + &pgp->psurfColor->SurfObj, + NULL, + &exlo.xlo, + &rclSurf, + &rclPointer, + &blendobj); + EXLATEOBJ_vCleanup(&exlo); + } } else { @@ -352,7 +374,15 @@ if (psoColor) { /* Color bitmap must have the same format as the dest surface */ - if (psoColor->iBitmapFormat != pso->iBitmapFormat) goto failure; + if (psoColor->iBitmapFormat != pso->iBitmapFormat) + { + /* It's OK if we have an alpha bitmap */ + if(!(fl & SPS_ALPHA)) + { + DPRINT1("Screen surface and cursor color bitmap format don't match!.\n"); + goto failure; + } + } /* Create a bitmap to copy the color bitmap to */ hbmColor = EngCreateBitmap(psoColor->sizlBitmap, @@ -452,6 +482,7 @@ pgp->HotSpot.x = xHot; pgp->HotSpot.y = yHot; pgp->Size = sizel; + pgp->flags = fl; if (x != -1) { @@ -598,12 +629,12 @@ LONG xHot, LONG yHot, LONG x, - LONG y) + LONG y, + FLONG fl) { PDC pdc; PSURFACE psurf, psurfMask, psurfColor; EXLATEOBJ exlo; - FLONG fl = 0; ULONG ulResult = 0; pdc = DC_LockDc(hdc); @@ -629,7 +660,10 @@ if (hbmMask) psurfMask = SURFACE_ShareLockSurface(hbmMask); else + { + ASSERT(fl & SPS_ALPHA); psurfMask = NULL; + } /* Check for color bitmap */ if (hbmColor) @@ -645,6 +679,9 @@ } else psurfColor = NULL; + + /* We must have a valid surface in case of alpha bitmap */ + ASSERT(((fl & SPS_ALPHA) && psurfColor) || !(fl & SPS_ALPHA)); /* Call the driver or eng function */ ulResult = IntEngSetPointerShape(&psurf->SurfObj, Modified: trunk/reactos/win32ss/gdi/eng/mouse.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/mouse.h?re…
============================================================================== --- trunk/reactos/win32ss/gdi/eng/mouse.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/eng/mouse.h [iso-8859-1] Sat Nov 10 15:56:42 2012 @@ -12,7 +12,8 @@ LONG xHot, LONG yHot, LONG x, - LONG y); + LONG y, + FLONG fl); VOID NTAPI Modified: trunk/reactos/win32ss/gdi/eng/pdevobj.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/eng/pdevobj.h?…
============================================================================== --- trunk/reactos/win32ss/gdi/eng/pdevobj.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/eng/pdevobj.h [iso-8859-1] Sat Nov 10 15:56:42 2012 @@ -34,6 +34,7 @@ SURFACE *psurfColor; SURFACE *psurfMask; SURFACE *psurfSave; + FLONG flags; /* Public pointer information */ RECTL Exclude; /* Required publicly for SPS_ACCEPT_EXCLUDE */ Modified: 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 [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/cursoricon_new.c [iso-8859-1] Sat Nov 10 15:56:42 2012 @@ -923,7 +923,6 @@ PCURICON_OBJECT CurIcon; NTSTATUS Status = STATUS_SUCCESS; BOOL Ret = FALSE; - CURSORDATA dataSafe; TRACE("Enter NtUserSetCursorIconData\n"); @@ -943,7 +942,15 @@ _SEH2_TRY { ProbeForRead(pCursorData, sizeof(*pCursorData), 1); - RtlCopyMemory(&dataSafe, pCursorData, sizeof(dataSafe)); + CurIcon->xHotspot = pCursorData->xHotspot; + CurIcon->yHotspot = pCursorData->yHotspot; + CurIcon->cx = pCursorData->cx; + CurIcon->cy = pCursorData->cy; + CurIcon->rt = pCursorData->rt; + CurIcon->bpp = pCursorData->bpp; + CurIcon->hbmMask = pCursorData->hbmMask; + CurIcon->hbmColor = pCursorData->hbmColor; + CurIcon->hbmAlpha = pCursorData->hbmAlpha; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -955,41 +962,6 @@ { SetLastNtError(Status); goto done; - } - - CurIcon->xHotspot = dataSafe.xHotspot; - CurIcon->yHotspot = dataSafe.yHotspot; - CurIcon->cx = dataSafe.cx; - CurIcon->cy = dataSafe.cy; - CurIcon->rt = dataSafe.rt; - CurIcon->bpp = dataSafe.bpp; - - if(!dataSafe.hbmMask) - { - ERR("NtUserSetCursorIconData was got no hbmMask.\n"); - EngSetLastError(ERROR_INVALID_PARAMETER); - goto done; - } - - CurIcon->hbmMask = BITMAP_CopyBitmap(dataSafe.hbmMask); - if(!CurIcon->hbmMask) - goto done; - GreSetObjectOwner(CurIcon->hbmMask, GDI_OBJ_HMGR_PUBLIC); - - if(dataSafe.hbmColor) - { - CurIcon->hbmColor = BITMAP_CopyBitmap(dataSafe.hbmColor); - if(!CurIcon->hbmColor) - goto done; - GreSetObjectOwner(CurIcon->hbmColor, GDI_OBJ_HMGR_PUBLIC); - } - - if(dataSafe.hbmAlpha) - { - CurIcon->hbmAlpha = BITMAP_CopyBitmap(dataSafe.hbmAlpha); - if(!CurIcon->hbmAlpha) - goto done; - GreSetObjectOwner(CurIcon->hbmAlpha, GDI_OBJ_HMGR_PUBLIC); } if(pustrModule) @@ -1002,30 +974,28 @@ if(!NT_SUCCESS(Status)) goto done; } + + + if(!CurIcon->hbmMask) + { + ERR("NtUserSetCursorIconData was got no hbmMask.\n"); + EngSetLastError(ERROR_INVALID_PARAMETER); + goto done; + } + + GreSetObjectOwner(CurIcon->hbmMask, GDI_OBJ_HMGR_PUBLIC); + + if(CurIcon->hbmColor) + GreSetObjectOwner(CurIcon->hbmColor, GDI_OBJ_HMGR_PUBLIC); + + if(CurIcon->hbmAlpha) + GreSetObjectOwner(CurIcon->hbmAlpha, GDI_OBJ_HMGR_PUBLIC); Ret = TRUE; done: if(!Ret) { - if (CurIcon->hbmMask) - { - GreSetObjectOwner(CurIcon->hbmMask, GDI_OBJ_HMGR_POWNED); - GreDeleteObject(CurIcon->hbmMask); - CurIcon->hbmMask = NULL; - } - if (CurIcon->hbmColor) - { - GreSetObjectOwner(CurIcon->hbmColor, GDI_OBJ_HMGR_POWNED); - GreDeleteObject(CurIcon->hbmColor); - CurIcon->hbmColor = NULL; - } - if (CurIcon->hbmAlpha) - { - GreSetObjectOwner(CurIcon->hbmAlpha, GDI_OBJ_HMGR_POWNED); - GreDeleteObject(CurIcon->hbmAlpha); - CurIcon->hbmAlpha = NULL; - } if(!IS_INTRESOURCE(CurIcon->strName.Buffer)) ExFreePoolWithTag(CurIcon->strName.Buffer, TAG_STRING); if(CurIcon->ustrModule.Buffer) 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] Sat Nov 10 15:56:42 2012 @@ -147,12 +147,13 @@ /* Call GDI to set the new screen cursor */ #ifdef NEW_CURSORICON GreSetPointerShape(hdcScreen, - NewCursor->hbmMask, - NewCursor->hbmColor, + NewCursor->hbmAlpha ? NULL : NewCursor->hbmMask, + NewCursor->hbmAlpha ? NewCursor->hbmAlpha : NewCursor->hbmColor, NewCursor->xHotspot, NewCursor->yHotspot, gpsi->ptCursor.x, - gpsi->ptCursor.y); + gpsi->ptCursor.y, + NewCursor->hbmAlpha ? SPS_ALPHA : 0); #else GreSetPointerShape(hdcScreen, NewCursor->IconInfo.hbmMask, @@ -160,7 +161,8 @@ NewCursor->IconInfo.xHotspot, NewCursor->IconInfo.yHotspot, gpsi->ptCursor.x, - gpsi->ptCursor.y); + gpsi->ptCursor.y, + 0); #endif } else /* Note: OldCursor != NewCursor so we have to hide cursor */ @@ -582,13 +584,16 @@ { /* Call GDI to set the new screen cursor */ #ifdef NEW_CURSORICON - GreSetPointerShape(hdcScreen, - MessageQueue->CursorObject->hbmMask, - MessageQueue->CursorObject->hbmColor, - MessageQueue->CursorObject->xHotspot, - MessageQueue->CursorObject->yHotspot, - gpsi->ptCursor.x, - gpsi->ptCursor.y); + GreSetPointerShape(hdcScreen, + MessageQueue->CursorObject->hbmAlpha ? + NULL : MessageQueue->CursorObject->hbmMask, + MessageQueue->CursorObject->hbmAlpha ? + MessageQueue->CursorObject->hbmAlpha : MessageQueue->CursorObject->hbmColor, + MessageQueue->CursorObject->xHotspot, + MessageQueue->CursorObject->yHotspot, + gpsi->ptCursor.x, + gpsi->ptCursor.y, + MessageQueue->CursorObject->hbmAlpha ? SPS_ALPHA : 0); #else GreSetPointerShape(hdcScreen, MessageQueue->CursorObject->IconInfo.hbmMask, @@ -596,7 +601,8 @@ MessageQueue->CursorObject->IconInfo.xHotspot, MessageQueue->CursorObject->IconInfo.yHotspot, gpsi->ptCursor.x, - gpsi->ptCursor.y); + gpsi->ptCursor.y, + 0); #endif } else GreMovePointer(hdcScreen, Msg->pt.x, Msg->pt.y); Modified: 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 [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/cursoricon_new.c [iso-8859-1] Sat Nov 10 15:56:42 2012 @@ -906,24 +906,26 @@ hCurIcon = NtUserxCreateEmptyCurObject(bIcon ? 0 : 1); if(!hCurIcon) - goto end_clean; + goto end_error; /* Tell win32k */ if(!NtUserSetCursorIconData(hCurIcon, NULL, NULL, &cursorData)) { NtUserDestroyCursor(hCurIcon, TRUE); - hCurIcon = NULL; - } - - /* Clean up */ -end_clean: + goto end_error; + } + +end: + UnmapViewOfFile(bits); + return hCurIcon; + + /* Clean up */ +end_error: DeleteObject(cursorData.hbmMask); if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); -end: - UnmapViewOfFile(bits); - return hCurIcon; + return NULL; } static @@ -1078,36 +1080,44 @@ if(!bStatus) goto done; + /* This is from resource */ + cursorData.CURSORF_flags = CURSORF_FROMRESOURCE; + /* Create the handle */ hCurIcon = NtUserxCreateEmptyCurObject(bIcon ? 0 : 1); if(!hCurIcon) { - DeleteObject(cursorData.hbmMask); - if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); - if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); - goto done; + goto end_error; } /* Tell win32k */ if(fuLoad & LR_SHARED) + { + cursorData.CURSORF_flags |= CURSORF_LRSHARED; bStatus = NtUserSetCursorIconData(hCurIcon, &ustrModule, &ustrRsrc, &cursorData); + } else bStatus = NtUserSetCursorIconData(hCurIcon, NULL, NULL, &cursorData); if(!bStatus) { NtUserDestroyCursor(hCurIcon, TRUE); - hCurIcon = NULL; - } - - DeleteObject(cursorData.hbmMask); - if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); - if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); + goto end_error; + } done: if(ustrModule.Buffer) HeapFree(GetProcessHeap(), 0, ustrModule.Buffer); return hCurIcon; + +end_error: + if(ustrModule.Buffer) + HeapFree(GetProcessHeap(), 0, ustrModule.Buffer); + DeleteObject(cursorData.hbmMask); + if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); + if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); + + return NULL; } static @@ -1912,54 +1922,60 @@ hIcon = NtUserxCreateEmptyCurObject(fIcon ? 0 : 1); if(!hIcon) - return NULL; + goto end_error; if(!NtUserSetCursorIconData(hIcon, NULL, NULL, &cursorData)) { ERR("NtUserSetCursorIconData failed.\n"); NtUserDestroyCursor(hIcon, TRUE); - hIcon = NULL; - } - + goto end_error; + } + + return hIcon; + + /* Clean up */ +end_error: + DeleteObject(cursorData.hbmMask); + if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); + if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); + + return NULL; +} + +HICON WINAPI CreateIconIndirect( + _In_ PICONINFO piconinfo +) +{ + /* As simple as creating a handle, and let win32k deal with the bitmaps */ + HICON hiconRet; + CURSORDATA cursorData; + + TRACE("%p.\n", piconinfo); + + if(!CURSORICON_GetCursorDataFromIconInfo(&cursorData, piconinfo)) + return NULL; + + hiconRet = NtUserxCreateEmptyCurObject(piconinfo->fIcon ? 0 : 1); + if(!hiconRet) + goto end_error; + + if(!NtUserSetCursorIconData(hiconRet, NULL, NULL, &cursorData)) + { + NtUserDestroyCursor(hiconRet, FALSE); + goto end_error; + } + + TRACE("Returning 0x%08x.\n", hiconRet); + + return hiconRet; + +end_error: /* Clean up */ DeleteObject(cursorData.hbmMask); if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); - return hIcon; -} - -HICON WINAPI CreateIconIndirect( - _In_ PICONINFO piconinfo -) -{ - /* As simple as creating a handle, and let win32k deal with the bitmaps */ - HICON hiconRet; - CURSORDATA cursorData; - - TRACE("%p.\n", piconinfo); - - if(!CURSORICON_GetCursorDataFromIconInfo(&cursorData, piconinfo)) - return NULL; - - hiconRet = NtUserxCreateEmptyCurObject(piconinfo->fIcon ? 0 : 1); - if(!hiconRet) - return NULL; - - if(!NtUserSetCursorIconData(hiconRet, NULL, NULL, &cursorData)) - { - NtUserDestroyCursor(hiconRet, FALSE); - hiconRet = NULL; - } - - /* Clean up */ - DeleteObject(cursorData.hbmMask); - if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); - if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); - - TRACE("Returning 0x%08x.\n", hiconRet); - - return hiconRet; + return NULL; } HCURSOR WINAPI CreateCursor(
12 years, 1 month
1
0
0
0
[hbelusca] 57694: [BASESRV] - Remove the unneeded CallProcessCreated function since the same functionality is programmed and executed in CSRSRV when CsrInsertProcess is called via a call of CsrCrea...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Fri Nov 9 23:39:45 2012 New Revision: 57694 URL:
http://svn.reactos.org/svn/reactos?rev=57694&view=rev
Log: [BASESRV] - Remove the unneeded CallProcessCreated function since the same functionality is programmed and executed in CSRSRV when CsrInsertProcess is called via a call of CsrCreateProcess. - Remove some hacks in process creation. - In BaseSrvExitProcess, use the 'Reply = 2' value instead of the old hack 'ApiMessage->ApiNumber = 0xBABE'. [USER32/WINSRV] - Make SetLogonNotifyWindow call our 'RosSetLogonNotifyWindow' hack and explicitely mark it as a hack. - CsrSetLogonNotifyWindow --> RosSetLogonNotifyWindow to emphasize that it is a ReactOS-specific hack. Modified: branches/ros-csrss/include/reactos/subsys/win/winmsg.h branches/ros-csrss/subsystems/win/basesrv/server.c branches/ros-csrss/win32ss/user/user32/misc/misc.c branches/ros-csrss/win32ss/user/winsrv/init.c branches/ros-csrss/win32ss/user/winsrv/shutdown.c branches/ros-csrss/win32ss/user/winsrv/winsrv.h Modified: branches/ros-csrss/include/reactos/subsys/win/winmsg.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/win/winmsg.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/win/winmsg.h [iso-8859-1] Fri Nov 9 23:39:45 2012 @@ -33,6 +33,9 @@ // UserpConsoleHandleOperation, // Added in Win7 // UserpGetSetShutdownBlockReason, // Added in Vista + /// HACK: ReactOS-specific + UserpRosSetLogonNotifyWindow, + UserpMaxApiNumber } USERSRV_API_NUMBER, *PUSERSRV_API_NUMBER; @@ -54,6 +57,7 @@ BOOL Register; } CSRSS_REGISTER_LOGON_PROCESS, *PCSRSS_REGISTER_LOGON_PROCESS; +/// HACK: ReactOS-specific typedef struct { HWND LogonNotifyWindow; @@ -73,6 +77,8 @@ CSRSS_EXIT_REACTOS ExitReactosRequest; CSRSS_REGISTER_SERVICES_PROCESS RegisterServicesProcessRequest; CSRSS_REGISTER_LOGON_PROCESS RegisterLogonProcessRequest; + + /// HACK: ReactOS-specific CSRSS_SET_LOGON_NOTIFY_WINDOW SetLogonNotifyWindowRequest; } Data; } USER_API_MESSAGE, *PUSER_API_MESSAGE; Modified: branches/ros-csrss/subsystems/win/basesrv/server.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win/basesr…
============================================================================== --- branches/ros-csrss/subsystems/win/basesrv/server.c [iso-8859-1] (original) +++ branches/ros-csrss/subsystems/win/basesrv/server.c [iso-8859-1] Fri Nov 9 23:39:45 2012 @@ -11,45 +11,14 @@ #define NDEBUG #include <debug.h> - -// extern NTSTATUS CallProcessCreated(PCSR_PROCESS, PCSR_PROCESS); // TODO: Import it from csrsrv/init.c -// Remove it and correct csrsrv instead... -#if 0 -NTSTATUS -CallProcessCreated(IN PCSR_PROCESS SourceProcessData, - IN PCSR_PROCESS TargetProcessData) -{ - NTSTATUS Status = STATUS_SUCCESS; - ULONG i; - PCSR_SERVER_DLL ServerDll; - - DPRINT("CSR: %s called\n", __FUNCTION__); - - /* Notify the Server DLLs */ - for (i = 0; i < CSR_SERVER_DLL_MAX; i++) - { - /* Get the current Server DLL */ - ServerDll = CsrLoadedServerDll[i]; - - /* Make sure it's valid and that it has callback */ - if ((ServerDll) && (ServerDll->NewProcessCallback)) - { - Status = ServerDll->NewProcessCallback(SourceProcessData, TargetProcessData); - } - } - - return Status; -} -#endif - CSR_API(BaseSrvCreateProcess) { NTSTATUS Status; PBASE_CREATE_PROCESS CreateProcessRequest = &((PBASE_API_MESSAGE)ApiMessage)->Data.CreateProcessRequest; HANDLE ProcessHandle, ThreadHandle; PCSR_THREAD CsrThread; - PCSR_PROCESS Process; // , NewProcess; - ULONG /* Flags, */ VdmPower = 0, DebugFlags = 0; + PCSR_PROCESS Process; + ULONG Flags = 0, VdmPower = 0, DebugFlags = 0; /* Get the current client thread */ CsrThread = CsrGetClientThread(); @@ -58,7 +27,7 @@ Process = CsrThread->Process; /* Extract the flags out of the process handle */ - // Flags = (ULONG_PTR)CreateProcessRequest->ProcessHandle & 3; + Flags = (ULONG_PTR)CreateProcessRequest->ProcessHandle & 3; CreateProcessRequest->ProcessHandle = (HANDLE)((ULONG_PTR)CreateProcessRequest->ProcessHandle & ~3); /* Duplicate the process handle */ @@ -107,7 +76,7 @@ } } - /* Convert some flags. FIXME: More need conversion */ + /* Flags conversion. FIXME: More need conversion */ if (CreateProcessRequest->CreationFlags & CREATE_NEW_PROCESS_GROUP) { DebugFlags |= CsrProcessCreateNewGroup; @@ -139,20 +108,6 @@ /* FIXME: VDM vodoo */ - /* ReactOS Compatibility */ -#if 0 - Status = CsrLockProcessByClientId(CreateProcessRequest->ClientId.UniqueProcess, &NewProcess); - ASSERT(Status == STATUS_SUCCESS); - if (!(CreateProcessRequest->CreationFlags & (CREATE_NEW_CONSOLE | DETACHED_PROCESS))) - { - NewProcess->ParentConsole = Process->Console; - NewProcess->bInheritHandles = CreateProcessRequest->bInheritHandles; - } - RtlInitializeCriticalSection(&NewProcess->HandleTableLock); - CallProcessCreated(Process, NewProcess); - CsrUnlockProcess(NewProcess); -#endif - /* Return the result of this operation */ return Status; } @@ -206,7 +161,8 @@ /* Call CSRSRV to tell it about the new thread */ Status = CsrCreateThread(CsrProcess, ThreadHandle, - &CreateThreadRequest->ClientId); + &CreateThreadRequest->ClientId, + TRUE); } /* Unlock the process and return */ @@ -232,8 +188,8 @@ PCSR_THREAD CsrThread = CsrGetClientThread(); ASSERT(CsrThread != NULL); - /* Set magic flag so we don't reply this message back */ - ApiMessage->ApiNumber = 0xBABE; + /* Set the special reply value so we don't reply this message back */ + *Reply = 2; /* Remove the CSR_THREADs and CSR_PROCESS */ return CsrDestroyProcess(&CsrThread->ClientId, Modified: branches/ros-csrss/win32ss/user/user32/misc/misc.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/user32/m…
============================================================================== --- branches/ros-csrss/win32ss/user/user32/misc/misc.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/user32/misc/misc.c [iso-8859-1] Fri Nov 9 23:39:45 2012 @@ -74,26 +74,25 @@ WINAPI SetLogonNotifyWindow(HWND Wnd, HWINSTA WinSta) { -#if 0 +/// HACK: Windows does not do this !! ReactOS-specific /* Maybe we should call NtUserSetLogonNotifyWindow and let that one inform CSRSS??? */ - CSR_API_MESSAGE Request; + USER_API_MESSAGE Request; NTSTATUS Status; Request.Data.SetLogonNotifyWindowRequest.LogonNotifyWindow = Wnd; - Status = CsrClientCallServer(&Request, + Status = CsrClientCallServer((PCSR_API_MESSAGE)&Request, NULL, - CSR_CREATE_API_NUMBER(CSR_GUI, SET_LOGON_NOTIFY_WINDOW), - sizeof(CSR_API_MESSAGE)); + CSR_CREATE_API_NUMBER(USERSRV_SERVERDLL_INDEX, UserpRosSetLogonNotifyWindow), + sizeof(CSRSS_SET_LOGON_NOTIFY_WINDOW)); if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) { SetLastError(RtlNtStatusToDosError(Status)); return FALSE; } +/// END HACK return NtUserSetLogonNotifyWindow(Wnd); -#endif - return TRUE; } /* Modified: branches/ros-csrss/win32ss/user/winsrv/init.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/i…
============================================================================== --- branches/ros-csrss/win32ss/user/winsrv/init.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/winsrv/init.c [iso-8859-1] Fri Nov 9 23:39:45 2012 @@ -40,6 +40,9 @@ // SrvCancelShutdown, // Added in Vista // SrvConsoleHandleOperation, // Added in Win7 // SrvGetSetShutdownBlockReason, // Added in Vista + + /// HACK: ReactOS-specific + RosSetLogonNotifyWindow }; BOOLEAN UserServerApiServerValidTable[UserpMaxApiNumber] = @@ -58,6 +61,9 @@ // FALSE, // SrvConsoleHandleOperation // FALSE, // SrvGetSetShutdownBlockReason + /// HACK: ReactOS-specific + FALSE, // RosSetLogonNotifyWindow + // FALSE }; @@ -76,6 +82,9 @@ // "SrvCancelShutdown", // "SrvConsoleHandleOperation", // "SrvGetSetShutdownBlockReason", + + /// HACK: ReactOS-specific + "RosSetLogonNotifyWindow", // NULL }; Modified: branches/ros-csrss/win32ss/user/winsrv/shutdown.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/s…
============================================================================== --- branches/ros-csrss/win32ss/user/winsrv/shutdown.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/winsrv/shutdown.c [iso-8859-1] Fri Nov 9 23:39:45 2012 @@ -56,7 +56,8 @@ return STATUS_SUCCESS; } -CSR_API(CsrSetLogonNotifyWindow) +/// HACK: ReactOS-specific +CSR_API(RosSetLogonNotifyWindow) { PCSRSS_SET_LOGON_NOTIFY_WINDOW SetLogonNotifyWindowRequest = &((PUSER_API_MESSAGE)ApiMessage)->Data.SetLogonNotifyWindowRequest; DWORD WindowCreator; Modified: branches/ros-csrss/win32ss/user/winsrv/winsrv.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/w…
============================================================================== --- branches/ros-csrss/win32ss/user/winsrv/winsrv.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/winsrv/winsrv.h [iso-8859-1] Fri Nov 9 23:39:45 2012 @@ -53,11 +53,12 @@ /* shutdown.c */ CSR_API(SrvExitWindowsEx); -CSR_API(CsrSetLogonNotifyWindow); +// CSR_API(CsrRegisterSystemClasses); +CSR_API(SrvRegisterServicesProcess); CSR_API(SrvRegisterLogonProcess); -// CSR_API(CsrRegisterSystemClasses); -CSR_API(SrvRegisterServicesProcess); +/// HACK: ReactOS-specific +CSR_API(RosSetLogonNotifyWindow); /*****************************
12 years, 1 month
1
0
0
0
[jgardou] 57693: [GDI32_APITEST] - Add test showing that a bitmap created using CreateDIBItmap can be selected into a DC despite a different bits depth
by jgardou@svn.reactos.org
Author: jgardou Date: Thu Nov 8 14:46:47 2012 New Revision: 57693 URL:
http://svn.reactos.org/svn/reactos?rev=57693&view=rev
Log: [GDI32_APITEST] - Add test showing that a bitmap created using CreateDIBItmap can be selected into a DC despite a different bits depth Modified: trunk/rostests/apitests/gdi32/CreateDIBitmap.c Modified: trunk/rostests/apitests/gdi32/CreateDIBitmap.c URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/gdi32/CreateDIBi…
============================================================================== --- trunk/rostests/apitests/gdi32/CreateDIBitmap.c [iso-8859-1] (original) +++ trunk/rostests/apitests/gdi32/CreateDIBitmap.c [iso-8859-1] Thu Nov 8 14:46:47 2012 @@ -415,7 +415,7 @@ void Test_CreateDIBitmap_CBM_CREATDIB(void) { - HBITMAP hbmp; + HBITMAP hbmp, hbmpOld; HDC hdc; BITMAPINFO bmi = {{sizeof(BITMAPINFOHEADER), 4, 4, 1, 8, BI_RGB, 0, 1, 1, 1, 0}, {{0,0,0,0}}}; @@ -437,6 +437,11 @@ ok_int(bitmap.bmBitsPixel, 8); ok_ptr(bitmap.bmBits, 0); + hbmpOld = SelectObject(hdc, hbmp); + ok(hbmpOld != NULL, "Couldn't select the bitmap.\n"); + SelectObject(hdc, hbmpOld); + DeleteObject(hbmp); + DeleteDC(hdc); } START_TEST(CreateDIBitmap)
12 years, 1 month
1
0
0
0
[jgardou] 57692: [WIN32SS/USER] - Start using CURSORDATA structure for passing data from user to kernel mode. - Start using the proper CURSOR structure for win32k internal represesentation of curso...
by jgardou@svn.reactos.org
Author: jgardou Date: Thu Nov 8 12:51:24 2012 New Revision: 57692 URL:
http://svn.reactos.org/svn/reactos?rev=57692&view=rev
Log: [WIN32SS/USER] - Start using CURSORDATA structure for passing data from user to kernel mode. - Start using the proper CURSOR structure for win32k internal represesentation of cursor and icons - Create the alpha bitmap in user mode instead of kernel mode. Modified: trunk/reactos/win32ss/include/ntuser.h trunk/reactos/win32ss/user/ntuser/cursoricon.h trunk/reactos/win32ss/user/ntuser/cursoricon_new.c trunk/reactos/win32ss/user/ntuser/msgqueue.c trunk/reactos/win32ss/user/user32/windows/cursoricon_new.c trunk/reactos/win32ss/w32ksvc.h 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] Thu Nov 8 12:51:24 2012 @@ -975,6 +975,43 @@ BOOL fGlobalHandle; BOOL fIncSerialNumber; } SETCLIPBDATA, *PSETCLIPBDATA; + +// Used with NtUserSetCursorIconData, last parameter. +typedef struct tagCURSORDATA +{ + LPWSTR lpName; + LPWSTR lpModName; + USHORT rt; + USHORT dummy; + ULONG CURSORF_flags; + SHORT xHotspot; + SHORT yHotspot; + HBITMAP hbmMask; + HBITMAP hbmColor; + HBITMAP hbmAlpha; + RECT rcBounds; + HBITMAP hbmUserAlpha; // Could be in W7U, not in W2k + ULONG bpp; + ULONG cx; + ULONG cy; + INT cpcur; + INT cicur; + struct tagCURSORDATA * aspcur; + DWORD * aicur; + INT * ajifRate; + INT iicur; +} CURSORDATA, *PCURSORDATA; /* !dso CURSORDATA */ + +// CURSORF_flags: +#define CURSORF_FROMRESOURCE 0x0001 +#define CURSORF_GLOBAL 0x0002 +#define CURSORF_LRSHARED 0x0004 +#define CURSORF_ACON 0x0008 +#define CURSORF_WOWCLEANUP 0x0010 +#define CURSORF_ACONFRAME 0x0040 +#define CURSORF_SECRET 0x0080 +#define CURSORF_LINKED 0x0100 +#define CURSORF_CURRENT 0x0200 DWORD NTAPI @@ -2737,15 +2774,21 @@ _In_ HCURSOR hCursor, _In_ PUNICODE_STRING pustrModule, _In_ PUNICODE_STRING puSrcName, - _In_ PICONINFO pii); + _In_ PCURSORDATA pCursorData); + +typedef struct _tagFINDEXISTINGCURICONPARAM +{ + BOOL bIcon; + LONG cx; + LONG cy; +} FINDEXISTINGCURICONPARAM; HICON NTAPI NtUserFindExistingCursorIcon( _In_ PUNICODE_STRING pustrModule, _In_ PUNICODE_STRING pustrRsrc, - _In_ LONG cxDesired, - _In_ LONG cyDesired); + _In_ FINDEXISTINGCURICONPARAM* param); #else BOOL NTAPI 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] Thu Nov 8 12:51:24 2012 @@ -9,26 +9,29 @@ } CURICON_PROCESS, *PCURICON_PROCESS; #ifdef NEW_CURSORICON -typedef struct _CURICON_FRAME -{ - HBITMAP hbmMask; - HBITMAP hbmColor; - HBITMAP hbmAlpha; -} CURICON_FRAME, *PCURICON_FRAME; - typedef struct _CURICON_OBJECT { - PROCMARKHEAD head; + PROCMARKHEAD head; + struct _tagCURSOR* pcurNext; + UNICODE_STRING strName; + USHORT atomModName; + USHORT rt; + ULONG CURSORF_flags; + SHORT xHotspot; + SHORT yHotspot; + HBITMAP hbmMask; + HBITMAP hbmColor; + HBITMAP hbmAlpha; + RECT rcBounds; + HBITMAP hbmUserAlpha; + ULONG bpp; + ULONG cx; + ULONG cy; +/* ReactOS specific, to be deleted */ LIST_ENTRY ListEntry; HANDLE Self; LIST_ENTRY ProcessList; UNICODE_STRING ustrModule; - UNICODE_STRING ustrRsrc; - SIZE Size; - BYTE Shadow; - BOOL bIcon; - POINTL ptlHotspot; - CURICON_FRAME aFrame[1]; } CURICON_OBJECT, *PCURICON_OBJECT; #else Modified: 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 [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/cursoricon_new.c [iso-8859-1] Thu Nov 8 12:51:24 2012 @@ -27,8 +27,8 @@ #include <win32k.h> DBG_DEFAULT_CHANNEL(UserIcon); -static PPAGED_LOOKASIDE_LIST pgProcessLookasideList; static LIST_ENTRY gCurIconList; +static PAGED_LOOKASIDE_LIST *pgProcessLookasideList; SYSTEM_CURSORINFO gSysCursorInfo; @@ -48,14 +48,14 @@ 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; + 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; } @@ -64,6 +64,13 @@ IntGetSysCursorInfo() { return &gSysCursorInfo; +} + +FORCEINLINE +BOOL +is_icon(PCURICON_OBJECT object) +{ + return MAKEINTRESOURCE(object->rt) == RT_ICON; } /* This function creates a reference for the object! */ @@ -182,23 +189,23 @@ LIST_FOR_EACH(CurIcon, &gCurIconList, CURICON_OBJECT, ListEntry) { /* See if we are looking for an icon or a cursor */ - if(CurIcon->bIcon != param->bIcon) + if(MAKEINTRESOURCE(CurIcon->rt) != (param->bIcon ? RT_ICON : RT_CURSOR)) continue; /* See if module names match */ if(RtlCompareUnicodeString(pustrModule, &CurIcon->ustrModule, TRUE) == 0) { /* They do. Now see if this is the same resource */ - if(IS_INTRESOURCE(CurIcon->ustrRsrc.Buffer) && IS_INTRESOURCE(pustrRsrc->Buffer)) + if(IS_INTRESOURCE(CurIcon->strName.Buffer) && IS_INTRESOURCE(pustrRsrc->Buffer)) { - if(CurIcon->ustrRsrc.Buffer != pustrRsrc->Buffer) + if(CurIcon->strName.Buffer != pustrRsrc->Buffer) continue; } - else if(IS_INTRESOURCE(CurIcon->ustrRsrc.Buffer) || IS_INTRESOURCE(pustrRsrc->Buffer)) + else if(IS_INTRESOURCE(CurIcon->strName.Buffer) || IS_INTRESOURCE(pustrRsrc->Buffer)) continue; - else if(RtlCompareUnicodeString(pustrRsrc, &CurIcon->ustrRsrc, TRUE) != 0) + else if(RtlCompareUnicodeString(pustrRsrc, &CurIcon->strName, TRUE) != 0) continue; - if ((param->cx == CurIcon->Size.cx) &&(param->cy == CurIcon->Size.cy)) + if ((param->cx == CurIcon->cx) && (param->cy == CurIcon->cy)) { if (! ReferenceCurIconByProcess(CurIcon)) { @@ -217,13 +224,12 @@ IntCreateCurIconHandle(DWORD dwNumber) { PCURICON_OBJECT CurIcon; - BOOLEAN bIcon = dwNumber == 0; HANDLE hCurIcon; if(dwNumber == 0) dwNumber = 1; - CurIcon = UserCreateObject(gHandleTable, NULL, NULL, &hCurIcon, otCursorIcon, FIELD_OFFSET(CURICON_OBJECT, aFrame[dwNumber])); + CurIcon = UserCreateObject(gHandleTable, NULL, NULL, &hCurIcon, otCursorIcon, sizeof(CURICON_OBJECT)); if (!CurIcon) { @@ -232,14 +238,13 @@ } CurIcon->Self = hCurIcon; - CurIcon->bIcon = bIcon; InitializeListHead(&CurIcon->ProcessList); if (! ReferenceCurIconByProcess(CurIcon)) { ERR("Failed to add process\n"); + UserDereferenceObject(CurIcon); UserDeleteObject(hCurIcon, otCursorIcon); - UserDereferenceObject(CurIcon); return NULL; } @@ -251,10 +256,16 @@ BOOLEAN FASTCALL IntDestroyCurIconObject(PCURICON_OBJECT CurIcon, PPROCESSINFO ppi, BOOLEAN bForce) { - PSYSTEM_CURSORINFO CurInfo; HBITMAP bmpMask, bmpColor, bmpAlpha; BOOLEAN Ret, bListEmpty, bFound = FALSE; PCURICON_PROCESS Current = NULL; + + /* Check if this is the current cursor */ + if(CurIcon->CURSORF_flags & CURSORF_CURRENT) + { + UserDereferenceObject(CurIcon); + return FALSE; + } /* For handles created without any data (error handling) */ if(IsListEmpty(&CurIcon->ProcessList)) @@ -308,40 +319,32 @@ /* 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; + bmpMask = CurIcon->hbmMask; + bmpColor = CurIcon->hbmColor; + bmpAlpha = CurIcon->hbmAlpha; /* Delete bitmaps */ if (bmpMask) { GreSetObjectOwner(bmpMask, GDI_OBJ_HMGR_POWNED); GreDeleteObject(bmpMask); - CurIcon->aFrame[0].hbmMask = NULL; + CurIcon->hbmMask = NULL; } if (bmpColor) { GreSetObjectOwner(bmpColor, GDI_OBJ_HMGR_POWNED); GreDeleteObject(bmpColor); - CurIcon->aFrame[0].hbmColor = NULL; + CurIcon->hbmColor = NULL; } if (bmpAlpha) { GreSetObjectOwner(bmpAlpha, GDI_OBJ_HMGR_POWNED); GreDeleteObject(bmpAlpha); - CurIcon->aFrame[0].hbmAlpha = NULL; - } - - if(!IS_INTRESOURCE(CurIcon->ustrRsrc.Buffer)) - ExFreePoolWithTag(CurIcon->ustrRsrc.Buffer, TAG_STRING); + CurIcon->hbmAlpha = NULL; + } + + if(!IS_INTRESOURCE(CurIcon->strName.Buffer)) + ExFreePoolWithTag(CurIcon->strName.Buffer, TAG_STRING); if(CurIcon->ustrModule.Buffer) ReleaseCapturedUnicodeString(&CurIcon->ustrModule, UserMode); @@ -408,27 +411,16 @@ if(IconInfo) { /* Fill data */ - ii.fIcon = CurIcon->bIcon; - ii.xHotspot = CurIcon->ptlHotspot.x; - ii.yHotspot = CurIcon->ptlHotspot.y; + ii.fIcon = is_icon(CurIcon); + ii.xHotspot = CurIcon->xHotspot; + ii.yHotspot = CurIcon->yHotspot; /* Copy bitmaps */ - ii.hbmMask = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmMask); + ii.hbmMask = BITMAP_CopyBitmap(CurIcon->hbmMask); GreSetObjectOwner(ii.hbmMask, GDI_OBJ_HMGR_POWNED); - ii.hbmColor = BITMAP_CopyBitmap(CurIcon->aFrame[0].hbmColor); + ii.hbmColor = BITMAP_CopyBitmap(CurIcon->hbmColor); GreSetObjectOwner(ii.hbmColor, GDI_OBJ_HMGR_POWNED); - - if (pbpp) - { - PSURFACE psurfBmp; - - psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmColor); - if (psurfBmp) - { - colorBpp = BitsPerFormat(psurfBmp->SurfObj.iBitmapFormat); - SURFACE_ShareUnlockSurface(psurfBmp); - } - } + colorBpp = CurIcon->bpp; /* Copy fields */ _SEH2_TRY @@ -487,7 +479,7 @@ if(lpResName) { - if(!CurIcon->ustrRsrc.Buffer) + if(!CurIcon->strName.Buffer) { EngSetLastError(ERROR_INVALID_HANDLE); goto leave; @@ -496,15 +488,15 @@ _SEH2_TRY { ProbeForWrite(lpResName, sizeof(UNICODE_STRING), 1); - if(IS_INTRESOURCE(CurIcon->ustrRsrc.Buffer)) + if(IS_INTRESOURCE(CurIcon->strName.Buffer)) { - lpResName->Buffer = CurIcon->ustrRsrc.Buffer; + lpResName->Buffer = CurIcon->strName.Buffer; lpResName->Length = 0; } else { - lpResName->Length = min(lpResName->MaximumLength, CurIcon->ustrRsrc.Length); - RtlCopyMemory(lpResName->Buffer, CurIcon->ustrRsrc.Buffer, lpResName->Length); + lpResName->Length = min(lpResName->MaximumLength, CurIcon->strName.Length); + RtlCopyMemory(lpResName->Buffer, CurIcon->strName.Buffer, lpResName->Length); } } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) @@ -558,9 +550,9 @@ _SEH2_TRY { ProbeForWrite(plcx, sizeof(LONG), 1); - RtlCopyMemory(plcx, &CurIcon->Size.cx, sizeof(LONG)); + *plcx = CurIcon->cx; ProbeForWrite(plcy, sizeof(LONG), 1); - RtlCopyMemory(plcy, &CurIcon->Size.cy, sizeof(LONG)); + *plcy = CurIcon->cy; } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -788,7 +780,7 @@ _SEH2_TRY { ProbeForRead(param, sizeof(*param), 1); - paramSafe = *param; + RtlCopyMemory(¶mSafe, param, sizeof(paramSafe)); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -882,6 +874,7 @@ EngSetLastError(ERROR_INVALID_CURSOR_HANDLE); goto leave; } + pcurNew->CURSORF_flags |= CURSORF_CURRENT; } else { @@ -892,6 +885,7 @@ if (pcurOld) { hOldCursor = (HCURSOR)pcurOld->Self; + pcurOld->CURSORF_flags &= ~CURSORF_CURRENT; UserDereferenceObject(pcurOld); } @@ -902,7 +896,7 @@ /* - * @implemented + * @unimplemented */ BOOL APIENTRY @@ -910,150 +904,8 @@ 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 (CurIcon) - { - UserDereferenceObject(CurIcon); - } - RETURN(Ret); - -CLEANUP: - TRACE("Leave NtUserSetCursorContents, ret=%i\n",_ret_); - UserLeave(); - END_CLEANUP; + FIXME(" is UNIMPLEMENTED.\n"); + return FALSE; } @@ -1066,13 +918,12 @@ _In_ HCURSOR Handle, _In_opt_ PUNICODE_STRING pustrModule, _In_opt_ PUNICODE_STRING pustrRsrc, - _In_ PICONINFO pIconInfo) + _In_ PCURSORDATA pCursorData) { PCURICON_OBJECT CurIcon; - PSURFACE psurfBmp; NTSTATUS Status = STATUS_SUCCESS; BOOL Ret = FALSE; - ICONINFO ii; + CURSORDATA dataSafe; TRACE("Enter NtUserSetCursorIconData\n"); @@ -1091,8 +942,8 @@ _SEH2_TRY { - ProbeForRead(pIconInfo, sizeof(ICONINFO), 1); - ii = *pIconInfo; + ProbeForRead(pCursorData, sizeof(*pCursorData), 1); + RtlCopyMemory(&dataSafe, pCursorData, sizeof(dataSafe)); } _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { @@ -1105,60 +956,46 @@ SetLastNtError(Status); goto done; } - - /* This is probably not what windows does, but consistency checks can't hurt */ - if(CurIcon->bIcon != ii.fIcon) - { + + CurIcon->xHotspot = dataSafe.xHotspot; + CurIcon->yHotspot = dataSafe.yHotspot; + CurIcon->cx = dataSafe.cx; + CurIcon->cy = dataSafe.cy; + CurIcon->rt = dataSafe.rt; + CurIcon->bpp = dataSafe.bpp; + + if(!dataSafe.hbmMask) + { + ERR("NtUserSetCursorIconData was got no hbmMask.\n"); EngSetLastError(ERROR_INVALID_PARAMETER); goto done; } - CurIcon->ptlHotspot.x = ii.xHotspot; - CurIcon->ptlHotspot.y = ii.yHotspot; - - if(!ii.hbmMask) - { - EngSetLastError(ERROR_INVALID_PARAMETER); + + CurIcon->hbmMask = BITMAP_CopyBitmap(dataSafe.hbmMask); + if(!CurIcon->hbmMask) 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) + GreSetObjectOwner(CurIcon->hbmMask, GDI_OBJ_HMGR_PUBLIC); + + if(dataSafe.hbmColor) + { + CurIcon->hbmColor = BITMAP_CopyBitmap(dataSafe.hbmColor); + if(!CurIcon->hbmColor) goto done; - } - - if (CurIcon->aFrame[0].hbmColor) - { - psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmColor); - if(!psurfBmp) + GreSetObjectOwner(CurIcon->hbmColor, GDI_OBJ_HMGR_PUBLIC); + } + + if(dataSafe.hbmAlpha) + { + CurIcon->hbmAlpha = BITMAP_CopyBitmap(dataSafe.hbmAlpha); + if(!CurIcon->hbmAlpha) goto done; - - CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; - CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy; - SURFACE_ShareUnlockSurface(psurfBmp); - GreSetObjectOwner(CurIcon->aFrame[0].hbmColor, GDI_OBJ_HMGR_PUBLIC); - } - else - { - psurfBmp = SURFACE_ShareLockSurface(CurIcon->aFrame[0].hbmMask); - if(!psurfBmp) - goto done; - - CurIcon->Size.cx = psurfBmp->SurfObj.sizlBitmap.cx; - CurIcon->Size.cy = psurfBmp->SurfObj.sizlBitmap.cy/2; - SURFACE_ShareUnlockSurface(psurfBmp); - } - GreSetObjectOwner(CurIcon->aFrame[0].hbmMask, GDI_OBJ_HMGR_PUBLIC); + GreSetObjectOwner(CurIcon->hbmAlpha, GDI_OBJ_HMGR_PUBLIC); + } if(pustrModule) { /* We use this convenient function, because INTRESOURCEs and ATOMs are the same */ - Status = ProbeAndCaptureUnicodeStringOrAtom(&CurIcon->ustrRsrc, pustrRsrc); + Status = ProbeAndCaptureUnicodeStringOrAtom(&CurIcon->strName, pustrRsrc); if(!NT_SUCCESS(Status)) goto done; Status = ProbeAndCaptureUnicodeString(&CurIcon->ustrModule, UserMode, pustrModule); @@ -1169,27 +1006,32 @@ 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; - } - if(!IS_INTRESOURCE(CurIcon->ustrRsrc.Buffer)) - ExFreePoolWithTag(CurIcon->ustrRsrc.Buffer, TAG_STRING); + if (CurIcon->hbmMask) + { + GreSetObjectOwner(CurIcon->hbmMask, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(CurIcon->hbmMask); + CurIcon->hbmMask = NULL; + } + if (CurIcon->hbmColor) + { + GreSetObjectOwner(CurIcon->hbmColor, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(CurIcon->hbmColor); + CurIcon->hbmColor = NULL; + } + if (CurIcon->hbmAlpha) + { + GreSetObjectOwner(CurIcon->hbmAlpha, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(CurIcon->hbmAlpha); + CurIcon->hbmAlpha = NULL; + } + if(!IS_INTRESOURCE(CurIcon->strName.Buffer)) + ExFreePoolWithTag(CurIcon->strName.Buffer, TAG_STRING); if(CurIcon->ustrModule.Buffer) ReleaseCapturedUnicodeString(&CurIcon->ustrModule, UserMode); } - + UserDereferenceObject(CurIcon); TRACE("Leave NtUserSetCursorIconData, ret=%i\n",Ret); UserLeave(); @@ -1232,9 +1074,9 @@ return FALSE; } - hbmMask = pIcon->aFrame[0].hbmMask; - hbmColor = pIcon->aFrame[0].hbmColor; - hbmAlpha = pIcon->aFrame[0].hbmAlpha; + hbmMask = pIcon->hbmMask; + hbmColor = pIcon->hbmColor; + hbmAlpha = pIcon->hbmAlpha; if (istepIfAniCur) ERR("NtUserDrawIconEx: istepIfAniCur is not supported!\n"); @@ -1254,7 +1096,7 @@ 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); + ASSERT(psurfMask->SurfObj.sizlBitmap.cy == 2*pIcon->cy); psurfColor = NULL; } else if ((psurfColor = SURFACE_ShareLockSurface(hbmColor)) == NULL) @@ -1294,26 +1136,26 @@ } /* Set source rect */ - RECTL_vSetRect(&rcSrc, 0, 0, pIcon->Size.cx, pIcon->Size.cy); + RECTL_vSetRect(&rcSrc, 0, 0, pIcon->cx, pIcon->cy); /* Fix width parameter, if needed */ if (!cxWidth) { if(diFlags & DI_DEFAULTSIZE) - cxWidth = pIcon->bIcon ? + cxWidth = is_icon(pIcon) ? UserGetSystemMetrics(SM_CXICON) : UserGetSystemMetrics(SM_CXCURSOR); else - cxWidth = pIcon->Size.cx; + cxWidth = pIcon->cx; } /* Fix height parameter, if needed */ if (!cyHeight) { if(diFlags & DI_DEFAULTSIZE) - cyHeight = pIcon->bIcon ? + cyHeight = is_icon(pIcon) ? UserGetSystemMetrics(SM_CYICON) : UserGetSystemMetrics(SM_CYCURSOR); else - cyHeight = pIcon->Size.cy; + cyHeight = pIcon->cy; } /* Should we render off-screen? */ @@ -1410,7 +1252,7 @@ } /* Now do the rendering */ - if(hbmAlpha && (diFlags & DI_IMAGE)) + if(hbmAlpha && ((diFlags & DI_NORMAL) == DI_NORMAL)) { BLENDOBJ blendobj = { {AC_SRC_OVER, 0, 255, AC_SRC_ALPHA } }; PSURFACE psurf = NULL; @@ -1501,7 +1343,7 @@ { /* 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); + RECTL_vOffsetRect(&rcSrc, 0, pIcon->cy); EXLATEOBJ_vInitSrcMonoXlate(&exlo, psurfDest->ppal, 0x00FFFFFF, 0); 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] Thu Nov 8 12:51:24 2012 @@ -147,10 +147,10 @@ /* Call GDI to set the new screen cursor */ #ifdef NEW_CURSORICON GreSetPointerShape(hdcScreen, - NewCursor->aFrame[0].hbmMask, - NewCursor->aFrame[0].hbmColor, - NewCursor->ptlHotspot.x, - NewCursor->ptlHotspot.y, + NewCursor->hbmMask, + NewCursor->hbmColor, + NewCursor->xHotspot, + NewCursor->yHotspot, gpsi->ptCursor.x, gpsi->ptCursor.y); #else @@ -583,10 +583,10 @@ /* Call GDI to set the new screen cursor */ #ifdef NEW_CURSORICON GreSetPointerShape(hdcScreen, - MessageQueue->CursorObject->aFrame[0].hbmMask, - MessageQueue->CursorObject->aFrame[0].hbmColor, - MessageQueue->CursorObject->ptlHotspot.x, - MessageQueue->CursorObject->ptlHotspot.y, + MessageQueue->CursorObject->hbmMask, + MessageQueue->CursorObject->hbmColor, + MessageQueue->CursorObject->xHotspot, + MessageQueue->CursorObject->yHotspot, gpsi->ptCursor.x, gpsi->ptCursor.y); #else Modified: 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 [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/cursoricon_new.c [iso-8859-1] Thu Nov 8 12:51:24 2012 @@ -1,8 +1,8 @@ /* * PROJECT: ReactOS user32.dll * COPYRIGHT: GPL - See COPYING in the top level directory - * FILE: dll/win32/user32/windows/class.c - * PURPOSE: Window classes + * FILE: dll/win32/user32/windows/cursoricon.c + * PURPOSE: cursor and icons implementation * PROGRAMMER: Jérôme Gardou (jerome.gardou(a)reactos.org) */ @@ -171,13 +171,144 @@ return -1; } +/*********************************************************************** + * bmi_has_alpha + */ +static BOOL bmi_has_alpha( const BITMAPINFO *info, const void *bits ) +{ + int i; + BOOL has_alpha = FALSE; + const unsigned char *ptr = bits; + + if (info->bmiHeader.biBitCount != 32) return FALSE; + for (i = 0; i < info->bmiHeader.biWidth * abs(info->bmiHeader.biHeight); i++, ptr += 4) + if ((has_alpha = (ptr[3] != 0))) break; + return has_alpha; +} + +/*********************************************************************** + * create_alpha_bitmap + * + * Create the alpha bitmap for a 32-bpp icon that has an alpha channel. + */ +static HBITMAP create_alpha_bitmap( + _In_ HBITMAP color, + _In_opt_ const BITMAPINFO *src_info, + _In_opt_ const void *color_bits ) +{ + HBITMAP alpha = NULL, hbmpOld; + BITMAPINFO *info = NULL; + HDC hdc = NULL, hdcScreen; + void *bits = NULL; + unsigned char *ptr; + int i; + LONG width, height; + BITMAP bm; + + if (!GetObjectW( color, sizeof(bm), &bm )) + return NULL; + if (bm.bmBitsPixel != 32) + return NULL; + + hdcScreen = CreateDCW(DISPLAYW, NULL, NULL, NULL); + if(!hdcScreen) + return NULL; + if(GetDeviceCaps(hdcScreen, BITSPIXEL) != 32) + goto done; + hdc = CreateCompatibleDC(hdcScreen); + if(!hdc) + goto done; + + if(src_info) + { + WORD bpp; + DWORD compr; + int size; + + if(!bmi_has_alpha(src_info, color_bits)) + goto done; + + if(!DIB_GetBitmapInfo(&src_info->bmiHeader, &width, &height, &bpp, &compr)) + goto done; + if(bpp != 32) + goto done; + + size = get_dib_image_size(width, height, bpp); + bits = HeapAlloc(GetProcessHeap(), 0, size); + if(!bits) + goto done; + CopyMemory(bits, color_bits, size); + } + else + { + info = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(BITMAPINFO, bmiColors[256])); + if(!info) + goto done; + info->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + info->bmiHeader.biWidth = bm.bmWidth; + info->bmiHeader.biHeight = -bm.bmHeight; + info->bmiHeader.biPlanes = 1; + info->bmiHeader.biBitCount = 32; + info->bmiHeader.biCompression = BI_RGB; + info->bmiHeader.biSizeImage = bm.bmWidth * bm.bmHeight * 4; + info->bmiHeader.biXPelsPerMeter = 0; + info->bmiHeader.biYPelsPerMeter = 0; + info->bmiHeader.biClrUsed = 0; + info->bmiHeader.biClrImportant = 0; + + bits = HeapAlloc(GetProcessHeap(), 0, info->bmiHeader.biSizeImage); + if(!bits) + goto done; + if(!GetDIBits( hdc, color, 0, bm.bmHeight, bits, info, DIB_RGB_COLORS )) + goto done; + if (!bmi_has_alpha( info, bits )) + goto done; + width = bm.bmWidth; + height = bm.bmHeight; + } + + /* pre-multiply by alpha */ + for (i = 0, ptr = bits; i < width * height; i++, ptr += 4) + { + unsigned int alpha = ptr[3]; + ptr[0] = ptr[0] * alpha / 255; + ptr[1] = ptr[1] * alpha / 255; + ptr[2] = ptr[2] * alpha / 255; + } + + /* Create the bitmap */ + alpha = CreateCompatibleBitmap(hdcScreen, bm.bmWidth, bm.bmHeight); + if(!alpha) + goto done; + hbmpOld = SelectObject(hdc, alpha); + if(!hbmpOld) + goto done; + if(!StretchDIBits( hdc, 0, 0, bm.bmWidth, bm.bmHeight, + 0, 0, width, height, + bits, src_info ? src_info : info, DIB_RGB_COLORS, SRCCOPY )) + { + SelectObject(hdc, hbmpOld); + hbmpOld = NULL; + DeleteObject(alpha); + alpha = NULL; + } + SelectObject(hdc, hbmpOld); + +done: + DeleteDC(hdcScreen); + if(hdc) DeleteDC( hdc ); + if(info) HeapFree( GetProcessHeap(), 0, info ); + if(bits) HeapFree(GetProcessHeap(), 0, bits); + + TRACE("Returning 0x%08x.\n", alpha); + return alpha; +} + /************* IMPLEMENTATION CORE ****************/ -static BOOL CURSORICON_GetIconInfoFromBMI( - _Inout_ ICONINFO* pii, - _In_ const BITMAPINFO *pbmi, - _In_ int cxDesired, - _In_ int cyDesired +static BOOL CURSORICON_GetCursorDataFromBMI( + _Inout_ CURSORDATA* pdata, + _In_ const BITMAPINFO *pbmi ) { UINT ubmiSize = bitmap_info_size(pbmi, DIB_RGB_COLORS); @@ -201,13 +332,22 @@ if(compr != BI_RGB) return FALSE; + /* If no dimensions were set, use the one from the icon */ + if(!pdata->cx) pdata->cx = width; + if(!pdata->cy) pdata->cy = height < 0 ? -height/2 : height/2; + /* Fix the hotspot coords */ - if(!pii->fIcon) - { - 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; + if(pdata->rt == (USHORT)((ULONG_PTR)RT_CURSOR)) + { + if(pdata->cx != width) + pdata->xHotspot = (pdata->xHotspot * pdata->cx) / width; + if(pdata->cy != height/2) + pdata->yHotspot = (pdata->yHotspot * pdata->cy * 2) / height; + } + else + { + pdata->xHotspot = pdata->cx/2; + pdata->yHotspot = pdata->cy/2; } hdcScreen = CreateDCW(DISPLAYW, NULL, NULL, NULL); @@ -230,49 +370,52 @@ ((BITMAPCOREHEADER*)&pbmiCopy->bmiHeader)->bcHeight /= 2; else pbmiCopy->bmiHeader.biHeight /= 2; + height /= 2; pvColor = (const char*)pbmi + ubmiSize; pvMask = (const char*)pvColor + - get_dib_image_size(pbmi->bmiHeader.biWidth, pbmiCopy->bmiHeader.biHeight, pbmi->bmiHeader.biBitCount ); + get_dib_image_size(width, height, bpp ); /* 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) + pdata->hbmColor = NULL; + pdata->hbmMask = CreateBitmap(pdata->cx, pdata->cy * 2, 1, 1, NULL); + if(!pdata->hbmMask) goto done; - hbmpOld = SelectObject(hdc, pii->hbmMask); + hbmpOld = SelectObject(hdc, pdata->hbmMask); if(!hbmpOld) goto done; - if(!StretchDIBits(hdc, 0, cyDesired, cxDesired, cyDesired, - 0, 0, pbmiCopy->bmiHeader.biWidth, pbmiCopy->bmiHeader.biHeight, + if(!StretchDIBits(hdc, 0, pdata->cy, pdata->cx, pdata->cy, + 0, 0, width, height, pvColor, pbmiCopy, DIB_RGB_COLORS, SRCCOPY)) goto done; + pdata->bpp = 1; } else { /* Create the bitmap. It has to be compatible with the screen surface */ - pii->hbmColor = CreateCompatibleBitmap(hdcScreen, cxDesired, cyDesired); - if(!pii->hbmColor) + pdata->hbmColor = CreateCompatibleBitmap(hdcScreen, pdata->cx, pdata->cy); + if(!pdata->hbmColor) goto done; /* Create the 1bpp mask bitmap */ - pii->hbmMask = CreateCompatibleBitmap(hdc, cxDesired, cyDesired); - if(!pii->hbmMask) + pdata->hbmMask = CreateBitmap(pdata->cx, pdata->cy, 1, 1, NULL); + if(!pdata->hbmMask) goto done; - hbmpOld = SelectObject(hdc, pii->hbmColor); + hbmpOld = SelectObject(hdc, pdata->hbmColor); if(!hbmpOld) goto done; - if(!StretchDIBits(hdc, 0, 0, cxDesired, cyDesired, - 0, 0, pbmiCopy->bmiHeader.biWidth, pbmiCopy->bmiHeader.biHeight, + if(!StretchDIBits(hdc, 0, 0, pdata->cx, pdata->cy, + 0, 0, width, height, pvColor, pbmiCopy, DIB_RGB_COLORS, SRCCOPY)) goto done; + pdata->bpp = GetDeviceCaps(hdcScreen, BITSPIXEL); + if(pdata->bpp == 32) + pdata->hbmAlpha = create_alpha_bitmap(pdata->hbmColor, pbmiCopy, pvColor); /* 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; @@ -281,6 +424,7 @@ 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; + pbmiCopy->bmiHeader.biBitCount = 1; } else { @@ -288,14 +432,15 @@ rgb[0].rgbtBlue = rgb[0].rgbtGreen = rgb[0].rgbtRed = 0x00; rgb[1].rgbtBlue = rgb[1].rgbtGreen = rgb[1].rgbtRed = 0xff; + ((BITMAPCOREHEADER*)&pbmiCopy->bmiHeader)->bcBitCount = 1; } } /* Set the mask bits */ - if(!SelectObject(hdc, pii->hbmMask)) + if(!SelectObject(hdc, pdata->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; + bResult = StretchDIBits(hdc, 0, 0, pdata->cx, pdata->cy, + 0, 0, width, height, + pvMask, pbmiCopy, DIB_RGB_COLORS, SRCCOPY) != 0; done: DeleteDC(hdcScreen); @@ -305,10 +450,63 @@ /* Clean up in case of failure */ if(!bResult) { - if(pii->hbmMask) DeleteObject(pii->hbmMask); - if(pii->hbmColor) DeleteObject(pii->hbmColor); + if(pdata->hbmMask) DeleteObject(pdata->hbmMask); + if(pdata->hbmColor) DeleteObject(pdata->hbmColor); + if(pdata->hbmAlpha) DeleteObject(pdata->hbmAlpha); } return bResult; +} + +static BOOL CURSORICON_GetCursorDataFromIconInfo( + _Out_ CURSORDATA* pCursorData, + _In_ ICONINFO* pIconInfo +) +{ + BITMAP bm; + + ZeroMemory(pCursorData, sizeof(*pCursorData)); + /* Use the CopyImage function, as it will gracefully convert our bitmap to the screen bit depth */ + if(pIconInfo->hbmColor) + { + pCursorData->hbmColor = CopyImage(pIconInfo->hbmColor, IMAGE_BITMAP, 0, 0, 0); + if(!pCursorData->hbmColor) + return FALSE; + } + pCursorData->hbmMask = CopyImage(pIconInfo->hbmMask, IMAGE_BITMAP, 0, 0, LR_MONOCHROME); + if(!pCursorData->hbmMask) + return FALSE; + + /* Now, fill some information */ + pCursorData->rt = (USHORT)((ULONG_PTR)(pIconInfo->fIcon ? RT_ICON : RT_CURSOR)); + if(pCursorData->hbmColor) + { + GetObject(pCursorData->hbmColor, sizeof(bm), &bm); + pCursorData->bpp = bm.bmBitsPixel; + pCursorData->cx = bm.bmWidth; + pCursorData->cy = bm.bmHeight; + if(pCursorData->bpp == 32) + pCursorData->hbmAlpha = create_alpha_bitmap(pCursorData->hbmColor, NULL, NULL); + } + else + { + GetObject(pCursorData->hbmMask, sizeof(bm), &bm); + pCursorData->bpp = 1; + pCursorData->cx = bm.bmWidth; + pCursorData->cy = bm.bmHeight/2; + } + + if(pIconInfo->fIcon) + { + pCursorData->xHotspot = pCursorData->cx/2; + pCursorData->yHotspot = pCursorData->cy/2; + } + else + { + pCursorData->xHotspot = pIconInfo->xHotspot; + pCursorData->yHotspot = pIconInfo->yHotspot; + } + + return TRUE; } static @@ -324,14 +522,17 @@ const BITMAPINFO* pbmi; BITMAPINFO* pbmiScaled = NULL; BITMAPINFO* pbmiCopy = NULL; - const VOID* pvMapping; + const VOID* pvMapping = NULL; DWORD dwOffset = 0; - HGLOBAL hgRsrc; + HGLOBAL hgRsrc = NULL; int iBMISize; PVOID pvBits; HDC hdcScreen = NULL; HDC hdc = NULL; - HBITMAP hbmpRet, hbmpOld; + HBITMAP hbmpOld, hbmpRet = NULL; + LONG width, height; + WORD bpp; + DWORD compr; /* Map the bitmap info */ if(fuLoad & LR_LOADFROMFILE) @@ -371,7 +572,18 @@ return NULL; } - /* See if we must scale the bitmap */ + /* Fix up values */ + if(DIB_GetBitmapInfo(&pbmi->bmiHeader, &width, &height, &bpp, &compr) == -1) + goto end; + if((width > 65535) || (height > 65535)) + goto end; + if(cxDesired == 0) + cxDesired = width; + if(cyDesired == 0) + cyDesired = height; + else if(height < 0) + cyDesired = -cyDesired; + iBMISize = bitmap_info_size(pbmi, DIB_RGB_COLORS); /* Get a pointer to the image data */ @@ -492,35 +704,15 @@ if(pbmiScaled->bmiHeader.biSize == sizeof(BITMAPCOREHEADER)) { BITMAPCOREHEADER* pbmch = (BITMAPCOREHEADER*)&pbmiScaled->bmiHeader; - if(cxDesired == 0) - cxDesired = pbmch->bcWidth; - if(cyDesired == 0) - cyDesired == pbmch->bcHeight; - else if(pbmch->bcHeight < 0) - cyDesired = -cyDesired; - pbmch->bcWidth = cxDesired; pbmch->bcHeight = cyDesired; } else { - if ((pbmi->bmiHeader.biHeight > 65535) || (pbmi->bmiHeader.biWidth > 65535)) { - WARN("Broken BITMAPINFO!\n"); - goto end; - } - - if(cxDesired == 0) - cxDesired = pbmi->bmiHeader.biWidth; - if(cyDesired == 0) - cyDesired = pbmi->bmiHeader.biHeight; - else if(pbmi->bmiHeader.biHeight < 0) - cyDesired = -cyDesired; - pbmiScaled->bmiHeader.biWidth = cxDesired; pbmiScaled->bmiHeader.biHeight = cyDesired; /* No compression for DIB sections */ - if(fuLoad & LR_CREATEDIBSECTION) - pbmiScaled->bmiHeader.biCompression = BI_RGB; + pbmiScaled->bmiHeader.biCompression = BI_RGB; } } @@ -574,9 +766,9 @@ HeapFree(GetProcessHeap(), 0, pbmiScaled); if(pbmiCopy) HeapFree(GetProcessHeap(), 0, pbmiCopy); - if (fuLoad & LR_LOADFROMFILE) + if (pvMapping) UnmapViewOfFile( pvMapping ); - else + if(hgRsrc) FreeResource(hgRsrc); return hbmpRet; @@ -621,9 +813,9 @@ CURSORICONFILEDIR *dir; DWORD filesize = 0; LPBYTE bits; - HANDLE hRet = NULL; + HANDLE hCurIcon = NULL; WORD i; - ICONINFO ii; + CURSORDATA cursorData; TRACE("loading %s\n", debugstr_w( lpszName )); @@ -696,25 +888,42 @@ /* Get our entry */ entry = &dir->idEntries[i-1]; + /* Fix dimensions */ + if(!cxDesired) cxDesired = entry->bWidth; + if(!cyDesired) cyDesired = entry->bHeight; /* A bit of preparation */ - ii.xHotspot = entry->xHotspot; - ii.yHotspot = entry->yHotspot; - ii.fIcon = bIcon; + ZeroMemory(&cursorData, sizeof(cursorData)); + if(!bIcon) + { + cursorData.xHotspot = entry->xHotspot; + cursorData.yHotspot = entry->yHotspot; + } + cursorData.rt = (USHORT)((ULONG_PTR)(bIcon ? RT_ICON : RT_CURSOR)); /* Do the dance */ - if(!CURSORICON_GetIconInfoFromBMI(&ii, (BITMAPINFO*)&bits[entry->dwDIBOffset], cxDesired, cyDesired)) + if(!CURSORICON_GetCursorDataFromBMI(&cursorData, (BITMAPINFO*)&bits[entry->dwDIBOffset])) goto end; - /* Create the icon. NOTE: there's no LR_SHARED icons if they are created from file */ - hRet = CreateIconIndirect(&ii); + hCurIcon = NtUserxCreateEmptyCurObject(bIcon ? 0 : 1); + if(!hCurIcon) + goto end_clean; + + /* Tell win32k */ + if(!NtUserSetCursorIconData(hCurIcon, NULL, NULL, &cursorData)) + { + NtUserDestroyCursor(hCurIcon, TRUE); + hCurIcon = NULL; + } /* Clean up */ - DeleteObject(ii.hbmMask); - DeleteObject(ii.hbmColor); +end_clean: + DeleteObject(cursorData.hbmMask); + if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); + if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); end: UnmapViewOfFile(bits); - return hRet; + return hCurIcon; } static @@ -733,7 +942,7 @@ CURSORICONDIR* dir; WORD wResId; LPBYTE bits; - ICONINFO ii; + CURSORDATA cursorData; BOOL bStatus; UNICODE_STRING ustrRsrc; UNICODE_STRING ustrModule = {0, 0, NULL}; @@ -775,7 +984,7 @@ /* Get it */ do { - DWORD ret = GetModuleFileName(hinst, ustrModule.Buffer, size); + DWORD ret = GetModuleFileNameW(hinst, ustrModule.Buffer, size); if(ret == 0) { HeapFree(GetProcessHeap(), 0, ustrModule.Buffer); @@ -783,8 +992,8 @@ } if(ret < size) { - ustrModule.Length = ret; - ustrModule.MaximumLength = size; + ustrModule.Length = ret*sizeof(WCHAR); + ustrModule.MaximumLength = size*sizeof(WCHAR); break; } size *= 2; @@ -845,27 +1054,24 @@ goto done; } - /* Get the hotspot */ - if(bIcon) - { - ii.xHotspot = cxDesired/2; - ii.yHotspot = cyDesired/2; - } - if(!bIcon) - { + ZeroMemory(&cursorData, sizeof(cursorData)); + + if(dir->idType == 2) + { + /* idType == 2 for cursor resources */ SHORT* ptr = (SHORT*)bits; - ii.xHotspot = ptr[0]; - ii.yHotspot = ptr[1]; + cursorData.xHotspot = ptr[0]; + cursorData.yHotspot = ptr[1]; bits += 2*sizeof(SHORT); } - ii.fIcon = bIcon; + cursorData.cx = cxDesired; + cursorData.cy = cyDesired; + cursorData.rt = (USHORT)((ULONG_PTR)(bIcon ? RT_ICON : RT_CURSOR)); /* Get the bitmaps */ - bStatus = CURSORICON_GetIconInfoFromBMI( - &ii, - (BITMAPINFO*)bits, - cxDesired, - cyDesired); + bStatus = CURSORICON_GetCursorDataFromBMI( + &cursorData, + (BITMAPINFO*)bits); FreeResource( handle ); @@ -876,16 +1082,17 @@ hCurIcon = NtUserxCreateEmptyCurObject(bIcon ? 0 : 1); if(!hCurIcon) { - DeleteObject(ii.hbmMask); - if(ii.hbmColor) DeleteObject(ii.hbmColor); + DeleteObject(cursorData.hbmMask); + if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); + if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); goto done; } /* Tell win32k */ if(fuLoad & LR_SHARED) - bStatus = NtUserSetCursorIconData(hCurIcon, &ustrModule, &ustrRsrc, &ii); + bStatus = NtUserSetCursorIconData(hCurIcon, &ustrModule, &ustrRsrc, &cursorData); else - bStatus = NtUserSetCursorIconData(hCurIcon, NULL, NULL, &ii); + bStatus = NtUserSetCursorIconData(hCurIcon, NULL, NULL, &cursorData); if(!bStatus) { @@ -893,8 +1100,9 @@ hCurIcon = NULL; } - DeleteObject(ii.hbmMask); - if(ii.hbmColor) DeleteObject(ii.hbmColor); + DeleteObject(cursorData.hbmMask); + if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); + if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); done: if(ustrModule.Buffer) @@ -905,10 +1113,10 @@ static HBITMAP BITMAP_CopyImage( - _In_ HBITMAP hbmp, - _In_ int cxDesired, - _In_ int cyDesired, - _In_ UINT fuFlags + _In_ HBITMAP hnd, + _In_ int desiredx, + _In_ int desiredy, + _In_ UINT flags ) { HBITMAP res = NULL; @@ -916,22 +1124,22 @@ int objSize; BITMAPINFO * bi; - objSize = GetObjectW( hbmp, sizeof(ds), &ds ); + objSize = GetObjectW( hnd, sizeof(ds), &ds ); if (!objSize) return 0; - if ((cxDesired < 0) || (cyDesired < 0)) return 0; - - if (fuFlags & LR_COPYFROMRESOURCE) + if ((desiredx < 0) || (desiredy < 0)) return 0; + + if (flags & LR_COPYFROMRESOURCE) { FIXME("The flag LR_COPYFROMRESOURCE is not implemented for bitmaps\n"); } - if (fuFlags & LR_COPYRETURNORG) + if (flags & LR_COPYRETURNORG) { FIXME("The flag LR_COPYRETURNORG is not implemented for bitmaps\n"); } - if (cxDesired == 0) cxDesired = ds.dsBm.bmWidth; - if (cyDesired == 0) cyDesired = ds.dsBm.bmHeight; + if (desiredx == 0) desiredx = ds.dsBm.bmWidth; + if (desiredy == 0) desiredy = ds.dsBm.bmHeight; /* Allocate memory for a BITMAPINFOHEADER structure and a color table. The maximum number of colors in a color table @@ -945,7 +1153,7 @@ bi->bmiHeader.biBitCount = ds.dsBm.bmBitsPixel; bi->bmiHeader.biCompression = BI_RGB; - if (fuFlags & LR_CREATEDIBSECTION) + if (flags & LR_CREATEDIBSECTION) { /* Create a DIB section. LR_MONOCHROME is ignored */ void * bits; @@ -958,12 +1166,11 @@ memcpy(bi, &ds.dsBmih, sizeof(BITMAPINFOHEADER)); } + bi->bmiHeader.biWidth = desiredx; + bi->bmiHeader.biHeight = desiredy; + /* Get the color table or the color masks */ - GetDIBits(dc, hbmp, 0, ds.dsBm.bmHeight, NULL, bi, DIB_RGB_COLORS); - - bi->bmiHeader.biWidth = cxDesired; - bi->bmiHeader.biHeight = cyDesired; - bi->bmiHeader.biSizeImage = 0; + GetDIBits(dc, hnd, 0, ds.dsBm.bmHeight, NULL, bi, DIB_RGB_COLORS); res = CreateDIBSection(dc, bi, DIB_RGB_COLORS, &bits, NULL, 0); DeleteDC(dc); @@ -972,16 +1179,16 @@ { /* Create a device-dependent bitmap */ - BOOL monochrome = (fuFlags & LR_MONOCHROME); + BOOL monochrome = (flags & LR_MONOCHROME); if (objSize == sizeof(DIBSECTION)) { /* The source bitmap is a DIB section. Get its attributes */ HDC dc = CreateCompatibleDC(NULL); - bi->bmiHeader.biSize = sizeof(bi->bmiHeader); - bi->bmiHeader.biBitCount = ds.dsBm.bmBitsPixel; - GetDIBits(dc, hbmp, 0, ds.dsBm.bmHeight, NULL, bi, DIB_RGB_COLORS); + bi->bmiHeader.biWidth = ds.dsBm.bmWidth; + bi->bmiHeader.biHeight = ds.dsBm.bmHeight; + GetDIBits(dc, hnd, 0, ds.dsBm.bmHeight, NULL, bi, DIB_RGB_COLORS); DeleteDC(dc); if (!monochrome && ds.dsBm.bmBitsPixel == 1) @@ -1015,12 +1222,12 @@ if (monochrome) { - res = CreateBitmap(cxDesired, cyDesired, 1, 1, NULL); + res = CreateBitmap(desiredx, desiredy, 1, 1, NULL); } else { HDC screenDC = GetDC(NULL); - res = CreateCompatibleBitmap(screenDC, cxDesired, cyDesired); + res = CreateCompatibleBitmap(screenDC, desiredx, desiredy); ReleaseDC(NULL, screenDC); } } @@ -1061,7 +1268,7 @@ bi->bmiHeader.biClrImportant = 0; /* Fill in biSizeImage */ - GetDIBits(dc, hbmp, 0, ds.dsBm.bmHeight, NULL, bi, DIB_RGB_COLORS); + GetDIBits(dc, hnd, 0, ds.dsBm.bmHeight, NULL, bi, DIB_RGB_COLORS); bits = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, bi->bmiHeader.biSizeImage); if (bits) @@ -1069,11 +1276,11 @@ HBITMAP oldBmp; /* Get the image bits of the source bitmap */ - GetDIBits(dc, hbmp, 0, ds.dsBm.bmHeight, bits, bi, DIB_RGB_COLORS); + GetDIBits(dc, hnd, 0, ds.dsBm.bmHeight, bits, bi, DIB_RGB_COLORS); /* Copy it to the destination bitmap */ oldBmp = SelectObject(dc, res); - StretchDIBits(dc, 0, 0, cxDesired, cyDesired, + StretchDIBits(dc, 0, 0, desiredx, desiredy, 0, 0, ds.dsBm.bmWidth, ds.dsBm.bmHeight, bits, bi, DIB_RGB_COLORS, SRCCOPY); SelectObject(dc, oldBmp); @@ -1084,9 +1291,9 @@ DeleteDC(dc); } - if (fuFlags & LR_COPYDELETEORG) - { - DeleteObject(hbmp); + if (flags & LR_COPYDELETEORG) + { + DeleteObject(hnd); } } HeapFree(GetProcessHeap(), 0, bi); @@ -1114,17 +1321,17 @@ PVOID pvBuf; HMODULE hModule; - ustrModule.MaximumLength = MAX_PATH; + ustrModule.MaximumLength = MAX_PATH * sizeof(WCHAR); ustrRsrc.MaximumLength = 256; - ustrModule.Buffer = HeapAlloc(GetProcessHeap(), 0, ustrModule.MaximumLength * sizeof(WCHAR)); + ustrModule.Buffer = HeapAlloc(GetProcessHeap(), 0, ustrModule.MaximumLength); if(!ustrModule.Buffer) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); return NULL; } /* Keep track of the buffer for the resource, NtUserGetIconInfo might overwrite it */ - pvBuf = HeapAlloc(GetProcessHeap(), 0, 256 * sizeof(WCHAR)); + pvBuf = HeapAlloc(GetProcessHeap(), 0, ustrRsrc.MaximumLength); if(!pvBuf) { HeapFree(GetProcessHeap(), 0, ustrModule.Buffer); @@ -1153,7 +1360,7 @@ { PWSTR newBuffer; ustrModule.MaximumLength *= 2; - newBuffer = HeapReAlloc(GetProcessHeap(), 0, ustrModule.Buffer, ustrModule.MaximumLength * sizeof(WCHAR)); + newBuffer = HeapReAlloc(GetProcessHeap(), 0, ustrModule.Buffer, ustrModule.MaximumLength); if(!ustrModule.Buffer) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -1165,7 +1372,7 @@ if(ustrRsrc.Length == ustrRsrc.MaximumLength) { ustrRsrc.MaximumLength *= 2; - pvBuf = HeapReAlloc(GetProcessHeap(), 0, ustrRsrc.Buffer, ustrRsrc.MaximumLength * sizeof(WCHAR)); + pvBuf = HeapReAlloc(GetProcessHeap(), 0, ustrRsrc.Buffer, ustrRsrc.MaximumLength); if(!pvBuf) { SetLastError(ERROR_NOT_ENOUGH_MEMORY); @@ -1176,14 +1383,15 @@ } while(TRUE); /* NULL-terminate our strings */ - ustrModule.Buffer[ustrModule.Length] = 0; + ustrModule.Buffer[ustrModule.Length/sizeof(WCHAR)] = 0; if(!IS_INTRESOURCE(ustrRsrc.Buffer)) - ustrRsrc.Buffer[ustrRsrc.Length] = 0; + ustrRsrc.Buffer[ustrRsrc.Length/sizeof(WCHAR)] = 0; /* Get the module handle */ if(!GetModuleHandleExW(0, ustrModule.Buffer, &hModule)) { /* This hould never happen */ + ERR("Invalid handle?.\n"); SetLastError(ERROR_INVALID_PARAMETER); goto leave; } @@ -1197,6 +1405,8 @@ leave: HeapFree(GetProcessHeap(), 0, ustrModule.Buffer); HeapFree(GetProcessHeap(), 0, pvBuf); + + TRACE("Returning 0x%08x.\n", ret); return ret; } @@ -1499,21 +1709,6 @@ return 0; } - /* idType == 2 is for cursors, 1 for icons */ - /*if(fIcon) - { - if(dir->idType == 2) - { - WARN("An icon was asked for a cursor resource.\n"); - return 0; - } - } - else if(dir->idType == 1) - { - WARN("A cursor was asked for an icon resource.\n"); - return 0; - }*/ - if(Flags & LR_MONOCHROME) bppDesired = 1; else @@ -1526,6 +1721,11 @@ bppDesired = GetDeviceCaps(icScreen, BITSPIXEL); DeleteDC(icScreen); } + + if(!cxDesired) + cxDesired = GetSystemMetrics(fIcon ? SM_CXICON : SM_CXCURSOR); + if(!cyDesired) + cyDesired = GetSystemMetrics(fIcon ? SM_CYICON : SM_CYCURSOR); /* Find the best match for the desired size */ cxyDiff = 0xFFFFFFFF; @@ -1658,7 +1858,7 @@ _In_ DWORD dwVer ) { - return CreateIconFromResourceEx( presbits, dwResSize, fIcon, dwVer, 0,0,0); + return CreateIconFromResourceEx( presbits, dwResSize, fIcon, dwVer, 0, 0, LR_DEFAULTSIZE | LR_SHARED); } HICON WINAPI CreateIconFromResourceEx( @@ -1671,34 +1871,60 @@ _In_ UINT uFlags ) { - ICONINFO ii; + CURSORDATA cursorData; HICON hIcon; - if(uFlags) - FIXME("uFlags 0x%08x ignored.\n", uFlags); - - if(fIcon) - { - ii.xHotspot = cxDesired/2; - ii.yHotspot = cyDesired/2; - } - else + TRACE("%p, %lu, %lu, %lu, %i, %i, %lu.\n", pbIconBits, cbIconBits, fIcon, dwVersion, cxDesired, cyDesired, uFlags); + + if(uFlags & ~LR_DEFAULTSIZE) + FIXME("uFlags 0x%08x ignored.\n", uFlags & ~LR_DEFAULTSIZE); + + if(uFlags & LR_DEFAULTSIZE) + { + if(!cxDesired) cxDesired = GetSystemMetrics(fIcon ? SM_CXICON : SM_CXCURSOR); + if(!cyDesired) cyDesired = GetSystemMetrics(fIcon ? SM_CYICON : SM_CYCURSOR); + } + + /* Check if this is an animated cursor */ + if(!memcmp(pbIconBits, "RIFF", 4)) + { + UNIMPLEMENTED; + return NULL; + } + + ZeroMemory(&cursorData, sizeof(cursorData)); + cursorData.cx = cxDesired; + cursorData.cy = cyDesired; + cursorData.rt = (USHORT)((ULONG_PTR)(fIcon ? RT_ICON : RT_CURSOR)); + if(!fIcon) { WORD* pt = (WORD*)pbIconBits; - ii.xHotspot = *pt++; - ii.yHotspot = *pt++; + cursorData.xHotspot = *pt++; + cursorData.yHotspot = *pt++; pbIconBits = (PBYTE)pt; } - ii.fIcon = fIcon; - - if(!CURSORICON_GetIconInfoFromBMI(&ii, (BITMAPINFO*)pbIconBits, cxDesired, cyDesired)) + + if(!CURSORICON_GetCursorDataFromBMI(&cursorData, (BITMAPINFO*)pbIconBits)) + { + ERR("Couldn't fill the CURSORDATA structure.\n"); return NULL; - - hIcon = CreateIconIndirect(&ii); + } + + hIcon = NtUserxCreateEmptyCurObject(fIcon ? 0 : 1); + if(!hIcon) + return NULL; + + if(!NtUserSetCursorIconData(hIcon, NULL, NULL, &cursorData)) + { + ERR("NtUserSetCursorIconData failed.\n"); + NtUserDestroyCursor(hIcon, TRUE); + hIcon = NULL; + } /* Clean up */ - DeleteObject(ii.hbmMask); - if(ii.hbmColor) DeleteObject(ii.hbmColor); + DeleteObject(cursorData.hbmMask); + if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); + if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); return hIcon; } @@ -1709,18 +1935,27 @@ { /* As simple as creating a handle, and let win32k deal with the bitmaps */ HICON hiconRet; + CURSORDATA cursorData; TRACE("%p.\n", piconinfo); + + if(!CURSORICON_GetCursorDataFromIconInfo(&cursorData, piconinfo)) + return NULL; hiconRet = NtUserxCreateEmptyCurObject(piconinfo->fIcon ? 0 : 1); if(!hiconRet) return NULL; - if(!NtUserSetCursorIconData(hiconRet, NULL, NULL, piconinfo)) + if(!NtUserSetCursorIconData(hiconRet, NULL, NULL, &cursorData)) { NtUserDestroyCursor(hiconRet, FALSE); hiconRet = NULL; } + + /* Clean up */ + DeleteObject(cursorData.hbmMask); + if(cursorData.hbmColor) DeleteObject(cursorData.hbmColor); + if(cursorData.hbmAlpha) DeleteObject(cursorData.hbmAlpha); TRACE("Returning 0x%08x.\n", hiconRet); @@ -1768,8 +2003,7 @@ _In_ int Y ) { - UNIMPLEMENTED; - return FALSE; + return NtUserxSetCursorPos(X,Y); } BOOL WINAPI GetCursorPos( @@ -1783,14 +2017,12 @@ _In_ BOOL bShow ) { - UNIMPLEMENTED; - return -1; + return NtUserxShowCursor(bShow); } HCURSOR WINAPI GetCursor(void) { - UNIMPLEMENTED; - return NULL; + return (HCURSOR)NtUserGetThreadState(THREADSTATE_GETCURSOR); } BOOL WINAPI DestroyCursor( Modified: trunk/reactos/win32ss/w32ksvc.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/w32ksvc.h?rev=5769…
============================================================================== --- trunk/reactos/win32ss/w32ksvc.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/w32ksvc.h [iso-8859-1] Thu Nov 8 12:51:24 2012 @@ -380,8 +380,11 @@ SVC_(UserEvent, 1) SVC_(UserExcludeUpdateRgn, 2) SVC_(UserFillWindow, 4) -// SVC_(UserFindExistingCursorIcon, 3, Wrong, number, of, param, ?) +#ifdef NEW_CURSORICON +SVC_(UserFindExistingCursorIcon, 3) +#else SVC_(UserFindExistingCursorIcon, 4) +#endif SVC_(UserFindWindowEx, 5) SVC_(UserFlashWindowEx, 1) SVC_(UserGetAltTabInfo, 6)
12 years, 1 month
1
0
0
0
[jgardou] 57691: [WIN32K] - Work only with BITMAPINFO in GreGetDIBItsInternal and convert the structure back to BITMAPCOREINFO if needed. - Set the rgbReserved member to 0 when getting palette of a...
by jgardou@svn.reactos.org
Author: jgardou Date: Thu Nov 8 12:40:41 2012 New Revision: 57691 URL:
http://svn.reactos.org/svn/reactos?rev=57691&view=rev
Log: [WIN32K] - Work only with BITMAPINFO in GreGetDIBItsInternal and convert the structure back to BITMAPCOREINFO if needed. - Set the rgbReserved member to 0 when getting palette of a DIB section Modified: trunk/reactos/win32ss/gdi/ntgdi/dib.h trunk/reactos/win32ss/gdi/ntgdi/dibobj.c trunk/reactos/win32ss/user/ntuser/clipboard.c trunk/reactos/win32ss/user/ntuser/misc/file.c Modified: trunk/reactos/win32ss/gdi/ntgdi/dib.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dib.h?re…
============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/dib.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/dib.h [iso-8859-1] Thu Nov 8 12:40:41 2012 @@ -7,8 +7,11 @@ INT APIENTRY DIB_GetDIBImageBytes (INT width, INT height, INT depth); HPALETTE FASTCALL DIB_MapPaletteColors(PPALETTE ppal, CONST BITMAPINFO* lpbmi); HPALETTE FASTCALL BuildDIBPalette (CONST BITMAPINFO *bmi); + +/* Those functions permit to tranparently work with a BITMAPCOREINFO structure */ BITMAPINFO* FASTCALL DIB_ConvertBitmapInfo(CONST BITMAPINFO* bmi, DWORD Usage); -VOID FASTCALL DIB_FreeConvertedBitmapInfo(BITMAPINFO* converted, BITMAPINFO* orig); +/* Pass Usage = -1 if you don't want to convert the BITMAPINFO back to BITMAPCOREINFO */ +VOID FASTCALL DIB_FreeConvertedBitmapInfo(BITMAPINFO* converted, BITMAPINFO* orig, DWORD Usage); INT APIENTRY Modified: trunk/reactos/win32ss/gdi/ntgdi/dibobj.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/gdi/ntgdi/dibobj.c…
============================================================================== --- trunk/reactos/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/gdi/ntgdi/dibobj.c [iso-8859-1] Thu Nov 8 12:40:41 2012 @@ -584,7 +584,6 @@ DWORD compr, size ; USHORT i; int bitmap_type; - RGBTRIPLE* rgbTriples; RGBQUAD* rgbQuads; VOID* colorPtr; @@ -594,7 +593,6 @@ return 0; colorPtr = (LPBYTE)Info + Info->bmiHeader.biSize; - rgbTriples = colorPtr; rgbQuads = colorPtr; bitmap_type = DIB_GetBitmapInfo(&Info->bmiHeader, @@ -643,15 +641,6 @@ switch(bpp) { case 0: /* Only info */ - if(pbmci) - { - pbmci->bmciHeader.bcWidth = (WORD)psurf->SurfObj.sizlBitmap.cx; - pbmci->bmciHeader.bcHeight = (WORD)((psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ? - -psurf->SurfObj.sizlBitmap.cy : - psurf->SurfObj.sizlBitmap.cy); - pbmci->bmciHeader.bcPlanes = 1; - pbmci->bmciHeader.bcBitCount = BitsPerFormat(psurf->SurfObj.iBitmapFormat); - } Info->bmiHeader.biWidth = psurf->SurfObj.sizlBitmap.cx; Info->bmiHeader.biHeight = (psurf->SurfObj.fjBitmap & BMF_TOPDOWN) ? -psurf->SurfObj.sizlBitmap.cy : @@ -702,40 +691,27 @@ if(Usage == DIB_RGB_COLORS) { ULONG colors = min(psurf->ppal->NumColors, 256); - - if(pbmci) - { - for(i = 0; i < colors; i++) - { - rgbTriples[i].rgbtRed = psurf->ppal->IndexedColors[i].peRed; - rgbTriples[i].rgbtGreen = psurf->ppal->IndexedColors[i].peGreen; - rgbTriples[i].rgbtBlue = psurf->ppal->IndexedColors[i].peBlue; - } - } if(colors != 256) Info->bmiHeader.biClrUsed = colors; for(i = 0; i < colors; i++) { rgbQuads[i].rgbRed = psurf->ppal->IndexedColors[i].peRed; rgbQuads[i].rgbGreen = psurf->ppal->IndexedColors[i].peGreen; rgbQuads[i].rgbBlue = psurf->ppal->IndexedColors[i].peBlue; + rgbQuads[i].rgbReserved = 0; } } else + { + for(i = 0; i < 256; i++) + ((WORD*)rgbQuads)[i] = i; + } + } + else + { + if(Usage == DIB_PAL_COLORS) { for(i = 0; i < 256; i++) { - if(pbmci) ((WORD*)rgbTriples)[i] = i; - ((WORD*)rgbQuads)[i] = i; - } - } - } - else - { - if(Usage == DIB_PAL_COLORS) - { - for(i = 0; i < 256; i++) - { - if(pbmci) ((WORD*)rgbTriples)[i] = i; ((WORD*)rgbQuads)[i] = i; } } @@ -752,13 +728,6 @@ } for (i = 0; i < pDcPal->NumColors; i++) { - if (pbmci) - { - rgbTriples[i].rgbtRed = pDcPal->IndexedColors[i].peRed; - rgbTriples[i].rgbtGreen = pDcPal->IndexedColors[i].peGreen; - rgbTriples[i].rgbtBlue = pDcPal->IndexedColors[i].peBlue; - } - rgbQuads[i].rgbRed = pDcPal->IndexedColors[i].peRed; rgbQuads[i].rgbGreen = pDcPal->IndexedColors[i].peGreen; rgbQuads[i].rgbBlue = pDcPal->IndexedColors[i].peBlue; @@ -771,55 +740,20 @@ switch (bpp) { case 1: - if (pbmci) - { - rgbTriples[0].rgbtRed = rgbTriples[0].rgbtGreen = - rgbTriples[0].rgbtBlue = 0; - rgbTriples[1].rgbtRed = rgbTriples[1].rgbtGreen = - rgbTriples[1].rgbtBlue = 0xff; - } - rgbQuads[0].rgbRed = rgbQuads[0].rgbGreen = - rgbQuads[0].rgbBlue = 0; + rgbQuads[0].rgbRed = rgbQuads[0].rgbGreen = rgbQuads[0].rgbBlue = 0; rgbQuads[0].rgbReserved = 0; - rgbQuads[1].rgbRed = rgbQuads[1].rgbGreen = - rgbQuads[1].rgbBlue = 0xff; + rgbQuads[1].rgbRed = rgbQuads[1].rgbGreen = rgbQuads[1].rgbBlue = 0xff; rgbQuads[1].rgbReserved = 0; break; case 4: - if (pbmci) - RtlCopyMemory(rgbTriples, EGAColorsTriples, sizeof(EGAColorsTriples)); RtlCopyMemory(rgbQuads, EGAColorsQuads, sizeof(EGAColorsQuads)); - break; case 8: { INT r, g, b; RGBQUAD *color; - if (pbmci) - { - RGBTRIPLE *colorTriple; - - RtlCopyMemory(rgbTriples, DefLogPaletteTriples, - 10 * sizeof(RGBTRIPLE)); - RtlCopyMemory(rgbTriples + 246, DefLogPaletteTriples + 10, - 10 * sizeof(RGBTRIPLE)); - colorTriple = rgbTriples + 10; - for(r = 0; r <= 5; r++) /* FIXME */ - { - for(g = 0; g <= 5; g++) - { - for(b = 0; b <= 5; b++) - { - colorTriple->rgbtRed = (r * 0xff) / 5; - colorTriple->rgbtGreen = (g * 0xff) / 5; - colorTriple->rgbtBlue = (b * 0xff) / 5; - colorTriple++; - } - } - } - } memcpy(rgbQuads, DefLogPaletteQuads, 10 * sizeof(RGBQUAD)); memcpy(rgbQuads + 246, DefLogPaletteQuads + 10, @@ -933,11 +867,8 @@ } psurfDest = SURFACE_ShareLockSurface(hBmpDest); - - rcDest.left = 0; - rcDest.top = 0; - rcDest.bottom = ScanLines; - rcDest.right = psurf->SurfObj.sizlBitmap.cx; + + RECTL_vSetRect(&rcDest, 0, 0, ScanLines, psurf->SurfObj.sizlBitmap.cx); srcPoint.x = 0; @@ -987,7 +918,7 @@ if(pDC) DC_UnlockDc(pDC); if(psurf) SURFACE_ShareUnlockSurface(psurf); - if(pbmci) DIB_FreeConvertedBitmapInfo(Info, (BITMAPINFO*)pbmci); + if(pbmci) DIB_FreeConvertedBitmapInfo(Info, (BITMAPINFO*)pbmci, Usage); return ScanLines; } @@ -1926,10 +1857,51 @@ /* Frees a BITMAPINFO created with DIB_ConvertBitmapInfo */ VOID FASTCALL -DIB_FreeConvertedBitmapInfo(BITMAPINFO* converted, BITMAPINFO* orig) -{ - if(converted != orig) +DIB_FreeConvertedBitmapInfo(BITMAPINFO* converted, BITMAPINFO* orig, DWORD usage) +{ + BITMAPCOREINFO* pbmci; + if(converted == orig) + return; + + if(usage == -1) + { + /* Caller don't want any conversion */ ExFreePoolWithTag(converted, TAG_DIB); + return; + } + + /* Perform inverse conversion */ + pbmci = (BITMAPCOREINFO*)orig; + + ASSERT(pbmci->bmciHeader.bcSize == sizeof(BITMAPCOREHEADER)); + pbmci->bmciHeader.bcBitCount = converted->bmiHeader.biBitCount; + pbmci->bmciHeader.bcWidth = converted->bmiHeader.biWidth; + pbmci->bmciHeader.bcHeight = converted->bmiHeader.biHeight; + pbmci->bmciHeader.bcPlanes = converted->bmiHeader.biPlanes; + + if(pbmci->bmciHeader.bcBitCount <= 8) + { + UINT numColors = converted->bmiHeader.biClrUsed; + if(!numColors) numColors = 1 << pbmci->bmciHeader.bcBitCount; + if(usage == DIB_PAL_COLORS) + { + RtlZeroMemory(pbmci->bmciColors, (1 << pbmci->bmciHeader.bcBitCount) * sizeof(WORD)); + RtlCopyMemory(pbmci->bmciColors, converted->bmiColors, numColors * sizeof(WORD)); + } + else + { + UINT i; + RtlZeroMemory(pbmci->bmciColors, (1 << pbmci->bmciHeader.bcBitCount) * sizeof(RGBTRIPLE)); + for(i=0; i<numColors; i++) + { + pbmci->bmciColors[i].rgbtRed = converted->bmiColors[i].rgbRed; + pbmci->bmciColors[i].rgbtGreen = converted->bmiColors[i].rgbGreen; + pbmci->bmciColors[i].rgbtBlue = converted->bmiColors[i].rgbBlue; + } + } + } + /* Now free it, it's not needed anymore */ + ExFreePoolWithTag(converted, TAG_DIB); } /* EOF */ 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] Thu Nov 8 12:40:41 2012 @@ -276,7 +276,7 @@ UserReleaseDC(NULL, hdc, FALSE); if (pConvertedBmi) - DIB_FreeConvertedBitmapInfo(pConvertedBmi, pBmi); + DIB_FreeConvertedBitmapInfo(pConvertedBmi, pBmi, -1); } VOID static NTAPI Modified: trunk/reactos/win32ss/user/ntuser/misc/file.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/misc/f…
============================================================================== --- trunk/reactos/win32ss/user/ntuser/misc/file.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/misc/file.c [iso-8859-1] Thu Nov 8 12:40:41 2012 @@ -233,7 +233,7 @@ 0); NtGdiDeleteObjectApp(hdc); - DIB_FreeConvertedBitmapInfo(pConvertedInfo, pbmi); + DIB_FreeConvertedBitmapInfo(pConvertedInfo, pbmi, -1); } else {
12 years, 1 month
1
0
0
0
[hbelusca] 57690: Synchronize up to trunk's revision r57689.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Wed Nov 7 23:07:18 2012 New Revision: 57690 URL:
http://svn.reactos.org/svn/reactos?rev=57690&view=rev
Log: Synchronize up to trunk's revision r57689. Added: branches/ros-csrss/dll/win32/netapi32/netapi32.h - copied unchanged from r57689, trunk/reactos/dll/win32/netapi32/netapi32.h Modified: branches/ros-csrss/ (props changed) branches/ros-csrss/Doxyfile branches/ros-csrss/base/shell/explorer/desktop/desktop.cpp branches/ros-csrss/base/shell/explorer/desktop/desktop.h branches/ros-csrss/base/shell/explorer/shell/shellbrowser.cpp branches/ros-csrss/base/shell/explorer/shell/shellbrowser.h branches/ros-csrss/base/shell/explorer/utility/window.cpp branches/ros-csrss/base/shell/explorer/utility/window.h branches/ros-csrss/boot/bootdata/hivesys_amd64.inf branches/ros-csrss/boot/bootdata/hivesys_i386.inf branches/ros-csrss/dll/ntdll/rtl/version.c branches/ros-csrss/dll/win32/advapi32/advapi32.h branches/ros-csrss/dll/win32/advapi32/sec/sid.c branches/ros-csrss/dll/win32/kernel32/client/version.c branches/ros-csrss/dll/win32/netapi32/CMakeLists.txt branches/ros-csrss/dll/win32/netapi32/local_group.c branches/ros-csrss/dll/win32/netapi32/netapi32.c branches/ros-csrss/dll/win32/netapi32/netapi32.spec branches/ros-csrss/dll/win32/samsrv/samrpc.c branches/ros-csrss/lib/rtl/version.c branches/ros-csrss/ntoskrnl/mm/ARM3/procsup.c branches/ros-csrss/ntoskrnl/rtl/misc.c branches/ros-csrss/win32ss/CMakeLists.txt branches/ros-csrss/win32ss/gdi/gdi32/CMakeLists.txt branches/ros-csrss/win32ss/include/ntuser.h branches/ros-csrss/win32ss/include/ntusrtyp.h branches/ros-csrss/win32ss/user/ntuser/class.c branches/ros-csrss/win32ss/user/ntuser/class.h branches/ros-csrss/win32ss/user/ntuser/cursoricon.c branches/ros-csrss/win32ss/user/ntuser/cursoricon.h branches/ros-csrss/win32ss/user/ntuser/cursoricon_new.c branches/ros-csrss/win32ss/user/ntuser/simplecall.c branches/ros-csrss/win32ss/user/user32/CMakeLists.txt branches/ros-csrss/win32ss/user/user32/controls/edit.c branches/ros-csrss/win32ss/user/user32/windows/cursoricon_new.c branches/ros-csrss/win32ss/user/user32/windows/dialog.c branches/ros-csrss/win32ss/user/user32/windows/mdi.c [This mail would be too long, it was shortened to contain the URLs only.] Modified: branches/ros-csrss/Doxyfile URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/Doxyfile?rev=57690&r1…
Modified: branches/ros-csrss/base/shell/explorer/desktop/desktop.cpp URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/base/shell/explorer/d…
Modified: branches/ros-csrss/base/shell/explorer/desktop/desktop.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/base/shell/explorer/d…
Modified: branches/ros-csrss/base/shell/explorer/shell/shellbrowser.cpp URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/base/shell/explorer/s…
Modified: branches/ros-csrss/base/shell/explorer/shell/shellbrowser.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/base/shell/explorer/s…
Modified: branches/ros-csrss/base/shell/explorer/utility/window.cpp URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/base/shell/explorer/u…
Modified: branches/ros-csrss/base/shell/explorer/utility/window.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/base/shell/explorer/u…
Modified: branches/ros-csrss/boot/bootdata/hivesys_amd64.inf URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/boot/bootdata/hivesys…
Modified: branches/ros-csrss/boot/bootdata/hivesys_i386.inf URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/boot/bootdata/hivesys…
Modified: branches/ros-csrss/dll/ntdll/rtl/version.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/ntdll/rtl/version…
Modified: branches/ros-csrss/dll/win32/advapi32/advapi32.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/advapi32/ad…
Modified: branches/ros-csrss/dll/win32/advapi32/sec/sid.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/advapi32/se…
Modified: branches/ros-csrss/dll/win32/kernel32/client/version.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
Modified: branches/ros-csrss/dll/win32/netapi32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/netapi32/CM…
Modified: branches/ros-csrss/dll/win32/netapi32/local_group.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/netapi32/lo…
Modified: branches/ros-csrss/dll/win32/netapi32/netapi32.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/netapi32/ne…
Modified: branches/ros-csrss/dll/win32/netapi32/netapi32.spec URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/netapi32/ne…
Modified: branches/ros-csrss/dll/win32/samsrv/samrpc.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/samsrv/samr…
Modified: branches/ros-csrss/lib/rtl/version.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/lib/rtl/version.c?rev…
Modified: branches/ros-csrss/ntoskrnl/mm/ARM3/procsup.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/ntoskrnl/mm/ARM3/proc…
Modified: branches/ros-csrss/ntoskrnl/rtl/misc.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/ntoskrnl/rtl/misc.c?r…
Modified: branches/ros-csrss/win32ss/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/CMakeLists.tx…
Modified: branches/ros-csrss/win32ss/gdi/gdi32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/gdi/gdi32/CMa…
Modified: branches/ros-csrss/win32ss/include/ntuser.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/include/ntuse…
Modified: branches/ros-csrss/win32ss/include/ntusrtyp.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/include/ntusr…
Modified: branches/ros-csrss/win32ss/user/ntuser/class.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
Modified: branches/ros-csrss/win32ss/user/ntuser/class.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
Modified: branches/ros-csrss/win32ss/user/ntuser/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
Modified: branches/ros-csrss/win32ss/user/ntuser/cursoricon.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
Modified: branches/ros-csrss/win32ss/user/ntuser/cursoricon_new.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/c…
Modified: branches/ros-csrss/win32ss/user/ntuser/simplecall.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/ntuser/s…
Modified: branches/ros-csrss/win32ss/user/user32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/user32/C…
Modified: branches/ros-csrss/win32ss/user/user32/controls/edit.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/user32/c…
Modified: branches/ros-csrss/win32ss/user/user32/windows/cursoricon_new.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/user32/w…
Modified: branches/ros-csrss/win32ss/user/user32/windows/dialog.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/user32/w…
Modified: branches/ros-csrss/win32ss/user/user32/windows/mdi.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/user32/w…
12 years, 1 month
1
0
0
0
[hbelusca] 57689: [CONSRV] - Use the DLL instance for getting its win23 resources. - Use the CONSOLE_PROCESS_DATA structure (see r57686) for accessing console-specific fields of the processes (inst...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Wed Nov 7 22:23:36 2012 New Revision: 57689 URL:
http://svn.reactos.org/svn/reactos?rev=57689&view=rev
Log: [CONSRV] - Use the DLL instance for getting its win23 resources. - Use the CONSOLE_PROCESS_DATA structure (see r57686) for accessing console-specific fields of the processes (instead of using them implemented in the CSR_PROCESS structure). - Win32CsrDuplicateHandleTable --> ConsoleNewProcess since it's the callback function called when a new process is created, and start to move some hacks currently present in BaseSrvCreateProcess. TODO: suppress the starting-application-related hacks in BaseSrvCreateProcess (in basesrv). Modified: branches/ros-csrss/win32ss/user/consrv/guiconsole.c branches/ros-csrss/win32ss/user/consrv/handle.c branches/ros-csrss/win32ss/user/consrv/lineinput.c Modified: branches/ros-csrss/win32ss/user/consrv/guiconsole.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/g…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] Wed Nov 7 22:23:36 2012 @@ -130,13 +130,12 @@ UINT i = 0; WCHAR szMenuString[255]; HMENU hSubMenu; - HINSTANCE hInst = GetModuleHandleW(L"win32csr"); do { if (Items[i].uID != (UINT)-1) { - if (LoadStringW(hInst, + if (LoadStringW(ConSrvDllInstance, Items[i].uID, szMenuString, sizeof(szMenuString) / sizeof(szMenuString[0])) > 0) @@ -406,15 +405,16 @@ GuiConsoleWriteUserSettings(PCSRSS_CONSOLE Console, PGUI_CONSOLE_DATA GuiData) { HKEY hKey; - PCSR_PROCESS ProcessData; + PCONSOLE_PROCESS_DATA ProcessData; if (Console->ProcessList.Flink == &Console->ProcessList) { DPRINT("GuiConsoleWriteUserSettings: No Process!!!\n"); return; } - ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CSR_PROCESS, ConsoleLink); - if (!GuiConsoleOpenUserSettings(GuiData, PtrToUlong(ProcessData->ClientId.UniqueProcess), &hKey, KEY_READ | KEY_WRITE, TRUE)) + + ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CONSOLE_PROCESS_DATA, ConsoleLink); + if (!GuiConsoleOpenUserSettings(GuiData, PtrToUlong(ProcessData->Process->ClientId.UniqueProcess), &hKey, KEY_READ | KEY_WRITE, TRUE)) { return; } @@ -703,7 +703,7 @@ HFONT OldFont; TEXTMETRICW Metrics; SIZE CharSize; - PCSR_PROCESS ProcessData; + PCONSOLE_PROCESS_DATA ProcessData; HKEY hKey; Console->hWindow = hWnd; @@ -717,8 +717,8 @@ GuiConsoleUseDefaults(Console, GuiData, Console->ActiveBuffer); if (Console->ProcessList.Flink != &Console->ProcessList) { - ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CSR_PROCESS, ConsoleLink); - if (GuiConsoleOpenUserSettings(GuiData, PtrToUlong(ProcessData->ClientId.UniqueProcess), &hKey, KEY_READ, FALSE)) + ProcessData = CONTAINING_RECORD(Console->ProcessList.Flink, CONSOLE_PROCESS_DATA, ConsoleLink); + if (GuiConsoleOpenUserSettings(GuiData, PtrToUlong(ProcessData->Process->ClientId.UniqueProcess), &hKey, KEY_READ, FALSE)) { GuiConsoleReadUserSettings(hKey, Console, GuiData, Console->ActiveBuffer); RegCloseKey(hKey); @@ -801,7 +801,7 @@ SetEvent(GuiData->hGuiInitEvent); - return (BOOL) DefWindowProcW(hWnd, WM_NCCREATE, 0, (LPARAM) Create); + return (BOOL)DefWindowProcW(hWnd, WM_NCCREATE, 0, (LPARAM)Create); } static VOID @@ -1276,7 +1276,7 @@ PCSRSS_CONSOLE Console; PGUI_CONSOLE_DATA GuiData; PLIST_ENTRY current_entry; - PCSR_PROCESS current; + PCONSOLE_PROCESS_DATA current; GuiConsoleGetDataPointers(hWnd, &Console, &GuiData); @@ -1285,7 +1285,7 @@ current_entry = Console->ProcessList.Flink; while (current_entry != &Console->ProcessList) { - current = CONTAINING_RECORD(current_entry, CSR_PROCESS, ConsoleLink); + current = CONTAINING_RECORD(current_entry, CONSOLE_PROCESS_DATA, ConsoleLink); current_entry = current_entry->Flink; /* FIXME: Windows will wait up to 5 seconds for the thread to exit. @@ -2194,7 +2194,7 @@ wc.lpszClassName = L"Win32CsrCreateNotify"; wc.lpfnWndProc = GuiConsoleNotifyWndProc; wc.style = 0; - wc.hInstance = (HINSTANCE) GetModuleHandleW(NULL); + wc.hInstance = (HINSTANCE)GetModuleHandleW(NULL); wc.hIcon = NULL; wc.hCursor = NULL; wc.hbrBackground = NULL; @@ -2212,14 +2212,14 @@ wc.lpszClassName = L"ConsoleWindowClass"; wc.lpfnWndProc = GuiConsoleWndProc; wc.style = 0; - wc.hInstance = (HINSTANCE) GetModuleHandleW(NULL); - wc.hIcon = LoadIconW(GetModuleHandleW(L"win32csr"), MAKEINTRESOURCEW(1)); + wc.hInstance = (HINSTANCE)GetModuleHandleW(NULL); + wc.hIcon = LoadIconW(ConSrvDllInstance, MAKEINTRESOURCEW(1)); wc.hCursor = LoadCursorW(NULL, (LPCWSTR) IDC_ARROW); wc.hbrBackground = CreateSolidBrush(RGB(0,0,0)); wc.lpszMenuName = NULL; wc.cbClsExtra = 0; wc.cbWndExtra = 0; - wc.hIconSm = LoadImageW(GetModuleHandleW(L"win32csr"), MAKEINTRESOURCEW(1), IMAGE_ICON, + wc.hIconSm = LoadImageW(ConSrvDllInstance, MAKEINTRESOURCEW(1), IMAGE_ICON, GetSystemMetrics(SM_CXSMICON), GetSystemMetrics(SM_CYSMICON), LR_SHARED); if (RegisterClassExW(&wc) == 0) @@ -2255,7 +2255,7 @@ Title = L""; } - SendMessageW(Console->hWindow, WM_SETTEXT, 0, (LPARAM) Title); + SendMessageW(Console->hWindow, WM_SETTEXT, 0, (LPARAM)Title); if (NULL != Buffer) { @@ -2277,7 +2277,7 @@ static VOID WINAPI GuiCleanupConsole(PCSRSS_CONSOLE Console) { - SendMessageW(NotifyWnd, PM_DESTROY_CONSOLE, 0, (LPARAM) Console); + SendMessageW(NotifyWnd, PM_DESTROY_CONSOLE, 0, (LPARAM)Console); } static CSRSS_CONSOLE_VTBL GuiVtbl = @@ -2362,7 +2362,7 @@ */ GuiData->hGuiInitEvent = CreateEventW(NULL, FALSE, FALSE, NULL); /* create console */ - PostMessageW(NotifyWnd, PM_CREATE_CONSOLE, ShowCmd, (LPARAM) Console); + PostMessageW(NotifyWnd, PM_CREATE_CONSOLE, ShowCmd, (LPARAM)Console); /* wait untill initialization has finished */ WaitForSingleObject(GuiData->hGuiInitEvent, INFINITE); Modified: branches/ros-csrss/win32ss/user/consrv/handle.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/h…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/handle.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/handle.c [iso-8859-1] Wed Nov 7 22:23:36 2012 @@ -15,15 +15,6 @@ #include <debug.h> -typedef struct _CSRSS_HANDLE -{ - Object_t *Object; - DWORD Access; - BOOL Inheritable; - DWORD ShareMode; -} CSRSS_HANDLE, *PCSRSS_HANDLE; - - /* FUNCTIONS *****************************************************************/ static @@ -80,7 +71,7 @@ NTSTATUS FASTCALL -Win32CsrReleaseObject(PCSR_PROCESS ProcessData, +Win32CsrReleaseObject(PCONSOLE_PROCESS_DATA ProcessData, HANDLE Handle) { ULONG_PTR h = (ULONG_PTR)Handle >> 2; @@ -100,7 +91,7 @@ NTSTATUS FASTCALL -Win32CsrLockObject(PCSR_PROCESS ProcessData, +Win32CsrLockObject(PCONSOLE_PROCESS_DATA ProcessData, HANDLE Handle, Object_t **Object, DWORD Access, @@ -108,7 +99,7 @@ { ULONG_PTR h = (ULONG_PTR)Handle >> 2; - DPRINT("CsrGetObject, Object: %x, %x, %x\n", + DPRINT("Win32CsrLockObject, Object: %x, %x, %x\n", Object, Handle, ProcessData ? ProcessData->HandleTableSize : 0); RtlEnterCriticalSection(&ProcessData->HandleTableLock); @@ -139,10 +130,87 @@ ConioDeleteConsole(&Console->Header); } +NTSTATUS +NTAPI +ConsoleNewProcess(PCSR_PROCESS SourceProcess, + PCSR_PROCESS TargetProcess) +{ + PCONSOLE_PROCESS_DATA SourceProcessData, TargetProcessData; + ULONG i; + + DPRINT1("ConsoleNewProcess inside\n"); + DPRINT1("SourceProcess = 0x%p ; TargetProcess = 0x%p\n", SourceProcess, TargetProcess); + + /* An empty target process is invalid */ + if (!TargetProcess) + return STATUS_INVALID_PARAMETER; + + DPRINT1("ConsoleNewProcess - OK\n"); + + TargetProcessData = ConsoleGetPerProcessData(TargetProcess); + + /* Initialize the new (target) process */ + TargetProcessData->Process = TargetProcess; + RtlInitializeCriticalSection(&TargetProcessData->HandleTableLock); + + /* Do nothing if the source process is NULL */ + if (!SourceProcess) + return STATUS_SUCCESS; + + SourceProcessData = ConsoleGetPerProcessData(SourceProcess); + + // TODO: Check if one of the processes is really a CONSOLE. + /* + if (!(CreateProcessRequest->CreationFlags & (CREATE_NEW_CONSOLE | DETACHED_PROCESS))) + { + // NewProcess == TargetProcess. + NewProcess->ParentConsole = Process->Console; + NewProcess->bInheritHandles = CreateProcessRequest->bInheritHandles; + } + */ + + /* Only inherit if the if the flag was set */ + if (!TargetProcessData->bInheritHandles) return STATUS_SUCCESS; + + if (TargetProcessData->HandleTableSize) + { + return STATUS_INVALID_PARAMETER; + } + + RtlEnterCriticalSection(&SourceProcessData->HandleTableLock); + + TargetProcessData->HandleTable = RtlAllocateHeap(ConSrvHeap, + HEAP_ZERO_MEMORY, + SourceProcessData->HandleTableSize + * sizeof(CSRSS_HANDLE)); + if (TargetProcessData->HandleTable == NULL) + { + RtlLeaveCriticalSection(&SourceProcessData->HandleTableLock); + return STATUS_UNSUCCESSFUL; + } + + TargetProcessData->HandleTableSize = SourceProcessData->HandleTableSize; + + for (i = 0; i < SourceProcessData->HandleTableSize; i++) + { + if (SourceProcessData->HandleTable[i].Object != NULL && + SourceProcessData->HandleTable[i].Inheritable) + { + TargetProcessData->HandleTable[i] = SourceProcessData->HandleTable[i]; + Win32CsrCreateHandleEntry(&TargetProcessData->HandleTable[i]); + } + } + + RtlLeaveCriticalSection(&SourceProcessData->HandleTableLock); + + return STATUS_SUCCESS; +} + VOID WINAPI -Win32CsrReleaseConsole(PCSR_PROCESS ProcessData) -{ +Win32CsrReleaseConsole(PCSR_PROCESS Process) +{ + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(Process); PCSRSS_CONSOLE Console; ULONG i; @@ -172,7 +240,7 @@ NTSTATUS FASTCALL -Win32CsrInsertObject(PCSR_PROCESS ProcessData, +Win32CsrInsertObject(PCONSOLE_PROCESS_DATA ProcessData, PHANDLE Handle, Object_t *Object, DWORD Access, @@ -215,112 +283,22 @@ Win32CsrCreateHandleEntry(&ProcessData->HandleTable[i]); *Handle = UlongToHandle((i << 2) | 0x3); RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - return(STATUS_SUCCESS); -} - -NTSTATUS -WINAPI -Win32CsrDuplicateHandleTable(PCSR_PROCESS SourceProcessData, - PCSR_PROCESS TargetProcessData) -{ - ULONG i; - - /* Only inherit if the flag was set */ - if (!TargetProcessData->bInheritHandles) return STATUS_SUCCESS; - - if (TargetProcessData->HandleTableSize) - { - return STATUS_INVALID_PARAMETER; - } - - RtlEnterCriticalSection(&SourceProcessData->HandleTableLock); - - /* we are called from CreateProcessData, it isn't necessary to lock the target process data */ - - TargetProcessData->HandleTable = RtlAllocateHeap(ConSrvHeap, - HEAP_ZERO_MEMORY, - SourceProcessData->HandleTableSize - * sizeof(CSRSS_HANDLE)); - if (TargetProcessData->HandleTable == NULL) - { - RtlLeaveCriticalSection(&SourceProcessData->HandleTableLock); - return(STATUS_UNSUCCESSFUL); - } - TargetProcessData->HandleTableSize = SourceProcessData->HandleTableSize; - for (i = 0; i < SourceProcessData->HandleTableSize; i++) - { - if (SourceProcessData->HandleTable[i].Object != NULL && - SourceProcessData->HandleTable[i].Inheritable) - { - TargetProcessData->HandleTable[i] = SourceProcessData->HandleTable[i]; - Win32CsrCreateHandleEntry(&TargetProcessData->HandleTable[i]); - } - } - RtlLeaveCriticalSection(&SourceProcessData->HandleTableLock); - return(STATUS_SUCCESS); -} - -CSR_API(CsrGetHandle) -{ - NTSTATUS Status = STATUS_SUCCESS; - PCSRSS_GET_INPUT_HANDLE GetInputHandleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetInputHandleRequest; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; - - GetInputHandleRequest->Handle = INVALID_HANDLE_VALUE; - - RtlEnterCriticalSection(&ProcessData->HandleTableLock); - if (ProcessData->Console) - { - DWORD DesiredAccess = GetInputHandleRequest->Access; - DWORD ShareMode = GetInputHandleRequest->ShareMode; - - PCSRSS_CONSOLE Console = ProcessData->Console; - Object_t *Object; - - EnterCriticalSection(&Console->Lock); - if (ApiMessage->ApiNumber == ConsolepGetHandleInformation) - Object = &Console->ActiveBuffer->Header; - else - Object = &Console->Header; - - if (((DesiredAccess & GENERIC_READ) && Object->ExclusiveRead != 0) || - ((DesiredAccess & GENERIC_WRITE) && Object->ExclusiveWrite != 0) || - (!(ShareMode & FILE_SHARE_READ) && Object->AccessRead != 0) || - (!(ShareMode & FILE_SHARE_WRITE) && Object->AccessWrite != 0)) - { - DPRINT1("Sharing violation\n"); - Status = STATUS_SHARING_VIOLATION; - } - else - { - Status = Win32CsrInsertObject(ProcessData, - &GetInputHandleRequest->Handle, - Object, - DesiredAccess, - GetInputHandleRequest->Inheritable, - ShareMode); - } - LeaveCriticalSection(&Console->Lock); - } - RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - - return Status; -} - -// CSR_API(CsrSetHandle) ?? + return STATUS_SUCCESS; +} CSR_API(SrvCloseHandle) { PCSRSS_CLOSE_HANDLE CloseHandleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CloseHandleRequest; - return Win32CsrReleaseObject(CsrGetClientThread()->Process, CloseHandleRequest->Handle); + return Win32CsrReleaseObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process), + CloseHandleRequest->Handle); } CSR_API(SrvVerifyConsoleIoHandle) { NTSTATUS Status = STATUS_SUCCESS; PCSRSS_VERIFY_HANDLE VerifyHandleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.VerifyHandleRequest; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); ULONG_PTR Index; Index = (ULONG_PTR)VerifyHandleRequest->Handle >> 2; @@ -342,7 +320,7 @@ PCSRSS_HANDLE Entry; DWORD DesiredAccess; PCSRSS_DUPLICATE_HANDLE DuplicateHandleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.DuplicateHandleRequest; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); Index = (ULONG_PTR)DuplicateHandleRequest->Handle >> 2; RtlEnterCriticalSection(&ProcessData->HandleTableLock); @@ -372,11 +350,11 @@ } ApiMessage->Status = Win32CsrInsertObject(ProcessData, - &DuplicateHandleRequest->Handle, - Entry->Object, - DesiredAccess, - DuplicateHandleRequest->Inheritable, - Entry->ShareMode); + &DuplicateHandleRequest->Handle, + Entry->Object, + DesiredAccess, + DuplicateHandleRequest->Inheritable, + Entry->ShareMode); if (NT_SUCCESS(ApiMessage->Status) && DuplicateHandleRequest->Options & DUPLICATE_CLOSE_SOURCE) { @@ -391,7 +369,9 @@ { PCSRSS_GET_INPUT_WAIT_HANDLE GetConsoleInputWaitHandle = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetConsoleInputWaitHandle; - GetConsoleInputWaitHandle->InputWaitHandle = CsrGetClientThread()->Process->ConsoleEvent; + GetConsoleInputWaitHandle->InputWaitHandle = + ConsoleGetPerProcessData(CsrGetClientThread()->Process)->ConsoleEvent; + return STATUS_SUCCESS; } Modified: branches/ros-csrss/win32ss/user/consrv/lineinput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/l…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/lineinput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/lineinput.c [iso-8859-1] Wed Nov 7 22:23:36 2012 @@ -152,21 +152,21 @@ CSR_API(SrvGetConsoleCommandHistoryLength) { PCSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLength; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCSR_PROCESS Process = CsrGetClientThread()->Process; PCSRSS_CONSOLE Console; NTSTATUS Status; PHISTORY_BUFFER Hist; ULONG Length = 0; INT i; - if (!Win32CsrValidateBuffer(ProcessData, + if (!Win32CsrValidateBuffer(Process, GetCommandHistoryLength->ExeName.Buffer, GetCommandHistoryLength->ExeName.Length, 1)) { return STATUS_ACCESS_VIOLATION; } - Status = ConioConsoleFromProcessData(ProcessData, &Console); + Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(Process), &Console); if (NT_SUCCESS(Status)) { Hist = HistoryFindBuffer(Console, &GetCommandHistoryLength->ExeName); @@ -184,7 +184,7 @@ CSR_API(SrvGetConsoleCommandHistory) { PCSRSS_GET_COMMAND_HISTORY GetCommandHistory = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistory; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCSR_PROCESS Process = CsrGetClientThread()->Process; PCSRSS_CONSOLE Console; NTSTATUS Status; PHISTORY_BUFFER Hist; @@ -192,15 +192,15 @@ ULONG BufferSize = GetCommandHistory->Length; INT i; - if (!Win32CsrValidateBuffer(ProcessData, Buffer, BufferSize, 1) || - !Win32CsrValidateBuffer(ProcessData, + if (!Win32CsrValidateBuffer(Process, Buffer, BufferSize, 1) || + !Win32CsrValidateBuffer(Process, GetCommandHistory->ExeName.Buffer, GetCommandHistory->ExeName.Length, 1)) { return STATUS_ACCESS_VIOLATION; } - Status = ConioConsoleFromProcessData(ProcessData, &Console); + Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(Process), &Console); if (NT_SUCCESS(Status)) { Hist = HistoryFindBuffer(Console, &GetCommandHistory->ExeName); @@ -228,19 +228,19 @@ CSR_API(SrvExpungeConsoleCommandHistory) { PCSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistory; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCSR_PROCESS Process = CsrGetClientThread()->Process; PCSRSS_CONSOLE Console; PHISTORY_BUFFER Hist; NTSTATUS Status; - if (!Win32CsrValidateBuffer(ProcessData, + if (!Win32CsrValidateBuffer(Process, ExpungeCommandHistory->ExeName.Buffer, ExpungeCommandHistory->ExeName.Length, 1)) { return STATUS_ACCESS_VIOLATION; } - Status = ConioConsoleFromProcessData(ProcessData, &Console); + Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(Process), &Console); if (NT_SUCCESS(Status)) { Hist = HistoryFindBuffer(Console, &ExpungeCommandHistory->ExeName); @@ -253,21 +253,21 @@ CSR_API(SrvSetConsoleNumberOfCommands) { PCSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommands; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCSR_PROCESS Process = CsrGetClientThread()->Process; PCSRSS_CONSOLE Console; PHISTORY_BUFFER Hist; NTSTATUS Status; WORD MaxEntries = SetHistoryNumberCommands->NumCommands; PUNICODE_STRING OldEntryList, NewEntryList; - if (!Win32CsrValidateBuffer(ProcessData, + if (!Win32CsrValidateBuffer(Process, SetHistoryNumberCommands->ExeName.Buffer, SetHistoryNumberCommands->ExeName.Length, 1)) { return STATUS_ACCESS_VIOLATION; } - Status = ConioConsoleFromProcessData(ProcessData, &Console); + Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(Process), &Console); if (NT_SUCCESS(Status)) { Hist = HistoryFindBuffer(Console, &SetHistoryNumberCommands->ExeName); @@ -304,7 +304,7 @@ { PCSRSS_GET_HISTORY_INFO GetHistoryInfo = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetHistoryInfo; PCSRSS_CONSOLE Console; - NTSTATUS Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console); + NTSTATUS Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console); if (NT_SUCCESS(Status)) { GetHistoryInfo->HistoryBufferSize = Console->HistoryBufferSize; @@ -319,7 +319,7 @@ { PCSRSS_SET_HISTORY_INFO SetHistoryInfo = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryInfo; PCSRSS_CONSOLE Console; - NTSTATUS Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console); + NTSTATUS Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console); if (NT_SUCCESS(Status)) { Console->HistoryBufferSize = (WORD)SetHistoryInfo->HistoryBufferSize;
12 years, 1 month
1
0
0
0
[hbelusca] 57688: [BASESRV] - Comment some code and correct the DllMain prototype. No functional changes though.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Wed Nov 7 22:08:38 2012 New Revision: 57688 URL:
http://svn.reactos.org/svn/reactos?rev=57688&view=rev
Log: [BASESRV] - Comment some code and correct the DllMain prototype. No functional changes though. Modified: branches/ros-csrss/subsystems/win/basesrv/init.c Modified: branches/ros-csrss/subsystems/win/basesrv/init.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/subsystems/win/basesr…
============================================================================== --- branches/ros-csrss/subsystems/win/basesrv/init.c [iso-8859-1] (original) +++ branches/ros-csrss/subsystems/win/basesrv/init.c [iso-8859-1] Wed Nov 7 22:08:38 2012 @@ -506,7 +506,7 @@ LoadedServerDll->SharedSection = BaseStaticServerData; } - +/* VOID WINAPI BaseStaticServerThread(PVOID x) { // NTSTATUS Status = STATUS_SUCCESS; @@ -523,11 +523,11 @@ { default: Reply = Request; - /* Status =*/ NtReplyPort(BaseApiPort, Reply); + /\* Status =*\/ NtReplyPort(BaseApiPort, Reply); break; } } - +*/ CSR_SERVER_DLL_INIT(ServerDllInitialization) { @@ -565,7 +565,7 @@ BOOL NTAPI -DllMain(IN HANDLE hDll, +DllMain(IN HINSTANCE hInstanceDll, IN DWORD dwReason, IN LPVOID lpReserved) { @@ -574,7 +574,7 @@ if (DLL_PROCESS_ATTACH == dwReason) { - DllHandle = hDll; + DllHandle = hInstanceDll; } else if (DLL_PROCESS_DETACH == dwReason) {
12 years, 1 month
1
0
0
0
[hbelusca] 57687: [CONSRV] Code formatting only.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Wed Nov 7 21:16:09 2012 New Revision: 57687 URL:
http://svn.reactos.org/svn/reactos?rev=57687&view=rev
Log: [CONSRV] Code formatting only. Modified: branches/ros-csrss/win32ss/user/consrv/tuiconsole.c Modified: branches/ros-csrss/win32ss/user/consrv/tuiconsole.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/t…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/tuiconsole.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/tuiconsole.c [iso-8859-1] Wed Nov 7 21:16:09 2012 @@ -310,7 +310,7 @@ } DWORD WINAPI -TuiConsoleThread (PVOID Data) +TuiConsoleThread(PVOID Data) { PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) Data; HWND NewWindow; @@ -384,7 +384,7 @@ Console->ActiveBuffer->MaxX = PhysicalConsoleSize.X; Console->ActiveBuffer->MaxY = PhysicalConsoleSize.Y; - ThreadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE) TuiConsoleThread, + ThreadHandle = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)TuiConsoleThread, Console, 0, NULL); if (NULL == ThreadHandle) {
12 years, 1 month
1
0
0
0
[hbelusca] 57686: [CONSRV] - Use the new PCONSOLE_PROCESS_DATA type instead of PCSR_PROCESS, for accessing console-specific fields inside a console structure (the code modifications inside these fu...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Wed Nov 7 21:10:48 2012 New Revision: 57686 URL:
http://svn.reactos.org/svn/reactos?rev=57686&view=rev
Log: [CONSRV] - Use the new PCONSOLE_PROCESS_DATA type instead of PCSR_PROCESS, for accessing console-specific fields inside a console structure (the code modifications inside these functions will follow in the next commits). - Remove unneeded included header files in consrv.h. - Use a DLL instance in order to facilitate the access to win32 resources. - Activate the declaration of server apis (or rename existing ones to the Windows scheme from the
http://j00ru.vexillium.org/csrss_list/api_list.html#Windows_2k3
list). - Comment the Win32CsrValidateBuffer helper (because it should be replaced by the usage of CsrValidateMessageBuffer). - Add the list of the old APIs (just for me, to remember at the end to check that I didn't forget ome of them during the process of moving / renaming). Modified: branches/ros-csrss/win32ss/user/consrv/conio.h branches/ros-csrss/win32ss/user/consrv/consrv.h branches/ros-csrss/win32ss/user/consrv/init.c branches/ros-csrss/win32ss/user/consrv/server.c Modified: branches/ros-csrss/win32ss/user/consrv/conio.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] Wed Nov 7 21:10:48 2012 @@ -136,13 +136,15 @@ #define ConioResizeBuffer(Console, Buff, Size) (Console)->Vtbl->ResizeBuffer(Console, Buff, Size) /* console.c */ -NTSTATUS FASTCALL ConioConsoleFromProcessData(PCSR_PROCESS ProcessData, PCSRSS_CONSOLE *Console); +NTSTATUS FASTCALL ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData, + PCSRSS_CONSOLE *Console); VOID WINAPI ConioDeleteConsole(Object_t *Object); VOID WINAPI CsrInitConsoleSupport(VOID); VOID FASTCALL ConioPause(PCSRSS_CONSOLE Console, UINT Flags); VOID FASTCALL ConioUnpause(PCSRSS_CONSOLE Console, UINT Flags); -VOID FASTCALL ConioConsoleCtrlEvent(DWORD Event, PCSR_PROCESS ProcessData); -VOID FASTCALL ConioConsoleCtrlEventTimeout(DWORD Event, PCSR_PROCESS ProcessData, +VOID FASTCALL ConioConsoleCtrlEvent(DWORD Event, PCONSOLE_PROCESS_DATA ProcessData); +VOID FASTCALL ConioConsoleCtrlEventTimeout(DWORD Event, + PCONSOLE_PROCESS_DATA ProcessData, DWORD Timeout); /* coninput.c */ Modified: branches/ros-csrss/win32ss/user/consrv/consrv.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/consrv.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/consrv.h [iso-8859-1] Wed Nov 7 21:10:48 2012 @@ -21,11 +21,8 @@ #include <csr/csrsrv.h> /* CONSOLE Headers */ +#include <win/console.h> #include <win/conmsg.h> -// #include <win/base.h> - -//#include "guiconsole.h" -//#include "tuiconsole.h" #include "resource.h" @@ -33,9 +30,12 @@ #include "console.h" +extern HINSTANCE ConSrvDllInstance; extern HANDLE ConSrvHeap; // extern HANDLE BaseSrvSharedHeap; // extern PBASE_STATIC_SERVER_DATA BaseStaticServerData; + + typedef struct Object_tt { @@ -47,6 +47,16 @@ } Object_t; +typedef struct _CSRSS_HANDLE +{ + Object_t *Object; + DWORD Access; + BOOL Inheritable; + DWORD ShareMode; +} CSRSS_HANDLE, *PCSRSS_HANDLE; + + + /* alias.c */ CSR_API(SrvAddConsoleAlias); CSR_API(SrvGetConsoleAlias); @@ -56,34 +66,31 @@ CSR_API(SrvGetConsoleAliasExesLength); /* coninput.c */ +CSR_API(SrvGetConsoleInput); +CSR_API(SrvWriteConsoleInput); CSR_API(SrvReadConsole); -CSR_API(CsrReadInputEvent); CSR_API(SrvFlushConsoleInputBuffer); CSR_API(SrvGetConsoleNumberOfInputEvents); -CSR_API(SrvGetConsoleInput); -CSR_API(SrvWriteConsoleInput); /* conoutput.c */ +CSR_API(SrvReadConsoleOutput); +CSR_API(SrvWriteConsoleOutput); +CSR_API(SrvReadConsoleOutputString); +CSR_API(SrvWriteConsoleOutputString); +CSR_API(SrvFillConsoleOutput); CSR_API(SrvWriteConsole); -CSR_API(SrvGetConsoleScreenBufferInfo); -CSR_API(SrvSetConsoleCursor); -CSR_API(CsrWriteConsoleOutputChar); -CSR_API(CsrFillOutputChar); -CSR_API(CsrWriteConsoleOutputAttrib); -CSR_API(CsrFillOutputAttrib); +CSR_API(SrvSetConsoleCursorPosition); CSR_API(SrvGetConsoleCursorInfo); CSR_API(SrvSetConsoleCursorInfo); -CSR_API(CsrSetTextAttrib); +CSR_API(SrvSetConsoleTextAttribute); CSR_API(SrvCreateConsoleScreenBuffer); +CSR_API(SrvGetConsoleScreenBufferInfo); CSR_API(SrvSetConsoleActiveScreenBuffer); -CSR_API(SrvWriteConsoleOutput); CSR_API(SrvScrollConsoleScreenBuffer); -CSR_API(CsrReadConsoleOutputChar); -CSR_API(CsrReadConsoleOutputAttrib); -CSR_API(SrvReadConsoleOutput); CSR_API(SrvSetConsoleScreenBufferSize); /* console.c */ +CSR_API(SrvOpenConsole); CSR_API(SrvAllocConsole); CSR_API(SrvFreeConsole); CSR_API(SrvSetConsoleMode); @@ -96,36 +103,34 @@ CSR_API(SrvSetConsoleIcon); CSR_API(SrvGetConsoleCP); CSR_API(SrvSetConsoleCP); -CSR_API(CsrGetConsoleOutputCodePage); -CSR_API(CsrSetConsoleOutputCodePage); CSR_API(SrvGetConsoleProcessList); CSR_API(SrvGenerateConsoleCtrlEvent); CSR_API(SrvGetConsoleSelectionInfo); /* handle.c */ -CSR_API(CsrGetHandle); CSR_API(SrvCloseHandle); CSR_API(SrvVerifyConsoleIoHandle); CSR_API(SrvDuplicateHandle); CSR_API(CsrGetInputWaitHandle); -NTSTATUS FASTCALL Win32CsrInsertObject(PCSR_PROCESS ProcessData, +NTSTATUS NTAPI ConsoleNewProcess(PCSR_PROCESS SourceProcess, + PCSR_PROCESS TargetProcess); +VOID NTAPI Win32CsrReleaseConsole(PCSR_PROCESS Process); + +NTSTATUS FASTCALL Win32CsrInsertObject(PCONSOLE_PROCESS_DATA ProcessData, PHANDLE Handle, Object_t *Object, DWORD Access, BOOL Inheritable, DWORD ShareMode); -NTSTATUS FASTCALL Win32CsrLockObject(PCSR_PROCESS ProcessData, +NTSTATUS FASTCALL Win32CsrLockObject(PCONSOLE_PROCESS_DATA ProcessData, HANDLE Handle, Object_t **Object, DWORD Access, - long Type); + LONG Type); VOID FASTCALL Win32CsrUnlockObject(Object_t *Object); -NTSTATUS FASTCALL Win32CsrReleaseObject(PCSR_PROCESS ProcessData, - HANDLE Object); -VOID WINAPI Win32CsrReleaseConsole(PCSR_PROCESS ProcessData); -NTSTATUS WINAPI Win32CsrDuplicateHandleTable(PCSR_PROCESS SourceProcessData, - PCSR_PROCESS TargetProcessData); +NTSTATUS FASTCALL Win32CsrReleaseObject(PCONSOLE_PROCESS_DATA ProcessData, + HANDLE Handle); /* lineinput.c */ CSR_API(SrvGetConsoleCommandHistoryLength); @@ -136,10 +141,12 @@ CSR_API(SrvSetConsoleHistory); /* server.c */ +#if 0 BOOL FASTCALL Win32CsrValidateBuffer(PCSR_PROCESS ProcessData, PVOID Buffer, SIZE_T NumElements, SIZE_T ElementSize); +#endif #endif // __CONSRV_H__ Modified: branches/ros-csrss/win32ss/user/consrv/init.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/i…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/init.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/init.c [iso-8859-1] Wed Nov 7 21:10:48 2012 @@ -12,7 +12,7 @@ #define NDEBUG #include <debug.h> -HANDLE DllHandle = NULL; +HINSTANCE ConSrvDllInstance = NULL; // HANDLE BaseApiPort = NULL; /* Memory */ @@ -25,14 +25,14 @@ // Some names are also deduced from the subsystems/win32/csrss/csrsrv/server.c ones. PCSR_API_ROUTINE ConsoleServerApiDispatchTable[ConsolepMaxApiNumber] = { - // SrvOpenConsole, + SrvOpenConsole, SrvGetConsoleInput, SrvWriteConsoleInput, SrvReadConsoleOutput, SrvWriteConsoleOutput, - // SrvReadConsoleOutputString, - // SrvWriteConsoleOutputString, - // SrvFillConsoleOutput, + SrvReadConsoleOutputString, + SrvWriteConsoleOutputString, + SrvFillConsoleOutput, SrvGetConsoleMode, // SrvGetConsoleNumberOfFonts, SrvGetConsoleNumberOfInputEvents, @@ -47,11 +47,11 @@ SrvFlushConsoleInputBuffer, // SrvGetLargestConsoleWindowSize, SrvSetConsoleScreenBufferSize, - // SrvSetConsoleCursorPosition, + SrvSetConsoleCursorPosition, SrvSetConsoleCursorInfo, // SrvSetConsoleWindowInfo, SrvScrollConsoleScreenBuffer, - // SrvSetConsoleTextAttribute, + SrvSetConsoleTextAttribute, // SrvSetConsoleFont, SrvSetConsoleIcon, SrvReadConsole, @@ -68,7 +68,7 @@ SrvCreateConsoleScreenBuffer, // SrvInvalidateBitMapRect, // SrvVDMConsoleOperation, - SrvSetConsoleCursor, + // SrvSetConsoleCursor, // SrvShowConsoleCursor, // SrvConsoleMenuControl, // SrvSetConsolePalette, @@ -116,14 +116,14 @@ BOOLEAN ConsoleServerApiServerValidTable[ConsolepMaxApiNumber] = { - // FALSE, // SrvOpenConsole, + FALSE, // SrvOpenConsole, FALSE, // SrvGetConsoleInput, FALSE, // SrvWriteConsoleInput, FALSE, // SrvReadConsoleOutput, FALSE, // SrvWriteConsoleOutput, - // FALSE, // SrvReadConsoleOutputString, - // FALSE, // SrvWriteConsoleOutputString, - // FALSE, // SrvFillConsoleOutput, + FALSE, // SrvReadConsoleOutputString, + FALSE, // SrvWriteConsoleOutputString, + FALSE, // SrvFillConsoleOutput, FALSE, // SrvGetConsoleMode, // FALSE, // SrvGetConsoleNumberOfFonts, FALSE, // SrvGetConsoleNumberOfInputEvents, @@ -138,11 +138,11 @@ FALSE, // SrvFlushConsoleInputBuffer, // FALSE, // SrvGetLargestConsoleWindowSize, FALSE, // SrvSetConsoleScreenBufferSize, - // FALSE, // SrvSetConsoleCursorPosition, + FALSE, // SrvSetConsoleCursorPosition, FALSE, // SrvSetConsoleCursorInfo, // FALSE, // SrvSetConsoleWindowInfo, FALSE, // SrvScrollConsoleScreenBuffer, - // FALSE, // SrvSetConsoleTextAttribute, + FALSE, // SrvSetConsoleTextAttribute, // FALSE, // SrvSetConsoleFont, FALSE, // SrvSetConsoleIcon, FALSE, // SrvReadConsole, @@ -159,7 +159,7 @@ FALSE, // SrvCreateConsoleScreenBuffer, // FALSE, // SrvInvalidateBitMapRect, // FALSE, // SrvVDMConsoleOperation, - FALSE, // SrvSetConsoleCursor, + // FALSE, // SrvSetConsoleCursor, // FALSE, // SrvShowConsoleCursor, // FALSE, // SrvConsoleMenuControl, // FALSE, // SrvSetConsolePalette, @@ -209,14 +209,14 @@ PCHAR ConsoleServerApiNameTable[ConsolepMaxApiNumber] = { - // "OpenConsole", + "OpenConsole", "GetConsoleInput", "WriteConsoleInput", "ReadConsoleOutput", "WriteConsoleOutput", - // "ReadConsoleOutputString", - // "WriteConsoleOutputString", - // "FillConsoleOutput", + "ReadConsoleOutputString", + "WriteConsoleOutputString", + "FillConsoleOutput", "GetConsoleMode", // "GetConsoleNumberOfFonts", "GetConsoleNumberOfInputEvents", @@ -231,11 +231,11 @@ "FlushConsoleInputBuffer", // "GetLargestConsoleWindowSize", "SetConsoleScreenBufferSize", - // "SetConsoleCursorPosition", + "SetConsoleCursorPosition", "SetConsoleCursorInfo", // "SetConsoleWindowInfo", "ScrollConsoleScreenBuffer", - // "SetConsoleTextAttribute", + "SetConsoleTextAttribute", // "SetConsoleFont", "SetConsoleIcon", "ReadConsole", @@ -252,7 +252,7 @@ "CreateConsoleScreenBuffer", // "InvalidateBitMapRect", // "VDMConsoleOperation", - "SetConsoleCursor", + // "SetConsoleCursor", // "ShowConsoleCursor", // "ConsoleMenuControl", // "SetConsolePalette", @@ -301,6 +301,106 @@ }; +/* +PCSR_API_ROUTINE Win32CsrApiDefinitions[] = +{ + CsrGetHandle, + CsrGetHandle, + CsrCloseHandle, + CsrVerifyHandle, + CsrDuplicateHandle, + CsrGetInputWaitHandle, + CsrFillOutputChar, + CsrReadInputEvent, + CsrWriteConsoleOutputChar, + CsrWriteConsoleOutputAttrib, + CsrFillOutputAttrib, + CsrSetTextAttrib, + CsrWriteConsoleOutput, + CsrFlushInputBuffer, + CsrReadConsoleOutputChar, + CsrReadConsoleOutputAttrib, + CsrExitReactos, + CsrHardwareStateProperty, + CsrCreateDesktop, + CsrShowDesktop, + CsrHideDesktop, + CsrSetLogonNotifyWindow, + CsrRegisterLogonProcess, + CsrGenerateCtrlEvent, +}; + +static CSRSS_API_DEFINITION Win32CsrApiDefinitions[] = +{ + CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetHandle), + CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetHandle), + CSRSS_DEFINE_API(CLOSE_HANDLE, CsrCloseHandle), + CSRSS_DEFINE_API(VERIFY_HANDLE, CsrVerifyHandle), + CSRSS_DEFINE_API(DUPLICATE_HANDLE, CsrDuplicateHandle), + CSRSS_DEFINE_API(GET_INPUT_WAIT_HANDLE, CsrGetInputWaitHandle), + CSRSS_DEFINE_API(WRITE_CONSOLE, CsrWriteConsole), + CSRSS_DEFINE_API(READ_CONSOLE, CsrReadConsole), + CSRSS_DEFINE_API(ALLOC_CONSOLE, CsrAllocConsole), + CSRSS_DEFINE_API(FREE_CONSOLE, CsrFreeConsole), + CSRSS_DEFINE_API(SCREEN_BUFFER_INFO, CsrGetScreenBufferInfo), + CSRSS_DEFINE_API(SET_CURSOR, CsrSetCursor), + CSRSS_DEFINE_API(FILL_OUTPUT, CsrFillOutputChar), + CSRSS_DEFINE_API(READ_INPUT, CsrReadInputEvent), + CSRSS_DEFINE_API(WRITE_CONSOLE_OUTPUT_CHAR, CsrWriteConsoleOutputChar), + CSRSS_DEFINE_API(WRITE_CONSOLE_OUTPUT_ATTRIB, CsrWriteConsoleOutputAttrib), + CSRSS_DEFINE_API(FILL_OUTPUT_ATTRIB, CsrFillOutputAttrib), + CSRSS_DEFINE_API(GET_CURSOR_INFO, CsrGetCursorInfo), + CSRSS_DEFINE_API(SET_CURSOR_INFO, CsrSetCursorInfo), + CSRSS_DEFINE_API(SET_ATTRIB, CsrSetTextAttrib), + CSRSS_DEFINE_API(GET_CONSOLE_MODE, CsrGetConsoleMode), + CSRSS_DEFINE_API(SET_CONSOLE_MODE, CsrSetConsoleMode), + CSRSS_DEFINE_API(CREATE_SCREEN_BUFFER, CsrCreateScreenBuffer), + CSRSS_DEFINE_API(SET_SCREEN_BUFFER, CsrSetScreenBuffer), + CSRSS_DEFINE_API(SET_TITLE, CsrSetTitle), + CSRSS_DEFINE_API(GET_TITLE, CsrGetTitle), + CSRSS_DEFINE_API(WRITE_CONSOLE_OUTPUT, CsrWriteConsoleOutput), + CSRSS_DEFINE_API(FLUSH_INPUT_BUFFER, CsrFlushInputBuffer), + CSRSS_DEFINE_API(SCROLL_CONSOLE_SCREEN_BUFFER, CsrScrollConsoleScreenBuffer), + CSRSS_DEFINE_API(READ_CONSOLE_OUTPUT_CHAR, CsrReadConsoleOutputChar), + CSRSS_DEFINE_API(READ_CONSOLE_OUTPUT_ATTRIB, CsrReadConsoleOutputAttrib), + CSRSS_DEFINE_API(GET_NUM_INPUT_EVENTS, CsrGetNumberOfConsoleInputEvents), + CSRSS_DEFINE_API(EXIT_REACTOS, CsrExitReactos), + CSRSS_DEFINE_API(PEEK_CONSOLE_INPUT, CsrPeekConsoleInput), + CSRSS_DEFINE_API(READ_CONSOLE_OUTPUT, CsrReadConsoleOutput), + CSRSS_DEFINE_API(WRITE_CONSOLE_INPUT, CsrWriteConsoleInput), + CSRSS_DEFINE_API(SETGET_CONSOLE_HW_STATE, CsrHardwareStateProperty), + CSRSS_DEFINE_API(GET_CONSOLE_WINDOW, CsrGetConsoleWindow), + CSRSS_DEFINE_API(CREATE_DESKTOP, CsrCreateDesktop), + CSRSS_DEFINE_API(SHOW_DESKTOP, CsrShowDesktop), + CSRSS_DEFINE_API(HIDE_DESKTOP, CsrHideDesktop), + CSRSS_DEFINE_API(SET_CONSOLE_ICON, CsrSetConsoleIcon), + CSRSS_DEFINE_API(SET_LOGON_NOTIFY_WINDOW, CsrSetLogonNotifyWindow), + CSRSS_DEFINE_API(REGISTER_LOGON_PROCESS, CsrRegisterLogonProcess), + CSRSS_DEFINE_API(GET_CONSOLE_CP, CsrGetConsoleCodePage), + CSRSS_DEFINE_API(SET_CONSOLE_CP, CsrSetConsoleCodePage), + CSRSS_DEFINE_API(GET_CONSOLE_OUTPUT_CP, CsrGetConsoleOutputCodePage), + CSRSS_DEFINE_API(SET_CONSOLE_OUTPUT_CP, CsrSetConsoleOutputCodePage), + CSRSS_DEFINE_API(GET_PROCESS_LIST, CsrGetProcessList), + CSRSS_DEFINE_API(ADD_CONSOLE_ALIAS, CsrAddConsoleAlias), + CSRSS_DEFINE_API(GET_CONSOLE_ALIAS, CsrGetConsoleAlias), + CSRSS_DEFINE_API(GET_ALL_CONSOLE_ALIASES, CsrGetAllConsoleAliases), + CSRSS_DEFINE_API(GET_ALL_CONSOLE_ALIASES_LENGTH, CsrGetAllConsoleAliasesLength), + CSRSS_DEFINE_API(GET_CONSOLE_ALIASES_EXES, CsrGetConsoleAliasesExes), + CSRSS_DEFINE_API(GET_CONSOLE_ALIASES_EXES_LENGTH, CsrGetConsoleAliasesExesLength), + CSRSS_DEFINE_API(GENERATE_CTRL_EVENT, CsrGenerateCtrlEvent), + CSRSS_DEFINE_API(SET_SCREEN_BUFFER_SIZE, CsrSetScreenBufferSize), + CSRSS_DEFINE_API(GET_CONSOLE_SELECTION_INFO, CsrGetConsoleSelectionInfo), + CSRSS_DEFINE_API(GET_COMMAND_HISTORY_LENGTH, CsrGetCommandHistoryLength), + CSRSS_DEFINE_API(GET_COMMAND_HISTORY, CsrGetCommandHistory), + CSRSS_DEFINE_API(EXPUNGE_COMMAND_HISTORY, CsrExpungeCommandHistory), + CSRSS_DEFINE_API(SET_HISTORY_NUMBER_COMMANDS, CsrSetHistoryNumberCommands), + CSRSS_DEFINE_API(GET_HISTORY_INFO, CsrGetHistoryInfo), + CSRSS_DEFINE_API(SET_HISTORY_INFO, CsrSetHistoryInfo), + { 0, 0, NULL } +}; +*/ + + /* FUNCTIONS ******************************************************************/ /* @@ -362,7 +462,7 @@ LoadedServerDll->SizeOfProcessData = 0; LoadedServerDll->ConnectCallback = NULL; LoadedServerDll->DisconnectCallback = Win32CsrReleaseConsole; - LoadedServerDll->NewProcessCallback = Win32CsrDuplicateHandleTable; + LoadedServerDll->NewProcessCallback = ConsoleNewProcess; // LoadedServerDll->HardErrorCallback = Win32CsrHardError; /* All done */ @@ -371,7 +471,7 @@ BOOL WINAPI -DllMain(IN HANDLE hDll, +DllMain(IN HINSTANCE hInstanceDll, IN DWORD dwReason, IN LPVOID lpReserved) { @@ -380,7 +480,7 @@ if (DLL_PROCESS_ATTACH == dwReason) { - DllHandle = hDll; + ConSrvDllInstance = hInstanceDll; } return TRUE; Modified: branches/ros-csrss/win32ss/user/consrv/server.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/s…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/server.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/server.c [iso-8859-1] Wed Nov 7 21:10:48 2012 @@ -11,7 +11,7 @@ #define NDEBUG #include <debug.h> - +#if 0 /* Ensure that a captured buffer is safe to access */ BOOL FASTCALL Win32CsrValidateBuffer(PCSR_PROCESS ProcessData, PVOID Buffer, @@ -37,5 +37,6 @@ } return TRUE; } +#endif /* EOF */
12 years, 1 month
1
0
0
0
← Newer
1
...
7
8
9
10
11
12
13
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
Results per page:
10
25
50
100
200