ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
October 2011
----- 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
18 participants
369 discussions
Start a n
N
ew thread
[rharabien] 54200: [USER32] - Fix a typo
by rharabien@svn.reactos.org
Author: rharabien Date: Wed Oct 19 16:37:34 2011 New Revision: 54200 URL:
http://svn.reactos.org/svn/reactos?rev=54200&view=rev
Log: [USER32] - Fix a typo Modified: trunk/reactos/dll/win32/user32/windows/input.c Modified: trunk/reactos/dll/win32/user32/windows/input.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/i…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/input.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/input.c [iso-8859-1] Wed Oct 19 16:37:34 2011 @@ -205,7 +205,7 @@ if (!GetKeyboardLayoutNameW(buf)) return FALSE; - if (!WideCharToMultiByte(CP_ACP, 0, buf, -1, pwszKLID, KL_NAMELENGTH, NULL, NULL)); + if (!WideCharToMultiByte(CP_ACP, 0, buf, -1, pwszKLID, KL_NAMELENGTH, NULL, NULL)) return FALSE; return TRUE;
13 years, 2 months
1
0
0
0
[rharabien] 54199: [USER32] - Simplify DrawCaret
by rharabien@svn.reactos.org
Author: rharabien Date: Wed Oct 19 16:17:32 2011 New Revision: 54199 URL:
http://svn.reactos.org/svn/reactos?rev=54199&view=rev
Log: [USER32] - Simplify DrawCaret Modified: trunk/reactos/dll/win32/user32/windows/caret.c Modified: trunk/reactos/dll/win32/user32/windows/caret.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/c…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/caret.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/caret.c [iso-8859-1] Wed Oct 19 16:17:32 2011 @@ -31,53 +31,56 @@ #include <user32.h> #include <wine/debug.h> +WINE_DEFAULT_DEBUG_CHANNEL(user32); + /* FUNCTIONS *****************************************************************/ void DrawCaret(HWND hWnd, PTHRDCARETINFO CaretInfo) { - HDC hDC, hComp; + HDC hdc, hdcMem; + HBITMAP hbmOld; + BOOL bDone = FALSE; - hDC = GetDC(hWnd); - if(hDC) + hdc = GetDC(hWnd); + if (!hdc) { - if(CaretInfo->Bitmap && GetBitmapDimensionEx(CaretInfo->Bitmap, &CaretInfo->Size)) + ERR("GetDC failed\n"); + return; + } + + if(CaretInfo->Bitmap && GetBitmapDimensionEx(CaretInfo->Bitmap, &CaretInfo->Size)) + { + hdcMem = CreateCompatibleDC(hdc); + if (hdcMem) { - hComp = CreateCompatibleDC(hDC); - if(hComp) - { - SelectObject(hComp, CaretInfo->Bitmap); - BitBlt(hDC, - CaretInfo->Pos.x, - CaretInfo->Pos.y, - CaretInfo->Size.cx, - CaretInfo->Size.cy, - hComp, - 0, - 0, - SRCINVERT); - DeleteDC(hComp); - } - else - PatBlt(hDC, - CaretInfo->Pos.x, - CaretInfo->Pos.y, - CaretInfo->Size.cx, - CaretInfo->Size.cy, - DSTINVERT); + hbmOld = SelectObject(hdcMem, CaretInfo->Bitmap); + bDone = BitBlt(hdc, + CaretInfo->Pos.x, + CaretInfo->Pos.y, + CaretInfo->Size.cx, + CaretInfo->Size.cy, + hdcMem, + 0, + 0, + SRCINVERT); + SelectObject(hdcMem, hbmOld); + DeleteDC(hdcMem); } - else - { - PatBlt(hDC, - CaretInfo->Pos.x, - CaretInfo->Pos.y, - CaretInfo->Size.cx, - CaretInfo->Size.cy, - DSTINVERT); - } - ReleaseDC(hWnd, hDC); } + + if (!bDone) + { + PatBlt(hdc, + CaretInfo->Pos.x, + CaretInfo->Pos.y, + CaretInfo->Size.cx, + CaretInfo->Size.cy, + DSTINVERT); + } + + ReleaseDC(hWnd, hdc); }
13 years, 2 months
1
0
0
0
[rharabien] 54198: [WIN32K] - Don't use exclusive lock when shared is enough - Don't declare functions in source code
by rharabien@svn.reactos.org
Author: rharabien Date: Wed Oct 19 16:00:46 2011 New Revision: 54198 URL:
http://svn.reactos.org/svn/reactos?rev=54198&view=rev
Log: [WIN32K] - Don't use exclusive lock when shared is enough - Don't declare functions in source code Modified: trunk/reactos/subsystems/win32/win32k/include/cursoricon.h trunk/reactos/subsystems/win32/win32k/ntuser/display.c Modified: trunk/reactos/subsystems/win32/win32k/include/cursoricon.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/cursoricon.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/cursoricon.h [iso-8859-1] Wed Oct 19 16:00:46 2011 @@ -68,9 +68,8 @@ BOOL UserDrawIconEx(HDC hDc, INT xLeft, INT yTop, PCURICON_OBJECT pIcon, INT cxWidth, INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags); PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon); - BOOL UserSetCursorPos( INT x, INT y, DWORD flags, ULONG_PTR dwExtraInfo, BOOL Hook); - +BOOL APIENTRY UserClipCursor(RECTL *prcl); PSYSTEM_CURSORINFO IntGetSysCursorInfo(VOID); #define IntReleaseCurIconObject(CurIconObj) \ Modified: trunk/reactos/subsystems/win32/win32k/ntuser/display.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/display.c [iso-8859-1] Wed Oct 19 16:00:46 2011 @@ -11,7 +11,6 @@ BOOL gbBaseVideo = 0; -static const PWCHAR KEY_ROOT = L""; static const PWCHAR KEY_VIDEO = L"\\Registry\\Machine\\HARDWARE\\DEVICEMAP\\VIDEO"; VOID @@ -384,7 +383,7 @@ } /* Acquire global USER lock */ - UserEnterExclusive(); + UserEnterShared(); /* Call the internal function */ Status = UserEnumDisplayDevices(pustrDevice, iDevNum, &dispdev, dwFlags); @@ -551,7 +550,6 @@ return Status ; } - NTSTATUS APIENTRY NtUserEnumDisplaySettings( @@ -593,7 +591,7 @@ } /* Acquire global USER lock */ - UserEnterExclusive(); + UserEnterShared(); if (iModeNum == ENUM_REGISTRY_SETTINGS) { @@ -646,9 +644,6 @@ return Status; } - -BOOL APIENTRY UserClipCursor(RECTL *prcl); -VOID APIENTRY UserRedrawDesktop(); LONG APIENTRY
13 years, 2 months
1
0
0
0
[rharabien] 54197: [WIN32K] - Simplify monitors code - fix few minor bugs (ie. not updating last error) - Make monitor object more compatible to windows
by rharabien@svn.reactos.org
Author: rharabien Date: Wed Oct 19 15:40:17 2011 New Revision: 54197 URL:
http://svn.reactos.org/svn/reactos?rev=54197&view=rev
Log: [WIN32K] - Simplify monitors code - fix few minor bugs (ie. not updating last error) - Make monitor object more compatible to windows Modified: trunk/reactos/subsystems/win32/win32k/include/monitor.h trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c Modified: trunk/reactos/subsystems/win32/win32k/include/monitor.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/monitor.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/monitor.h [iso-8859-1] Wed Oct 19 15:40:17 2011 @@ -4,30 +4,28 @@ typedef struct _MONITOR { HEAD head; -// - UNICODE_STRING DeviceName; /* name of the monitor */ - PDEVOBJ *GdiDevice; /* pointer to the GDI device to - which this monitor is attached */ -// This is the structure Windows uses: -// struct _MONITOR* pMonitorNext; - union { - DWORD dwMONFlags; - struct { - DWORD IsVisible:1; - DWORD IsPalette:1; - DWORD IsPrimary:1; /* wether this is the primary monitor */ - };}; + struct _MONITOR* pMonitorNext; + union + { + DWORD dwMONFlags; + struct + { + DWORD IsVisible: 1; + DWORD IsPalette: 1; + DWORD IsPrimary: 1; /* wether this is the primary monitor */ + }; + }; RECT rcMonitor; RECT rcWork; HRGN hrgnMonitor; SHORT cFullScreen; SHORT cWndStack; HDEV hDev; - HDEV hDevReal; -// BYTE DockTargets[4][7]; -// Use LIST_ENTRY - struct _MONITOR* Next; //Flink; - struct _MONITOR* Prev; //Blink; + + // ReactOS specific fields: + UNICODE_STRING DeviceName; /* name of the monitor */ + PDEVOBJ *GdiDevice; /* pointer to the GDI device to + which this monitor is attached */ } MONITOR, *PMONITOR; NTSTATUS IntAttachMonitor(PDEVOBJ *pGdiDevice, ULONG DisplayNumber); Modified: trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c [iso-8859-1] Wed Oct 19 15:40:17 2011 @@ -1,9 +1,10 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel - * PURPOSE: Monitor support + * PURPOSE: pMonitor support * FILE: subsys/win32k/ntuser/monitor.c - * PROGRAMER: Anich Gregor (blight(a)blight.eu.org) + * PROGRAMERS: Anich Gregor (blight(a)blight.eu.org) + * Rafal Harabien (rafalh(a)reactos.org) */ #include <win32k.h> @@ -20,7 +21,7 @@ /* GLOBALS *******************************************************************/ -/* list of monitors */ +/* List of monitors */ static PMONITOR gMonitorList = NULL; /* PRIVATE FUNCTIONS **********************************************************/ @@ -37,16 +38,7 @@ PMONITOR IntCreateMonitorObject() { - HANDLE Handle; - PMONITOR Monitor; - - Monitor = UserCreateObject(gHandleTable, NULL, &Handle, otMonitor, sizeof (MONITOR)); - if (Monitor == NULL) - { - return NULL; - } - - return Monitor; + return UserCreateObject(gHandleTable, NULL, NULL, otMonitor, sizeof(MONITOR)); } /* IntDestroyMonitorObject @@ -63,15 +55,34 @@ void IntDestroyMonitorObject(IN PMONITOR pMonitor) { + /* Free monitor name */ RtlFreeUnicodeString(&pMonitor->DeviceName); + + /* Remove monitor region */ + if (pMonitor->hrgnMonitor) + { + GreSetObjectOwner(pMonitor->hrgnMonitor, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(pMonitor->hrgnMonitor); + } + + /* Destroy monitor object */ UserDereferenceObject(pMonitor); -} - - + UserDeleteObject(UserHMGetHandle(pMonitor), otMonitor); +} + +/* UserGetMonitorObject + * + * Returns monitor object from handle or sets last error if handle is invalid + * + * Arguments + * + * hMonitor + * Handle of MONITOR object + */ PMONITOR FASTCALL UserGetMonitorObject(IN HMONITOR hMonitor) { - PMONITOR Monitor; + PMONITOR pMonitor; if (!hMonitor) { @@ -79,16 +90,38 @@ return NULL; } - Monitor = (PMONITOR)UserGetObject(gHandleTable, hMonitor, otMonitor); - if (!Monitor) + pMonitor = (PMONITOR)UserGetObject(gHandleTable, hMonitor, otMonitor); + if (!pMonitor) { EngSetLastError(ERROR_INVALID_MONITOR_HANDLE); return NULL; } - return Monitor; -} - + return pMonitor; +} + +/* IntGetPrimaryMonitor + * + * Returns a PMONITOR for the primary monitor + * + * Return value + * PMONITOR + */ +PMONITOR +FASTCALL +IntGetPrimaryMonitor() +{ + PMONITOR pMonitor; + + /* Find primary monitor */ + for (pMonitor = gMonitorList; pMonitor != NULL; pMonitor = pMonitor->pMonitorNext) + { + if (pMonitor->IsPrimary) + break; + } + + return pMonitor; +} /* IntAttachMonitor * @@ -106,46 +139,45 @@ IntAttachMonitor(IN PDEVOBJ *pGdiDevice, IN ULONG DisplayNumber) { - PMONITOR Monitor; + PMONITOR pMonitor; WCHAR Buffer[CCHDEVICENAME]; TRACE("Attaching monitor...\n"); /* create new monitor object */ - Monitor = IntCreateMonitorObject(); - if (Monitor == NULL) + pMonitor = IntCreateMonitorObject(); + if (pMonitor == NULL) { TRACE("Couldnt create monitor object\n"); return STATUS_INSUFFICIENT_RESOURCES; } _snwprintf(Buffer, CCHDEVICENAME, L"\\\\.\\DISPLAY%d", DisplayNumber + 1); - if (!RtlCreateUnicodeString(&Monitor->DeviceName, Buffer)) + if (!RtlCreateUnicodeString(&pMonitor->DeviceName, Buffer)) { TRACE("Couldn't duplicate monitor name!\n"); - UserDereferenceObject(Monitor); - UserDeleteObject(UserHMGetHandle(Monitor), otMonitor); + UserDereferenceObject(pMonitor); + UserDeleteObject(UserHMGetHandle(pMonitor), otMonitor); return STATUS_INSUFFICIENT_RESOURCES; } - Monitor->GdiDevice = pGdiDevice; - Monitor->cWndStack = 0; + pMonitor->GdiDevice = pGdiDevice; + pMonitor->cWndStack = 0; if (gMonitorList == NULL) { TRACE("Primary monitor is beeing attached\n"); - Monitor->IsPrimary = TRUE; - gMonitorList = Monitor; + pMonitor->IsPrimary = TRUE; + gMonitorList = pMonitor; } else { - PMONITOR p; + PMONITOR pmonLast = gMonitorList; TRACE("Additional monitor is beeing attached\n"); - for (p = gMonitorList; p->Next != NULL; p = p->Next) - { - p->Next = Monitor; - } - Monitor->Prev = p; + while (pmonLast->pMonitorNext != NULL) + pmonLast = pmonLast->pMonitorNext; + + pmonLast->pMonitorNext = pMonitor; } IntUpdateMonitorSize(pGdiDevice); @@ -167,44 +199,33 @@ NTSTATUS IntDetachMonitor(IN PDEVOBJ *pGdiDevice) { - PMONITOR Monitor; - - for (Monitor = gMonitorList; Monitor != NULL; Monitor = Monitor->Next) - { - if (Monitor->GdiDevice == pGdiDevice) + PMONITOR pMonitor = gMonitorList, *pLink = &gMonitorList; + + /* Find monitor attached to given device */ + while (pMonitor != NULL) + { + if (pMonitor->GdiDevice == pGdiDevice) break; - } - - if (Monitor == NULL) - { - /* no monitor for given device found */ + + pLink = &pMonitor->pMonitorNext; + pMonitor = pMonitor->pMonitorNext; + } + + if (pMonitor == NULL) + { + /* No monitor has been found */ return STATUS_INVALID_PARAMETER; } - if (Monitor->IsPrimary && (Monitor->Next != NULL || Monitor->Prev != NULL)) - { - PMONITOR NewPrimaryMonitor = (Monitor->Prev != NULL) ? (Monitor->Prev) : (Monitor->Next); - - NewPrimaryMonitor->IsPrimary = TRUE; - } - - if (gMonitorList == Monitor) - { - gMonitorList = Monitor->Next; - if (Monitor->Next != NULL) - Monitor->Next->Prev = NULL; - } - else - { - Monitor->Prev->Next = Monitor->Next; - if (Monitor->Next != NULL) - Monitor->Next->Prev = Monitor->Prev; - } - - if (Monitor->hrgnMonitor) - GreDeleteObject(Monitor->hrgnMonitor); - - IntDestroyMonitorObject(Monitor); + /* We destroy primary monitor - set next as primary */ + if (pMonitor->IsPrimary && pMonitor->pMonitorNext != NULL) + pMonitor->pMonitorNext->IsPrimary = TRUE; + + /* Update Next ptr in previous monitor */ + *pLink = pMonitor->pMonitorNext; + + /* Finally destroy monitor */ + IntDestroyMonitorObject(pMonitor); return STATUS_SUCCESS; } @@ -224,60 +245,41 @@ NTSTATUS IntUpdateMonitorSize(IN PDEVOBJ *pGdiDevice) { - PMONITOR Monitor; - - for (Monitor = gMonitorList; Monitor != NULL; Monitor = Monitor->Next) - { - if (Monitor->GdiDevice == pGdiDevice) + PMONITOR pMonitor; + + /* Find monitor attached to given device */ + for (pMonitor = gMonitorList; pMonitor != NULL; pMonitor = pMonitor->pMonitorNext) + { + if (pMonitor->GdiDevice == pGdiDevice) break; } - if (Monitor == NULL) - { - /* no monitor for given device found */ + if (pMonitor == NULL) + { + /* No monitor has been found */ return STATUS_INVALID_PARAMETER; } - Monitor->rcMonitor.left = 0; - Monitor->rcMonitor.top = 0; - Monitor->rcMonitor.right = Monitor->rcMonitor.left + Monitor->GdiDevice->gdiinfo.ulHorzRes; - Monitor->rcMonitor.bottom = Monitor->rcMonitor.top + Monitor->GdiDevice->gdiinfo.ulVertRes; - Monitor->rcWork = Monitor->rcMonitor; - - if (Monitor->hrgnMonitor) - { - GreSetObjectOwner(Monitor->hrgnMonitor, GDI_OBJ_HMGR_POWNED); - GreDeleteObject(Monitor->hrgnMonitor); - } - - Monitor->hrgnMonitor = IntSysCreateRectRgnIndirect( &Monitor->rcMonitor ); - - IntGdiSetRegionOwner(Monitor->hrgnMonitor, GDI_OBJ_HMGR_PUBLIC); + /* Update monitor size */ + pMonitor->rcMonitor.left = 0; + pMonitor->rcMonitor.top = 0; + pMonitor->rcMonitor.right = pMonitor->rcMonitor.left + pMonitor->GdiDevice->gdiinfo.ulHorzRes; + pMonitor->rcMonitor.bottom = pMonitor->rcMonitor.top + pMonitor->GdiDevice->gdiinfo.ulVertRes; + pMonitor->rcWork = pMonitor->rcMonitor; + + /* Destroy monitor region... */ + if (pMonitor->hrgnMonitor) + { + GreSetObjectOwner(pMonitor->hrgnMonitor, GDI_OBJ_HMGR_POWNED); + GreDeleteObject(pMonitor->hrgnMonitor); + } + + /* ...and create new one */ + pMonitor->hrgnMonitor = IntSysCreateRectRgnIndirect(&pMonitor->rcMonitor); + if (pMonitor->hrgnMonitor) + IntGdiSetRegionOwner(pMonitor->hrgnMonitor, GDI_OBJ_HMGR_PUBLIC); return STATUS_SUCCESS; -} - -/* IntGetPrimaryMonitor - * - * Returns a PMONITOR for the primary monitor - * - * Return value - * PMONITOR - */ -PMONITOR -FASTCALL -IntGetPrimaryMonitor() -{ - PMONITOR Monitor; - - for (Monitor = gMonitorList; Monitor != NULL; Monitor = Monitor->Next) - { - /* FIXME: I guess locking the monitor is not neccessary to read 1 int */ - if (Monitor->IsPrimary) - break; - } - - return Monitor; } /* IntGetMonitorsFromRect @@ -291,21 +293,21 @@ * Rectangle in desktop coordinates. If this is NULL all monitors are * returned and the rect list is filled with the sizes of the monitors. * - * hMonitorList + * phMonitorList * Pointer to an array of HMONITOR which is filled with monitor handles. * Can be NULL * - * monitorRectList + * prcMonitorList * Pointer to an array of RECT which is filled with intersection rects in * desktop coordinates. * Can be NULL, will be ignored if no intersecting monitor is found and * flags is MONITOR_DEFAULTTONEAREST * - * listSize - * Size of the hMonitorList and monitorRectList arguments. If this is zero - * hMonitorList and monitorRectList are ignored. - * - * flags + * dwListSize + * Size of the phMonitorList and prcMonitorList arguments. If this is zero + * phMonitorList and prcMonitorList are ignored. + * + * dwFlags * Either 0 or MONITOR_DEFAULTTONEAREST (ignored if rect is NULL) * * Returns @@ -314,29 +316,28 @@ static UINT IntGetMonitorsFromRect(OPTIONAL IN LPCRECTL pRect, - OPTIONAL OUT HMONITOR *hMonitorList, - OPTIONAL OUT PRECTL monitorRectList, - OPTIONAL IN DWORD listSize, - OPTIONAL IN DWORD flags) -{ - PMONITOR Monitor, NearestMonitor = NULL, PrimaryMonitor = NULL; - UINT iCount = 0; + OPTIONAL OUT HMONITOR *phMonitorList, + OPTIONAL OUT PRECTL prcMonitorList, + OPTIONAL IN DWORD dwListSize, + OPTIONAL IN DWORD dwFlags) +{ + PMONITOR pMonitor, pNearestMonitor = NULL, pPrimaryMonitor = NULL; + UINT cMonitors = 0; ULONG iNearestDistance = 0xffffffff; - /* Find monitors which intersect the rectangle */ - for (Monitor = gMonitorList; Monitor != NULL; Monitor = Monitor->Next) + /* Find monitors which intersects the rectangle */ + for (pMonitor = gMonitorList; pMonitor != NULL; pMonitor = pMonitor->pMonitorNext) { RECTL MonitorRect, IntersectionRect; - MonitorRect = Monitor->rcMonitor; + MonitorRect = pMonitor->rcMonitor; TRACE("MonitorRect: left = %d, top = %d, right = %d, bottom = %d\n", MonitorRect.left, MonitorRect.top, MonitorRect.right, MonitorRect.bottom); - if (flags == MONITOR_DEFAULTTOPRIMARY && Monitor->IsPrimary) - { - PrimaryMonitor = Monitor; - } + /* Save primary monitor for later usage */ + if (dwFlags == MONITOR_DEFAULTTOPRIMARY && pMonitor->IsPrimary) + pPrimaryMonitor = pMonitor; /* Check if a rect is given */ if (pRect == NULL) @@ -344,12 +345,11 @@ /* No rect given, so use the full monitor rect */ IntersectionRect = MonitorRect; } - /* We have a rect, calculate intersection */ else if (!RECTL_bIntersectRect(&IntersectionRect, &MonitorRect, pRect)) { /* Rects did not intersect */ - if (flags == MONITOR_DEFAULTTONEAREST) + if (dwFlags == MONITOR_DEFAULTTONEAREST) { ULONG cx, cy, iDistance; @@ -366,7 +366,7 @@ if (iDistance < iNearestDistance) { iNearestDistance = iDistance; - NearestMonitor = Monitor; + pNearestMonitor = pMonitor; } } @@ -374,38 +374,39 @@ } /* Check if there's space in the buffer */ - if (iCount < listSize) - { - if (hMonitorList != NULL) - hMonitorList[iCount] = UserHMGetHandle(Monitor); - if (monitorRectList != NULL) - monitorRectList[iCount] = IntersectionRect; + if (cMonitors < dwListSize) + { + /* Save monitor data */ + if (phMonitorList != NULL) + phMonitorList[cMonitors] = UserHMGetHandle(pMonitor); + if (prcMonitorList != NULL) + prcMonitorList[cMonitors] = IntersectionRect; } /* Increase count of found monitors */ - iCount++; - } - - /* Found nothing intersecting? */ - if (iCount == 0) + cMonitors++; + } + + /* Nothing has been found? */ + if (cMonitors == 0) { /* Check if we shall default to the nearest monitor */ - if (flags == MONITOR_DEFAULTTONEAREST && NearestMonitor) - { - if (hMonitorList && listSize > 0) - hMonitorList[iCount] = UserHMGetHandle(NearestMonitor); - iCount++; + if (dwFlags == MONITOR_DEFAULTTONEAREST && pNearestMonitor) + { + if (phMonitorList && dwListSize > 0) + phMonitorList[cMonitors] = UserHMGetHandle(pNearestMonitor); + cMonitors++; } /* Check if we shall default to the primary monitor */ - else if (flags == MONITOR_DEFAULTTOPRIMARY && PrimaryMonitor) - { - if (hMonitorList != NULL && listSize > 0) - hMonitorList[iCount] = UserHMGetHandle(PrimaryMonitor); - iCount++; - } - } - - return iCount; + else if (dwFlags == MONITOR_DEFAULTTOPRIMARY && pPrimaryMonitor) + { + if (phMonitorList != NULL && dwListSize > 0) + phMonitorList[cMonitors] = UserHMGetHandle(pPrimaryMonitor); + cMonitors++; + } + } + + return cMonitors; } /* PUBLIC FUNCTIONS ***********************************************************/ @@ -416,24 +417,24 @@ * * Arguments * - * hDC + * hdc * Handle to a DC for which to enum intersecting monitors. If this is NULL * it returns all monitors which are part of the current virtual screen. * - * pRect + * pUnsafeRect * Clipping rectangle with coordinate system origin at the DCs origin if the * given HDC is not NULL or in virtual screen coordinated if it is NULL. * Can be NULL * - * hMonitorList + * phUnsafeMonitorList * Pointer to an array of HMONITOR which is filled with monitor handles. * Can be NULL * - * monitorRectList + * prcUnsafeMonitorList * Pointer to an array of RECT which is filled with intersection rectangles. * Can be NULL * - * listSize + * dwListSize * Size of the hMonitorList and monitorRectList arguments. If this is zero * hMonitorList and monitorRectList are ignored. * @@ -443,154 +444,158 @@ INT APIENTRY NtUserEnumDisplayMonitors( - OPTIONAL IN HDC hDC, - OPTIONAL IN LPCRECTL pRect, - OPTIONAL OUT HMONITOR *hMonitorList, - OPTIONAL OUT PRECTL monitorRectList, - OPTIONAL IN DWORD listSize) -{ - INT numMonitors, i; - HMONITOR *safeHMonitorList = NULL; - PRECTL safeRectList = NULL; - RECTL rect, *myRect; - RECTL dcRect; - NTSTATUS status; - - /* get rect */ - if (pRect != NULL) - { - status = MmCopyFromCaller(&rect, pRect, sizeof (RECT)); - if (!NT_SUCCESS(status)) + OPTIONAL IN HDC hdc, + OPTIONAL IN LPCRECTL pUnsafeRect, + OPTIONAL OUT HMONITOR *phUnsafeMonitorList, + OPTIONAL OUT PRECTL prcUnsafeMonitorList, + OPTIONAL IN DWORD dwListSize) +{ + INT cMonitors, iRet = -1, i; + HMONITOR *phMonitorList = NULL; + PRECTL prcMonitorList = NULL; + RECTL rc, *pRect; + RECTL DcRect = {0}; + NTSTATUS Status; + + /* Get rectangle */ + if (pUnsafeRect != NULL) + { + Status = MmCopyFromCaller(&rc, pUnsafeRect, sizeof(RECT)); + if (!NT_SUCCESS(Status)) { TRACE("MmCopyFromCaller() failed!\n"); - SetLastNtError(status); + SetLastNtError(Status); return -1; } } - if (hDC != NULL) - { - PDC dc; - INT regionType; - - /* get visible region bounding rect */ - dc = DC_LockDc(hDC); - if (dc == NULL) + if (hdc != NULL) + { + PDC pDc; + INT iRgnType; + + /* Get visible region bounding rect */ + pDc = DC_LockDc(hdc); + if (pDc == NULL) { TRACE("DC_LockDc() failed!\n"); /* FIXME: setlasterror? */ return -1; } - regionType = REGION_GetRgnBox(dc->prgnVis, &dcRect); - DC_UnlockDc(dc); - - if (regionType == 0) + iRgnType = REGION_GetRgnBox(pDc->prgnVis, &DcRect); + DC_UnlockDc(pDc); + + if (iRgnType == 0) { TRACE("NtGdiGetRgnBox() failed!\n"); return -1; } - if (regionType == NULLREGION) + if (iRgnType == NULLREGION) return 0; - if (regionType == COMPLEXREGION) + if (iRgnType == COMPLEXREGION) { /* TODO: warning */ } - /* if hDC and pRect are given the area of interest is pRect with + /* if hdc and pRect are given the area of interest is pRect with coordinate origin at the DC position */ - if (pRect != NULL) - { - rect.left += dcRect.left; - rect.right += dcRect.left; - rect.top += dcRect.top; - rect.bottom += dcRect.top; - } - /* if hDC is given and pRect is not the area of interest is the - bounding rect of hDC */ + if (pUnsafeRect != NULL) + { + rc.left += DcRect.left; + rc.right += DcRect.left; + rc.top += DcRect.top; + rc.bottom += DcRect.top; + } + /* if hdc is given and pRect is not the area of interest is the + bounding rect of hdc */ else { - rect = dcRect; - } - } - - if (hDC == NULL && pRect == NULL) - myRect = NULL; + rc = DcRect; + } + } + + if (hdc == NULL && pUnsafeRect == NULL) + pRect = NULL; else - myRect = ▭ + pRect = &rc; UserEnterShared(); - /* find intersecting monitors */ - numMonitors = IntGetMonitorsFromRect(myRect, NULL, NULL, 0, 0); - if (numMonitors == 0 || listSize == 0 || - (hMonitorList == NULL && monitorRectList == NULL)) - { - TRACE("numMonitors = %d\n", numMonitors); + /* Find intersecting monitors */ + cMonitors = IntGetMonitorsFromRect(pRect, NULL, NULL, 0, MONITOR_DEFAULTTONULL); + if (cMonitors == 0 || dwListSize == 0 || + (phUnsafeMonitorList == NULL && prcUnsafeMonitorList == NULL)) + { + /* Simple case - just return monitors count */ + TRACE("cMonitors = %d\n", cMonitors); + iRet = cMonitors; goto cleanup; } - if (hMonitorList != NULL && listSize != 0) - { - safeHMonitorList = ExAllocatePoolWithTag(PagedPool, sizeof (HMONITOR) * listSize, USERTAG_MONITORRECTS); - if (safeHMonitorList == NULL) + /* Allocate safe buffers */ + if (phUnsafeMonitorList != NULL && dwListSize != 0) + { + phMonitorList = ExAllocatePoolWithTag(PagedPool, sizeof (HMONITOR) * dwListSize, USERTAG_MONITORRECTS); + if (phMonitorList == NULL) { EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); - numMonitors = -1; goto cleanup; } } - if (monitorRectList != NULL && listSize != 0) - { - safeRectList = ExAllocatePoolWithTag(PagedPool, sizeof (RECT) * listSize, USERTAG_MONITORRECTS); - if (safeRectList == NULL) - { - ExFreePoolWithTag(safeHMonitorList, USERTAG_MONITORRECTS); + if (prcUnsafeMonitorList != NULL && dwListSize != 0) + { + prcMonitorList = ExAllocatePoolWithTag(PagedPool, sizeof (RECT) * dwListSize, USERTAG_MONITORRECTS); + if (prcMonitorList == NULL) + { EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); - numMonitors = -1; goto cleanup; } } - /* get intersecting monitors */ - numMonitors = IntGetMonitorsFromRect(myRect, safeHMonitorList, safeRectList, - listSize, 0 ); - - if (hDC != NULL && pRect != NULL && safeRectList != NULL) - for (i = 0; i < numMonitors; i++) - { - safeRectList[i].left -= dcRect.left; - safeRectList[i].right -= dcRect.left; - safeRectList[i].top -= dcRect.top; - safeRectList[i].bottom -= dcRect.top; - } - - /* output result */ - if (hMonitorList != NULL && listSize != 0) - { - status = MmCopyToCaller(hMonitorList, safeHMonitorList, sizeof (HMONITOR) * listSize); - ExFreePoolWithTag(safeHMonitorList, USERTAG_MONITORRECTS); - if (!NT_SUCCESS(status)) - { - ExFreePoolWithTag(safeRectList, USERTAG_MONITORRECTS); - SetLastNtError(status); - numMonitors = -1; + /* Get intersecting monitors */ + cMonitors = IntGetMonitorsFromRect(pRect, phMonitorList, prcMonitorList, + dwListSize, MONITOR_DEFAULTTONULL); + + if (hdc != NULL && pRect != NULL && prcMonitorList != NULL) + for (i = 0; i < cMonitors; i++) + { + prcMonitorList[i].left -= DcRect.left; + prcMonitorList[i].right -= DcRect.left; + prcMonitorList[i].top -= DcRect.top; + prcMonitorList[i].bottom -= DcRect.top; + } + + /* Output result */ + if (phUnsafeMonitorList != NULL && dwListSize != 0) + { + Status = MmCopyToCaller(phUnsafeMonitorList, phMonitorList, sizeof(HMONITOR) * dwListSize); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); goto cleanup; } } - if (monitorRectList != NULL && listSize != 0) - { - status = MmCopyToCaller(monitorRectList, safeRectList, sizeof (RECT) * listSize); - ExFreePoolWithTag(safeRectList, USERTAG_MONITORRECTS); - if (!NT_SUCCESS(status)) - { - SetLastNtError(status); - numMonitors = -1; - } - } + if (prcUnsafeMonitorList != NULL && dwListSize != 0) + { + Status = MmCopyToCaller(prcUnsafeMonitorList, prcMonitorList, sizeof(RECT) * dwListSize); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + goto cleanup; + } + } + + /* Return monitors count on success */ + iRet = cMonitors; cleanup: + if (phMonitorList) + ExFreePoolWithTag(phMonitorList, USERTAG_MONITORRECTS); + if (prcMonitorList) + ExFreePoolWithTag(prcMonitorList, USERTAG_MONITORRECTS); + UserLeave(); - return numMonitors; + return iRet; } /* NtUserGetMonitorInfo @@ -602,7 +607,7 @@ * hMonitor * Handle to a monitor for which to get information * - * pMonitorInfo + * pMonitorInfoUnsafe * Pointer to a MONITORINFO struct which is filled with the information. * The cbSize member must be set to sizeof(MONITORINFO) or * sizeof(MONITORINFOEX). Even if set to sizeof(MONITORINFOEX) only parts @@ -621,77 +626,80 @@ APIENTRY NtUserGetMonitorInfo( IN HMONITOR hMonitor, - OUT LPMONITORINFO pMonitorInfo) -{ - PMONITOR Monitor; + OUT LPMONITORINFO pMonitorInfoUnsafe) +{ + PMONITOR pMonitor; MONITORINFOEXW MonitorInfo; NTSTATUS Status; - DECLARE_RETURN(BOOL); + BOOL bRet = FALSE; TRACE("Enter NtUserGetMonitorInfo\n"); UserEnterShared(); - /* get monitor object */ - if (!(Monitor = UserGetMonitorObject(hMonitor))) + /* Get monitor object */ + pMonitor = UserGetMonitorObject(hMonitor); + if (!pMonitor) { TRACE("Couldnt find monitor 0x%lx\n", hMonitor); - RETURN(FALSE); - } - - if(pMonitorInfo == NULL) + goto cleanup; + } + + /* Check if pMonitorInfoUnsafe is valid */ + if(pMonitorInfoUnsafe == NULL) { SetLastNtError(STATUS_INVALID_PARAMETER); - RETURN(FALSE); - } - - /* get size of pMonitorInfo */ - Status = MmCopyFromCaller(&MonitorInfo.cbSize, &pMonitorInfo->cbSize, sizeof (MonitorInfo.cbSize)); + goto cleanup; + } + + /* Get size of pMonitorInfoUnsafe */ + Status = MmCopyFromCaller(&MonitorInfo.cbSize, &pMonitorInfoUnsafe->cbSize, sizeof(MonitorInfo.cbSize)); if (!NT_SUCCESS(Status)) { SetLastNtError(Status); - RETURN(FALSE); - } - if ((MonitorInfo.cbSize != sizeof (MONITORINFO)) && - (MonitorInfo.cbSize != sizeof (MONITORINFOEXW))) + goto cleanup; + } + + /* Check if size of struct is valid */ + if (MonitorInfo.cbSize != sizeof(MONITORINFO) && + MonitorInfo.cbSize != sizeof(MONITORINFOEXW)) { SetLastNtError(STATUS_INVALID_PARAMETER); - RETURN(FALSE); - } - - /* fill monitor info */ - MonitorInfo.rcMonitor = Monitor->rcMonitor; - MonitorInfo.rcWork = Monitor->rcWork; + goto cleanup; + } + + /* Fill monitor info */ + MonitorInfo.rcMonitor = pMonitor->rcMonitor; + MonitorInfo.rcWork = pMonitor->rcWork; MonitorInfo.dwFlags = 0; - - if (Monitor->IsPrimary) + if (pMonitor->IsPrimary) MonitorInfo.dwFlags |= MONITORINFOF_PRIMARY; - /* fill device name */ - if (MonitorInfo.cbSize == sizeof (MONITORINFOEXW)) - { - RtlStringCbCopyNW(MonitorInfo.szDevice, + /* Fill device name */ + if (MonitorInfo.cbSize == sizeof(MONITORINFOEXW)) + { + RtlStringCbCopyNExW(MonitorInfo.szDevice, sizeof(MonitorInfo.szDevice), - Monitor->DeviceName.Buffer, - Monitor->DeviceName.Length); - } - - /* output data */ - Status = MmCopyToCaller(pMonitorInfo, &MonitorInfo, MonitorInfo.cbSize); + pMonitor->DeviceName.Buffer, + pMonitor->DeviceName.Length, + NULL, NULL, STRSAFE_FILL_BEHIND_NULL); + } + + /* Output data */ + Status = MmCopyToCaller(pMonitorInfoUnsafe, &MonitorInfo, MonitorInfo.cbSize); if (!NT_SUCCESS(Status)) { TRACE("GetMonitorInfo: MmCopyToCaller failed\n"); SetLastNtError(Status); - RETURN(FALSE); + goto cleanup; } TRACE("GetMonitorInfo: success\n"); - - RETURN(TRUE); - -CLEANUP: - TRACE("Leave NtUserGetMonitorInfo, ret=%i\n",_ret_); + bRet = TRUE; + +cleanup: + TRACE("Leave NtUserGetMonitorInfo, ret=%i\n", bRet); UserLeave(); - END_CLEANUP; + return bRet; } /* NtUserMonitorFromPoint @@ -700,7 +708,7 @@ * * Arguments * - * point + * pt * Point for which to find monitor * * dwFlags @@ -713,25 +721,32 @@ HMONITOR APIENTRY NtUserMonitorFromPoint( - IN POINT point, + IN POINT pt, IN DWORD dwFlags) { - INT NumMonitors; - RECTL InRect; + INT cMonitors; + RECTL rc; HMONITOR hMonitor = NULL; - /* fill inRect (bottom-right exclusive) */ - InRect.left = point.x; - InRect.right = point.x + 1; - InRect.top = point.y; - InRect.bottom = point.y + 1; + /* Check if flags are valid */ + if (dwFlags != MONITOR_DEFAULTTONULL && + dwFlags != MONITOR_DEFAULTTOPRIMARY && + dwFlags != MONITOR_DEFAULTTONEAREST) + { + EngSetLastError(ERROR_INVALID_FLAGS); + return NULL; + } + + /* Fill rect (bottom-right exclusive) */ + rc.left = pt.x; + rc.right = pt.x + 1; + rc.top = pt.y; + rc.bottom = pt.y + 1; UserEnterShared(); - /* find intersecting monitor */ - NumMonitors = IntGetMonitorsFromRect(&InRect, &hMonitor, NULL, 1, dwFlags); - if (NumMonitors < 0) - hMonitor = NULL; + /* Find intersecting monitor */ + cMonitors = IntGetMonitorsFromRect(&rc, &hMonitor, NULL, 1, dwFlags); UserLeave(); return hMonitor; @@ -744,7 +759,7 @@ * * Arguments * - * pRect + * pRectUnsafe * Pointer to a RECT for which to find monitor * * dwFlags @@ -757,78 +772,87 @@ HMONITOR APIENTRY NtUserMonitorFromRect( - IN LPCRECTL pRect, + IN LPCRECTL pRectUnsafe, IN DWORD dwFlags) { - ULONG numMonitors, iLargestArea = 0, i; - PRECTL rectList = NULL; - HMONITOR *hMonitorList = NULL; + ULONG cMonitors, LargestArea = 0, i; + PRECTL prcMonitorList = NULL; + HMONITOR *phMonitorList = NULL; HMONITOR hMonitor = NULL; - RECTL rect; - NTSTATUS status; - - /* get rect */ - status = MmCopyFromCaller(&rect, pRect, sizeof (RECT)); - if (!NT_SUCCESS(status)) - { - SetLastNtError(status); - return (HMONITOR)NULL; + RECTL Rect; + NTSTATUS Status; + + /* Check if flags are valid */ + if (dwFlags != MONITOR_DEFAULTTONULL && + dwFlags != MONITOR_DEFAULTTOPRIMARY && + dwFlags != MONITOR_DEFAULTTONEAREST) + { + EngSetLastError(ERROR_INVALID_FLAGS); + return NULL; + } + + /* Copy rectangle to safe buffer */ + Status = MmCopyFromCaller(&Rect, pRectUnsafe, sizeof (RECT)); + if (!NT_SUCCESS(Status)) + { + SetLastNtError(Status); + return NULL; } UserEnterShared(); - /* find intersecting monitors */ - numMonitors = IntGetMonitorsFromRect(&rect, &hMonitor, NULL, 1, dwFlags); - if (numMonitors <= 1) - { + /* Find intersecting monitors */ + cMonitors = IntGetMonitorsFromRect(&Rect, &hMonitor, NULL, 1, dwFlags); + if (cMonitors <= 1) + { + /* No or one monitor found. Just return handle. */ goto cleanup; } - hMonitorList = ExAllocatePoolWithTag(PagedPool, - sizeof(HMONITOR) * numMonitors, - USERTAG_MONITORRECTS); - if (hMonitorList == NULL) + /* There is more than one monitor. Find monitor with largest intersection. + Temporary reset hMonitor */ + hMonitor = NULL; + + /* Allocate helper buffers */ + phMonitorList = ExAllocatePoolWithTag(PagedPool, + sizeof(HMONITOR) * cMonitors, + USERTAG_MONITORRECTS); + if (phMonitorList == NULL) { EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); - hMonitor = NULL; goto cleanup; } - rectList = ExAllocatePoolWithTag(PagedPool, - sizeof(RECT) * numMonitors, - USERTAG_MONITORRECTS); - if (rectList == NULL) + prcMonitorList = ExAllocatePoolWithTag(PagedPool, + sizeof(RECT) * cMonitors, + USERTAG_MONITORRECTS); + if (prcMonitorList == NULL) { EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); - hMonitor = NULL; goto cleanup; } - /* get intersecting monitors */ - numMonitors = IntGetMonitorsFromRect(&rect, hMonitorList, rectList, - numMonitors, 0); - if (numMonitors == 0) - { - hMonitor = NULL; - goto cleanup; - } - - /* find largest intersection */ - for (i = 0; i < numMonitors; i++) - { - ULONG area = (rectList[i].right - rectList[i].left) * - (rectList[i].bottom - rectList[i].top); - if (area >= iLargestArea) - { - hMonitor = hMonitorList[i]; + /* Get intersecting monitors again but now with rectangle list */ + cMonitors = IntGetMonitorsFromRect(&Rect, phMonitorList, prcMonitorList, + cMonitors, 0); + + /* Find largest intersection */ + for (i = 0; i < cMonitors; i++) + { + ULONG Area = (prcMonitorList[i].right - prcMonitorList[i].left) * + (prcMonitorList[i].bottom - prcMonitorList[i].top); + if (Area >= LargestArea) + { + hMonitor = phMonitorList[i]; + LargestArea = Area; } } cleanup: - if (hMonitorList) - ExFreePoolWithTag(hMonitorList, USERTAG_MONITORRECTS); - if (rectList) - ExFreePoolWithTag(rectList, USERTAG_MONITORRECTS); + if (phMonitorList) + ExFreePoolWithTag(phMonitorList, USERTAG_MONITORRECTS); + if (prcMonitorList) + ExFreePoolWithTag(prcMonitorList, USERTAG_MONITORRECTS); UserLeave(); return hMonitor; @@ -841,33 +865,41 @@ IN HWND hWnd, IN DWORD dwFlags) { - PWND Window; + PWND pWnd; HMONITOR hMonitor = NULL; - RECTL Rect; - DECLARE_RETURN(HMONITOR); + RECTL Rect = {0, 0, 0, 0}; TRACE("Enter NtUserMonitorFromWindow\n"); + + /* Check if flags are valid */ + if (dwFlags != MONITOR_DEFAULTTONULL && + dwFlags != MONITOR_DEFAULTTOPRIMARY && + dwFlags != MONITOR_DEFAULTTONEAREST) + { + EngSetLastError(ERROR_INVALID_FLAGS); + return NULL; + } + UserEnterShared(); - if (!(Window = UserGetWindowObject(hWnd))) - { - if (dwFlags == MONITOR_DEFAULTTONULL) - { - RETURN(hMonitor); - } - IntGetMonitorsFromRect(NULL, &hMonitor, NULL, 1, dwFlags); - RETURN(hMonitor); - } - - Rect.left = Rect.right = Window->rcWindow.left; - Rect.top = Rect.bottom = Window->rcWindow.bottom; - + /* If window is given, use it first */ + if (hWnd) + { + /* Get window object */ + pWnd = UserGetWindowObject(hWnd); + if (!pWnd) + goto cleanup; + + /* Find only monitors which have intersection with given window */ + Rect.left = Rect.right = pWnd->rcWindow.left; + Rect.top = Rect.bottom = pWnd->rcWindow.bottom; + } + + /* Find monitors now */ IntGetMonitorsFromRect(&Rect, &hMonitor, NULL, 1, dwFlags); - RETURN(hMonitor); - -CLEANUP: - TRACE("Leave NtUserMonitorFromWindow, ret=%i\n",_ret_); +cleanup: + TRACE("Leave NtUserMonitorFromWindow, ret=%p\n", hMonitor); UserLeave(); - END_CLEANUP; -} + return hMonitor; +}
13 years, 2 months
1
0
0
0
[jimtabor] 54196: - Move mouse history to mouse.c and it is not effected by the hook bypass.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Wed Oct 19 01:07:19 2011 New Revision: 54196 URL:
http://svn.reactos.org/svn/reactos?rev=54196&view=rev
Log: - Move mouse history to mouse.c and it is not effected by the hook bypass. Modified: trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c Modified: trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/mouse.c [iso-8859-1] Wed Oct 19 01:07:19 2011 @@ -10,6 +10,9 @@ #include <win32k.h> DBG_DEFAULT_CHANNEL(UserInput); +MOUSEMOVEPOINT MouseHistoryOfMoves[64]; +INT gcur_count = 0; + #define ClearMouseInput(mi) \ mi.dx = 0; \ mi.dy = 0; \ @@ -159,6 +162,14 @@ MousePos.y += mi->dy; } } + + /* Do GetMouseMovePointsEx FIFO. */ + MouseHistoryOfMoves[gcur_count].x = MousePos.x; + MouseHistoryOfMoves[gcur_count].y = MousePos.y; + MouseHistoryOfMoves[gcur_count].time = mi->time; + MouseHistoryOfMoves[gcur_count].dwExtraInfo = mi->dwExtraInfo; + if (++gcur_count == ARRAYSIZE(MouseHistoryOfMoves)) + gcur_count = 0; // 0 - 63 is 64, FIFO forwards. /* * Insert the messages into the system queue Modified: trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c [iso-8859-1] Wed Oct 19 01:07:19 2011 @@ -14,8 +14,6 @@ /* GLOBALS *******************************************************************/ static PAGED_LOOKASIDE_LIST MessageLookasideList; -MOUSEMOVEPOINT MouseHistoryOfMoves[64]; -INT gcur_count = 0; PUSER_MESSAGE_QUEUE gpqCursor; /* FUNCTIONS *****************************************************************/ @@ -587,14 +585,6 @@ GreMovePointer(hdcScreen, Msg->pt.x, Msg->pt.y); CurInfo->ShowingCursor = 0; } - - /* Do GetMouseMovePointsEx FIFO. */ - MouseHistoryOfMoves[gcur_count].x = Msg->pt.x; - MouseHistoryOfMoves[gcur_count].y = Msg->pt.y; - MouseHistoryOfMoves[gcur_count].time = Msg->time; - MouseHistoryOfMoves[gcur_count].dwExtraInfo = dwExtraInfo; - if (++gcur_count == ARRAYSIZE(MouseHistoryOfMoves)) - gcur_count = 0; // 0 - 63 is 64, FIFO forwards. } VOID FASTCALL
13 years, 2 months
1
0
0
0
[rharabien] 54195: [WIN32K] - Add missing locks in monitors API - Set proper last error when allocation fails
by rharabien@svn.reactos.org
Author: rharabien Date: Tue Oct 18 23:01:29 2011 New Revision: 54195 URL:
http://svn.reactos.org/svn/reactos?rev=54195&view=rev
Log: [WIN32K] - Add missing locks in monitors API - Set proper last error when allocation fails Modified: trunk/reactos/subsystems/win32/win32k/include/monitor.h trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c Modified: trunk/reactos/subsystems/win32/win32k/include/monitor.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/in…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/include/monitor.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/include/monitor.h [iso-8859-1] Tue Oct 18 23:01:29 2011 @@ -5,7 +5,6 @@ { HEAD head; // - FAST_MUTEX Lock; /* R/W lock */ UNICODE_STRING DeviceName; /* name of the monitor */ PDEVOBJ *GdiDevice; /* pointer to the GDI device to which this monitor is attached */ @@ -21,7 +20,7 @@ RECT rcMonitor; RECT rcWork; HRGN hrgnMonitor; - SHORT Spare0; + SHORT cFullScreen; SHORT cWndStack; HDEV hDev; HDEV hDevReal; Modified: trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/monitor.c [iso-8859-1] Tue Oct 18 23:01:29 2011 @@ -46,8 +46,6 @@ return NULL; } - ExInitializeFastMutex(&Monitor->Lock); - return Monitor; } @@ -187,9 +185,7 @@ { PMONITOR NewPrimaryMonitor = (Monitor->Prev != NULL) ? (Monitor->Prev) : (Monitor->Next); - ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&NewPrimaryMonitor->Lock); NewPrimaryMonitor->IsPrimary = TRUE; - ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&NewPrimaryMonitor->Lock); } if (gMonitorList == Monitor) @@ -332,9 +328,7 @@ { RECTL MonitorRect, IntersectionRect; - ExEnterCriticalRegionAndAcquireFastMutexUnsafe(&Monitor->Lock); MonitorRect = Monitor->rcMonitor; - ExReleaseFastMutexUnsafeAndLeaveCriticalRegion(&Monitor->Lock); TRACE("MonitorRect: left = %d, top = %d, right = %d, bottom = %d\n", MonitorRect.left, MonitorRect.top, MonitorRect.right, MonitorRect.bottom); @@ -524,13 +518,15 @@ else myRect = ▭ + UserEnterShared(); + /* find intersecting monitors */ numMonitors = IntGetMonitorsFromRect(myRect, NULL, NULL, 0, 0); if (numMonitors == 0 || listSize == 0 || (hMonitorList == NULL && monitorRectList == NULL)) { TRACE("numMonitors = %d\n", numMonitors); - return numMonitors; + goto cleanup; } if (hMonitorList != NULL && listSize != 0) @@ -538,8 +534,9 @@ safeHMonitorList = ExAllocatePoolWithTag(PagedPool, sizeof (HMONITOR) * listSize, USERTAG_MONITORRECTS); if (safeHMonitorList == NULL) { - /* FIXME: EngSetLastError? */ - return -1; + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); + numMonitors = -1; + goto cleanup; } } if (monitorRectList != NULL && listSize != 0) @@ -548,8 +545,9 @@ if (safeRectList == NULL) { ExFreePoolWithTag(safeHMonitorList, USERTAG_MONITORRECTS); - /* FIXME: EngSetLastError? */ - return -1; + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); + numMonitors = -1; + goto cleanup; } } @@ -570,12 +568,13 @@ if (hMonitorList != NULL && listSize != 0) { status = MmCopyToCaller(hMonitorList, safeHMonitorList, sizeof (HMONITOR) * listSize); - ExFreePool(safeHMonitorList); + ExFreePoolWithTag(safeHMonitorList, USERTAG_MONITORRECTS); if (!NT_SUCCESS(status)) { ExFreePoolWithTag(safeRectList, USERTAG_MONITORRECTS); SetLastNtError(status); - return -1; + numMonitors = -1; + goto cleanup; } } if (monitorRectList != NULL && listSize != 0) @@ -585,10 +584,12 @@ if (!NT_SUCCESS(status)) { SetLastNtError(status); - return -1; - } - } - + numMonitors = -1; + } + } + +cleanup: + UserLeave(); return numMonitors; } @@ -725,13 +726,14 @@ InRect.top = point.y; InRect.bottom = point.y + 1; + UserEnterShared(); + /* find intersecting monitor */ NumMonitors = IntGetMonitorsFromRect(&InRect, &hMonitor, NULL, 1, dwFlags); if (NumMonitors < 0) - { - return (HMONITOR)NULL; - } - + hMonitor = NULL; + + UserLeave(); return hMonitor; } @@ -759,8 +761,8 @@ IN DWORD dwFlags) { ULONG numMonitors, iLargestArea = 0, i; - PRECTL rectList; - HMONITOR *hMonitorList; + PRECTL rectList = NULL; + HMONITOR *hMonitorList = NULL; HMONITOR hMonitor = NULL; RECTL rect; NTSTATUS status; @@ -773,11 +775,13 @@ return (HMONITOR)NULL; } + UserEnterShared(); + /* find intersecting monitors */ numMonitors = IntGetMonitorsFromRect(&rect, &hMonitor, NULL, 1, dwFlags); if (numMonitors <= 1) { - return hMonitor; + goto cleanup; } hMonitorList = ExAllocatePoolWithTag(PagedPool, @@ -785,8 +789,9 @@ USERTAG_MONITORRECTS); if (hMonitorList == NULL) { - /* FIXME: EngSetLastError? */ - return (HMONITOR)NULL; + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); + hMonitor = NULL; + goto cleanup; } rectList = ExAllocatePoolWithTag(PagedPool, @@ -794,9 +799,9 @@ USERTAG_MONITORRECTS); if (rectList == NULL) { - ExFreePoolWithTag(hMonitorList, USERTAG_MONITORRECTS); - /* FIXME: EngSetLastError? */ - return (HMONITOR)NULL; + EngSetLastError(ERROR_NOT_ENOUGH_MEMORY); + hMonitor = NULL; + goto cleanup; } /* get intersecting monitors */ @@ -804,9 +809,8 @@ numMonitors, 0); if (numMonitors == 0) { - ExFreePoolWithTag(hMonitorList, USERTAG_MONITORRECTS); - ExFreePoolWithTag(rectList, USERTAG_MONITORRECTS); - return (HMONITOR)NULL; + hMonitor = NULL; + goto cleanup; } /* find largest intersection */ @@ -820,8 +824,12 @@ } } - ExFreePoolWithTag(hMonitorList, USERTAG_MONITORRECTS); - ExFreePoolWithTag(rectList, USERTAG_MONITORRECTS); +cleanup: + if (hMonitorList) + ExFreePoolWithTag(hMonitorList, USERTAG_MONITORRECTS); + if (rectList) + ExFreePoolWithTag(rectList, USERTAG_MONITORRECTS); + UserLeave(); return hMonitor; }
13 years, 2 months
1
0
0
0
[cgutman] 54194: [STREAM] - Fix a typo - Search for bad !! usage inspired by r54193
by cgutman@svn.reactos.org
Author: cgutman Date: Tue Oct 18 20:36:54 2011 New Revision: 54194 URL:
http://svn.reactos.org/svn/reactos?rev=54194&view=rev
Log: [STREAM] - Fix a typo - Search for bad !! usage inspired by r54193 Modified: trunk/reactos/drivers/wdm/audio/legacy/stream/pnp.c Modified: trunk/reactos/drivers/wdm/audio/legacy/stream/pnp.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/wdm/audio/legacy/s…
============================================================================== --- trunk/reactos/drivers/wdm/audio/legacy/stream/pnp.c [iso-8859-1] (original) +++ trunk/reactos/drivers/wdm/audio/legacy/stream/pnp.c [iso-8859-1] Tue Oct 18 20:36:54 2011 @@ -264,7 +264,7 @@ } } - if (!!bUseInterrupt || DriverObjectExtension->Data.HwInterrupt == NULL || Config->BusInterruptLevel == 0 || Config->BusInterruptVector == 0) + if (!bUseInterrupt || DriverObjectExtension->Data.HwInterrupt == NULL || Config->BusInterruptLevel == 0 || Config->BusInterruptVector == 0) { /* requirements not satisfied */ DeviceExtension->SynchronizeFunction = StreamClassSynchronize;
13 years, 2 months
1
0
0
0
[gadamopoulos] 54193: [uxtheme] - Fix a stupid typo that caused all fonts defined in the theme file to be italic
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Tue Oct 18 20:18:19 2011 New Revision: 54193 URL:
http://svn.reactos.org/svn/reactos?rev=54193&view=rev
Log: [uxtheme] - Fix a stupid typo that caused all fonts defined in the theme file to be italic Modified: trunk/reactos/dll/win32/uxtheme/msstyles.c Modified: trunk/reactos/dll/win32/uxtheme/msstyles.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/uxtheme/msstyles…
============================================================================== --- trunk/reactos/dll/win32/uxtheme/msstyles.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/uxtheme/msstyles.c [iso-8859-1] Tue Oct 18 20:18:19 2011 @@ -1254,9 +1254,9 @@ pFont->lfCharSet = DEFAULT_CHARSET; while(MSSTYLES_GetNextToken(lpCur, lpEnd, &lpCur, attr, sizeof(attr)/sizeof(attr[0]))) { if(!lstrcmpiW(szBold, attr)) pFont->lfWeight = FW_BOLD; - else if(!!lstrcmpiW(szItalic, attr)) pFont->lfItalic = TRUE; - else if(!!lstrcmpiW(szUnderline, attr)) pFont->lfUnderline = TRUE; - else if(!!lstrcmpiW(szStrikeOut, attr)) pFont->lfStrikeOut = TRUE; + else if(!lstrcmpiW(szItalic, attr)) pFont->lfItalic = TRUE; + else if(!lstrcmpiW(szUnderline, attr)) pFont->lfUnderline = TRUE; + else if(!lstrcmpiW(szStrikeOut, attr)) pFont->lfStrikeOut = TRUE; } *lpValEnd = lpCur; return S_OK;
13 years, 2 months
1
0
0
0
[rharabien] 54192: [USER32] - Formatting. No code changes.
by rharabien@svn.reactos.org
Author: rharabien Date: Tue Oct 18 18:12:35 2011 New Revision: 54192 URL:
http://svn.reactos.org/svn/reactos?rev=54192&view=rev
Log: [USER32] - Formatting. No code changes. Modified: trunk/reactos/dll/win32/user32/windows/input.c Modified: trunk/reactos/dll/win32/user32/windows/input.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/i…
============================================================================== --- trunk/reactos/dll/win32/user32/windows/input.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/input.c [iso-8859-1] Tue Oct 18 18:12:35 2011 @@ -45,58 +45,58 @@ BOOL WINAPI DragDetect( - HWND hWnd, - POINT pt) -{ - return NtUserDragDetect(hWnd, pt); + HWND hWnd, + POINT pt) +{ + return NtUserDragDetect(hWnd, pt); #if 0 - MSG msg; - RECT rect; - POINT tmp; - ULONG dx = GetSystemMetrics(SM_CXDRAG); - ULONG dy = GetSystemMetrics(SM_CYDRAG); - - rect.left = pt.x - dx; - rect.right = pt.x + dx; - rect.top = pt.y - dy; - rect.bottom = pt.y + dy; - - SetCapture(hWnd); - - for (;;) - { - while ( - PeekMessageW(&msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || - PeekMessageW(&msg, 0, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE) - ) + MSG msg; + RECT rect; + POINT tmp; + ULONG dx = GetSystemMetrics(SM_CXDRAG); + ULONG dy = GetSystemMetrics(SM_CYDRAG); + + rect.left = pt.x - dx; + rect.right = pt.x + dx; + rect.top = pt.y - dy; + rect.bottom = pt.y + dy; + + SetCapture(hWnd); + + for (;;) { - if (msg.message == WM_LBUTTONUP) - { - ReleaseCapture(); - return FALSE; - } - if (msg.message == WM_MOUSEMOVE) - { - tmp.x = LOWORD(msg.lParam); - tmp.y = HIWORD(msg.lParam); - if (!PtInRect(&rect, tmp)) + while ( + PeekMessageW(&msg, 0, WM_MOUSEFIRST, WM_MOUSELAST, PM_REMOVE) || + PeekMessageW(&msg, 0, WM_KEYFIRST, WM_KEYLAST, PM_REMOVE) + ) { - ReleaseCapture(); - return TRUE; + if (msg.message == WM_LBUTTONUP) + { + ReleaseCapture(); + return FALSE; + } + if (msg.message == WM_MOUSEMOVE) + { + tmp.x = LOWORD(msg.lParam); + tmp.y = HIWORD(msg.lParam); + if (!PtInRect(&rect, tmp)) + { + ReleaseCapture(); + return TRUE; + } + } + if (msg.message == WM_KEYDOWN) + { + if (msg.wParam == VK_ESCAPE) + { + ReleaseCapture(); + return TRUE; + } + } } - } - if (msg.message == WM_KEYDOWN) - { - if (msg.wParam == VK_ESCAPE) - { - ReleaseCapture(); - return TRUE; - } - } + WaitMessage(); } - WaitMessage(); - } - return 0; + return 0; #endif } @@ -106,7 +106,7 @@ BOOL WINAPI EnableWindow(HWND hWnd, BOOL bEnable) { - return NtUserxEnableWindow(hWnd, bEnable); + return NtUserxEnableWindow(hWnd, bEnable); } /* @@ -115,9 +115,9 @@ SHORT WINAPI GetAsyncKeyState(int vKey) { - if (vKey < 0 || vKey > 256) - return 0; - return (SHORT) NtUserGetAsyncKeyState((DWORD) vKey); + if (vKey < 0 || vKey > 256) + return 0; + return (SHORT)NtUserGetAsyncKeyState((DWORD)vKey); } @@ -127,7 +127,7 @@ HKL WINAPI GetKeyboardLayout(DWORD idThread) { - return NtUserxGetKeyboardLayout(idThread); + return NtUserxGetKeyboardLayout(idThread); } @@ -137,7 +137,7 @@ UINT WINAPI GetKBCodePage(VOID) { - return GetOEMCP(); + return GetOEMCP(); } @@ -146,27 +146,32 @@ */ int WINAPI GetKeyNameTextA(LONG lParam, - LPSTR lpString, - int nSize) -{ - LPWSTR intermediateString = - HeapAlloc(GetProcessHeap(),0,nSize * sizeof(WCHAR)); - int ret = 0; - UINT wstrLen = 0; - BOOL defChar = FALSE; - - if( !intermediateString ) return 0; - ret = GetKeyNameTextW(lParam,intermediateString,nSize); - if( ret == 0 ) { lpString[0] = 0; return 0; } - - wstrLen = wcslen( intermediateString ); - ret = WideCharToMultiByte(CP_ACP, 0, - intermediateString, wstrLen, - lpString, nSize, ".", &defChar ); - lpString[ret] = 0; - HeapFree(GetProcessHeap(),0,intermediateString); - - return ret; + LPSTR lpString, + int nSize) +{ + LPWSTR intermediateString = + HeapAlloc(GetProcessHeap(), 0, nSize * sizeof(WCHAR)); + int ret = 0; + UINT wstrLen = 0; + BOOL defChar = FALSE; + + if (!intermediateString) + return 0; + ret = GetKeyNameTextW(lParam, intermediateString, nSize); + if (ret == 0) + { + lpString[0] = 0; + return 0; + } + + wstrLen = wcslen(intermediateString); + ret = WideCharToMultiByte(CP_ACP, 0, + intermediateString, wstrLen, + lpString, nSize, ".", &defChar); + lpString[ret] = 0; + HeapFree(GetProcessHeap(), 0, intermediateString); + + return ret; } /* @@ -174,10 +179,10 @@ */ int WINAPI GetKeyNameTextW(LONG lParam, - LPWSTR lpString, - int nSize) -{ - return NtUserGetKeyNameText( lParam, lpString, nSize ); + LPWSTR lpString, + int nSize) +{ + return NtUserGetKeyNameText(lParam, lpString, nSize); } /* @@ -186,7 +191,7 @@ SHORT WINAPI GetKeyState(int nVirtKey) { - return (SHORT) NtUserGetKeyState((DWORD) nVirtKey); + return (SHORT)NtUserGetKeyState((DWORD)nVirtKey); } /* @@ -195,11 +200,15 @@ BOOL WINAPI GetKeyboardLayoutNameA(LPSTR pwszKLID) { - WCHAR buf[KL_NAMELENGTH]; - - if (GetKeyboardLayoutNameW(buf)) - return WideCharToMultiByte( CP_ACP, 0, buf, -1, pwszKLID, KL_NAMELENGTH, NULL, NULL ) != 0; - return FALSE; + WCHAR buf[KL_NAMELENGTH]; + + if (!GetKeyboardLayoutNameW(buf)) + return FALSE; + + if (!WideCharToMultiByte(CP_ACP, 0, buf, -1, pwszKLID, KL_NAMELENGTH, NULL, NULL)); + return FALSE; + + return TRUE; } @@ -209,7 +218,7 @@ BOOL WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID) { - return NtUserGetKeyboardLayoutName( pwszKLID ); + return NtUserGetKeyboardLayoutName(pwszKLID); } @@ -219,7 +228,7 @@ int WINAPI GetKeyboardType(int nTypeFlag) { - return NtUserxGetKeyboardType( nTypeFlag ); + return NtUserxGetKeyboardType(nTypeFlag); } /* @@ -228,16 +237,16 @@ BOOL WINAPI GetLastInputInfo(PLASTINPUTINFO plii) { - TRACE("%p\n", plii); - - if (plii->cbSize != sizeof (*plii) ) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - plii->dwTime = gpsi->dwLastRITEventTickCount; - return TRUE; + TRACE("%p\n", plii); + + if (plii->cbSize != sizeof (*plii)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + plii->dwTime = gpsi->dwLastRITEventTickCount; + return TRUE; } /* @@ -245,11 +254,11 @@ */ HKL WINAPI LoadKeyboardLayoutA(LPCSTR pwszKLID, - UINT Flags) -{ - return NtUserLoadKeyboardLayoutEx( NULL, 0, NULL, NULL, NULL, - strtoul(pwszKLID, NULL, 16), - Flags); + UINT Flags) +{ + return NtUserLoadKeyboardLayoutEx(NULL, 0, NULL, NULL, NULL, + strtoul(pwszKLID, NULL, 16), + Flags); } /* @@ -257,13 +266,13 @@ */ HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, - UINT Flags) -{ - // Look at revision 25596 to see how it's done in windows. - // We will do things our own way. Also be compatible too! - return NtUserLoadKeyboardLayoutEx( NULL, 0, NULL, NULL, NULL, - wcstoul(pwszKLID, NULL, 16), - Flags); + UINT Flags) +{ + // Look at revision 25596 to see how it's done in windows. + // We will do things our own way. Also be compatible too! + return NtUserLoadKeyboardLayoutEx(NULL, 0, NULL, NULL, NULL, + wcstoul(pwszKLID, NULL, 16), + Flags); } /* @@ -271,9 +280,9 @@ */ UINT WINAPI MapVirtualKeyA(UINT uCode, - UINT uMapType) -{ - return MapVirtualKeyExA( uCode, uMapType, GetKeyboardLayout( 0 ) ); + UINT uMapType) +{ + return MapVirtualKeyExA(uCode, uMapType, GetKeyboardLayout(0)); } /* @@ -281,10 +290,10 @@ */ UINT WINAPI MapVirtualKeyExA(UINT uCode, - UINT uMapType, - HKL dwhkl) -{ - return MapVirtualKeyExW( uCode, uMapType, dwhkl ); + UINT uMapType, + HKL dwhkl) +{ + return MapVirtualKeyExW(uCode, uMapType, dwhkl); } @@ -293,10 +302,10 @@ */ UINT WINAPI MapVirtualKeyExW(UINT uCode, - UINT uMapType, - HKL dwhkl) -{ - return NtUserMapVirtualKeyEx( uCode, uMapType, 0, dwhkl ); + UINT uMapType, + HKL dwhkl) +{ + return NtUserMapVirtualKeyEx(uCode, uMapType, 0, dwhkl); } @@ -305,9 +314,9 @@ */ UINT WINAPI MapVirtualKeyW(UINT uCode, - UINT uMapType) -{ - return MapVirtualKeyExW( uCode, uMapType, GetKeyboardLayout( 0 ) ); + UINT uMapType) +{ + return MapVirtualKeyExW(uCode, uMapType, GetKeyboardLayout(0)); } @@ -317,19 +326,19 @@ DWORD WINAPI OemKeyScan(WORD wOemChar) { - WCHAR p; - SHORT Vk; - UINT Scan; - - MultiByteToWideChar(CP_OEMCP, 0, (PCSTR)&wOemChar, 1, &p, 1); - Vk = VkKeyScanW(p); - Scan = MapVirtualKeyW((Vk & 0x00ff), 0); - if(!Scan) return -1; - /* - Page 450-1, MS W2k SuperBible by SAMS. Return, low word has the - scan code and high word has the shift state. - */ - return ((Vk & 0xff00) << 8) | Scan; + WCHAR p; + SHORT Vk; + UINT Scan; + + MultiByteToWideChar(CP_OEMCP, 0, (PCSTR)&wOemChar, 1, &p, 1); + Vk = VkKeyScanW(p); + Scan = MapVirtualKeyW((Vk & 0x00ff), 0); + if (!Scan) return -1; + /* + Page 450-1, MS W2k SuperBible by SAMS. Return, low word has the + scan code and high word has the shift state. + */ + return ((Vk & 0xff00) << 8) | Scan; } @@ -339,10 +348,10 @@ BOOL WINAPI SetDoubleClickTime(UINT uInterval) { - return (BOOL)NtUserSystemParametersInfo(SPI_SETDOUBLECLICKTIME, - uInterval, - NULL, - 0); + return (BOOL)NtUserSystemParametersInfo(SPI_SETDOUBLECLICKTIME, + uInterval, + NULL, + 0); } @@ -352,9 +361,9 @@ BOOL WINAPI SwapMouseButton( - BOOL fSwap) -{ - return NtUserxSwapMouseButton(fSwap); + BOOL fSwap) +{ + return NtUserxSwapMouseButton(fSwap); } @@ -363,12 +372,12 @@ */ int WINAPI ToAscii(UINT uVirtKey, - UINT uScanCode, - CONST BYTE *lpKeyState, - LPWORD lpChar, - UINT uFlags) -{ - return ToAsciiEx(uVirtKey, uScanCode, lpKeyState, lpChar, uFlags, 0); + UINT uScanCode, + CONST BYTE *lpKeyState, + LPWORD lpChar, + UINT uFlags) +{ + return ToAsciiEx(uVirtKey, uScanCode, lpKeyState, lpChar, uFlags, 0); } @@ -377,20 +386,20 @@ */ int WINAPI ToAsciiEx(UINT uVirtKey, - UINT uScanCode, - CONST BYTE *lpKeyState, - LPWORD lpChar, - UINT uFlags, - HKL dwhkl) -{ - WCHAR UniChars[2]; - int Ret, CharCount; - - Ret = ToUnicodeEx(uVirtKey, uScanCode, lpKeyState, UniChars, 2, uFlags, dwhkl); - CharCount = (Ret < 0 ? 1 : Ret); - WideCharToMultiByte(CP_ACP, 0, UniChars, CharCount, (LPSTR) lpChar, 2, NULL, NULL); - - return Ret; + UINT uScanCode, + CONST BYTE *lpKeyState, + LPWORD lpChar, + UINT uFlags, + HKL dwhkl) +{ + WCHAR UniChars[2]; + int Ret, CharCount; + + Ret = ToUnicodeEx(uVirtKey, uScanCode, lpKeyState, UniChars, 2, uFlags, dwhkl); + CharCount = (Ret < 0 ? 1 : Ret); + WideCharToMultiByte(CP_ACP, 0, UniChars, CharCount, (LPSTR)lpChar, 2, NULL, NULL); + + return Ret; } @@ -399,14 +408,14 @@ */ int WINAPI ToUnicode(UINT wVirtKey, - UINT wScanCode, - CONST BYTE *lpKeyState, - LPWSTR pwszBuff, - int cchBuff, - UINT wFlags) -{ - return ToUnicodeEx( wVirtKey, wScanCode, lpKeyState, pwszBuff, cchBuff, - wFlags, 0 ); + UINT wScanCode, + CONST BYTE *lpKeyState, + LPWSTR pwszBuff, + int cchBuff, + UINT wFlags) +{ + return ToUnicodeEx(wVirtKey, wScanCode, lpKeyState, pwszBuff, cchBuff, + wFlags, 0); } @@ -415,15 +424,15 @@ */ int WINAPI ToUnicodeEx(UINT wVirtKey, - UINT wScanCode, - CONST BYTE *lpKeyState, - LPWSTR pwszBuff, - int cchBuff, - UINT wFlags, - HKL dwhkl) -{ - return NtUserToUnicodeEx( wVirtKey, wScanCode, (PBYTE)lpKeyState, pwszBuff, cchBuff, - wFlags, dwhkl ); + UINT wScanCode, + CONST BYTE *lpKeyState, + LPWSTR pwszBuff, + int cchBuff, + UINT wFlags, + HKL dwhkl) +{ + return NtUserToUnicodeEx(wVirtKey, wScanCode, (PBYTE)lpKeyState, pwszBuff, cchBuff, + wFlags, dwhkl); } @@ -434,12 +443,13 @@ SHORT WINAPI VkKeyScanA(CHAR ch) { - WCHAR wChar; - - if (IsDBCSLeadByte(ch)) return -1; - - MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wChar, 1); - return VkKeyScanW(wChar); + WCHAR wChar; + + if (IsDBCSLeadByte(ch)) + return -1; + + MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wChar, 1); + return VkKeyScanW(wChar); } @@ -448,14 +458,15 @@ */ SHORT WINAPI VkKeyScanExA(CHAR ch, - HKL dwhkl) -{ - WCHAR wChar; - - if (IsDBCSLeadByte(ch)) return -1; - - MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wChar, 1); - return VkKeyScanExW(wChar, dwhkl); + HKL dwhkl) +{ + WCHAR wChar; + + if (IsDBCSLeadByte(ch)) + return -1; + + MultiByteToWideChar(CP_ACP, 0, &ch, 1, &wChar, 1); + return VkKeyScanExW(wChar, dwhkl); } @@ -464,9 +475,9 @@ */ SHORT WINAPI VkKeyScanExW(WCHAR ch, - HKL dwhkl) -{ - return (SHORT) NtUserVkKeyScanEx(ch, dwhkl, TRUE); + HKL dwhkl) +{ + return (SHORT) NtUserVkKeyScanEx(ch, dwhkl, TRUE); } @@ -476,7 +487,7 @@ SHORT WINAPI VkKeyScanW(WCHAR ch) { - return (SHORT) NtUserVkKeyScanEx(ch, 0, FALSE); + return (SHORT) NtUserVkKeyScanEx(ch, 0, FALSE); } @@ -486,23 +497,23 @@ VOID WINAPI keybd_event( - BYTE bVk, - BYTE bScan, - DWORD dwFlags, - ULONG_PTR dwExtraInfo) - - -{ - INPUT Input; - - Input.type = INPUT_KEYBOARD; - Input.ki.wVk = bVk; - Input.ki.wScan = bScan; - Input.ki.dwFlags = dwFlags; - Input.ki.time = 0; - Input.ki.dwExtraInfo = dwExtraInfo; - - NtUserSendInput(1, &Input, sizeof(INPUT)); + BYTE bVk, + BYTE bScan, + DWORD dwFlags, + ULONG_PTR dwExtraInfo) + + +{ + INPUT Input; + + Input.type = INPUT_KEYBOARD; + Input.ki.wVk = bVk; + Input.ki.wScan = bScan; + Input.ki.dwFlags = dwFlags; + Input.ki.time = 0; + Input.ki.dwExtraInfo = dwExtraInfo; + + NtUserSendInput(1, &Input, sizeof(INPUT)); } @@ -512,23 +523,23 @@ VOID WINAPI mouse_event( - DWORD dwFlags, - DWORD dx, - DWORD dy, - DWORD dwData, - ULONG_PTR dwExtraInfo) -{ - INPUT Input; - - Input.type = INPUT_MOUSE; - Input.mi.dx = dx; - Input.mi.dy = dy; - Input.mi.mouseData = dwData; - Input.mi.dwFlags = dwFlags; - Input.mi.time = 0; - Input.mi.dwExtraInfo = dwExtraInfo; - - NtUserSendInput(1, &Input, sizeof(INPUT)); + DWORD dwFlags, + DWORD dx, + DWORD dy, + DWORD dwData, + ULONG_PTR dwExtraInfo) +{ + INPUT Input; + + Input.type = INPUT_MOUSE; + Input.mi.dx = dx; + Input.mi.dy = dy; + Input.mi.mouseData = dwData; + Input.mi.dwFlags = dwFlags; + Input.mi.time = 0; + Input.mi.dwExtraInfo = dwExtraInfo; + + NtUserSendInput(1, &Input, sizeof(INPUT)); } /* EOF */
13 years, 2 months
1
0
0
0
[janderwald] 54191: [KS] - Probe input / output parameters when requests are coming from user mode - Fix KspPinPropertyHandler to use the correct output parameter location - Fix KsHandleSizedListQu...
by janderwald@svn.reactos.org
Author: janderwald Date: Tue Oct 18 18:02:56 2011 New Revision: 54191 URL:
http://svn.reactos.org/svn/reactos?rev=54191&view=rev
Log: [KS] - Probe input / output parameters when requests are coming from user mode - Fix KspPinPropertyHandler to use the correct output parameter location - Fix KsHandleSizedListQuery to use the correct output parameter location - Tested in Vbox 4.1.4 r74291 - May fix a few sound drivers who are having user mode extra utility apps Modified: trunk/reactos/drivers/ksfilter/ks/connectivity.c trunk/reactos/drivers/ksfilter/ks/property.c Modified: trunk/reactos/drivers/ksfilter/ks/connectivity.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/connec…
============================================================================== --- trunk/reactos/drivers/ksfilter/ks/connectivity.c [iso-8859-1] (original) +++ trunk/reactos/drivers/ksfilter/ks/connectivity.c [iso-8859-1] Tue Oct 18 18:02:56 2011 @@ -333,7 +333,7 @@ LPGUID Guid; IoStack = IoGetCurrentIrpStackLocation(Irp); - Buffer = Irp->UserBuffer; + Buffer = Data; //DPRINT("KsPinPropertyHandler Irp %p Property %p Data %p DescriptorsCount %u Descriptor %p OutputLength %u Id %u\n", Irp, Property, Data, DescriptorsCount, Descriptor, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Property->Id); @@ -775,7 +775,7 @@ Size = DataItemSize * DataItemsCount + sizeof(KSMULTIPLE_ITEM); /* get multiple item */ - Item = (PKSMULTIPLE_ITEM)Irp->UserBuffer; + Item = (PKSMULTIPLE_ITEM)Irp->AssociatedIrp.SystemBuffer; if (IoStack->Parameters.DeviceIoControl.OutputBufferLength == 0) { Modified: trunk/reactos/drivers/ksfilter/ks/property.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/ksfilter/ks/proper…
============================================================================== --- trunk/reactos/drivers/ksfilter/ks/property.c [iso-8859-1] (original) +++ trunk/reactos/drivers/ksfilter/ks/property.c [iso-8859-1] Tue Oct 18 18:02:56 2011 @@ -136,38 +136,131 @@ PIO_STACK_LOCATION IoStack; NTSTATUS Status; PFNKSHANDLER PropertyHandler = NULL; - ULONG Index; + ULONG Index, InputBufferLength, OutputBufferLength, TotalSize; LPGUID Guid; /* get current irp stack */ IoStack = IoGetCurrentIrpStackLocation(Irp); + /* get parameters */ + OutputBufferLength = (IoStack->Parameters.DeviceIoControl.OutputBufferLength + 7) & ~7; + InputBufferLength = IoStack->Parameters.DeviceIoControl.InputBufferLength; + + /* check for invalid buffer length size */ + if (OutputBufferLength < IoStack->Parameters.DeviceIoControl.OutputBufferLength) + { + /* unsigned overflow */ + return STATUS_INVALID_BUFFER_SIZE; + } + + /* check for integer overflow */ + if (InputBufferLength + OutputBufferLength < IoStack->Parameters.DeviceIoControl.OutputBufferLength) + { + /* overflow */ + return STATUS_INVALID_BUFFER_SIZE; + } + /* check if inputbuffer at least holds KSPROPERTY item */ if (IoStack->Parameters.DeviceIoControl.InputBufferLength < sizeof(KSPROPERTY)) { /* invalid parameter */ - Irp->IoStatus.Information = sizeof(KSPROPERTY); return STATUS_INVALID_BUFFER_SIZE; } - /* FIXME probe the input / output buffer if from user mode */ + /* get total size */ + TotalSize = InputBufferLength + OutputBufferLength; /* get input property request */ Property = (PKSPROPERTY)IoStack->Parameters.DeviceIoControl.Type3InputBuffer; -// DPRINT("KspPropertyHandler Irp %p PropertySetsCount %u PropertySet %p Allocator %p PropertyItemSize %u ExpectedPropertyItemSize %u\n", Irp, PropertySetsCount, PropertySet, Allocator, PropertyItemSize, sizeof(KSPROPERTY_ITEM)); + /* have the parameters been checked yet */ + if (!Irp->AssociatedIrp.SystemBuffer) + { + /* is it from user mode */ + if (Irp->RequestorMode == UserMode) + { + /* probe user buffer */ + ProbeForRead(IoStack->Parameters.DeviceIoControl.Type3InputBuffer, InputBufferLength, 1); + } + + /* do we have an allocator */ + if ((Allocator) && (Property->Flags & (KSPROPERTY_TYPE_GET | KSPROPERTY_TYPE_SET))) + { + /* call allocator */ + Status = Allocator(Irp, TotalSize, (Property->Flags & KSPROPERTY_TYPE_GET)); + + /* check for success */ + if (!NT_SUCCESS(Status)) + return Status; + } + else + { + /* allocate buffer */ + Irp->AssociatedIrp.SystemBuffer = AllocateItem(NonPagedPool, TotalSize); + + /* sanity check */ + ASSERT(Irp->AssociatedIrp.SystemBuffer != NULL); + + /* mark irp as buffered so that changes the stream headers are propagated back */ + Irp->Flags |= IRP_DEALLOCATE_BUFFER | IRP_BUFFERED_IO; + } + + /* now copy the buffer */ + RtlCopyMemory((PVOID)((ULONG_PTR)Irp->AssociatedIrp.SystemBuffer + OutputBufferLength), IoStack->Parameters.DeviceIoControl.Type3InputBuffer, InputBufferLength); + + /* use new property buffer */ + Property = (PKSPROPERTY)((ULONG_PTR)Irp->AssociatedIrp.SystemBuffer + OutputBufferLength); + + /* is it a set operation */ + if (Property->Flags & KSPROPERTY_TYPE_SET) + { + /* for set operations, the output parameters need to be copied */ + if (Irp->RequestorMode == UserMode) + { + /* probe user parameter */ + ProbeForRead(Irp->UserBuffer, IoStack->Parameters.DeviceIoControl.OutputBufferLength, 1); + } + + /* copy parameters, needs un-aligned parameter length */ + RtlCopyMemory(Irp->AssociatedIrp.SystemBuffer, Irp->UserBuffer, IoStack->Parameters.DeviceIoControl.OutputBufferLength); + } + + /* is there an output buffer */ + if (IoStack->Parameters.DeviceIoControl.OutputBufferLength) + { + /* is it from user mode */ + if (Irp->RequestorMode == UserMode) + { + /* probe buffer for writing */ + ProbeForWrite(Irp->UserBuffer, IoStack->Parameters.DeviceIoControl.OutputBufferLength, 1); + } + + if (!Allocator || !(Property->Flags & KSPROPERTY_TYPE_GET)) + { + /* it is an input operation */ + Irp->Flags |= IRP_INPUT_OPERATION; + } + } + } + else + { + /* use new property buffer */ + Property = (PKSPROPERTY)((ULONG_PTR)Irp->AssociatedIrp.SystemBuffer + OutputBufferLength); + } + + DPRINT("KspPropertyHandler Irp %p PropertySetsCount %u PropertySet %p Allocator %p PropertyItemSize %u ExpectedPropertyItemSize %u\n", Irp, PropertySetsCount, PropertySet, Allocator, PropertyItemSize, sizeof(KSPROPERTY_ITEM)); /* sanity check */ ASSERT(PropertyItemSize == 0 || PropertyItemSize == sizeof(KSPROPERTY_ITEM)); /* find the property handler */ - Status = FindPropertyHandler(&Irp->IoStatus, PropertySet, PropertySetsCount, Property, IoStack->Parameters.DeviceIoControl.InputBufferLength, IoStack->Parameters.DeviceIoControl.OutputBufferLength, Irp->UserBuffer, &PropertyHandler, &Set); + Status = FindPropertyHandler(&Irp->IoStatus, PropertySet, PropertySetsCount, Property, InputBufferLength, OutputBufferLength, Irp->AssociatedIrp.SystemBuffer, &PropertyHandler, &Set); if (NT_SUCCESS(Status) && PropertyHandler) { /* call property handler */ KSPROPERTY_SET_IRP_STORAGE(Irp) = Set; - Status = PropertyHandler(Irp, Property, Irp->UserBuffer); + Status = PropertyHandler(Irp, Property, Irp->AssociatedIrp.SystemBuffer); if (Status == STATUS_BUFFER_TOO_SMALL) { @@ -185,7 +278,7 @@ } /* re-call property handler */ - Status = PropertyHandler(Irp, Property, Irp->UserBuffer); + Status = PropertyHandler(Irp, Property, Irp->AssociatedIrp.SystemBuffer); } } } @@ -200,7 +293,7 @@ } // get output buffer - Guid = (LPGUID)Irp->UserBuffer; + Guid = (LPGUID)Irp->AssociatedIrp.SystemBuffer; // copy property guids from property sets for(Index = 0; Index < PropertySetsCount; Index++)
13 years, 2 months
1
0
0
0
← Newer
1
...
6
7
8
9
10
11
12
...
37
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
Results per page:
10
25
50
100
200