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
2025
January
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
May 2010
----- 2025 -----
January 2025
----- 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
21 participants
438 discussions
Start a n
N
ew thread
[mjmartin] 47325: [win32k] - For the Low Level Mouse Hook (WH_MOUSE_LL), input can come from the mouse driver or mouse_event. Both of which result in a call to UserSetCursorPos. UserMode SetCursorPos API also ends up here. Add BOOL parameter that can be used to determine if hooks are to be called. - Move the code related to calling the hook procedure from MsqInsertSystemMessage into UserSetCursorPos and call the hook procedure here if needed. If hook procedure returns non 0 value. Dont insert th
by mjmartin@svn.reactos.org
Author: mjmartin Date: Sun May 23 13:53:01 2010 New Revision: 47325 URL:
http://svn.reactos.org/svn/reactos?rev=47325&view=rev
Log: [win32k] - For the Low Level Mouse Hook (WH_MOUSE_LL), input can come from the mouse driver or mouse_event. Both of which result in a call to UserSetCursorPos. UserMode SetCursorPos API also ends up here. Add BOOL parameter that can be used to determine if hooks are to be called. - Move the code related to calling the hook procedure from MsqInsertSystemMessage into UserSetCursorPos and call the hook procedure here if needed. If hook procedure returns non 0 value. Dont insert the system message. - Fixes a recursive call to the hook procedure resulting thread using to much stack exposed by user32 winetest for input. Modified: trunk/reactos/subsystems/win32/win32k/include/cursoricon.h trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c trunk/reactos/subsystems/win32/win32k/ntuser/input.c trunk/reactos/subsystems/win32/win32k/ntuser/msgqueue.c trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.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] Sun May 23 13:53:01 2010 @@ -77,7 +77,7 @@ INT cyHeight, UINT istepIfAniCur, HBRUSH hbrFlickerFreeDraw, UINT diFlags); PCURICON_OBJECT FASTCALL UserGetCurIconObject(HCURSOR hCurIcon); -BOOL UserSetCursorPos( INT x, INT y); +BOOL UserSetCursorPos( INT x, INT y, BOOL CallHooks); int UserShowCursor(BOOL bShow); Modified: trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/cursoricon.c [iso-8859-1] Sun May 23 13:53:01 2010 @@ -175,10 +175,12 @@ return hOldCursor; } -BOOL UserSetCursorPos( INT x, INT y) +BOOL UserSetCursorPos( INT x, INT y, BOOL CallHooks) { PWINDOW_OBJECT DesktopWindow; PSYSTEM_CURSORINFO CurInfo; + LARGE_INTEGER LargeTickCount; + MSLLHOOKSTRUCT MouseHookData; HDC hDC; MSG Msg; @@ -221,6 +223,9 @@ gpsi->ptCursor.x = x; gpsi->ptCursor.y = y; + KeQueryTickCount(&LargeTickCount); + Msg.time = MsqCalculateMessageTime(&LargeTickCount); + //Move the mouse pointer GreMovePointer(hDC, x, y); @@ -229,8 +234,39 @@ Msg.wParam = CurInfo->ButtonsDown; Msg.lParam = MAKELPARAM(x, y); Msg.pt = gpsi->ptCursor; + + MouseHookData.pt.x = LOWORD(Msg.lParam); + MouseHookData.pt.y = HIWORD(Msg.lParam); + switch(Msg.message) + { + case WM_MOUSEWHEEL: + MouseHookData.mouseData = MAKELONG(0, GET_WHEEL_DELTA_WPARAM(Msg.wParam)); + break; + case WM_XBUTTONDOWN: + case WM_XBUTTONUP: + case WM_XBUTTONDBLCLK: + case WM_NCXBUTTONDOWN: + case WM_NCXBUTTONUP: + case WM_NCXBUTTONDBLCLK: + MouseHookData.mouseData = MAKELONG(0, HIWORD(Msg.wParam)); + break; + default: + MouseHookData.mouseData = 0; + break; + } + + MouseHookData.flags = 0; + MouseHookData.time = Msg.time; + MouseHookData.dwExtraInfo = 0; + + if (CallHooks) + { + /* If the hook procedure returned non zero, dont send the message */ + if (co_HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION, Msg.message, (LPARAM) &MouseHookData)) + return FALSE; + } + MsqInsertSystemMessage(&Msg); - return TRUE; } @@ -814,7 +850,7 @@ CurInfo->CursorClipInfo.Right = min(Rect.right, DesktopWindow->Wnd->rcWindow.right); CurInfo->CursorClipInfo.Bottom = min(Rect.bottom, DesktopWindow->Wnd->rcWindow.bottom); - UserSetCursorPos(gpsi->ptCursor.x, gpsi->ptCursor.y); + UserSetCursorPos(gpsi->ptCursor.x, gpsi->ptCursor.y, FALSE); RETURN(TRUE); } Modified: trunk/reactos/subsystems/win32/win32k/ntuser/input.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/input.c [iso-8859-1] Sun May 23 13:53:01 2010 @@ -1128,7 +1128,7 @@ if(mi->dwFlags & MOUSEEVENTF_MOVE) { - UserSetCursorPos(MousePos.x, MousePos.y); + UserSetCursorPos(MousePos.x, MousePos.y, TRUE); } if(mi->dwFlags & MOUSEEVENTF_LEFTDOWN) { 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] Sun May 23 13:53:01 2010 @@ -171,38 +171,8 @@ VOID FASTCALL MsqInsertSystemMessage(MSG* Msg) { - LARGE_INTEGER LargeTickCount; KIRQL OldIrql; ULONG Prev; - MSLLHOOKSTRUCT MouseHookData; - - KeQueryTickCount(&LargeTickCount); - Msg->time = MsqCalculateMessageTime(&LargeTickCount); - - MouseHookData.pt.x = LOWORD(Msg->lParam); - MouseHookData.pt.y = HIWORD(Msg->lParam); - switch(Msg->message) - { - case WM_MOUSEWHEEL: - MouseHookData.mouseData = MAKELONG(0, GET_WHEEL_DELTA_WPARAM(Msg->wParam)); - break; - case WM_XBUTTONDOWN: - case WM_XBUTTONUP: - case WM_XBUTTONDBLCLK: - case WM_NCXBUTTONDOWN: - case WM_NCXBUTTONUP: - case WM_NCXBUTTONDBLCLK: - MouseHookData.mouseData = MAKELONG(0, HIWORD(Msg->wParam)); - break; - default: - MouseHookData.mouseData = 0; - break; - } - MouseHookData.flags = 0; - MouseHookData.time = Msg->time; - MouseHookData.dwExtraInfo = 0; - if( co_HOOK_CallHooks(WH_MOUSE_LL, HC_ACTION, Msg->message, (LPARAM) &MouseHookData)) - return; /* * If we got WM_MOUSEMOVE and there are already messages in the Modified: trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/win32k/nt…
============================================================================== --- trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/win32k/ntuser/simplecall.c [iso-8859-1] Sun May 23 13:53:01 2010 @@ -440,7 +440,7 @@ RETURN( (DWORD_PTR)co_IntRegisterLogonProcess((HANDLE)Param1, (BOOL)Param2)); case TWOPARAM_ROUTINE_SETCURSORPOS: - RETURN( (DWORD_PTR)UserSetCursorPos((int)Param1, (int)Param2)); + RETURN( (DWORD_PTR)UserSetCursorPos((int)Param1, (int)Param2, FALSE)); } DPRINT1("Calling invalid routine number 0x%x in NtUserCallTwoParam(), Param1=0x%x Parm2=0x%x\n",
14 years, 8 months
1
0
0
0
[ekohl] 47324: [WINLOGON] - Set the APPDATA environment variable without loading shell32.dll. This should fix bug #5398.
by ekohl@svn.reactos.org
Author: ekohl Date: Sun May 23 13:35:08 2010 New Revision: 47324 URL:
http://svn.reactos.org/svn/reactos?rev=47324&view=rev
Log: [WINLOGON] - Set the APPDATA environment variable without loading shell32.dll. This should fix bug #5398. Modified: trunk/reactos/base/system/winlogon/environment.c Modified: trunk/reactos/base/system/winlogon/environment.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/winlogon/envir…
============================================================================== --- trunk/reactos/base/system/winlogon/environment.c [iso-8859-1] (original) +++ trunk/reactos/base/system/winlogon/environment.c [iso-8859-1] Sun May 23 13:35:08 2010 @@ -19,25 +19,42 @@ /* GLOBALS ******************************************************************/ -typedef HRESULT (WINAPI *PFSHGETFOLDERPATHW)(HWND, int, HANDLE, DWORD, LPWSTR); - /* FUNCTIONS ****************************************************************/ static VOID BuildVolatileEnvironment(IN PWLSESSION Session, - IN HKEY hKey) + IN HKEY hKeyCurrentUser) { - HINSTANCE hShell32 = NULL; - PFSHGETFOLDERPATHW pfSHGetFolderPathW = NULL; WCHAR szPath[MAX_PATH + 1]; - WCHAR szExpandedPath[MAX_PATH + 1]; LPCWSTR wstr; SIZE_T size; WCHAR szEnvKey[MAX_PATH]; WCHAR szEnvValue[1024]; SIZE_T length; LPWSTR eqptr, endptr; + DWORD dwDisp; + LONG lError; + HKEY hKeyVolatileEnv; + HKEY hKeyShellFolders; + DWORD dwType; + DWORD dwSize; + + /* Create the 'Volatile Environment' key */ + lError = RegCreateKeyExW(hKeyCurrentUser, + L"Volatile Environment", + 0, + NULL, + REG_OPTION_VOLATILE, + KEY_WRITE, + NULL, + &hKeyVolatileEnv, + &dwDisp); + if (lError != ERROR_SUCCESS) + { + WARN("WL: RegCreateKeyExW() failed to create the volatile environment key (Error: %ld)\n", lError); + return; + } /* Parse the environment variables and add them to the volatile environment key */ if (Session->Profile->dwType == WLX_PROFILE_TYPE_V2_0 && @@ -68,7 +85,7 @@ eqptr++; wcscpy(szEnvValue, eqptr); - RegSetValueExW(hKey, + RegSetValueExW(hKeyVolatileEnv, szEnvKey, 0, REG_SZ, @@ -80,50 +97,44 @@ } } - /* Load shell32.dll and call SHGetFolderPathW to get the users appdata folder path */ - hShell32 = LoadLibraryW(L"shell32.dll"); - if (hShell32 != NULL) + /* Set the 'APPDATA' environment variable */ + lError = RegOpenKeyExW(hKeyCurrentUser, + L"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", + 0, + KEY_READ, + &hKeyShellFolders); + if (lError == ERROR_SUCCESS) { - pfSHGetFolderPathW = (PFSHGETFOLDERPATHW)GetProcAddress(hShell32, - "SHGetFolderPathW"); - if (pfSHGetFolderPathW != NULL) + dwSize = (MAX_PATH + 1) * sizeof(WCHAR); + lError = RegQueryValueExW(hKeyShellFolders, + L"AppData", + NULL, + &dwType, + (LPBYTE)szPath, + &dwSize); + if (lError == ERROR_SUCCESS) { - if (pfSHGetFolderPathW(NULL, - CSIDL_APPDATA | CSIDL_FLAG_DONT_VERIFY, - Session->UserToken, - 0, - szPath) == S_OK) - { - /* FIXME: Expand %USERPROFILE% here. SHGetFolderPathW should do it for us. See Bug #5372.*/ - TRACE("APPDATA path: %S\n", szPath); - ExpandEnvironmentStringsForUserW(Session->UserToken, - szPath, - szExpandedPath, - MAX_PATH); - - /* Add the appdata folder path to the users volatile environment key */ - TRACE("APPDATA expanded path: %S\n", szExpandedPath); - RegSetValueExW(hKey, - L"APPDATA", - 0, - REG_SZ, - (LPBYTE)szExpandedPath, - (wcslen(szExpandedPath) + 1) * sizeof(WCHAR)); - } + TRACE("APPDATA path: %S\n", szPath); + RegSetValueExW(hKeyVolatileEnv, + L"APPDATA", + 0, + REG_SZ, + (LPBYTE)szPath, + (wcslen(szPath) + 1) * sizeof(WCHAR)); } - FreeLibrary(hShell32); + RegCloseKey(hKeyShellFolders); } + + RegCloseKey(hKeyVolatileEnv); } BOOL CreateUserEnvironment(IN PWLSESSION Session) { - HKEY hKey; - DWORD dwDisp; + HKEY hKeyCurrentUser; LONG lError; - HKEY hKeyCurrentUser; TRACE("WL: CreateUserEnvironment called\n"); @@ -135,28 +146,8 @@ &hKeyCurrentUser); if (lError == ERROR_SUCCESS) { - /* Create the 'Volatile Environment' key */ - lError = RegCreateKeyExW(hKeyCurrentUser, - L"Volatile Environment", - 0, - NULL, - REG_OPTION_VOLATILE, - KEY_WRITE, - NULL, - &hKey, - &dwDisp); - if (lError == ERROR_SUCCESS) - { - BuildVolatileEnvironment(Session, - hKey); - - RegCloseKey(hKey); - } - else - { - WARN("WL: RegCreateKeyExW() failed (Error: %ld)\n", lError); - } - + BuildVolatileEnvironment(Session, + hKeyCurrentUser); RegCloseKey(hKeyCurrentUser); }
14 years, 8 months
1
0
0
0
[fireball] 47323: - Sync up to Wine-1.2-rc1. - Further refactoring of cursor icons code according to recent Wine's improvements.
by fireball@svn.reactos.org
Author: fireball Date: Sun May 23 13:16:16 2010 New Revision: 47323 URL:
http://svn.reactos.org/svn/reactos?rev=47323&view=rev
Log: - Sync up to Wine-1.2-rc1. - Further refactoring of cursor icons code according to recent Wine's improvements. Modified: branches/arwinss/reactos/dll/win32/gdi32/ (props changed) branches/arwinss/reactos/dll/win32/gdi32/bidi.c branches/arwinss/reactos/dll/win32/gdi32/dib.c branches/arwinss/reactos/dll/win32/gdi32/font.c branches/arwinss/reactos/dll/win32/gdi32/freetype.c branches/arwinss/reactos/dll/win32/gdi32/gdi_private.h branches/arwinss/reactos/dll/win32/user32/ (props changed) branches/arwinss/reactos/dll/win32/user32/button.c branches/arwinss/reactos/dll/win32/user32/caret.c branches/arwinss/reactos/dll/win32/user32/cursoricon.c branches/arwinss/reactos/dll/win32/user32/dde_server.c branches/arwinss/reactos/dll/win32/user32/dialog.c branches/arwinss/reactos/dll/win32/user32/driver.c branches/arwinss/reactos/dll/win32/user32/input.c branches/arwinss/reactos/dll/win32/user32/listbox.c branches/arwinss/reactos/dll/win32/user32/painting.c branches/arwinss/reactos/dll/win32/user32/user_private.h branches/arwinss/reactos/dll/win32/winent.drv/mouse.c branches/arwinss/reactos/dll/win32/winent.drv/winent.drv.spec branches/arwinss/reactos/dll/win32/winex11.drv/ (props changed) branches/arwinss/reactos/dll/win32/winex11.drv/desktop.c branches/arwinss/reactos/dll/win32/winex11.drv/dib.c branches/arwinss/reactos/dll/win32/winex11.drv/mouse.c branches/arwinss/reactos/dll/win32/winex11.drv/opengl.c branches/arwinss/reactos/dll/win32/winex11.drv/window.c branches/arwinss/reactos/dll/win32/winex11.drv/winex11.drv.spec branches/arwinss/reactos/dll/win32/winex11.drv/x11drv.h branches/arwinss/reactos/dll/win32/winex11.drv/xrender.c branches/arwinss/reactos/include/reactos/win32k/rosuser.h branches/arwinss/reactos/include/reactos/wine/server_protocol.h branches/arwinss/reactos/subsystems/win32/win32k/include/ (props changed) branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h branches/arwinss/reactos/subsystems/win32/win32k/include/request.h (contents, props changed) branches/arwinss/reactos/subsystems/win32/win32k/include/user.h (props changed) branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c branches/arwinss/reactos/subsystems/win32/win32k/wine/ (props changed) branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c [This mail would be too long, it was shortened to contain the URLs only.] Modified: branches/arwinss/reactos/dll/win32/gdi32/bidi.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/gdi32…
Modified: branches/arwinss/reactos/dll/win32/gdi32/dib.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/gdi32…
Modified: branches/arwinss/reactos/dll/win32/gdi32/font.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/gdi32…
Modified: branches/arwinss/reactos/dll/win32/gdi32/freetype.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/gdi32…
Modified: branches/arwinss/reactos/dll/win32/gdi32/gdi_private.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/gdi32…
Modified: branches/arwinss/reactos/dll/win32/user32/button.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
Modified: branches/arwinss/reactos/dll/win32/user32/caret.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
Modified: branches/arwinss/reactos/dll/win32/user32/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
Modified: branches/arwinss/reactos/dll/win32/user32/dde_server.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
Modified: branches/arwinss/reactos/dll/win32/user32/dialog.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
Modified: branches/arwinss/reactos/dll/win32/user32/driver.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
Modified: branches/arwinss/reactos/dll/win32/user32/input.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
Modified: branches/arwinss/reactos/dll/win32/user32/listbox.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
Modified: branches/arwinss/reactos/dll/win32/user32/painting.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
Modified: branches/arwinss/reactos/dll/win32/user32/user_private.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/user3…
Modified: branches/arwinss/reactos/dll/win32/winent.drv/mouse.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winen…
Modified: branches/arwinss/reactos/dll/win32/winent.drv/winent.drv.spec URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winen…
Modified: branches/arwinss/reactos/dll/win32/winex11.drv/desktop.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winex…
Modified: branches/arwinss/reactos/dll/win32/winex11.drv/dib.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winex…
Modified: branches/arwinss/reactos/dll/win32/winex11.drv/mouse.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winex…
Modified: branches/arwinss/reactos/dll/win32/winex11.drv/opengl.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winex…
Modified: branches/arwinss/reactos/dll/win32/winex11.drv/window.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winex…
Modified: branches/arwinss/reactos/dll/win32/winex11.drv/winex11.drv.spec URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winex…
Modified: branches/arwinss/reactos/dll/win32/winex11.drv/x11drv.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winex…
Modified: branches/arwinss/reactos/dll/win32/winex11.drv/xrender.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winex…
Modified: branches/arwinss/reactos/include/reactos/win32k/rosuser.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/include/reactos…
Modified: branches/arwinss/reactos/include/reactos/wine/server_protocol.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/include/reactos…
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/request.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
Modified: branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
Modified: branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
Modified: branches/arwinss/reactos/subsystems/win32/win32k/wine/queue.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
14 years, 8 months
1
0
0
0
[gadamopoulos] 47322: [kernel32_winetest] - kernel32 tests need a resource file
by gadamopoulos@svn.reactos.org
Author: gadamopoulos Date: Sun May 23 12:59:41 2010 New Revision: 47322 URL:
http://svn.reactos.org/svn/reactos?rev=47322&view=rev
Log: [kernel32_winetest] - kernel32 tests need a resource file Modified: trunk/rostests/winetests/kernel32/kernel32.rbuild Modified: trunk/rostests/winetests/kernel32/kernel32.rbuild URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/winetests/kernel32/kernel…
============================================================================== --- trunk/rostests/winetests/kernel32/kernel32.rbuild [iso-8859-1] (original) +++ trunk/rostests/winetests/kernel32/kernel32.rbuild [iso-8859-1] Sun May 23 12:59:41 2010 @@ -41,4 +41,5 @@ <file>virtual.c</file> <file>volume.c</file> <file>testlist.c</file> + <file>resource.rc</file> </module>
14 years, 8 months
1
0
0
0
[fireball] 47321: [VENDOR/WINE] - Import Wine-1.2-rc1 gdi32, user32, winex11.drv, wineserver.
by fireball@svn.reactos.org
Author: fireball Date: Sun May 23 12:42:47 2010 New Revision: 47321 URL:
http://svn.reactos.org/svn/reactos?rev=47321&view=rev
Log: [VENDOR/WINE] - Import Wine-1.2-rc1 gdi32, user32, winex11.drv, wineserver. Modified: vendor/wine/dlls/gdi32/current/bidi.c vendor/wine/dlls/gdi32/current/dib.c vendor/wine/dlls/gdi32/current/font.c vendor/wine/dlls/gdi32/current/freetype.c vendor/wine/dlls/gdi32/current/gdi_private.h vendor/wine/dlls/gdi32/current/tests/bitmap.c vendor/wine/dlls/gdi32/current/tests/font.c vendor/wine/dlls/gdi32/current/tests/path.c vendor/wine/dlls/user32/current/button.c vendor/wine/dlls/user32/current/caret.c vendor/wine/dlls/user32/current/cursoricon.c vendor/wine/dlls/user32/current/dde_server.c vendor/wine/dlls/user32/current/dialog.c vendor/wine/dlls/user32/current/driver.c vendor/wine/dlls/user32/current/input.c vendor/wine/dlls/user32/current/listbox.c vendor/wine/dlls/user32/current/painting.c vendor/wine/dlls/user32/current/tests/cursoricon.c vendor/wine/dlls/user32/current/tests/dce.c vendor/wine/dlls/user32/current/tests/msg.c vendor/wine/dlls/user32/current/tests/win.c vendor/wine/dlls/user32/current/user_private.h vendor/wine/dlls/winex11.drv/current/desktop.c vendor/wine/dlls/winex11.drv/current/dib.c vendor/wine/dlls/winex11.drv/current/mouse.c vendor/wine/dlls/winex11.drv/current/opengl.c vendor/wine/dlls/winex11.drv/current/window.c vendor/wine/dlls/winex11.drv/current/winex11.drv.spec vendor/wine/dlls/winex11.drv/current/x11drv.h vendor/wine/dlls/winex11.drv/current/xrender.c vendor/wine/server/current/async.c vendor/wine/server/current/file.h vendor/wine/server/current/protocol.def vendor/wine/server/current/queue.c vendor/wine/server/current/request.h vendor/wine/server/current/sock.c vendor/wine/server/current/thread.c vendor/wine/server/current/trace.c [This mail would be too long, it was shortened to contain the URLs only.] Modified: vendor/wine/dlls/gdi32/current/bidi.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/gdi32/current/bidi.c?re…
Modified: vendor/wine/dlls/gdi32/current/dib.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/gdi32/current/dib.c?rev…
Modified: vendor/wine/dlls/gdi32/current/font.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/gdi32/current/font.c?re…
Modified: vendor/wine/dlls/gdi32/current/freetype.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/gdi32/current/freetype.…
Modified: vendor/wine/dlls/gdi32/current/gdi_private.h URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/gdi32/current/gdi_priva…
Modified: vendor/wine/dlls/gdi32/current/tests/bitmap.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/gdi32/current/tests/bit…
Modified: vendor/wine/dlls/gdi32/current/tests/font.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/gdi32/current/tests/fon…
Modified: vendor/wine/dlls/gdi32/current/tests/path.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/gdi32/current/tests/pat…
Modified: vendor/wine/dlls/user32/current/button.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/button.c…
Modified: vendor/wine/dlls/user32/current/caret.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/caret.c?…
Modified: vendor/wine/dlls/user32/current/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/cursoric…
Modified: vendor/wine/dlls/user32/current/dde_server.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/dde_serv…
Modified: vendor/wine/dlls/user32/current/dialog.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/dialog.c…
Modified: vendor/wine/dlls/user32/current/driver.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/driver.c…
Modified: vendor/wine/dlls/user32/current/input.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/input.c?…
Modified: vendor/wine/dlls/user32/current/listbox.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/listbox.…
Modified: vendor/wine/dlls/user32/current/painting.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/painting…
Modified: vendor/wine/dlls/user32/current/tests/cursoricon.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/tests/cu…
Modified: vendor/wine/dlls/user32/current/tests/dce.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/tests/dc…
Modified: vendor/wine/dlls/user32/current/tests/msg.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/tests/ms…
Modified: vendor/wine/dlls/user32/current/tests/win.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/tests/wi…
Modified: vendor/wine/dlls/user32/current/user_private.h URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/user32/current/user_pri…
Modified: vendor/wine/dlls/winex11.drv/current/desktop.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/winex11.drv/current/des…
Modified: vendor/wine/dlls/winex11.drv/current/dib.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/winex11.drv/current/dib…
Modified: vendor/wine/dlls/winex11.drv/current/mouse.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/winex11.drv/current/mou…
Modified: vendor/wine/dlls/winex11.drv/current/opengl.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/winex11.drv/current/ope…
Modified: vendor/wine/dlls/winex11.drv/current/window.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/winex11.drv/current/win…
Modified: vendor/wine/dlls/winex11.drv/current/winex11.drv.spec URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/winex11.drv/current/win…
Modified: vendor/wine/dlls/winex11.drv/current/x11drv.h URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/winex11.drv/current/x11…
Modified: vendor/wine/dlls/winex11.drv/current/xrender.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/dlls/winex11.drv/current/xre…
Modified: vendor/wine/server/current/async.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/server/current/async.c?rev=4…
Modified: vendor/wine/server/current/file.h URL:
http://svn.reactos.org/svn/reactos/vendor/wine/server/current/file.h?rev=47…
Modified: vendor/wine/server/current/protocol.def URL:
http://svn.reactos.org/svn/reactos/vendor/wine/server/current/protocol.def?…
Modified: vendor/wine/server/current/queue.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/server/current/queue.c?rev=4…
Modified: vendor/wine/server/current/request.h URL:
http://svn.reactos.org/svn/reactos/vendor/wine/server/current/request.h?rev…
Modified: vendor/wine/server/current/sock.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/server/current/sock.c?rev=47…
Modified: vendor/wine/server/current/thread.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/server/current/thread.c?rev=…
Modified: vendor/wine/server/current/trace.c URL:
http://svn.reactos.org/svn/reactos/vendor/wine/server/current/trace.c?rev=4…
14 years, 8 months
1
0
0
0
[fireball] 47320: - Initial cursor icons support, work in progress. When it's finished, improvements and optimisations are welcome.
by fireball@svn.reactos.org
Author: fireball Date: Sun May 23 12:22:09 2010 New Revision: 47320 URL:
http://svn.reactos.org/svn/reactos?rev=47320&view=rev
Log: - Initial cursor icons support, work in progress. When it's finished, improvements and optimisations are welcome. Modified: branches/arwinss/reactos/dll/win32/winent.drv/mouse.c branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c branches/arwinss/reactos/dll/win32/winent.drv/winent.h branches/arwinss/reactos/include/reactos/win32k/rosuser.h branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c branches/arwinss/reactos/subsystems/win32/win32k/main/init.c branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db Modified: branches/arwinss/reactos/dll/win32/winent.drv/mouse.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winen…
============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/mouse.c [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/mouse.c [iso-8859-1] Sun May 23 12:22:09 2010 @@ -107,6 +107,7 @@ BYTE* key_state_table) { MSLLHOOKSTRUCT hook; + HCURSOR cursor; hook.pt.x = x; hook.pt.y = y; @@ -129,9 +130,38 @@ req->time = time; req->info = extra_info; wine_server_call( req ); + cursor = (reply->count >= 0) ? wine_server_ptr_handle(reply->cursor) : 0; } SERVER_END_REQ; + if (hwnd) + { + // TODO: Add cursor change support + /*Cursor xcursor; + struct x11drv_win_data *data = X11DRV_get_win_data( hwnd ); + if (data && cursor != data->cursor) + { + wine_tsx11_lock(); + if ((xcursor = get_x11_cursor( cursor ))) + XDefineCursor( gdi_display, data->whole_window, xcursor ); + data->cursor = cursor; + wine_tsx11_unlock(); + }*/ + } +} + +/*********************************************************************** + * set_window_cursor + */ +void set_window_cursor( HWND hwnd, HCURSOR handle ) +{ + struct ntdrv_win_data *data; + + if (!(data = NTDRV_get_win_data( hwnd ))) return; + + /* Set the cursor */ + SwmDefineCursor(hwnd, handle); + data->cursor = handle; } @@ -493,16 +523,13 @@ #endif /* Create cursor bitmaps */ - RosDrv_GetIconInfo( lpCursor, &IconInfo ); - - //cursor = create_cursor( gdi_display, info ); - //if (cursor) - //{ - //if (!cursor_context) cursor_context = XUniqueContext(); - //XSaveContext( gdi_display, (XID)handle, cursor_context, (char *)cursor ); - FIXME( "cursor %p %ux%u, planes %u, bpp %u -> xid %lx\n", + RosDrv_GetIconInfo( info, &IconInfo ); + + /* Create the cursor icon */ + RosUserCreateCursorIcon( &IconInfo, handle ); + + FIXME( "cursor %p %ux%u, planes %u, bpp %u -> xid %lx\n", handle, info->nWidth, info->nHeight, info->bPlanes, info->bBitsPerPixel, /*cursor*/ 0); - //} } /*********************************************************************** @@ -510,22 +537,25 @@ */ void CDECL RosDrv_DestroyCursorIcon( HCURSOR handle ) { - //Cursor cursor; + ICONINFO IconInfo; FIXME( "%p xid %lx\n", handle, /*cursor*/ 0 ); - /*if ((cursor = get_x11_cursor( handle ))) - { - TRACE( "%p xid %lx\n", handle, cursor ); - XFreeCursor( gdi_display, cursor ); - XDeleteContext( gdi_display, (XID)handle, cursor_context ); - }*/ + /* Destroy kernel mode part of the cursor icon */ + RosUserDestroyCursorIcon( &IconInfo, handle ); + + /* Destroy usermode-created bitmaps */ + // FIXME: Will it delete kernelmode bitmaps?! + if (IconInfo.hbmColor) DeleteObject( IconInfo.hbmColor ); + if (IconInfo.hbmMask) DeleteObject( IconInfo.hbmMask ); } void CDECL RosDrv_SetCursor( HCURSOR handle ) { - //if (cursor_window) SendNotifyMessageW( cursor_window, WM_X11DRV_SET_CURSOR, 0, (LPARAM)handle ); + if (cursor_window) SendNotifyMessageW( cursor_window, WM_NTDRV_SET_CURSOR, 0, (LPARAM)handle ); FIXME("handle %x, cursor_window %x\n", handle, cursor_window); + + // FIXME: Remove! RosUserSetCursor(NULL); } Modified: branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winen…
============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/userdrv.c [iso-8859-1] Sun May 23 12:22:09 2010 @@ -761,8 +761,15 @@ LRESULT CDECL RosDrv_WindowMessage( HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam ) { - UNIMPLEMENTED; - return 0; + switch(msg) + { + case WM_NTDRV_SET_CURSOR: + set_window_cursor( hwnd, (HCURSOR)lparam ); + return 0; + default: + FIXME( "got window msg %x hwnd %p wp %lx lp %lx\n", msg, hwnd, wparam, lparam ); + return 0; + } } void CDECL RosDrv_WindowPosChanging( HWND hwnd, HWND insert_after, UINT swp_flags, Modified: branches/arwinss/reactos/dll/win32/winent.drv/winent.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/dll/win32/winen…
============================================================================== --- branches/arwinss/reactos/dll/win32/winent.drv/winent.h [iso-8859-1] (original) +++ branches/arwinss/reactos/dll/win32/winent.drv/winent.h [iso-8859-1] Sun May 23 12:22:09 2010 @@ -14,6 +14,12 @@ NTDRV_GET_GLX_DRAWABLE, /* get current glx drawable for a DC */ NTDRV_SYNC_PIXMAP, /* sync the dibsection to its pixmap */ NTDRV_FLUSH_GL_DRAWABLE /* flush changes made to the gl drawable */ +}; + +/* NT driver private messages, must be in the range 0x80001000..0x80001fff */ +enum ntdrv_window_messages +{ + WM_NTDRV_SET_CURSOR = 0x80001000 }; struct ntdrv_escape_set_drawable @@ -35,6 +41,7 @@ RECT window_rect; /* USER window rectangle relative to parent */ RECT whole_rect; /* X window rectangle for the whole window relative to parent */ RECT client_rect; /* client area relative to parent */ + HCURSOR cursor; /* current cursor */ }; /* gdidrv.c */ @@ -56,6 +63,9 @@ const RECT *lprect, LPCWSTR wstr, UINT count, const INT *lpDx ); +/* mouse.c */ +void set_window_cursor( HWND hwnd, HCURSOR handle ); + void NTDRV_SendMouseInput( HWND hwnd, DWORD flags, DWORD x, DWORD y, DWORD data, DWORD time, DWORD extra_info, UINT injected_flags ); Modified: branches/arwinss/reactos/include/reactos/win32k/rosuser.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/include/reactos…
============================================================================== --- branches/arwinss/reactos/include/reactos/win32k/rosuser.h [iso-8859-1] (original) +++ branches/arwinss/reactos/include/reactos/win32k/rosuser.h [iso-8859-1] Sun May 23 12:22:09 2010 @@ -37,17 +37,25 @@ ); #endif -BOOL NTAPI +BOOL NTAPI RosUserGetCursorPos( LPPOINT pt ); -BOOL NTAPI +BOOL NTAPI RosUserSetCursorPos( INT x, INT y ); -BOOL NTAPI +BOOL NTAPI RosUserClipCursor( LPCRECT clip ); -void NTAPI +void NTAPI RosUserSetCursor( ICONINFO* IconInfo ); + +VOID APIENTRY +RosUserCreateCursorIcon(ICONINFO* IconInfoUnsafe, + HCURSOR Handle); + +VOID APIENTRY +RosUserDestroyCursorIcon(ICONINFO* IconInfoUnsafe, + HCURSOR Handle); LONG APIENTRY @@ -160,6 +168,9 @@ SwmAddDesktopWindow(HWND hWnd, UINT Width, UINT Height); VOID NTAPI +SwmDefineCursor(HWND hWnd, HCURSOR hCursor); + +VOID NTAPI SwmRemoveWindow(HWND hWnd); VOID NTAPI Modified: branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/include/cursor.h [iso-8859-1] Sun May 23 12:22:09 2010 @@ -21,4 +21,14 @@ RECTL Exclude; /* required publicly for SPS_ACCEPT_EXCLUDE */ } GDIPOINTER, *PGDIPOINTER; +typedef struct _CURSORICONENTRY +{ + HANDLE hbmMask; + HANDLE hbmColor; + HANDLE hUser; + LIST_ENTRY Entry; +} CURSORICONENTRY, *PCURSORICONENTRY; + extern SYSTEM_CURSORINFO CursorInfo; + +VOID NTAPI USER_InitCursorIcons(); Modified: branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/main/cursor.c [iso-8859-1] Sun May 23 12:22:09 2010 @@ -10,6 +10,10 @@ #define NDEBUG #include <debug.h> +/* Cursor icons list */ +LIST_ENTRY CursorIcons; +ERESOURCE CursorIconsLock; + SYSTEM_CURSORINFO CursorInfo; extern PDEVOBJ PrimarySurface; @@ -140,3 +144,89 @@ } } +VOID +APIENTRY +RosUserCreateCursorIcon(ICONINFO* IconInfoUnsafe, + HCURSOR Handle) +{ + PCURSORICONENTRY pCursorIcon; + + // FIXME: SEH! + + /* Allocate an entry in the cursor icons list */ + pCursorIcon = ExAllocatePool(PagedPool, sizeof(CURSORICONENTRY)); + RtlZeroMemory(pCursorIcon, sizeof(CURSORICONENTRY)); + + /* Save the usermode handle and other fields */ + pCursorIcon->hUser = Handle; + //pCursorIcon->hbmMask = GDI_MapUserHandle(IconInfoUnsafe->hbmMask); + //pCursorIcon->hbmColor = GDI_MapUserHandle(IconInfoUnsafe->hbmColor); + pCursorIcon->hbmMask = IconInfoUnsafe->hbmMask; + pCursorIcon->hbmColor = IconInfoUnsafe->hbmColor; + + /* Acquire lock */ + KeEnterCriticalRegion(); + ExAcquireResourceExclusiveLite(&CursorIconsLock, TRUE); + + /* Add it to the list */ + InsertTailList(&CursorIcons, &pCursorIcon->Entry); + + /* Release lock */ + ExReleaseResourceLite(&CursorIconsLock); + KeLeaveCriticalRegion(); +} + +VOID +APIENTRY +RosUserDestroyCursorIcon(ICONINFO* IconInfoUnsafe, + HCURSOR Handle) +{ + PLIST_ENTRY Current; + PCURSORICONENTRY pCursorIcon; + + /* Acquire lock */ + KeEnterCriticalRegion(); + ExAcquireResourceExclusiveLite(&CursorIconsLock, TRUE); + + /* Traverse the list to find our mapping */ + Current = CursorIcons.Flink; + while(Current != &CursorIcons) + { + pCursorIcon = CONTAINING_RECORD(Current, CURSORICONENTRY, Entry); + + /* Check if it's our entry */ + if (pCursorIcon->hUser == Handle) + { + /* Remove it from the list */ + RemoveEntryList(Current); + + /* Get handles back to the user for proper disposal */ + IconInfoUnsafe->hbmColor = pCursorIcon->hbmColor; + IconInfoUnsafe->hbmMask = pCursorIcon->hbmMask; + + /* Free memory */ + ExFreePool(pCursorIcon); + break; + } + + /* Advance to the next pair */ + Current = Current->Flink; + } + + /* Release lock */ + ExReleaseResourceLite(&CursorIconsLock); + KeLeaveCriticalRegion(); +} + +VOID NTAPI +USER_InitCursorIcons() +{ + NTSTATUS Status; + + /* Initialize cursor icons list and a spinlock */ + InitializeListHead(&CursorIcons); + Status = ExInitializeResourceLite(&CursorIconsLock); + if (!NT_SUCCESS(Status)) + DPRINT1("Initializing cursor icons lock failed with Status 0x%08X\n", Status); +} + Modified: branches/arwinss/reactos/subsystems/win32/win32k/main/init.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/main/init.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/main/init.c [iso-8859-1] Sun May 23 12:22:09 2010 @@ -357,6 +357,9 @@ /* Initialize handle-mapping */ GDI_InitHandleMapping(); + /* Initialize cursor icons */ + USER_InitCursorIcons(); + /* Create stock objects */ CreateStockBitmap(); PALETTE_Init(); Modified: branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/swm/winman.c [iso-8859-1] Sun May 23 12:22:09 2010 @@ -800,6 +800,11 @@ return 0; } +VOID +NTAPI +SwmDefineCursor(HWND hWnd, HCURSOR hCursor) +{ +} VOID NTAPI Modified: branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db URL:
http://svn.reactos.org/svn/reactos/branches/arwinss/reactos/subsystems/win3…
============================================================================== --- branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] (original) +++ branches/arwinss/reactos/subsystems/win32/win32k/w32ksvc.db [iso-8859-1] Sun May 23 12:22:09 2010 @@ -64,6 +64,8 @@ RosGdiSwapBuffers 1 RosGdiUnrealizePalette 1 RosUserConnectCsrss 0 +RosUserCreateCursorIcon 2 +RosUserDestroyCursorIcon 2 RosUserGetCursorPos 1 RosUserSetCursorPos 2 RosUserClipCursor 1 @@ -86,6 +88,7 @@ RosUserGetAsyncKeyState 1 SwmAddWindow 2 SwmAddDesktopWindow 3 +SwmDefineCursor 2 SwmRemoveWindow 1 SwmSetForeground 1 SwmPosChanging 2
14 years, 8 months
1
0
0
0
[jmorlan] 47319: [WIN32CSR] Implement FILE_SHARE_* flags for console handles. Fixes some more winetests.
by jmorlan@svn.reactos.org
Author: jmorlan Date: Sun May 23 11:10:02 2010 New Revision: 47319 URL:
http://svn.reactos.org/svn/reactos?rev=47319&view=rev
Log: [WIN32CSR] Implement FILE_SHARE_* flags for console handles. Fixes some more winetests. Modified: trunk/reactos/dll/win32/kernel32/misc/console.c trunk/reactos/include/reactos/subsys/csrss/csrss.h trunk/reactos/subsystems/win32/csrss/win32csr/conio.c trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c trunk/reactos/subsystems/win32/csrss/win32csr/handle.c trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.h Modified: trunk/reactos/dll/win32/kernel32/misc/console.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/co…
============================================================================== --- trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] Sun May 23 11:10:02 2010 @@ -1022,6 +1022,7 @@ /* Structures for GET_INPUT_HANDLE and GET_OUTPUT_HANDLE requests are identical */ Request.Data.GetInputHandleRequest.Access = dwDesiredAccess; Request.Data.GetInputHandleRequest.Inheritable = bInheritHandle; + Request.Data.GetInputHandleRequest.ShareMode = dwShareMode; Status = CsrClientCallServer(&Request, NULL, @@ -1033,7 +1034,7 @@ return INVALID_HANDLE_VALUE; } - return Request.Data.GetInputHandleRequest.InputHandle; + return Request.Data.GetInputHandleRequest.Handle; } Modified: trunk/reactos/include/reactos/subsys/csrss/csrss.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/csr…
============================================================================== --- trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] (original) +++ trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] Sun May 23 11:10:02 2010 @@ -320,15 +320,10 @@ { DWORD Access; BOOL Inheritable; - HANDLE InputHandle; -} CSRSS_GET_INPUT_HANDLE, *PCSRSS_GET_INPUT_HANDLE; - -typedef struct -{ - DWORD Access; - BOOL Inheritable; - HANDLE OutputHandle; -} CSRSS_GET_OUTPUT_HANDLE, *PCSRSS_GET_OUTPUT_HANDLE; + HANDLE Handle; + DWORD ShareMode; +} CSRSS_GET_INPUT_HANDLE, *PCSRSS_GET_INPUT_HANDLE, + CSRSS_GET_OUTPUT_HANDLE, *PCSRSS_GET_OUTPUT_HANDLE; typedef struct { Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] Sun May 23 11:10:02 2010 @@ -317,7 +317,8 @@ &Request->Data.AllocConsoleRequest.InputHandle, &Console->Header, GENERIC_READ | GENERIC_WRITE, - TRUE); + TRUE, + FILE_SHARE_READ | FILE_SHARE_WRITE); if (! NT_SUCCESS(Status)) { DPRINT1("Failed to insert object\n"); @@ -331,7 +332,8 @@ &Request->Data.AllocConsoleRequest.OutputHandle, &Console->ActiveBuffer->Header, GENERIC_READ | GENERIC_WRITE, - TRUE); + TRUE, + FILE_SHARE_READ | FILE_SHARE_WRITE); if (!NT_SUCCESS(Status)) { DPRINT1("Failed to insert object\n"); @@ -1975,7 +1977,8 @@ &Request->Data.CreateScreenBufferRequest.OutputHandle, &Buff->Header, Request->Data.CreateScreenBufferRequest.Access, - Request->Data.CreateScreenBufferRequest.Inheritable); + Request->Data.CreateScreenBufferRequest.Inheritable, + Request->Data.CreateScreenBufferRequest.ShareMode); } } else Modified: trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] Sun May 23 11:10:02 2010 @@ -24,8 +24,8 @@ static CSRSS_API_DEFINITION Win32CsrApiDefinitions[] = { - CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetInputHandle), - CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetOutputHandle), + 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), Modified: trunk/reactos/subsystems/win32/csrss/win32csr/handle.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] Sun May 23 11:10:02 2010 @@ -23,17 +23,26 @@ return ((ULONG_PTR)Handle & 0x10000003) == 0x3; } +static INT +AdjustHandleCounts(PCSRSS_HANDLE Entry, INT Change) +{ + Object_t *Object = Entry->Object; + if (Entry->Access & GENERIC_READ) Object->AccessRead += Change; + if (Entry->Access & GENERIC_WRITE) Object->AccessWrite += Change; + if (!(Entry->ShareMode & FILE_SHARE_READ)) Object->ExclusiveRead += Change; + if (!(Entry->ShareMode & FILE_SHARE_WRITE)) Object->ExclusiveWrite += Change; + Object->HandleCount += Change; + return Object->HandleCount; +} + static VOID Win32CsrCreateHandleEntry( - PCSRSS_HANDLE Entry, - Object_t *Object, - DWORD Access, - BOOL Inheritable) -{ - Entry->Object = Object; - Entry->Access = Access; - Entry->Inheritable = Inheritable; - _InterlockedIncrement(&Object->HandleCount); + PCSRSS_HANDLE Entry) +{ + Object_t *Object = Entry->Object; + EnterCriticalSection(&Object->Console->Lock); + AdjustHandleCounts(Entry, +1); + LeaveCriticalSection(&Object->Console->Lock); } static VOID @@ -43,21 +52,21 @@ Object_t *Object = Entry->Object; if (Object != NULL) { - Entry->Object = NULL; + PCSRSS_CONSOLE Console = Object->Console; + EnterCriticalSection(&Console->Lock); /* If the last handle to a screen buffer is closed, delete it */ - if (_InterlockedDecrement(&Object->HandleCount) == 0 + if (AdjustHandleCounts(Entry, -1) == 0 && Object->Type == CONIO_SCREEN_BUFFER_MAGIC) { - PCSRSS_CONSOLE Console = Object->Console; PCSRSS_SCREEN_BUFFER Buffer = (PCSRSS_SCREEN_BUFFER)Object; - EnterCriticalSection(&Console->Lock); /* ...unless it's the only buffer left. Windows allows deletion * even of the last buffer, but having to deal with a lack of * any active buffer might be error-prone. */ if (Buffer->ListEntry.Flink != Buffer->ListEntry.Blink) ConioDeleteScreenBuffer(Buffer); - LeaveCriticalSection(&Console->Lock); - } + } + LeaveCriticalSection(&Console->Lock); + Entry->Object = NULL; } } @@ -163,7 +172,8 @@ PHANDLE Handle, Object_t *Object, DWORD Access, - BOOL Inheritable) + BOOL Inheritable, + DWORD ShareMode) { ULONG i; PCSRSS_HANDLE Block; @@ -194,7 +204,11 @@ ProcessData->HandleTable = Block; ProcessData->HandleTableSize += 64; } - Win32CsrCreateHandleEntry(&ProcessData->HandleTable[i], Object, Access, Inheritable); + ProcessData->HandleTable[i].Object = Object; + ProcessData->HandleTable[i].Access = Access; + ProcessData->HandleTable[i].Inheritable = Inheritable; + ProcessData->HandleTable[i].ShareMode = ShareMode; + Win32CsrCreateHandleEntry(&ProcessData->HandleTable[i]); *Handle = UlongToHandle((i << 2) | 0x3); RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return(STATUS_SUCCESS); @@ -232,62 +246,60 @@ if (SourceProcessData->HandleTable[i].Object != NULL && SourceProcessData->HandleTable[i].Inheritable) { - Win32CsrCreateHandleEntry(&TargetProcessData->HandleTable[i], - SourceProcessData->HandleTable[i].Object, - SourceProcessData->HandleTable[i].Access, - SourceProcessData->HandleTable[i].Inheritable); + TargetProcessData->HandleTable[i] = SourceProcessData->HandleTable[i]; + Win32CsrCreateHandleEntry(&TargetProcessData->HandleTable[i]); } } RtlLeaveCriticalSection(&SourceProcessData->HandleTableLock); return(STATUS_SUCCESS); } -CSR_API(CsrGetInputHandle) -{ - Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); - Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); +CSR_API(CsrGetHandle) +{ + NTSTATUS Status = STATUS_SUCCESS; + + Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); + Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); + + Request->Data.GetInputHandleRequest.Handle = INVALID_HANDLE_VALUE; RtlEnterCriticalSection(&ProcessData->HandleTableLock); if (ProcessData->Console) { - Request->Status = Win32CsrInsertObject(ProcessData, - &Request->Data.GetInputHandleRequest.InputHandle, - &ProcessData->Console->Header, - Request->Data.GetInputHandleRequest.Access, - Request->Data.GetInputHandleRequest.Inheritable); - } - else - { - Request->Data.GetInputHandleRequest.InputHandle = INVALID_HANDLE_VALUE; - Request->Status = STATUS_SUCCESS; - } - RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - - return Request->Status; -} - -CSR_API(CsrGetOutputHandle) -{ - Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); - Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); - - RtlEnterCriticalSection(&ProcessData->HandleTableLock); - if (ProcessData->Console) - { - Request->Status = Win32CsrInsertObject(ProcessData, - &Request->Data.GetOutputHandleRequest.OutputHandle, - &ProcessData->Console->ActiveBuffer->Header, - Request->Data.GetOutputHandleRequest.Access, - Request->Data.GetOutputHandleRequest.Inheritable); - } - else - { - Request->Data.GetOutputHandleRequest.OutputHandle = INVALID_HANDLE_VALUE; - Request->Status = STATUS_SUCCESS; - } - RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - - return Request->Status; + DWORD DesiredAccess = Request->Data.GetInputHandleRequest.Access; + DWORD ShareMode = Request->Data.GetInputHandleRequest.ShareMode; + + PCSRSS_CONSOLE Console = ProcessData->Console; + Object_t *Object; + + EnterCriticalSection(&Console->Lock); + if (Request->Type == GET_OUTPUT_HANDLE) + 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, + &Request->Data.GetInputHandleRequest.Handle, + Object, + DesiredAccess, + Request->Data.GetInputHandleRequest.Inheritable, + ShareMode); + } + LeaveCriticalSection(&Console->Lock); + } + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); + + return Status; } CSR_API(CsrCloseHandle) @@ -359,7 +371,8 @@ &Request->Data.DuplicateHandleRequest.Handle, Entry->Object, DesiredAccess, - Request->Data.DuplicateHandleRequest.Inheritable); + Request->Data.DuplicateHandleRequest.Inheritable, + Entry->ShareMode); if (NT_SUCCESS(Request->Status) && Request->Data.DuplicateHandleRequest.Options & DUPLICATE_CLOSE_SOURCE) { Modified: trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.h [iso-8859-1] Sun May 23 11:10:02 2010 @@ -18,6 +18,8 @@ { LONG Type; struct tagCSRSS_CONSOLE *Console; + LONG AccessRead, AccessWrite; + LONG ExclusiveRead, ExclusiveWrite; LONG HandleCount; } Object_t; @@ -26,6 +28,7 @@ Object_t *Object; DWORD Access; BOOL Inheritable; + DWORD ShareMode; } CSRSS_HANDLE, *PCSRSS_HANDLE; typedef VOID (WINAPI *CSR_CLEANUP_OBJECT_PROC)(Object_t *Object); @@ -41,7 +44,8 @@ PHANDLE Handle, Object_t *Object, DWORD Access, - BOOL Inheritable); + BOOL Inheritable, + DWORD ShareMode); NTSTATUS FASTCALL Win32CsrLockObject(PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, Object_t **Object, @@ -53,8 +57,7 @@ NTSTATUS WINAPI Win32CsrReleaseConsole(PCSRSS_PROCESS_DATA ProcessData); NTSTATUS WINAPI Win32CsrDuplicateHandleTable(PCSRSS_PROCESS_DATA SourceProcessData, PCSRSS_PROCESS_DATA TargetProcessData); -CSR_API(CsrGetInputHandle); -CSR_API(CsrGetOutputHandle); +CSR_API(CsrGetHandle); CSR_API(CsrCloseHandle); CSR_API(CsrVerifyHandle); CSR_API(CsrDuplicateHandle);
14 years, 8 months
1
0
0
0
[jmorlan] 47318: [WIN32CSR] Delete even the active screen buffer when all handles are closed. Fixes a winetest.
by jmorlan@svn.reactos.org
Author: jmorlan Date: Sun May 23 08:04:15 2010 New Revision: 47318 URL:
http://svn.reactos.org/svn/reactos?rev=47318&view=rev
Log: [WIN32CSR] Delete even the active screen buffer when all handles are closed. Fixes a winetest. Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c trunk/reactos/subsystems/win32/csrss/win32csr/conio.h trunk/reactos/subsystems/win32/csrss/win32csr/handle.c Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] Sun May 23 08:04:15 2010 @@ -137,6 +137,7 @@ Buffer->CurrentX = 0; Buffer->CurrentY = 0; + InsertHeadList(&Console->BufferList, &Buffer->ListEntry); return STATUS_SUCCESS; } @@ -162,6 +163,7 @@ Console->Header.Console = Console; Console->Mode = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT; Console->EarlyReturn = FALSE; + InitializeListHead(&Console->BufferList); Console->ActiveBuffer = NULL; InitializeListHead(&Console->InputEvents); Console->CodePage = GetOEMCP(); @@ -893,11 +895,24 @@ } VOID WINAPI -ConioDeleteScreenBuffer(Object_t *Object) -{ - PCSRSS_SCREEN_BUFFER Buffer = (PCSRSS_SCREEN_BUFFER) Object; - HeapFree(Win32CsrApiHeap, 0, Buffer->Buffer); - HeapFree(Win32CsrApiHeap, 0, Buffer); +ConioDeleteScreenBuffer(PCSRSS_SCREEN_BUFFER Buffer) +{ + PCSRSS_CONSOLE Console = Buffer->Header.Console; + + RemoveEntryList(&Buffer->ListEntry); + if (Buffer == Console->ActiveBuffer) + { + /* Deleted active buffer; switch to most recently created */ + Console->ActiveBuffer = NULL; + if (!IsListEmpty(&Console->BufferList)) + { + Console->ActiveBuffer = CONTAINING_RECORD(Console->BufferList.Flink, CSRSS_SCREEN_BUFFER, ListEntry); + ConioDrawConsole(Console); + } + } + + HeapFree(Win32CsrApiHeap, 0, Buffer->Buffer); + HeapFree(Win32CsrApiHeap, 0, Buffer); } VOID FASTCALL @@ -929,9 +944,11 @@ } ConioCleanupConsole(Console); - ConioDeleteScreenBuffer((Object_t *) Console->ActiveBuffer); - - Console->ActiveBuffer = NULL; + ConioDeleteScreenBuffer(Console->ActiveBuffer); + if (!IsListEmpty(&Console->BufferList)) + { + DPRINT1("BUG: screen buffer list not empty\n"); + } CloseHandle(Console->ActiveEvent); DeleteCriticalSection(&Console->Lock); @@ -1998,7 +2015,7 @@ /* If old buffer has no handles, it's now unreferenced */ if (Console->ActiveBuffer->Header.HandleCount == 0) { - ConioDeleteScreenBuffer((Object_t *) Console->ActiveBuffer); + ConioDeleteScreenBuffer(Console->ActiveBuffer); } /* tie console to new buffer */ Console->ActiveBuffer = Buff; Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/conio.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.h [iso-8859-1] Sun May 23 08:04:15 2010 @@ -46,6 +46,7 @@ USHORT VirtualY; /* top row of buffer being displayed, reported to callers */ CONSOLE_CURSOR_INFO CursorInfo; USHORT Mode; + LIST_ENTRY ListEntry; /* entry in console's list of buffers */ } CSRSS_SCREEN_BUFFER, *PCSRSS_SCREEN_BUFFER; typedef struct tagCSRSS_CONSOLE *PCSRSS_CONSOLE; @@ -76,6 +77,7 @@ LIST_ENTRY InputEvents; /* List head for input event queue */ WORD WaitingChars; WORD WaitingLines; /* number of chars and lines in input queue */ + LIST_ENTRY BufferList; /* List of all screen buffers for this console */ PCSRSS_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */ WORD Mode; /* Console mode flags */ WORD EchoCount; /* count of chars to echo, in line buffered mode */ @@ -103,7 +105,7 @@ NTSTATUS FASTCALL ConioConsoleFromProcessData(PCSRSS_PROCESS_DATA ProcessData, PCSRSS_CONSOLE *Console); VOID WINAPI ConioDeleteConsole(Object_t *Object); -VOID WINAPI ConioDeleteScreenBuffer(Object_t *Buffer); +VOID WINAPI ConioDeleteScreenBuffer(PCSRSS_SCREEN_BUFFER Buffer); VOID WINAPI CsrInitConsoleSupport(VOID); void WINAPI ConioProcessKey(MSG *msg, PCSRSS_CONSOLE Console, BOOL TextMode); PBYTE FASTCALL ConioCoordToPointer(PCSRSS_SCREEN_BUFFER Buf, ULONG X, ULONG Y); Modified: trunk/reactos/subsystems/win32/csrss/win32csr/handle.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] Sun May 23 08:04:15 2010 @@ -49,11 +49,13 @@ && Object->Type == CONIO_SCREEN_BUFFER_MAGIC) { PCSRSS_CONSOLE Console = Object->Console; + PCSRSS_SCREEN_BUFFER Buffer = (PCSRSS_SCREEN_BUFFER)Object; EnterCriticalSection(&Console->Lock); - /* TODO: Should delete even the active buffer, but we're not yet ready - * to deal with the case where this results in no buffers left. */ - if (Object != &Console->ActiveBuffer->Header) - ConioDeleteScreenBuffer(Object); + /* ...unless it's the only buffer left. Windows allows deletion + * even of the last buffer, but having to deal with a lack of + * any active buffer might be error-prone. */ + if (Buffer->ListEntry.Flink != Buffer->ListEntry.Blink) + ConioDeleteScreenBuffer(Buffer); LeaveCriticalSection(&Console->Lock); } }
14 years, 8 months
1
0
0
0
[jmorlan] 47317: [WIN32CSR] - Simplify locking: having a lock for each screen buffer is overkill since most programs only use one screen buffer at a time. (besides, almost all APIs were taking the console lock anyway) Reduce to just having one lock for a console. - Instead of keeping track of how many references a screen buffer has, keep track of handles only. When all handles to a screen buffer are closed, it should be deleted even if it's the active buffer (not yet implemented).
by jmorlan@svn.reactos.org
Author: jmorlan Date: Sun May 23 07:33:21 2010 New Revision: 47317 URL:
http://svn.reactos.org/svn/reactos?rev=47317&view=rev
Log: [WIN32CSR] - Simplify locking: having a lock for each screen buffer is overkill since most programs only use one screen buffer at a time. (besides, almost all APIs were taking the console lock anyway) Reduce to just having one lock for a console. - Instead of keeping track of how many references a screen buffer has, keep track of handles only. When all handles to a screen buffer are closed, it should be deleted even if it's the active buffer (not yet implemented). Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c trunk/reactos/subsystems/win32/csrss/win32csr/conio.h trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c trunk/reactos/subsystems/win32/csrss/win32csr/handle.c trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.h Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] Sun May 23 07:33:21 2010 @@ -53,9 +53,9 @@ return STATUS_INVALID_HANDLE; } - InterlockedIncrement(&ProcessConsole->Header.ReferenceCount); + InterlockedIncrement(&ProcessConsole->ReferenceCount); RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - EnterCriticalSection(&(ProcessConsole->Header.Lock)); + EnterCriticalSection(&(ProcessConsole->Lock)); *Console = ProcessConsole; return STATUS_SUCCESS; @@ -117,7 +117,8 @@ DPRINT("CsrInitConsoleScreenBuffer Size X %d Size Y %d\n", Buffer->MaxX, Buffer->MaxY); Buffer->Header.Type = CONIO_SCREEN_BUFFER_MAGIC; - Buffer->Header.ReferenceCount = 0; + Buffer->Header.Console = Console; + Buffer->Header.HandleCount = 0; Buffer->ShowX = 0; Buffer->ShowY = 0; Buffer->VirtualY = 0; @@ -126,7 +127,6 @@ { return STATUS_INSUFFICIENT_RESOURCES; } - InitializeCriticalSection(&Buffer->Header.Lock); ConioInitScreenBuffer(Console, Buffer); /* initialize buffer to be empty with default attributes */ for (Buffer->CurrentY = 0 ; Buffer->CurrentY < Buffer->MaxY; Buffer->CurrentY++) @@ -154,11 +154,12 @@ //FIXME RtlCreateUnicodeString(&Console->Title, L"Command Prompt"); - Console->Header.ReferenceCount = 0; + Console->ReferenceCount = 0; Console->WaitingChars = 0; Console->WaitingLines = 0; Console->EchoCount = 0; Console->Header.Type = CONIO_CONSOLE_MAGIC; + Console->Header.Console = Console; Console->Mode = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT; Console->EarlyReturn = FALSE; Console->ActiveBuffer = NULL; @@ -177,7 +178,7 @@ return STATUS_UNSUCCESSFUL; } Console->PrivateData = NULL; - InitializeCriticalSection(&Console->Header.Lock); + InitializeCriticalSection(&Console->Lock); GuiMode = DtbgIsDesktopVisible(); @@ -186,7 +187,7 @@ if (NULL == NewBuffer) { RtlFreeUnicodeString(&Console->Title); - DeleteCriticalSection(&Console->Header.Lock); + DeleteCriticalSection(&Console->Lock); CloseHandle(Console->ActiveEvent); return STATUS_INSUFFICIENT_RESOURCES; } @@ -212,7 +213,7 @@ { HeapFree(Win32CsrApiHeap,0, NewBuffer); RtlFreeUnicodeString(&Console->Title); - DeleteCriticalSection(&Console->Header.Lock); + DeleteCriticalSection(&Console->Lock); CloseHandle(Console->ActiveEvent); DPRINT1("GuiInitConsole: failed\n"); return Status; @@ -224,15 +225,12 @@ { ConioCleanupConsole(Console); RtlFreeUnicodeString(&Console->Title); - DeleteCriticalSection(&Console->Header.Lock); + DeleteCriticalSection(&Console->Lock); CloseHandle(Console->ActiveEvent); HeapFree(Win32CsrApiHeap, 0, NewBuffer); DPRINT1("CsrInitConsoleScreenBuffer: failed\n"); return Status; } - - /* add a reference count because the buffer is tied to the console */ - InterlockedIncrement(&Console->ActiveBuffer->Header.ReferenceCount); /* copy buffer contents to screen */ ConioDrawConsole(Console); @@ -308,7 +306,7 @@ Request->Data.AllocConsoleRequest.Console = Console; /* Add a reference count because the process is tied to the console */ - Console->Header.ReferenceCount++; + _InterlockedIncrement(&Console->ReferenceCount); if (NewConsole || !ProcessData->bInheritHandles) { @@ -836,15 +834,16 @@ Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); return STATUS_INVALID_PARAMETER; } - Status = ConioConsoleFromProcessData(ProcessData, &Console); - - Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); - Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); - - if (! NT_SUCCESS(Status)) - { - return Status; - } + + Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); + Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); + + Status = ConioLockScreenBuffer(ProcessData, Request->Data.WriteConsoleRequest.ConsoleHandle, &Buff, GENERIC_WRITE); + if (! NT_SUCCESS(Status)) + { + return Status; + } + Console = Buff->Header.Console; if(Request->Data.WriteConsoleRequest.Unicode) { @@ -872,7 +871,6 @@ if (Buffer) { - Status = ConioLockScreenBuffer(ProcessData, Request->Data.WriteConsoleRequest.ConsoleHandle, &Buff, GENERIC_WRITE); if (NT_SUCCESS(Status)) { Status = ConioWriteConsole(Console, Buff, Buffer, @@ -881,14 +879,13 @@ { Written = Request->Data.WriteConsoleRequest.NrCharactersToWrite; } - ConioUnlockScreenBuffer(Buff); } if (Request->Data.WriteConsoleRequest.Unicode) { RtlFreeHeap(GetProcessHeap(), 0, Buffer); } } - ConioUnlockConsole(Console); + ConioUnlockScreenBuffer(Buff); Request->Data.WriteConsoleRequest.NrCharactersWritten = Written; @@ -899,7 +896,6 @@ ConioDeleteScreenBuffer(Object_t *Object) { PCSRSS_SCREEN_BUFFER Buffer = (PCSRSS_SCREEN_BUFFER) Object; - DeleteCriticalSection(&Buffer->Header.Lock); HeapFree(Win32CsrApiHeap, 0, Buffer->Buffer); HeapFree(Win32CsrApiHeap, 0, Buffer); } @@ -933,15 +929,12 @@ } ConioCleanupConsole(Console); - if (0 == InterlockedDecrement(&Console->ActiveBuffer->Header.ReferenceCount)) - { - ConioDeleteScreenBuffer((Object_t *) Console->ActiveBuffer); - } + ConioDeleteScreenBuffer((Object_t *) Console->ActiveBuffer); Console->ActiveBuffer = NULL; CloseHandle(Console->ActiveEvent); - DeleteCriticalSection(&Console->Header.Lock); + DeleteCriticalSection(&Console->Lock); RtlFreeUnicodeString(&Console->Title); IntDeleteAllAliases(Console->Aliases); HeapFree(Win32CsrApiHeap, 0, Console); @@ -1280,17 +1273,12 @@ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (! NT_SUCCESS(Status)) - { - return Status; - } Status = ConioLockScreenBuffer(ProcessData, Request->Data.ScreenBufferInfoRequest.ConsoleHandle, &Buff, GENERIC_READ); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; pInfo = &Request->Data.ScreenBufferInfoRequest.Info; pInfo->dwSize.X = Buff->MaxX; pInfo->dwSize.Y = Buff->MaxY; @@ -1304,7 +1292,6 @@ pInfo->dwMaximumWindowSize.X = Buff->MaxX; pInfo->dwMaximumWindowSize.Y = Buff->MaxY; ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_SUCCESS; } @@ -1319,21 +1306,15 @@ DPRINT("CsrSetCursor\n"); - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); Status = ConioLockScreenBuffer(ProcessData, Request->Data.SetCursorRequest.ConsoleHandle, &Buff, GENERIC_WRITE); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; NewCursorX = Request->Data.SetCursorRequest.Position.X; NewCursorY = Request->Data.SetCursorRequest.Position.Y; @@ -1341,7 +1322,6 @@ NewCursorY < 0 || NewCursorY >= Buff->MaxY) { ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_INVALID_PARAMETER; } OldCursorX = Buff->CurrentX; @@ -1353,13 +1333,11 @@ if (! ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY)) { ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_UNSUCCESSFUL; } } ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_SUCCESS; } @@ -1415,11 +1393,15 @@ return STATUS_INVALID_PARAMETER; } - Status = ConioConsoleFromProcessData(ProcessData, &Console); + Status = ConioLockScreenBuffer(ProcessData, + Request->Data.WriteConsoleOutputCharRequest.ConsoleHandle, + &Buff, + GENERIC_WRITE); Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); if (NT_SUCCESS(Status)) { + Console = Buff->Header.Console; if(Request->Data.WriteConsoleOutputCharRequest.Unicode) { Length = WideCharToMultiByte(Console->OutputCodePage, 0, @@ -1446,10 +1428,6 @@ if (String) { - Status = ConioLockScreenBuffer(ProcessData, - Request->Data.WriteConsoleOutputCharRequest.ConsoleHandle, - &Buff, - GENERIC_WRITE); if (NT_SUCCESS(Status)) { X = Request->Data.WriteConsoleOutputCharRequest.Coord.X; @@ -1481,14 +1459,13 @@ Request->Data.WriteConsoleOutputCharRequest.EndCoord.X = X; Request->Data.WriteConsoleOutputCharRequest.EndCoord.Y = (Y + Buff->MaxY - Buff->VirtualY) % Buff->MaxY; - ConioUnlockScreenBuffer(Buff); } if (Request->Data.WriteConsoleRequest.Unicode) { RtlFreeHeap(GetProcessHeap(), 0, tmpString); } } - ConioUnlockConsole(Console); + ConioUnlockScreenBuffer(Buff); } Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten = Written; return Status; @@ -1509,18 +1486,12 @@ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Status = ConioLockScreenBuffer(ProcessData, Request->Data.FillOutputRequest.ConsoleHandle, &Buff, GENERIC_WRITE); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; X = Request->Data.FillOutputRequest.Position.X; Y = (Request->Data.FillOutputRequest.Position.Y + Buff->VirtualY) % Buff->MaxY; @@ -1554,7 +1525,6 @@ } ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); Length = Request->Data.FillOutputRequest.Length; Request->Data.FillOutputRequest.NrCharactersWritten = Length; return STATUS_SUCCESS; @@ -1661,13 +1631,8 @@ return STATUS_INVALID_PARAMETER; } - Status = ConioConsoleFromProcessData(ProcessData, &Console); - Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); - Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); - if (! NT_SUCCESS(Status)) - { - return Status; - } + Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); + Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); Status = ConioLockScreenBuffer(ProcessData, Request->Data.WriteConsoleOutputAttribRequest.ConsoleHandle, @@ -1675,9 +1640,9 @@ GENERIC_WRITE); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; X = Request->Data.WriteConsoleOutputAttribRequest.Coord.X; Y = (Request->Data.WriteConsoleOutputAttribRequest.Coord.Y + Buff->VirtualY) % Buff->MaxY; @@ -1706,8 +1671,6 @@ ConioDrawRegion(Console, &UpdateRect); } - ConioUnlockConsole(Console); - Request->Data.WriteConsoleOutputAttribRequest.EndCoord.X = X; Request->Data.WriteConsoleOutputAttribRequest.EndCoord.Y = (Y + Buff->MaxY - Buff->VirtualY) % Buff->MaxY; @@ -1728,20 +1691,14 @@ DPRINT("CsrFillOutputAttrib\n"); - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); Status = ConioLockScreenBuffer(ProcessData, Request->Data.FillOutputAttribRequest.ConsoleHandle, &Buff, GENERIC_WRITE); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; X = Request->Data.FillOutputAttribRequest.Coord.X; Y = (Request->Data.FillOutputAttribRequest.Coord.Y + Buff->VirtualY) % Buff->MaxY; @@ -1771,7 +1728,6 @@ } ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_SUCCESS; } @@ -1812,18 +1768,12 @@ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Status = ConioLockScreenBuffer(ProcessData, Request->Data.SetCursorInfoRequest.ConsoleHandle, &Buff, GENERIC_WRITE); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; Size = Request->Data.SetCursorInfoRequest.Info.dwSize; Visible = Request->Data.SetCursorInfoRequest.Info.bVisible; @@ -1845,13 +1795,11 @@ if (! ConioSetCursorInfo(Console, Buff)) { ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_UNSUCCESSFUL; } } ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_SUCCESS; } @@ -1864,18 +1812,12 @@ DPRINT("CsrSetTextAttrib\n"); - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Status = ConioLockScreenBuffer(ProcessData, Request->Data.SetCursorRequest.ConsoleHandle, &Buff, GENERIC_WRITE); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; Buff->DefaultAttrib = Request->Data.SetAttribRequest.Attrib; if (Buff == Console->ActiveBuffer) @@ -1883,13 +1825,11 @@ if (! ConioUpdateScreenInfo(Console, Buff)) { ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_UNSUCCESSFUL; } } ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_SUCCESS; } @@ -1904,9 +1844,9 @@ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); - Status = Win32CsrGetObject(ProcessData, - Request->Data.SetConsoleModeRequest.ConsoleHandle, - (Object_t **) &Console, GENERIC_WRITE); + Status = Win32CsrLockObject(ProcessData, + Request->Data.SetConsoleModeRequest.ConsoleHandle, + (Object_t **) &Console, GENERIC_WRITE, 0); if (! NT_SUCCESS(Status)) { return Status; @@ -1926,7 +1866,7 @@ Status = STATUS_INVALID_HANDLE; } - Win32CsrReleaseObjectByPointer((Object_t *)Console); + Win32CsrUnlockObject((Object_t *)Console); return Status; } @@ -1941,8 +1881,8 @@ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); - Status = Win32CsrGetObject(ProcessData, Request->Data.GetConsoleModeRequest.ConsoleHandle, - (Object_t **) &Console, GENERIC_READ); + Status = Win32CsrLockObject(ProcessData, Request->Data.GetConsoleModeRequest.ConsoleHandle, + (Object_t **) &Console, GENERIC_READ, 0); if (! NT_SUCCESS(Status)) { return Status; @@ -1962,7 +1902,7 @@ Status = STATUS_INVALID_HANDLE; } - Win32CsrReleaseObjectByPointer((Object_t *)Console); + Win32CsrUnlockObject((Object_t *)Console); return Status; } @@ -2039,43 +1979,33 @@ DPRINT("CsrSetScreenBuffer\n"); - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); Status = ConioLockScreenBuffer(ProcessData, Request->Data.SetScreenBufferRequest.OutputHandle, &Buff, GENERIC_WRITE); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; if (Buff == Console->ActiveBuffer) { ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_SUCCESS; } - /* drop reference to old buffer, maybe delete */ - if (! InterlockedDecrement(&Console->ActiveBuffer->Header.ReferenceCount)) + /* If old buffer has no handles, it's now unreferenced */ + if (Console->ActiveBuffer->Header.HandleCount == 0) { ConioDeleteScreenBuffer((Object_t *) Console->ActiveBuffer); } /* tie console to new buffer */ Console->ActiveBuffer = Buff; - /* inc ref count on new buffer */ - InterlockedIncrement(&Buff->Header.ReferenceCount); /* Redraw the console */ ConioDrawConsole(Console); ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_SUCCESS; } @@ -2181,12 +2111,6 @@ DPRINT("CsrWriteConsoleOutput\n"); - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); Status = ConioLockScreenBuffer(ProcessData, @@ -2195,9 +2119,9 @@ GENERIC_WRITE); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; BufferSize = Request->Data.WriteConsoleOutputRequest.BufferSize; PSize = BufferSize.X * BufferSize.Y * sizeof(CHAR_INFO); @@ -2208,7 +2132,6 @@ ((ULONG_PTR)ProcessData->CsrSectionViewBase + ProcessData->CsrSectionViewSize))) { ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_ACCESS_VIOLATION; } WriteRegion.left = Request->Data.WriteConsoleOutputRequest.WriteRegion.Left; @@ -2226,7 +2149,6 @@ if (! ConioGetIntersection(&WriteRegion, &ScreenBuffer, &WriteRegion)) { ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); /* It is okay to have a WriteRegion completely outside the screen buffer. No data is written then. */ @@ -2257,7 +2179,6 @@ ConioDrawRegion(Console, &WriteRegion); ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); Request->Data.WriteConsoleOutputRequest.WriteRegion.Right = WriteRegion.left + SizeX - 1; Request->Data.WriteConsoleOutputRequest.WriteRegion.Bottom = WriteRegion.top + SizeY - 1; @@ -2327,20 +2248,14 @@ DestinationOrigin = Request->Data.ScrollConsoleScreenBufferRequest.DestinationOrigin; Fill = Request->Data.ScrollConsoleScreenBufferRequest.Fill; - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); Status = ConioLockScreenBuffer(ProcessData, ConsoleHandle, &Buff, GENERIC_WRITE); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; ScrollRectangle.left = Request->Data.ScrollConsoleScreenBufferRequest.ScrollRectangle.Left; ScrollRectangle.top = Request->Data.ScrollConsoleScreenBufferRequest.ScrollRectangle.Top; @@ -2352,7 +2267,6 @@ if (! ConioGetIntersection(&SrcRegion, &ScreenBuffer, &ScrollRectangle)) { ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_SUCCESS; } @@ -2374,7 +2288,6 @@ ClipRectangle.bottom = Request->Data.ScrollConsoleScreenBufferRequest.ClipRectangle.Bottom; if (!ConioGetIntersection(&ClipRectangle, &ClipRectangle, &ScreenBuffer)) { - ConioUnlockConsole(Console); ConioUnlockScreenBuffer(Buff); return STATUS_SUCCESS; } @@ -2408,7 +2321,6 @@ } ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return STATUS_SUCCESS; } @@ -2432,18 +2344,12 @@ CharSize = (Request->Data.ReadConsoleOutputCharRequest.Unicode ? sizeof(WCHAR) : sizeof(CHAR)); - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Status = ConioLockScreenBuffer(ProcessData, Request->Data.ReadConsoleOutputCharRequest.ConsoleHandle, &Buff, GENERIC_READ); if (! NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); - return Status; - } + return Status; + } + Console = Buff->Header.Console; Xpos = Request->Data.ReadConsoleOutputCharRequest.ReadCoord.X; Ypos = (Request->Data.ReadConsoleOutputCharRequest.ReadCoord.Y + Buff->VirtualY) % Buff->MaxY; @@ -2479,7 +2385,6 @@ Request->Data.ReadConsoleOutputCharRequest.EndCoord.Y = (Ypos - Buff->VirtualY + Buff->MaxY) % Buff->MaxY; ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); Request->Data.ReadConsoleOutputCharRequest.CharsRead = (DWORD)((ULONG_PTR)ReadBuffer - (ULONG_PTR)Request->Data.ReadConsoleOutputCharRequest.String) / CharSize; if (Request->Data.ReadConsoleOutputCharRequest.CharsRead * CharSize + CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR) > sizeof(CSR_API_MESSAGE)) @@ -3131,22 +3036,15 @@ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); - Status = ConioConsoleFromProcessData(ProcessData, &Console); - if (!NT_SUCCESS(Status)) - { - return Status; - } - Status = ConioLockScreenBuffer(ProcessData, Request->Data.SetScreenBufferSize.OutputHandle, &Buff, GENERIC_WRITE); if (!NT_SUCCESS(Status)) { - ConioUnlockConsole(Console); return Status; } + Console = Buff->Header.Console; Status = ConioResizeBuffer(Console, Buff, Request->Data.SetScreenBufferSize.Size); ConioUnlockScreenBuffer(Buff); - ConioUnlockConsole(Console); return Status; } Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/conio.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.h [iso-8859-1] Sun May 23 07:33:21 2010 @@ -69,6 +69,8 @@ typedef struct tagCSRSS_CONSOLE { Object_t Header; /* Object header */ + LONG ReferenceCount; + CRITICAL_SECTION Lock; PCSRSS_CONSOLE Prev, Next; /* Next and Prev consoles in console wheel */ HANDLE ActiveEvent; LIST_ENTRY InputEvents; /* List head for input event queue */ Modified: trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/guiconsole.c [iso-8859-1] Sun May 23 07:33:21 2010 @@ -872,7 +872,7 @@ Buff = Console->ActiveBuffer; - EnterCriticalSection(&Buff->Header.Lock); + EnterCriticalSection(&Buff->Header.Console->Lock); TopLine = rc->top / GuiData->CharHeight + Buff->ShowY; BottomLine = (rc->bottom + (GuiData->CharHeight - 1)) / GuiData->CharHeight - 1 + Buff->ShowY; @@ -971,7 +971,7 @@ } } - LeaveCriticalSection(&Buff->Header.Lock); + LeaveCriticalSection(&Buff->Header.Console->Lock); SelectObject(hDC, OldFont); @@ -1327,7 +1327,7 @@ GuiConsoleGetDataPointers(hWnd, &Console, &GuiData); - EnterCriticalSection(&Console->Header.Lock); + EnterCriticalSection(&Console->Lock); current_entry = Console->ProcessList.Flink; while (current_entry != &Console->ProcessList) @@ -1341,7 +1341,7 @@ ConioConsoleCtrlEvent(CTRL_CLOSE_EVENT, current); } - LeaveCriticalSection(&Console->Header.Lock); + LeaveCriticalSection(&Console->Lock); } static VOID FASTCALL @@ -1809,7 +1809,7 @@ COORD BufSize; BOOL SizeChanged = FALSE; - EnterCriticalSection(&ActiveBuffer->Header.Lock); + EnterCriticalSection(&Console->Lock); /* apply text / background color */ GuiData->ScreenText = pConInfo->ScreenText; @@ -1844,7 +1844,7 @@ GuiData->WindowSizeLock = FALSE; } - LeaveCriticalSection(&ActiveBuffer->Header.Lock); + LeaveCriticalSection(&Console->Lock); InvalidateRect(pConInfo->hConsoleWindow, NULL, TRUE); } Modified: trunk/reactos/subsystems/win32/csrss/win32csr/handle.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] Sun May 23 07:33:21 2010 @@ -16,13 +16,6 @@ /* FUNCTIONS *****************************************************************/ -static unsigned ObjectDefinitionsCount = 2; -static CSRSS_OBJECT_DEFINITION ObjectDefinitions[] = -{ - { CONIO_CONSOLE_MAGIC, ConioDeleteConsole }, - { CONIO_SCREEN_BUFFER_MAGIC, ConioDeleteScreenBuffer }, -}; - static BOOL CsrIsConsoleHandle(HANDLE Handle) @@ -30,58 +23,40 @@ return ((ULONG_PTR)Handle & 0x10000003) == 0x3; } -NTSTATUS -FASTCALL -Win32CsrGetObject( - PCSRSS_PROCESS_DATA ProcessData, - HANDLE Handle, - Object_t **Object, - DWORD Access ) -{ - ULONG_PTR h = (ULONG_PTR)Handle >> 2; - - DPRINT("CsrGetObject, Object: %x, %x, %x\n", - Object, Handle, ProcessData ? ProcessData->HandleTableSize : 0); - - RtlEnterCriticalSection(&ProcessData->HandleTableLock); - if (!CsrIsConsoleHandle(Handle) || h >= ProcessData->HandleTableSize - || (*Object = ProcessData->HandleTable[h].Object) == NULL - || ~ProcessData->HandleTable[h].Access & Access) - { - DPRINT1("CsrGetObject returning invalid handle (%x)\n", Handle); - RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - return STATUS_INVALID_HANDLE; - } - _InterlockedIncrement(&(*Object)->ReferenceCount); - RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - // DbgPrint( "CsrGetObject returning\n" ); - return STATUS_SUCCESS; -} - - -NTSTATUS -FASTCALL -Win32CsrReleaseObjectByPointer( - Object_t *Object) -{ - unsigned DefIndex; - - /* dec ref count */ - if (_InterlockedDecrement(&Object->ReferenceCount) == 0) - { - for (DefIndex = 0; DefIndex < ObjectDefinitionsCount; DefIndex++) - { - if (Object->Type == ObjectDefinitions[DefIndex].Type) - { - (ObjectDefinitions[DefIndex].CsrCleanupObjectProc)(Object); - return STATUS_SUCCESS; - } - } - - DPRINT1("CSR: Error: releasing unknown object type 0x%x", Object->Type); - } - - return STATUS_SUCCESS; +static VOID +Win32CsrCreateHandleEntry( + PCSRSS_HANDLE Entry, + Object_t *Object, + DWORD Access, + BOOL Inheritable) +{ + Entry->Object = Object; + Entry->Access = Access; + Entry->Inheritable = Inheritable; + _InterlockedIncrement(&Object->HandleCount); +} + +static VOID +Win32CsrCloseHandleEntry( + PCSRSS_HANDLE Entry) +{ + Object_t *Object = Entry->Object; + if (Object != NULL) + { + Entry->Object = NULL; + /* If the last handle to a screen buffer is closed, delete it */ + if (_InterlockedDecrement(&Object->HandleCount) == 0 + && Object->Type == CONIO_SCREEN_BUFFER_MAGIC) + { + PCSRSS_CONSOLE Console = Object->Console; + EnterCriticalSection(&Console->Lock); + /* TODO: Should delete even the active buffer, but we're not yet ready + * to deal with the case where this results in no buffers left. */ + if (Object != &Console->ActiveBuffer->Header) + ConioDeleteScreenBuffer(Object); + LeaveCriticalSection(&Console->Lock); + } + } } NTSTATUS @@ -100,10 +75,9 @@ RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return STATUS_INVALID_HANDLE; } - ProcessData->HandleTable[h].Object = NULL; - RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - - return Win32CsrReleaseObjectByPointer(Object); + Win32CsrCloseHandleEntry(&ProcessData->HandleTable[h]); + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); + return STATUS_SUCCESS; } NTSTATUS @@ -114,22 +88,25 @@ DWORD Access, LONG Type) { - NTSTATUS Status; - - Status = Win32CsrGetObject(ProcessData, Handle, Object, Access); - if (! NT_SUCCESS(Status)) - { - return Status; - } - - if ((*Object)->Type != Type) - { - Win32CsrReleaseObjectByPointer(*Object); + ULONG_PTR h = (ULONG_PTR)Handle >> 2; + + DPRINT("CsrGetObject, Object: %x, %x, %x\n", + Object, Handle, ProcessData ? ProcessData->HandleTableSize : 0); + + RtlEnterCriticalSection(&ProcessData->HandleTableLock); + if (!CsrIsConsoleHandle(Handle) || h >= ProcessData->HandleTableSize + || (*Object = ProcessData->HandleTable[h].Object) == NULL + || ~ProcessData->HandleTable[h].Access & Access + || (Type != 0 && (*Object)->Type != Type)) + { + DPRINT1("CsrGetObject returning invalid handle (%x)\n", Handle); + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return STATUS_INVALID_HANDLE; } - - EnterCriticalSection(&((*Object)->Lock)); - + _InterlockedIncrement(&(*Object)->Console->ReferenceCount); + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); + + EnterCriticalSection(&((*Object)->Console->Lock)); return STATUS_SUCCESS; } @@ -137,8 +114,11 @@ FASTCALL Win32CsrUnlockObject(Object_t *Object) { - LeaveCriticalSection(&(Object->Lock)); - Win32CsrReleaseObjectByPointer(Object); + PCSRSS_CONSOLE Console = Object->Console; + LeaveCriticalSection(&Console->Lock); + /* dec ref count */ + if (_InterlockedDecrement(&Console->ReferenceCount) == 0) + ConioDeleteConsole(&Console->Header); } NTSTATUS @@ -153,27 +133,24 @@ RtlEnterCriticalSection(&ProcessData->HandleTableLock); for (i = 0; i < ProcessData->HandleTableSize; i++) - { - if (ProcessData->HandleTable[i].Object != NULL) - Win32CsrReleaseObjectByPointer(ProcessData->HandleTable[i].Object); - } + Win32CsrCloseHandleEntry(&ProcessData->HandleTable[i]); ProcessData->HandleTableSize = 0; RtlFreeHeap(Win32CsrApiHeap, 0, ProcessData->HandleTable); ProcessData->HandleTable = NULL; Console = ProcessData->Console; - ProcessData->Console = NULL; - RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - if (Console != NULL) { - EnterCriticalSection(&Console->Header.Lock); + ProcessData->Console = NULL; + EnterCriticalSection(&Console->Lock); RemoveEntryList(&ProcessData->ProcessEntry); - LeaveCriticalSection(&Console->Header.Lock); - Win32CsrReleaseObjectByPointer(&Console->Header); + LeaveCriticalSection(&Console->Lock); + if (_InterlockedDecrement(&Console->ReferenceCount) == 0) + ConioDeleteConsole(&Console->Header); + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return STATUS_SUCCESS; } - + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return STATUS_INVALID_PARAMETER; } @@ -215,11 +192,8 @@ ProcessData->HandleTable = Block; ProcessData->HandleTableSize += 64; } - ProcessData->HandleTable[i].Object = Object; - ProcessData->HandleTable[i].Access = Access; - ProcessData->HandleTable[i].Inheritable = Inheritable; + Win32CsrCreateHandleEntry(&ProcessData->HandleTable[i], Object, Access, Inheritable); *Handle = UlongToHandle((i << 2) | 0x3); - _InterlockedIncrement( &Object->ReferenceCount ); RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return(STATUS_SUCCESS); } @@ -256,8 +230,10 @@ if (SourceProcessData->HandleTable[i].Object != NULL && SourceProcessData->HandleTable[i].Inheritable) { - TargetProcessData->HandleTable[i] = SourceProcessData->HandleTable[i]; - _InterlockedIncrement( &SourceProcessData->HandleTable[i].Object->ReferenceCount ); + Win32CsrCreateHandleEntry(&TargetProcessData->HandleTable[i], + SourceProcessData->HandleTable[i].Object, + SourceProcessData->HandleTable[i].Access, + SourceProcessData->HandleTable[i].Inheritable); } } RtlLeaveCriticalSection(&SourceProcessData->HandleTableLock); @@ -385,9 +361,7 @@ if (NT_SUCCESS(Request->Status) && Request->Data.DuplicateHandleRequest.Options & DUPLICATE_CLOSE_SOURCE) { - /* Close the original handle. This cannot drop the count to 0, since a new handle now exists */ - _InterlockedDecrement(&Entry->Object->ReferenceCount); - Entry->Object = NULL; + Win32CsrCloseHandleEntry(Entry); } RtlLeaveCriticalSection(&ProcessData->HandleTableLock); Modified: trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.h [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/win32csr.h [iso-8859-1] Sun May 23 07:33:21 2010 @@ -17,8 +17,8 @@ typedef struct Object_tt { LONG Type; - LONG ReferenceCount; - CRITICAL_SECTION Lock; + struct tagCSRSS_CONSOLE *Console; + LONG HandleCount; } Object_t; typedef struct _CSRSS_HANDLE @@ -48,11 +48,6 @@ DWORD Access, long Type); VOID FASTCALL Win32CsrUnlockObject(Object_t *Object); -NTSTATUS FASTCALL Win32CsrGetObject(PCSRSS_PROCESS_DATA ProcessData, - HANDLE Handle, - Object_t **Object, - DWORD Access); -NTSTATUS FASTCALL Win32CsrReleaseObjectByPointer(Object_t *Object); NTSTATUS FASTCALL Win32CsrReleaseObject(PCSRSS_PROCESS_DATA ProcessData, HANDLE Object); NTSTATUS WINAPI Win32CsrReleaseConsole(PCSRSS_PROCESS_DATA ProcessData);
14 years, 8 months
1
0
0
0
[jmorlan] 47316: [WIN32CSR] Protect ProcessData->Console with the HandleTableLock.
by jmorlan@svn.reactos.org
Author: jmorlan Date: Sun May 23 04:58:23 2010 New Revision: 47316 URL:
http://svn.reactos.org/svn/reactos?rev=47316&view=rev
Log: [WIN32CSR] Protect ProcessData->Console with the HandleTableLock. Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c trunk/reactos/subsystems/win32/csrss/win32csr/handle.c Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] Sun May 23 04:58:23 2010 @@ -41,15 +41,20 @@ NTSTATUS FASTCALL ConioConsoleFromProcessData(PCSRSS_PROCESS_DATA ProcessData, PCSRSS_CONSOLE *Console) { - PCSRSS_CONSOLE ProcessConsole = ProcessData->Console; + PCSRSS_CONSOLE ProcessConsole; + + RtlEnterCriticalSection(&ProcessData->HandleTableLock); + ProcessConsole = ProcessData->Console; if (!ProcessConsole) { *Console = NULL; + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return STATUS_INVALID_HANDLE; } InterlockedIncrement(&ProcessConsole->Header.ReferenceCount); + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); EnterCriticalSection(&(ProcessConsole->Header.Lock)); *Console = ProcessConsole; @@ -247,9 +252,11 @@ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); + RtlEnterCriticalSection(&ProcessData->HandleTableLock); if (ProcessData->Console) { DPRINT1("Process already has a console\n"); + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return STATUS_INVALID_PARAMETER; } @@ -257,6 +264,7 @@ if (!Request->Data.AllocConsoleRequest.ConsoleNeeded) { DPRINT("No console needed\n"); + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return STATUS_SUCCESS; } @@ -270,6 +278,7 @@ if (NULL == Console) { DPRINT1("Not enough memory for console\n"); + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return STATUS_NO_MEMORY; } /* initialize list head */ @@ -282,6 +291,7 @@ { DPRINT1("Console init failed\n"); HeapFree(Win32CsrApiHeap, 0, Console); + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return Status; } } @@ -313,6 +323,7 @@ DPRINT1("Failed to insert object\n"); ConioDeleteConsole((Object_t *) Console); ProcessData->Console = 0; + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return Status; } @@ -328,6 +339,7 @@ Win32CsrReleaseObject(ProcessData, Request->Data.AllocConsoleRequest.InputHandle); ProcessData->Console = 0; + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return Status; } } @@ -351,6 +363,7 @@ Request->Data.AllocConsoleRequest.InputHandle); } ProcessData->Console = 0; + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return Status; } @@ -364,6 +377,7 @@ InsertHeadList(&ProcessData->Console->ProcessList, &ProcessData->ProcessEntry); } + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return STATUS_SUCCESS; } @@ -1960,6 +1974,7 @@ DPRINT("CsrCreateScreenBuffer\n"); + RtlEnterCriticalSection(&ProcessData->HandleTableLock); Status = ConioConsoleFromProcessData(ProcessData, &Console); if (! NT_SUCCESS(Status)) { @@ -2012,6 +2027,7 @@ } ConioUnlockConsole(Console); + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return Status; } Modified: trunk/reactos/subsystems/win32/csrss/win32csr/handle.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
============================================================================== --- trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] (original) +++ trunk/reactos/subsystems/win32/csrss/win32csr/handle.c [iso-8859-1] Sun May 23 04:58:23 2010 @@ -146,27 +146,24 @@ Win32CsrReleaseConsole( PCSRSS_PROCESS_DATA ProcessData) { - ULONG HandleTableSize; - PCSRSS_HANDLE HandleTable; PCSRSS_CONSOLE Console; ULONG i; /* Close all console handles and detach process from console */ RtlEnterCriticalSection(&ProcessData->HandleTableLock); - HandleTableSize = ProcessData->HandleTableSize; - HandleTable = ProcessData->HandleTable; + + for (i = 0; i < ProcessData->HandleTableSize; i++) + { + if (ProcessData->HandleTable[i].Object != NULL) + Win32CsrReleaseObjectByPointer(ProcessData->HandleTable[i].Object); + } + ProcessData->HandleTableSize = 0; + RtlFreeHeap(Win32CsrApiHeap, 0, ProcessData->HandleTable); + ProcessData->HandleTable = NULL; + Console = ProcessData->Console; - ProcessData->HandleTableSize = 0; - ProcessData->HandleTable = NULL; ProcessData->Console = NULL; RtlLeaveCriticalSection(&ProcessData->HandleTableLock); - - for (i = 0; i < HandleTableSize; i++) - { - if (HandleTable[i].Object != NULL) - Win32CsrReleaseObjectByPointer(HandleTable[i].Object); - } - RtlFreeHeap(Win32CsrApiHeap, 0, HandleTable); if (Console != NULL) { @@ -272,6 +269,7 @@ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); + RtlEnterCriticalSection(&ProcessData->HandleTableLock); if (ProcessData->Console) { Request->Status = Win32CsrInsertObject(ProcessData, @@ -285,6 +283,7 @@ Request->Data.GetInputHandleRequest.InputHandle = INVALID_HANDLE_VALUE; Request->Status = STATUS_SUCCESS; } + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return Request->Status; } @@ -294,6 +293,7 @@ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE); Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE); + RtlEnterCriticalSection(&ProcessData->HandleTableLock); if (ProcessData->Console) { Request->Status = Win32CsrInsertObject(ProcessData, @@ -307,6 +307,7 @@ Request->Data.GetOutputHandleRequest.OutputHandle = INVALID_HANDLE_VALUE; Request->Status = STATUS_SUCCESS; } + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); return Request->Status; }
14 years, 8 months
1
0
0
0
← Newer
1
...
16
17
18
19
20
21
22
...
44
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
38
39
40
41
42
43
44
Results per page:
10
25
50
100
200