ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 2012
----- 2024 -----
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
11 participants
124 discussions
Start a n
N
ew thread
[hbelusca] 57725: [KERNEL32] - Use new structures and api indices namings. [CONSRV] - CSRSS_SET_CURSOR ==> CSRSS_SET_CURSOR_POSITION for SrvSetConsoleCursorPosition. - Merge CSRSS_GET_CURSOR_INFO a...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Nov 17 23:29:53 2012 New Revision: 57725 URL:
http://svn.reactos.org/svn/reactos?rev=57725&view=rev
Log: [KERNEL32] - Use new structures and api indices namings. [CONSRV] - CSRSS_SET_CURSOR ==> CSRSS_SET_CURSOR_POSITION for SrvSetConsoleCursorPosition. - Merge CSRSS_GET_CURSOR_INFO and CSRSS_SET_CURSOR_INFO into CSRSS_CURSOR_INFO. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c branches/ros-csrss/include/reactos/subsys/win/conmsg.h branches/ros-csrss/win32ss/user/consrv/conoutput.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/console.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/console.c [iso-8859-1] Sat Nov 17 23:29:53 2012 @@ -362,7 +362,7 @@ { DPRINT1("GetNumberOfConsoleFonts() UNIMPLEMENTED!\n"); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 1; /* FIXME: call csrss.exe */ + return 1; } @@ -593,11 +593,14 @@ /* * FUNCTION: Checks whether the given handle is a valid console handle. + * * ARGUMENTS: * Handle - Handle to be checked + * * RETURNS: * TRUE: Handle is a valid console handle * FALSE: Handle is not a valid console handle. + * * STATUS: Officially undocumented * * @implemented @@ -606,22 +609,22 @@ WINAPI VerifyConsoleIoHandle(HANDLE Handle) { - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.VerifyHandleRequest.Handle = Handle; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_NATIVE, VERIFY_HANDLE), - sizeof(CSR_API_MESSAGE)); + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + + ApiMessage.Data.VerifyHandleRequest.Handle = Handle; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepVerifyIoHandle), + sizeof(CSRSS_VERIFY_HANDLE)); if (!NT_SUCCESS(Status)) { BaseSetLastNTError(Status); return FALSE; } - return (BOOL)NT_SUCCESS(Request.Status); + return (BOOL)NT_SUCCESS(ApiMessage.Status); } @@ -664,15 +667,15 @@ WINAPI CloseConsoleHandle(HANDLE Handle) { - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.CloseHandleRequest.Handle = Handle; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_NATIVE, CLOSE_HANDLE), - sizeof(CSR_API_MESSAGE)); + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + + ApiMessage.Data.CloseHandleRequest.Handle = Handle; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepCloseHandle), + sizeof(CSRSS_CLOSE_HANDLE)); if (!NT_SUCCESS(Status)) { BaseSetLastNTError(Status); @@ -682,20 +685,23 @@ return TRUE; } + /* * @implemented */ HANDLE WINAPI GetStdHandle(DWORD nStdHandle) - /* - * FUNCTION: Get a handle for the standard input, standard output - * and a standard error device. - * ARGUMENTS: - * nStdHandle - Specifies the device for which to return the handle. - * RETURNS: If the function succeeds, the return value is the handle - * of the specified device. Otherwise the value is INVALID_HANDLE_VALUE. - */ +/* + * FUNCTION: Get a handle for the standard input, standard output + * and a standard error device. + * + * ARGUMENTS: + * nStdHandle - Specifies the device for which to return the handle. + * + * RETURNS: If the function succeeds, the return value is the handle + * of the specified device. Otherwise the value is INVALID_HANDLE_VALUE. + */ { PRTL_USER_PROCESS_PARAMETERS Ppb; @@ -712,7 +718,7 @@ return Ppb->StandardError; } - SetLastError (ERROR_INVALID_PARAMETER); + SetLastError(ERROR_INVALID_PARAMETER); return INVALID_HANDLE_VALUE; } @@ -724,14 +730,16 @@ WINAPI SetStdHandle(DWORD nStdHandle, HANDLE hHandle) - /* - * FUNCTION: Set the handle for the standard input, standard output or - * the standard error device. - * ARGUMENTS: - * nStdHandle - Specifies the handle to be set. - * hHandle - The handle to set. - * RETURNS: TRUE if the function succeeds, FALSE otherwise. - */ +/* + * FUNCTION: Set the handle for the standard input, standard output or + * the standard error device. + * + * ARGUMENTS: + * nStdHandle - Specifies the handle to be set. + * hHandle - The handle to set. + * + * RETURNS: TRUE if the function succeeds, FALSE otherwise. + */ { PRTL_USER_PROCESS_PARAMETERS Ppb; @@ -769,8 +777,9 @@ WINAPI AllocConsole(VOID) { - CSR_API_MESSAGE Request; - NTSTATUS Status; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_ALLOC_CONSOLE AllocConsoleRequest = &ApiMessage.Data.AllocConsoleRequest; HANDLE hStdError; STARTUPINFO si; @@ -783,26 +792,26 @@ GetStartupInfo(&si); - Request.Data.AllocConsoleRequest.CtrlDispatcher = ConsoleControlDispatcher; - Request.Data.AllocConsoleRequest.ConsoleNeeded = TRUE; - Request.Data.AllocConsoleRequest.ShowCmd = si.wShowWindow; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, ALLOC_CONSOLE), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - - NtCurrentPeb()->ProcessParameters->ConsoleHandle = Request.Data.AllocConsoleRequest.Console; - - SetStdHandle(STD_INPUT_HANDLE, Request.Data.AllocConsoleRequest.InputHandle); - SetStdHandle(STD_OUTPUT_HANDLE, Request.Data.AllocConsoleRequest.OutputHandle); - - hStdError = DuplicateConsoleHandle(Request.Data.AllocConsoleRequest.OutputHandle, + AllocConsoleRequest->CtrlDispatcher = ConsoleControlDispatcher; + AllocConsoleRequest->ConsoleNeeded = TRUE; + AllocConsoleRequest->ShowCmd = si.wShowWindow; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepAlloc), + sizeof(CSRSS_ALLOC_CONSOLE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + NtCurrentPeb()->ProcessParameters->ConsoleHandle = AllocConsoleRequest->Console; + + SetStdHandle(STD_INPUT_HANDLE, AllocConsoleRequest->InputHandle); + SetStdHandle(STD_OUTPUT_HANDLE, AllocConsoleRequest->OutputHandle); + + hStdError = DuplicateConsoleHandle(AllocConsoleRequest->OutputHandle, 0, TRUE, DUPLICATE_SAME_ACCESS); @@ -824,14 +833,14 @@ // AG: I'm not sure if this is correct (what happens to std handles?) // but I just tried to reverse what AllocConsole() does... - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, FREE_CONSOLE), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepFree), + sizeof(CSRSS_FREE_CONSOLE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return FALSE; @@ -852,21 +861,23 @@ GetConsoleScreenBufferInfo(HANDLE hConsoleOutput, PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo) { - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.ScreenBufferInfoRequest.ConsoleHandle = hConsoleOutput; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, SCREEN_BUFFER_INFO), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - *lpConsoleScreenBufferInfo = Request.Data.ScreenBufferInfoRequest.Info; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + + ApiMessage.Data.ScreenBufferInfoRequest.ConsoleHandle = hConsoleOutput; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetScreenBufferInfo), + sizeof(CSRSS_SCREEN_BUFFER_INFO)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + *lpConsoleScreenBufferInfo = ApiMessage.Data.ScreenBufferInfoRequest.Info; + return TRUE; } @@ -881,17 +892,17 @@ SetConsoleCursorPosition(HANDLE hConsoleOutput, COORD dwCursorPosition) { - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.SetCursorRequest.ConsoleHandle = hConsoleOutput; - Request.Data.SetCursorRequest.Position = dwCursorPosition; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_CURSOR), - sizeof(CSR_API_MESSAGE)); - if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + + ApiMessage.Data.SetCursorPositionRequest.ConsoleHandle = hConsoleOutput; + ApiMessage.Data.SetCursorPositionRequest.Position = dwCursorPosition; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetCursorPosition), + sizeof(CSRSS_SET_CURSOR_POSITION)); + if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return FALSE; @@ -996,8 +1007,8 @@ GetConsoleCursorInfo(HANDLE hConsoleOutput, PCONSOLE_CURSOR_INFO lpConsoleCursorInfo) { - CSR_API_MESSAGE Request; - NTSTATUS Status; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; if (!lpConsoleCursorInfo) { @@ -1009,19 +1020,19 @@ return FALSE; } - Request.Data.GetCursorInfoRequest.ConsoleHandle = hConsoleOutput; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CURSOR_INFO), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - - *lpConsoleCursorInfo = Request.Data.GetCursorInfoRequest.Info; + ApiMessage.Data.CursorInfoRequest.ConsoleHandle = hConsoleOutput; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCursorInfo), + sizeof(CSRSS_CURSOR_INFO)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + *lpConsoleCursorInfo = ApiMessage.Data.CursorInfoRequest.Info; return TRUE; } @@ -1158,6 +1169,7 @@ return TRUE; } + /*-------------------------------------------------------------- * SetConsoleCursorInfo * @@ -1168,17 +1180,17 @@ SetConsoleCursorInfo(HANDLE hConsoleOutput, CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo) { - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.SetCursorInfoRequest.ConsoleHandle = hConsoleOutput; - Request.Data.SetCursorInfoRequest.Info = *lpConsoleCursorInfo; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_CURSOR_INFO), - sizeof(CSR_API_MESSAGE)); - if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + + ApiMessage.Data.CursorInfoRequest.ConsoleHandle = hConsoleOutput; + ApiMessage.Data.CursorInfoRequest.Info = *lpConsoleCursorInfo; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetCursorInfo), + sizeof(CSRSS_CURSOR_INFO)); + if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return FALSE; Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] Sat Nov 17 23:29:53 2012 @@ -42,7 +42,7 @@ ConsolepFlushInputBuffer, // ConsolepGetLargestWindowSize, ConsolepSetScreenBufferSize, - // ConsolepSetCursorPosition, + ConsolepSetCursorPosition, ConsolepSetCursorInfo, // ConsolepSetWindowInfo, ConsolepScrollScreenBuffer, @@ -63,7 +63,7 @@ ConsolepCreateScreenBuffer, // ConsolepInvalidateBitMapRect, // ConsolepVDMOperation, - ConsolepSetCursor, + // ConsolepSetCursor, // ConsolepShowCursor, // ConsolepMenuControl, // ConsolepSetPalette, @@ -181,7 +181,7 @@ { HANDLE ConsoleHandle; COORD Position; -} CSRSS_SET_CURSOR, *PCSRSS_SET_CURSOR; +} CSRSS_SET_CURSOR_POSITION, *PCSRSS_SET_CURSOR_POSITION; typedef struct { @@ -229,13 +229,7 @@ { HANDLE ConsoleHandle; CONSOLE_CURSOR_INFO Info; -} CSRSS_GET_CURSOR_INFO, *PCSRSS_GET_CURSOR_INFO; - -typedef struct -{ - HANDLE ConsoleHandle; - CONSOLE_CURSOR_INFO Info; -} CSRSS_SET_CURSOR_INFO, *PCSRSS_SET_CURSOR_INFO; +} CSRSS_CURSOR_INFO, *PCSRSS_CURSOR_INFO; typedef struct { @@ -585,11 +579,8 @@ CSRSS_GET_INPUT_WAIT_HANDLE GetConsoleInputWaitHandle; /* Cursor */ - CSRSS_SET_CURSOR SetCursorRequest; - CSRSS_GET_CURSOR_INFO GetCursorInfoRequest; - CSRSS_SET_CURSOR_INFO SetCursorInfoRequest; - - CSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest; + CSRSS_CURSOR_INFO CursorInfoRequest; + CSRSS_SET_CURSOR_POSITION SetCursorPositionRequest; /* Screen buffer */ CSRSS_CREATE_SCREEN_BUFFER CreateScreenBufferRequest; @@ -599,6 +590,7 @@ CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER ScrollConsoleScreenBufferRequest; CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo; + CSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest; /* Console mode */ CSRSS_CONSOLE_MODE ConsoleModeRequest; Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Sat Nov 17 23:29:53 2012 @@ -1092,18 +1092,16 @@ CSR_API(SrvGetConsoleCursorInfo) { NTSTATUS Status; - PCSRSS_GET_CURSOR_INFO GetCursorInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCursorInfoRequest; + PCSRSS_CURSOR_INFO CursorInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CursorInfoRequest; PCSRSS_SCREEN_BUFFER Buff; DPRINT("SrvGetConsoleCursorInfo\n"); - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, GetCursorInfoRequest->ConsoleHandle, &Buff, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - GetCursorInfoRequest->Info.bVisible = Buff->CursorInfo.bVisible; - GetCursorInfoRequest->Info.dwSize = Buff->CursorInfo.dwSize; + Status = ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), CursorInfoRequest->ConsoleHandle, &Buff, GENERIC_READ); + if (!NT_SUCCESS(Status)) return Status; + + CursorInfoRequest->Info.bVisible = Buff->CursorInfo.bVisible; + CursorInfoRequest->Info.dwSize = Buff->CursorInfo.dwSize; ConioUnlockScreenBuffer(Buff); return STATUS_SUCCESS; @@ -1111,24 +1109,22 @@ CSR_API(SrvSetConsoleCursorInfo) { - PCSRSS_SET_CURSOR_INFO SetCursorInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorInfoRequest; + NTSTATUS Status; + PCSRSS_CURSOR_INFO CursorInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.CursorInfoRequest; PCSRSS_CONSOLE Console; PCSRSS_SCREEN_BUFFER Buff; DWORD Size; BOOL Visible; - NTSTATUS Status; DPRINT("SrvSetConsoleCursorInfo\n"); - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, SetCursorInfoRequest->ConsoleHandle, &Buff, GENERIC_WRITE); - if (! NT_SUCCESS(Status)) - { - return Status; - } + Status = ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), CursorInfoRequest->ConsoleHandle, &Buff, GENERIC_WRITE); + if (!NT_SUCCESS(Status)) return Status; + Console = Buff->Header.Console; - Size = SetCursorInfoRequest->Info.dwSize; - Visible = SetCursorInfoRequest->Info.bVisible; + Size = CursorInfoRequest->Info.dwSize; + Visible = CursorInfoRequest->Info.bVisible; if (Size < 1) { Size = 1; @@ -1138,13 +1134,14 @@ Size = 100; } - if (Size != Buff->CursorInfo.dwSize - || (Visible && ! Buff->CursorInfo.bVisible) || (! Visible && Buff->CursorInfo.bVisible)) + if ( (Size != Buff->CursorInfo.dwSize) || + (Visible && ! Buff->CursorInfo.bVisible) || + (! Visible && Buff->CursorInfo.bVisible) ) { Buff->CursorInfo.dwSize = Size; Buff->CursorInfo.bVisible = Visible; - if (! ConioSetCursorInfo(Console, Buff)) + if (!ConioSetCursorInfo(Console, Buff)) { ConioUnlockScreenBuffer(Buff); return STATUS_UNSUCCESSFUL; @@ -1159,7 +1156,7 @@ CSR_API(SrvSetConsoleCursorPosition) { NTSTATUS Status; - PCSRSS_SET_CURSOR SetCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorRequest; + PCSRSS_SET_CURSOR_POSITION SetCursorPositionRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorPositionRequest; PCSRSS_CONSOLE Console; PCSRSS_SCREEN_BUFFER Buff; LONG OldCursorX, OldCursorY; @@ -1167,17 +1164,15 @@ DPRINT("SrvSetConsoleCursorPosition\n"); - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, SetCursorRequest->ConsoleHandle, &Buff, GENERIC_WRITE); - if (! NT_SUCCESS(Status)) - { - return Status; - } + Status = ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), SetCursorPositionRequest->ConsoleHandle, &Buff, GENERIC_WRITE); + if (!NT_SUCCESS(Status)) return Status; + Console = Buff->Header.Console; - NewCursorX = SetCursorRequest->Position.X; - NewCursorY = SetCursorRequest->Position.Y; - if (NewCursorX < 0 || NewCursorX >= Buff->MaxX || - NewCursorY < 0 || NewCursorY >= Buff->MaxY) + NewCursorX = SetCursorPositionRequest->Position.X; + NewCursorY = SetCursorPositionRequest->Position.Y; + if ( NewCursorX < 0 || NewCursorX >= Buff->MaxX || + NewCursorY < 0 || NewCursorY >= Buff->MaxY ) { ConioUnlockScreenBuffer(Buff); return STATUS_INVALID_PARAMETER;
11 years, 11 months
1
0
0
0
[hbelusca] 57724: [KERNEL32] - Make some functions compliant with the new structures and server apis indices names. [KERNEL32/CONSRV] - Merge CSRSS_SET_CONSOLE_MODE and CSRSS_GET_CONSOLE_MODE into ...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Nov 17 23:07:59 2012 New Revision: 57724 URL:
http://svn.reactos.org/svn/reactos?rev=57724&view=rev
Log: [KERNEL32] - Make some functions compliant with the new structures and server apis indices names. [KERNEL32/CONSRV] - Merge CSRSS_SET_CONSOLE_MODE and CSRSS_GET_CONSOLE_MODE into CSRSS_CONSOLE_MODE. - Rename CSRSS_SETGET_CONSOLE_HW_STATE into CSRSS_CONSOLE_HW_STATE. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c branches/ros-csrss/include/reactos/subsys/win/conmsg.h branches/ros-csrss/win32ss/user/consrv/console.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/console.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/console.c [iso-8859-1] Sat Nov 17 23:07:59 2012 @@ -202,33 +202,34 @@ BOOL bInheritHandle, DWORD dwOptions) { - CSR_API_MESSAGE Request; - NTSTATUS Status; - - if (dwOptions & ~(DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS) - || (!(dwOptions & DUPLICATE_SAME_ACCESS) - && dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE))) + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_DUPLICATE_HANDLE DuplicateHandleRequest = &ApiMessage.Data.DuplicateHandleRequest; + + if ( (dwOptions & ~(DUPLICATE_CLOSE_SOURCE | DUPLICATE_SAME_ACCESS)) || + (!(dwOptions & DUPLICATE_SAME_ACCESS) && + (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE))) ) { SetLastError (ERROR_INVALID_PARAMETER); return INVALID_HANDLE_VALUE; } - Request.Data.DuplicateHandleRequest.Handle = hConsole; - Request.Data.DuplicateHandleRequest.Access = dwDesiredAccess; - Request.Data.DuplicateHandleRequest.Inheritable = bInheritHandle; - Request.Data.DuplicateHandleRequest.Options = dwOptions; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_NATIVE, DUPLICATE_HANDLE), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status=Request.Status)) + DuplicateHandleRequest->Handle = hConsole; + DuplicateHandleRequest->Access = dwDesiredAccess; + DuplicateHandleRequest->Inheritable = bInheritHandle; + DuplicateHandleRequest->Options = dwOptions; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepDuplicateHandle), + sizeof(CSRSS_DUPLICATE_HANDLE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return INVALID_HANDLE_VALUE; } - return Request.Data.DuplicateHandleRequest.Handle; + return DuplicateHandleRequest->Handle; } @@ -292,23 +293,23 @@ DWORD Flags, PDWORD State) { - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.ConsoleHardwareStateRequest.ConsoleHandle = hConsole; - Request.Data.ConsoleHardwareStateRequest.SetGet = CONSOLE_HARDWARE_STATE_GET; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, SETGET_CONSOLE_HW_STATE), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - - *State = Request.Data.ConsoleHardwareStateRequest.State; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_CONSOLE_HW_STATE ConsoleHardwareStateRequest = &ApiMessage.Data.ConsoleHardwareStateRequest; + + ConsoleHardwareStateRequest->ConsoleHandle = hConsole; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetHardwareState), + sizeof(CSRSS_CONSOLE_HW_STATE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + *State = ConsoleHardwareStateRequest->State; return TRUE; } @@ -498,18 +499,18 @@ DWORD Flags, DWORD State) { - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.ConsoleHardwareStateRequest.ConsoleHandle = hConsole; - Request.Data.ConsoleHardwareStateRequest.SetGet = CONSOLE_HARDWARE_STATE_SET; - Request.Data.ConsoleHardwareStateRequest.State = State; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, SETGET_CONSOLE_HW_STATE), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_CONSOLE_HW_STATE ConsoleHardwareStateRequest = &ApiMessage.Data.ConsoleHardwareStateRequest; + + ConsoleHardwareStateRequest->ConsoleHandle = hConsole; + ConsoleHardwareStateRequest->State = State; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetHardwareState), + sizeof(CSRSS_CONSOLE_HW_STATE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return FALSE; @@ -910,22 +911,23 @@ GetConsoleMode(HANDLE hConsoleHandle, LPDWORD lpMode) { - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.GetConsoleModeRequest.ConsoleHandle = hConsoleHandle; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_MODE), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - - *lpMode = Request.Data.GetConsoleModeRequest.ConsoleMode; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_CONSOLE_MODE ConsoleModeRequest = &ApiMessage.Data.ConsoleModeRequest; + + ConsoleModeRequest->ConsoleHandle = hConsoleHandle; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetMode), + sizeof(CSRSS_CONSOLE_MODE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + *lpMode = ConsoleModeRequest->ConsoleMode; return TRUE; } @@ -1050,17 +1052,18 @@ SetConsoleMode(HANDLE hConsoleHandle, DWORD dwMode) { - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.SetConsoleModeRequest.ConsoleHandle = hConsoleHandle; - Request.Data.SetConsoleModeRequest.Mode = dwMode; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_CONSOLE_MODE), - sizeof(CSR_API_MESSAGE)); - if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_CONSOLE_MODE ConsoleModeRequest = &ApiMessage.Data.ConsoleModeRequest; + + ConsoleModeRequest->ConsoleHandle = hConsoleHandle; + ConsoleModeRequest->ConsoleMode = dwMode; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetMode), + sizeof(CSRSS_CONSOLE_MODE)); + if(!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return FALSE; Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] Sat Nov 17 23:07:59 2012 @@ -52,7 +52,7 @@ ConsolepReadConsole, ConsolepWriteConsole, ConsolepDuplicateHandle, - /**/ ConsolepGetHandleInformation /**/, + // ConsolepGetHandleInformation, // ConsolepSetHandleInformation, ConsolepCloseHandle, ConsolepVerifyIoHandle, @@ -246,14 +246,8 @@ typedef struct { HANDLE ConsoleHandle; - DWORD Mode; -} CSRSS_SET_CONSOLE_MODE, *PCSRSS_SET_CONSOLE_MODE; - -typedef struct -{ - HANDLE ConsoleHandle; DWORD ConsoleMode; -} CSRSS_GET_CONSOLE_MODE, *PCSRSS_GET_CONSOLE_MODE; +} CSRSS_CONSOLE_MODE, *PCSRSS_CONSOLE_MODE; typedef struct { @@ -415,18 +409,18 @@ HANDLE InputWaitHandle; } CSRSS_GET_INPUT_WAIT_HANDLE, *PCSRSS_GET_INPUT_WAIT_HANDLE; -#define CONSOLE_HARDWARE_STATE_GET 0 -#define CONSOLE_HARDWARE_STATE_SET 1 - + +/* + * Console hardware states. + */ #define CONSOLE_HARDWARE_STATE_GDI_MANAGED 0 #define CONSOLE_HARDWARE_STATE_DIRECT 1 typedef struct { HANDLE ConsoleHandle; - DWORD SetGet; /* 0=get; 1=set */ DWORD State; -} CSRSS_SETGET_CONSOLE_HW_STATE, *PCSRSS_SETGET_CONSOLE_HW_STATE; +} CSRSS_CONSOLE_HW_STATE, *PCSRSS_CONSOLE_HW_STATE; typedef struct { @@ -607,9 +601,8 @@ CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo; /* Console mode */ - CSRSS_SET_CONSOLE_MODE SetConsoleModeRequest; - CSRSS_GET_CONSOLE_MODE GetConsoleModeRequest; - CSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest; + CSRSS_CONSOLE_MODE ConsoleModeRequest; + CSRSS_CONSOLE_HW_STATE ConsoleHardwareStateRequest; /* Console window */ CSRSS_SET_TITLE SetTitleRequest; Modified: branches/ros-csrss/win32ss/user/consrv/console.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] Sat Nov 17 23:07:59 2012 @@ -463,28 +463,26 @@ CSR_API(SrvSetConsoleMode) { NTSTATUS Status; - PCSRSS_SET_CONSOLE_MODE SetConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetConsoleModeRequest; + PCSRSS_CONSOLE_MODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest; PCSRSS_CONSOLE Console; PCSRSS_SCREEN_BUFFER Buff; DPRINT("SrvSetConsoleMode\n"); - Status = Win32CsrLockObject(CsrGetClientThread()->Process, - SetConsoleModeRequest->ConsoleHandle, + Status = Win32CsrLockObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process), + ConsoleModeRequest->ConsoleHandle, (Object_t **) &Console, GENERIC_WRITE, 0); - if (! NT_SUCCESS(Status)) - { - return Status; - } + if (!NT_SUCCESS(Status)) return Status; Buff = (PCSRSS_SCREEN_BUFFER)Console; + if (CONIO_CONSOLE_MAGIC == Console->Header.Type) { - Console->Mode = SetConsoleModeRequest->Mode & CONSOLE_INPUT_MODE_VALID; + Console->Mode = ConsoleModeRequest->ConsoleMode & CONSOLE_INPUT_MODE_VALID; } else if (CONIO_SCREEN_BUFFER_MAGIC == Console->Header.Type) { - Buff->Mode = SetConsoleModeRequest->Mode & CONSOLE_OUTPUT_MODE_VALID; + Buff->Mode = ConsoleModeRequest->ConsoleMode & CONSOLE_OUTPUT_MODE_VALID; } else { @@ -499,27 +497,27 @@ CSR_API(SrvGetConsoleMode) { NTSTATUS Status; - PCSRSS_GET_CONSOLE_MODE GetConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetConsoleModeRequest; + PCSRSS_CONSOLE_MODE ConsoleModeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest; PCSRSS_CONSOLE Console; PCSRSS_SCREEN_BUFFER Buff; DPRINT("SrvGetConsoleMode\n"); - Status = Win32CsrLockObject(CsrGetClientThread()->Process, GetConsoleModeRequest->ConsoleHandle, + Status = Win32CsrLockObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process), + ConsoleModeRequest->ConsoleHandle, (Object_t **) &Console, GENERIC_READ, 0); - if (! NT_SUCCESS(Status)) - { - return Status; - } + if (!NT_SUCCESS(Status)) return Status; + Status = STATUS_SUCCESS; Buff = (PCSRSS_SCREEN_BUFFER) Console; + if (CONIO_CONSOLE_MAGIC == Console->Header.Type) { - GetConsoleModeRequest->ConsoleMode = Console->Mode; + ConsoleModeRequest->ConsoleMode = Console->Mode; } else if (CONIO_SCREEN_BUFFER_MAGIC == Buff->Header.Type) { - GetConsoleModeRequest->ConsoleMode = Buff->Mode; + ConsoleModeRequest->ConsoleMode = Buff->Mode; } else { @@ -614,18 +612,18 @@ } /********************************************************************** - * HardwareStateProperty + * HardwareStateProperty * - * DESCRIPTION - * Set/Get the value of the HardwareState and switch - * between direct video buffer ouput and GDI windowed - * output. - * ARGUMENTS - * Client hands us a CSRSS_CONSOLE_HARDWARE_STATE - * object. We use the same object to Request. - * NOTE - * ConsoleHwState has the correct size to be compatible - * with NT's, but values are not. + * DESCRIPTION + * Set/Get the value of the HardwareState and switch + * between direct video buffer ouput and GDI windowed + * output. + * ARGUMENTS + * Client hands us a CSRSS_CONSOLE_HARDWARE_STATE + * object. We use the same object to Request. + * NOTE + * ConsoleHwState has the correct size to be compatible + * with NT's, but values are not. */ static NTSTATUS FASTCALL SetConsoleHardwareState(PCSRSS_CONSOLE Console, DWORD ConsoleHwState) @@ -650,37 +648,23 @@ CSR_API(SrvGetConsoleHardwareState) { - PCSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleHardwareStateRequest; - PCSRSS_CONSOLE Console; - NTSTATUS Status; + NTSTATUS Status; + PCSRSS_CONSOLE_HW_STATE ConsoleHardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleHardwareStateRequest; + PCSRSS_CONSOLE Console; DPRINT("SrvGetConsoleHardwareState\n"); - Status = ConioLockConsole(CsrGetClientThread()->Process, + Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), ConsoleHardwareStateRequest->ConsoleHandle, &Console, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - DPRINT1("Failed to get console handle in SetConsoleHardwareState\n"); - return Status; - } - - switch (ConsoleHardwareStateRequest->SetGet) - { - case CONSOLE_HARDWARE_STATE_GET: - ConsoleHardwareStateRequest->State = Console->HardwareState; - break; - - case CONSOLE_HARDWARE_STATE_SET: - DPRINT("Setting console hardware state.\n"); - Status = SetConsoleHardwareState(Console, ConsoleHardwareStateRequest->State); - break; - - default: - Status = STATUS_INVALID_PARAMETER_2; /* Client: (handle, [set_get], mode) */ - break; - } + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to get console handle in SrvGetConsoleHardwareState\n"); + return Status; + } + + ConsoleHardwareStateRequest->State = Console->HardwareState; ConioUnlockConsole(Console); @@ -689,37 +673,24 @@ CSR_API(SrvSetConsoleHardwareState) { - PCSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleHardwareStateRequest; - PCSRSS_CONSOLE Console; - NTSTATUS Status; + NTSTATUS Status; + PCSRSS_CONSOLE_HW_STATE ConsoleHardwareStateRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleHardwareStateRequest; + PCSRSS_CONSOLE Console; DPRINT("SrvSetConsoleHardwareState\n"); - Status = ConioLockConsole(CsrGetClientThread()->Process, + Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), ConsoleHardwareStateRequest->ConsoleHandle, &Console, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - DPRINT1("Failed to get console handle in SetConsoleHardwareState\n"); - return Status; - } - - switch (ConsoleHardwareStateRequest->SetGet) - { - case CONSOLE_HARDWARE_STATE_GET: - ConsoleHardwareStateRequest->State = Console->HardwareState; - break; - - case CONSOLE_HARDWARE_STATE_SET: - DPRINT("Setting console hardware state.\n"); - Status = SetConsoleHardwareState(Console, ConsoleHardwareStateRequest->State); - break; - - default: - Status = STATUS_INVALID_PARAMETER_2; /* Client: (handle, [set_get], mode) */ - break; - } + if (!NT_SUCCESS(Status)) + { + DPRINT1("Failed to get console handle in SrvSetConsoleHardwareState\n"); + return Status; + } + + DPRINT("Setting console hardware state.\n"); + Status = SetConsoleHardwareState(Console, ConsoleHardwareStateRequest->State); ConioUnlockConsole(Console);
11 years, 11 months
1
0
0
0
[hbelusca] 57723: [KERNEL32/CONSRV] - Make OpenConsole call only one server api, namely SrvOpenConsole, which was known before under the name CsrGetHandle (this latter function was removed in r5768...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Nov 17 22:42:04 2012 New Revision: 57723 URL:
http://svn.reactos.org/svn/reactos?rev=57723&view=rev
Log: [KERNEL32/CONSRV] - Make OpenConsole call only one server api, namely SrvOpenConsole, which was known before under the name CsrGetHandle (this latter function was removed in r57689 by error). - Merge CSRSS_GET_INPUT_HANDLE and CSRSS_GET_OUTPUT_HANDLE structures into CSRSS_OPEN_CONSOLE (used by the functions named above). [CONSRV] - Add SrvOpenConsole (copied from CsrGetHandle), and add DPRINT1s to it. - Load the localized string "Command Prompt" using the Server DLL's instance handle instead of calling GetModuleHandleW. - Make use of CONSOLE_PROCESS_DATA structures. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c branches/ros-csrss/include/reactos/subsys/win/conmsg.h branches/ros-csrss/win32ss/user/consrv/console.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/console.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/console.c [iso-8859-1] Sat Nov 17 22:42:04 2012 @@ -389,52 +389,53 @@ BOOL bInheritHandle, DWORD dwShareMode) { - CSR_API_MESSAGE Request; - ULONG CsrRequest; NTSTATUS Status = STATUS_SUCCESS; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_OPEN_CONSOLE OpenConsoleRequest = &ApiMessage.Data.OpenConsoleRequest; + HANDLE_TYPE HandleType; if (wsName && 0 == _wcsicmp(wsName, L"CONIN$")) { - CsrRequest = CSR_CREATE_API_NUMBER(CSR_NATIVE, GET_INPUT_HANDLE); + HandleType = HANDLE_INPUT; } else if (wsName && 0 == _wcsicmp(wsName, L"CONOUT$")) { - CsrRequest = CSR_CREATE_API_NUMBER(CSR_NATIVE, GET_OUTPUT_HANDLE); + HandleType = HANDLE_OUTPUT; } else { SetLastError(ERROR_INVALID_PARAMETER); - return(INVALID_HANDLE_VALUE); - } - - if (dwDesiredAccess & ~(GENERIC_READ|GENERIC_WRITE)) + return INVALID_HANDLE_VALUE; + } + + if (dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE)) { SetLastError(ERROR_INVALID_PARAMETER); - return(INVALID_HANDLE_VALUE); - } - - if (dwShareMode & ~(FILE_SHARE_READ|FILE_SHARE_WRITE)) + return INVALID_HANDLE_VALUE; + } + + if (dwShareMode & ~(FILE_SHARE_READ | FILE_SHARE_WRITE)) { SetLastError(ERROR_INVALID_PARAMETER); - return(INVALID_HANDLE_VALUE); - } - - /* 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, - CsrRequest, - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); return INVALID_HANDLE_VALUE; } - return Request.Data.GetInputHandleRequest.Handle; + OpenConsoleRequest->HandleType = HandleType; + OpenConsoleRequest->Access = dwDesiredAccess; + OpenConsoleRequest->Inheritable = bInheritHandle; + OpenConsoleRequest->ShareMode = dwShareMode; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepOpenConsole), + sizeof(CSRSS_OPEN_CONSOLE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + BaseSetLastNTError(Status); + return INVALID_HANDLE_VALUE; + } + + return OpenConsoleRequest->Handle; } Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] Sat Nov 17 22:42:04 2012 @@ -20,8 +20,8 @@ // Some names are also deduced from the subsystems/win32/csrss/csrsrv/server.c ones. typedef enum _CONSRV_API_NUMBER { - // ConsolepOpenConsole = CONSRV_FIRST_API_NUMBER, - ConsolepGetConsoleInput = CONSRV_FIRST_API_NUMBER, + ConsolepOpenConsole = CONSRV_FIRST_API_NUMBER, + ConsolepGetConsoleInput, ConsolepWriteConsoleInput, ConsolepReadConsoleOutput, ConsolepWriteConsoleOutput, @@ -392,14 +392,23 @@ DWORD Options; } CSRSS_DUPLICATE_HANDLE, *PCSRSS_DUPLICATE_HANDLE; -typedef struct -{ +/* + * Type of handles. + */ +typedef enum _HANDLE_TYPE +{ + HANDLE_INPUT = 0x01, + HANDLE_OUTPUT = 0x02 +} HANDLE_TYPE; + +typedef struct +{ + HANDLE Handle; + HANDLE_TYPE HandleType; DWORD Access; BOOL Inheritable; - HANDLE Handle; DWORD ShareMode; -} CSRSS_GET_INPUT_HANDLE, *PCSRSS_GET_INPUT_HANDLE, - CSRSS_GET_OUTPUT_HANDLE, *PCSRSS_GET_OUTPUT_HANDLE; +} CSRSS_OPEN_CONSOLE, *PCSRSS_OPEN_CONSOLE; typedef struct { @@ -575,8 +584,7 @@ CSRSS_FREE_CONSOLE FreeConsoleRequest; /* Handles */ - CSRSS_GET_INPUT_HANDLE GetInputHandleRequest; - CSRSS_GET_OUTPUT_HANDLE GetOutputHandleRequest; + CSRSS_OPEN_CONSOLE OpenConsoleRequest; CSRSS_CLOSE_HANDLE CloseHandleRequest; CSRSS_VERIFY_HANDLE VerifyHandleRequest; CSRSS_DUPLICATE_HANDLE DuplicateHandleRequest; Modified: branches/ros-csrss/win32ss/user/consrv/console.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] Sat Nov 17 22:42:04 2012 @@ -17,7 +17,6 @@ /* FUNCTIONS *****************************************************************/ -/*** Taken from win32ss/user/win32csr/desktopbg.c ***/ BOOL FASTCALL DtbgIsDesktopVisible(VOID) { @@ -31,10 +30,10 @@ return VisibleDesktopWindow != NULL; } -/****************************************************/ NTSTATUS FASTCALL -ConioConsoleFromProcessData(PCSR_PROCESS ProcessData, PCSRSS_CONSOLE *Console) +ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData, + PCSRSS_CONSOLE *Console) { PCSRSS_CONSOLE ProcessConsole; @@ -57,30 +56,32 @@ } VOID FASTCALL -ConioConsoleCtrlEventTimeout(DWORD Event, PCSR_PROCESS ProcessData, DWORD Timeout) +ConioConsoleCtrlEventTimeout(DWORD Event, + PCONSOLE_PROCESS_DATA ProcessData, + DWORD Timeout) { HANDLE Thread; - DPRINT("ConioConsoleCtrlEvent Parent ProcessId = %x\n", ProcessData->ClientId.UniqueProcess); + DPRINT("ConioConsoleCtrlEvent Parent ProcessId = %x\n", ProcessData->Process->ClientId.UniqueProcess); if (ProcessData->CtrlDispatcher) { - - Thread = CreateRemoteThread(ProcessData->ProcessHandle, NULL, 0, - (LPTHREAD_START_ROUTINE) ProcessData->CtrlDispatcher, + Thread = CreateRemoteThread(ProcessData->Process->ProcessHandle, NULL, 0, + ProcessData->CtrlDispatcher, UlongToPtr(Event), 0, NULL); if (NULL == Thread) { DPRINT1("Failed thread creation (Error: 0x%x)\n", GetLastError()); return; } + WaitForSingleObject(Thread, Timeout); CloseHandle(Thread); } } VOID FASTCALL -ConioConsoleCtrlEvent(DWORD Event, PCSR_PROCESS ProcessData) +ConioConsoleCtrlEvent(DWORD Event, PCONSOLE_PROCESS_DATA ProcessData) { ConioConsoleCtrlEventTimeout(Event, ProcessData, 0); } @@ -93,13 +94,11 @@ PCSRSS_SCREEN_BUFFER NewBuffer; BOOL GuiMode; WCHAR Title[255]; - HINSTANCE hInst; Console->Title.MaximumLength = Console->Title.Length = 0; Console->Title.Buffer = NULL; - hInst = GetModuleHandleW(L"win32csr"); - if (LoadStringW(hInst,IDS_COMMAND_PROMPT,Title,sizeof(Title)/sizeof(Title[0]))) + if (LoadStringW(ConSrvDllInstance, IDS_COMMAND_PROMPT, Title, sizeof(Title) / sizeof(Title[0]))) { RtlCreateUnicodeString(&Console->Title, Title); } @@ -150,10 +149,10 @@ /* make console active, and insert into console list */ Console->ActiveBuffer = (PCSRSS_SCREEN_BUFFER) NewBuffer; - if (! GuiMode) + if (!GuiMode) { Status = TuiInitConsole(Console); - if (! NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { DPRINT1("Failed to open text-mode console, switching to gui-mode\n"); GuiMode = TRUE; @@ -162,7 +161,7 @@ else /* GuiMode */ { Status = GuiInitConsole(Console, ShowCmd); - if (! NT_SUCCESS(Status)) + if (!NT_SUCCESS(Status)) { HeapFree(ConSrvHeap,0, NewBuffer); RtlFreeUnicodeString(&Console->Title); @@ -189,6 +188,64 @@ ConioDrawConsole(Console); return STATUS_SUCCESS; +} + +CSR_API(SrvOpenConsole) +{ + NTSTATUS Status = STATUS_SUCCESS; + PCSRSS_OPEN_CONSOLE OpenConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.OpenConsoleRequest; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); + + DPRINT("SrvOpenConsole\n"); + + OpenConsoleRequest->Handle = INVALID_HANDLE_VALUE; + + RtlEnterCriticalSection(&ProcessData->HandleTableLock); + + DPRINT1("SrvOpenConsole - Checkpoint 1\n"); + DPRINT1("ProcessData = 0x%p ; ProcessData->Console = 0x%p\n", ProcessData, ProcessData->Console); + + if (ProcessData->Console) + { + DWORD DesiredAccess = OpenConsoleRequest->Access; + DWORD ShareMode = OpenConsoleRequest->ShareMode; + + PCSRSS_CONSOLE Console = ProcessData->Console; + Object_t *Object; + + DPRINT1("SrvOpenConsole - Checkpoint 2\n"); + EnterCriticalSection(&Console->Lock); + DPRINT1("SrvOpenConsole - Checkpoint 3\n"); + + if (OpenConsoleRequest->HandleType == HANDLE_OUTPUT) + Object = &Console->ActiveBuffer->Header; + else // HANDLE_INPUT + 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, + &OpenConsoleRequest->Handle, + Object, + DesiredAccess, + OpenConsoleRequest->Inheritable, + ShareMode); + } + + LeaveCriticalSection(&Console->Lock); + } + + RtlLeaveCriticalSection(&ProcessData->HandleTableLock); + + return Status; } CSR_API(SrvAllocConsole)
11 years, 11 months
1
0
0
0
[hbelusca] 57722: [CONSRV] Reorganize the data members according to their purposes (increases the lisibility only). No code changes.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Nov 17 22:05:41 2012 New Revision: 57722 URL:
http://svn.reactos.org/svn/reactos?rev=57722&view=rev
Log: [CONSRV] Reorganize the data members according to their purposes (increases the lisibility only). No code changes. Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] Sat Nov 17 22:05:41 2012 @@ -571,35 +571,41 @@ ULONG Reserved; union { - CSRSS_WRITE_CONSOLE WriteConsoleRequest; CSRSS_ALLOC_CONSOLE AllocConsoleRequest; CSRSS_FREE_CONSOLE FreeConsoleRequest; - CSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest; - CSRSS_SET_CURSOR SetCursorRequest; - CSRSS_FILL_OUTPUT FillOutputRequest; - CSRSS_FILL_OUTPUT_ATTRIB FillOutputAttribRequest; - CSRSS_WRITE_CONSOLE_OUTPUT_CHAR WriteConsoleOutputCharRequest; - CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest; - CSRSS_GET_CURSOR_INFO GetCursorInfoRequest; - CSRSS_SET_CURSOR_INFO SetCursorInfoRequest; - CSRSS_SET_ATTRIB SetAttribRequest; - CSRSS_SET_CONSOLE_MODE SetConsoleModeRequest; - CSRSS_GET_CONSOLE_MODE GetConsoleModeRequest; - CSRSS_CREATE_SCREEN_BUFFER CreateScreenBufferRequest; - CSRSS_SET_SCREEN_BUFFER SetScreenBufferRequest; - CSRSS_SET_TITLE SetTitleRequest; - CSRSS_GET_TITLE GetTitleRequest; - CSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest; - CSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest; - CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER ScrollConsoleScreenBufferRequest; - CSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest; + + /* Handles */ CSRSS_GET_INPUT_HANDLE GetInputHandleRequest; CSRSS_GET_OUTPUT_HANDLE GetOutputHandleRequest; CSRSS_CLOSE_HANDLE CloseHandleRequest; CSRSS_VERIFY_HANDLE VerifyHandleRequest; CSRSS_DUPLICATE_HANDLE DuplicateHandleRequest; CSRSS_GET_INPUT_WAIT_HANDLE GetConsoleInputWaitHandle; + + /* Cursor */ + CSRSS_SET_CURSOR SetCursorRequest; + CSRSS_GET_CURSOR_INFO GetCursorInfoRequest; + CSRSS_SET_CURSOR_INFO SetCursorInfoRequest; + + CSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest; + + /* Screen buffer */ + CSRSS_CREATE_SCREEN_BUFFER CreateScreenBufferRequest; + CSRSS_SET_SCREEN_BUFFER SetScreenBufferRequest; + CSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest; + CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize; + CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER ScrollConsoleScreenBufferRequest; + + CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo; + + /* Console mode */ + CSRSS_SET_CONSOLE_MODE SetConsoleModeRequest; + CSRSS_GET_CONSOLE_MODE GetConsoleModeRequest; CSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest; + + /* Console window */ + CSRSS_SET_TITLE SetTitleRequest; + CSRSS_GET_TITLE GetTitleRequest; CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest; CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest; @@ -608,6 +614,17 @@ CSRSS_GET_CONSOLE_INPUT GetConsoleInputRequest; // SrvGetConsoleInput / PeekConsoleInput & ReadConsoleInput CSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest; // SrvReadConsoleOutput / ReadConsoleOutput CSRSS_READ_CONSOLE_OUTPUT_CODE ReadConsoleOutputCodeRequest; // SrvReadConsoleOutputString / ReadConsoleOutputAttribute & ReadConsoleOutputCharacter + + /* Write */ + CSRSS_WRITE_CONSOLE WriteConsoleRequest; + CSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest; + CSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest; + CSRSS_WRITE_CONSOLE_OUTPUT_CHAR WriteConsoleOutputCharRequest; + CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest; + + CSRSS_FILL_OUTPUT FillOutputRequest; + CSRSS_FILL_OUTPUT_ATTRIB FillOutputAttribRequest; + CSRSS_SET_ATTRIB SetAttribRequest; /* Aliases */ CSRSS_CONSOLE_ALIAS ConsoleAlias; @@ -625,12 +642,13 @@ CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent; CSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest; - CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize; - CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo; + + /* CodePage */ CSRSS_GET_CONSOLE_CP GetConsoleCodePage; CSRSS_SET_CONSOLE_CP SetConsoleCodePage; CSRSS_GET_CONSOLE_OUTPUT_CP GetConsoleOutputCodePage; CSRSS_SET_CONSOLE_OUTPUT_CP SetConsoleOutputCodePage; + CSRSS_GET_PROCESS_LIST GetProcessListRequest; } Data; } CONSOLE_API_MESSAGE, *PCONSOLE_API_MESSAGE;
11 years, 11 months
1
0
0
0
[hbelusca] 57721: [KERNEL32/CONSRV] - Move the waiting loop of IntReadConsole into SrvReadConsole instead. - Merge IntPeekConsoleInput and IntReadConsoleInput helpers into a single IntGetConsoleInp...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Nov 17 21:39:41 2012 New Revision: 57721 URL:
http://svn.reactos.org/svn/reactos?rev=57721&view=rev
Log: [KERNEL32/CONSRV] - Move the waiting loop of IntReadConsole into SrvReadConsole instead. - Merge IntPeekConsoleInput and IntReadConsoleInput helpers into a single IntGetConsoleInput helper function and make PeekConsoleInputW/A and ReadConsoleInputW/A use it. Indeed, the "only" difference between these two functions, is that the first one keeps the data read inside the console input buffer, but on the contrary the second removes the data and does not return until at least one input record has been read. In server-side, CsrReadInputEvent and CsrPeekConsoleInput are merged into SrvGetConsoleInput. Merge the corresponding structures. - Use shorter variable names in IntReadConsoleOutput and use CONSOLE_PROCESS_DATA structure in SrvReadConsoleOutput. - Merge IntReadConsoleOutputCharacter and ReadConsoleOutputAttribute functions into a single IntReadConsoleOutputCode helper function, and make ReadConsoleOutputAttribute and ReadConsoleOutputCharacterW/A use it. In server-side, CsrReadConsoleOutputChar and CsrReadConsoleOutputAttrib are merged into SrvReadConsoleOutputString. (Remark: the SrvReadConsoleOutputString name comes from
http://j00ru.vexillium.org/csrss_list/api_list.html
and I checked that it was indeed the server function that was called by both ReadConsoleOutputAttribute and ReadConsoleOutputCharacter). The idea behind merging these two functions is, that an attribute or a character are instances of the same entity, namely a "code" (what would be called an (ANSI) escape sequence). Therefore I encode them inside the same CSRSS_READ_CONSOLE_OUTPUT_CODE structure and I use it with the previous functions. [CONSRV] - Make use of the CONSOLE_PROCESS_DATA structure (introduced in r57685). - Use CsrValidateMessageBuffer instead of Win32CsrValidateBuffer. - Reorganize conmsg.h a little bit. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c branches/ros-csrss/include/reactos/subsys/win/conmsg.h branches/ros-csrss/win32ss/user/consrv/coninput.c branches/ros-csrss/win32ss/user/consrv/conoutput.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] Sat Nov 17 21:39:41 2012 @@ -33,13 +33,18 @@ PCONSOLE_READCONSOLE_CONTROL pInputControl, BOOL bUnicode) { - CSR_API_MESSAGE Request; - ULONG CsrRequest; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_READ_CONSOLE ReadConsoleRequest = &ApiMessage.Data.ReadConsoleRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status = STATUS_SUCCESS; - ULONG CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); - - CaptureBuffer = CsrAllocateCaptureBuffer(1, nNumberOfCharsToRead * CharSize); + ULONG CharSize; + + /* Determine the needed size */ + CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + ReadConsoleRequest->BufferSize = nNumberOfCharsToRead * CharSize; + + /* Allocate a Capture Buffer */ + CaptureBuffer = CsrAllocateCaptureBuffer(1, ReadConsoleRequest->BufferSize); if (CaptureBuffer == NULL) { DPRINT1("CsrAllocateCaptureBuffer failed!\n"); @@ -47,221 +52,193 @@ return FALSE; } + /* Allocate space in the Buffer */ CsrAllocateMessagePointer(CaptureBuffer, - nNumberOfCharsToRead * CharSize, - &Request.Data.ReadConsoleRequest.Buffer); - - Request.Data.ReadConsoleRequest.ConsoleHandle = hConsoleInput; - Request.Data.ReadConsoleRequest.Unicode = bUnicode; - Request.Data.ReadConsoleRequest.NrCharactersToRead = (WORD)nNumberOfCharsToRead; - Request.Data.ReadConsoleRequest.NrCharactersRead = 0; - Request.Data.ReadConsoleRequest.CtrlWakeupMask = 0; + ReadConsoleRequest->BufferSize, + (PVOID*)&ReadConsoleRequest->Buffer); + + ReadConsoleRequest->ConsoleHandle = hConsoleInput; + ReadConsoleRequest->Unicode = bUnicode; + ReadConsoleRequest->NrCharactersToRead = (WORD)nNumberOfCharsToRead; + ReadConsoleRequest->NrCharactersRead = 0; + ReadConsoleRequest->CtrlWakeupMask = 0; if (pInputControl && pInputControl->nLength == sizeof(CONSOLE_READCONSOLE_CONTROL)) { - Request.Data.ReadConsoleRequest.NrCharactersRead = pInputControl->nInitialChars; - memcpy(Request.Data.ReadConsoleRequest.Buffer, + ReadConsoleRequest->NrCharactersRead = pInputControl->nInitialChars; + memcpy(ReadConsoleRequest->Buffer, lpBuffer, pInputControl->nInitialChars * sizeof(WCHAR)); - Request.Data.ReadConsoleRequest.CtrlWakeupMask = pInputControl->dwCtrlWakeupMask; - } - - CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, READ_CONSOLE); - - do - { - if (Status == STATUS_PENDING) + ReadConsoleRequest->CtrlWakeupMask = pInputControl->dwCtrlWakeupMask; + } + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepReadConsole), + sizeof(CSRSS_READ_CONSOLE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + DPRINT1("CSR returned error in ReadConsole\n"); + CsrFreeCaptureBuffer(CaptureBuffer); + BaseSetLastNTError(Status); + return FALSE; + } + + memcpy(lpBuffer, + ReadConsoleRequest->Buffer, + ReadConsoleRequest->NrCharactersRead * CharSize); + + if (lpNumberOfCharsRead != NULL) + *lpNumberOfCharsRead = ReadConsoleRequest->NrCharactersRead; + + if (pInputControl && pInputControl->nLength == sizeof(CONSOLE_READCONSOLE_CONTROL)) + pInputControl->dwControlKeyState = ReadConsoleRequest->ControlKeyState; + + CsrFreeCaptureBuffer(CaptureBuffer); + + return TRUE; +} + + +static +BOOL +IntGetConsoleInput(HANDLE hConsoleInput, + BOOL bRead, + PINPUT_RECORD lpBuffer, + DWORD nLength, + LPDWORD lpNumberOfEventsRead, + BOOL bUnicode) +{ + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_GET_CONSOLE_INPUT GetConsoleInputRequest = &ApiMessage.Data.GetConsoleInputRequest; + PCSR_CAPTURE_BUFFER CaptureBuffer; + ULONG Size; + + if (lpBuffer == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + Size = nLength * sizeof(INPUT_RECORD); + + DPRINT("IntGetConsoleInput: %lx %p\n", Size, lpNumberOfEventsRead); + + /* Allocate a Capture Buffer */ + CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + /* Allocate space in the Buffer */ + CsrAllocateMessagePointer(CaptureBuffer, + Size, + (PVOID*)&GetConsoleInputRequest->InputRecord); + + /* Set up the data to send to the Console Server */ + GetConsoleInputRequest->ConsoleHandle = hConsoleInput; + GetConsoleInputRequest->Unicode = bUnicode; + GetConsoleInputRequest->bRead = bRead; + if (bRead == TRUE) + { + GetConsoleInputRequest->InputsRead = 0; + } + GetConsoleInputRequest->Length = nLength; + + /* Call the server */ + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetConsoleInput), + sizeof(CSRSS_GET_CONSOLE_INPUT)); + DPRINT("Server returned: %x\n", ApiMessage.Status); + +/** For Read only ** + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + // BaseSetLastNTError(Status); ???? + if (GetConsoleInputRequest->InputsRead == 0) { - Status = NtWaitForSingleObject(Request.Data.ReadConsoleRequest.EventHandle, - FALSE, - 0); - if (!NT_SUCCESS(Status)) - { - DPRINT1("Wait for console input failed!\n"); - break; - } - } - - Status = CsrClientCallServer(&Request, - CaptureBuffer, - CsrRequest, - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - DPRINT1("CSR returned error in ReadConsole\n"); - CsrFreeCaptureBuffer(CaptureBuffer); + /\* we couldn't read a single record, fail *\/ BaseSetLastNTError(Status); return FALSE; } - } - while (Status == STATUS_PENDING); - - memcpy(lpBuffer, - Request.Data.ReadConsoleRequest.Buffer, - Request.Data.ReadConsoleRequest.NrCharactersRead * CharSize); - - if (lpNumberOfCharsRead != NULL) - *lpNumberOfCharsRead = Request.Data.ReadConsoleRequest.NrCharactersRead; - - if (pInputControl && pInputControl->nLength == sizeof(CONSOLE_READCONSOLE_CONTROL)) - pInputControl->dwControlKeyState = Request.Data.ReadConsoleRequest.ControlKeyState; - - CsrFreeCaptureBuffer(CaptureBuffer); - - return TRUE; -} - - -static -BOOL -IntPeekConsoleInput(HANDLE hConsoleInput, - PINPUT_RECORD lpBuffer, - DWORD nLength, - LPDWORD lpNumberOfEventsRead, - BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - ULONG Size; - - if (lpBuffer == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - Size = nLength * sizeof(INPUT_RECORD); - - /* Allocate a Capture Buffer */ - DPRINT("IntPeekConsoleInput: %lx %p\n", Size, lpNumberOfEventsRead); - CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); - if (CaptureBuffer == NULL) - { - DPRINT1("CsrAllocateCaptureBuffer failed!\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - /* Allocate space in the Buffer */ - CsrCaptureMessageBuffer(CaptureBuffer, - NULL, - Size, - (PVOID*)&Request.Data.PeekConsoleInputRequest.InputRecord); - - /* Set up the data to send to the Console Server */ - Request.Data.PeekConsoleInputRequest.ConsoleHandle = hConsoleInput; - Request.Data.PeekConsoleInputRequest.Unicode = bUnicode; - Request.Data.PeekConsoleInputRequest.Length = nLength; - - /* Call the server */ - CsrClientCallServer(&Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, PEEK_CONSOLE_INPUT), - sizeof(CSR_API_MESSAGE)); - DPRINT("Server returned: %x\n", Request.Status); - - /* Check for success*/ - if (NT_SUCCESS(Request.Status)) - { - /* Return the number of events read */ - DPRINT("Events read: %lx\n", Request.Data.PeekConsoleInputRequest.Length); - *lpNumberOfEventsRead = Request.Data.PeekConsoleInputRequest.Length; - - /* Copy into the buffer */ - DPRINT("Copying to buffer\n"); - RtlCopyMemory(lpBuffer, - Request.Data.PeekConsoleInputRequest.InputRecord, - sizeof(INPUT_RECORD) * *lpNumberOfEventsRead); - } - else - { - /* Error out */ - *lpNumberOfEventsRead = 0; - BaseSetLastNTError(Request.Status); - } - - /* Release the capture buffer */ - CsrFreeCaptureBuffer(CaptureBuffer); - - /* Return TRUE or FALSE */ - return NT_SUCCESS(Request.Status); -} - - -static -BOOL -IntReadConsoleInput(HANDLE hConsoleInput, - PINPUT_RECORD lpBuffer, - DWORD nLength, - LPDWORD lpNumberOfEventsRead, - BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - ULONG CsrRequest; - ULONG Read; - NTSTATUS Status; - - CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, READ_INPUT); - Read = 0; - - while (nLength > 0) - { - Request.Data.ReadInputRequest.ConsoleHandle = hConsoleInput; - Request.Data.ReadInputRequest.Unicode = bUnicode; - - Status = CsrClientCallServer(&Request, - NULL, - CsrRequest, - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + else { - if (Read == 0) - { - /* we couldn't read a single record, fail */ - BaseSetLastNTError(Status); - return FALSE; - } - else - { - /* FIXME - fail gracefully in case we already read at least one record? */ - break; - } + /\* FIXME - fail gracefully in case we already read at least one record? *\/ + // break; } - else if (Status == STATUS_PENDING) + } +**/ + + /** + ** TODO: !! Simplify the function !! + **/ + if (bRead == TRUE) // ReadConsoleInput call. + { + /* Check for success */ + if (NT_SUCCESS(Status) || NT_SUCCESS(Status = ApiMessage.Status)) { - if (Read == 0) - { - Status = NtWaitForSingleObject(Request.Data.ReadInputRequest.Event, FALSE, 0); - if (!NT_SUCCESS(Status)) - { - BaseSetLastNTError(Status); - break; - } - } - else - { - /* nothing more to read (waiting for more input??), let's just bail */ - break; - } + /* Return the number of events read */ + DPRINT("Events read: %lx\n", GetConsoleInputRequest->InputsRead/*Length*/); + + if (lpNumberOfEventsRead != NULL) + *lpNumberOfEventsRead = GetConsoleInputRequest->InputsRead/*Length*/; + + /* Copy into the buffer */ + DPRINT("Copying to buffer\n"); + RtlCopyMemory(lpBuffer, + GetConsoleInputRequest->InputRecord, + sizeof(INPUT_RECORD) * GetConsoleInputRequest->InputsRead/*Length*/); } else { - lpBuffer[Read++] = Request.Data.ReadInputRequest.Input; - nLength--; - - if (!Request.Data.ReadInputRequest.MoreEvents) - { - /* nothing more to read, bail */ - break; - } + if (lpNumberOfEventsRead != NULL) + *lpNumberOfEventsRead = 0; + + /* Error out */ + BaseSetLastNTError(ApiMessage.Status); } - } - - if (lpNumberOfEventsRead != NULL) - { - *lpNumberOfEventsRead = Read; - } - - return (Read > 0); + + /* Release the capture buffer */ + CsrFreeCaptureBuffer(CaptureBuffer); + + return (GetConsoleInputRequest->InputsRead > 0); + } + else // PeekConsoleInput call. + { + /* Check for success */ + if (NT_SUCCESS(Status) || NT_SUCCESS(ApiMessage.Status)) + { + /* Return the number of events read */ + DPRINT("Events read: %lx\n", GetConsoleInputRequest->Length); + + if (lpNumberOfEventsRead != NULL) + *lpNumberOfEventsRead = GetConsoleInputRequest->Length; + + /* Copy into the buffer */ + DPRINT("Copying to buffer\n"); + RtlCopyMemory(lpBuffer, + GetConsoleInputRequest->InputRecord, + sizeof(INPUT_RECORD) * GetConsoleInputRequest->Length); + } + else + { + if (lpNumberOfEventsRead != NULL) + *lpNumberOfEventsRead = 0; + + /* Error out */ + BaseSetLastNTError(ApiMessage.Status); + } + + /* Release the capture buffer */ + CsrFreeCaptureBuffer(CaptureBuffer); + + /* Return TRUE or FALSE */ + return NT_SUCCESS(ApiMessage.Status); + } } @@ -274,7 +251,8 @@ PSMALL_RECT lpReadRegion, BOOL bUnicode) { - CSR_API_MESSAGE Request; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest = &ApiMessage.Data.ReadConsoleOutputRequest; PCSR_CAPTURE_BUFFER CaptureBuffer; DWORD Size, SizeX, SizeY; @@ -286,8 +264,9 @@ Size = dwBufferSize.X * dwBufferSize.Y * sizeof(CHAR_INFO); + DPRINT("IntReadConsoleOutput: %lx %p\n", Size, lpReadRegion); + /* Allocate a Capture Buffer */ - DPRINT("IntReadConsoleOutput: %lx %p\n", Size, lpReadRegion); CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); if (CaptureBuffer == NULL) { @@ -297,124 +276,140 @@ } /* Allocate space in the Buffer */ - CsrCaptureMessageBuffer(CaptureBuffer, - NULL, - Size, - (PVOID*)&Request.Data.ReadConsoleOutputRequest.CharInfo); + CsrAllocateMessagePointer(CaptureBuffer, + Size, + (PVOID*)&ReadConsoleOutputRequest->CharInfo); /* Set up the data to send to the Console Server */ - Request.Data.ReadConsoleOutputRequest.ConsoleHandle = hConsoleOutput; - Request.Data.ReadConsoleOutputRequest.Unicode = bUnicode; - Request.Data.ReadConsoleOutputRequest.BufferSize = dwBufferSize; - Request.Data.ReadConsoleOutputRequest.BufferCoord = dwBufferCoord; - Request.Data.ReadConsoleOutputRequest.ReadRegion = *lpReadRegion; + ReadConsoleOutputRequest->ConsoleHandle = hConsoleOutput; + ReadConsoleOutputRequest->Unicode = bUnicode; + ReadConsoleOutputRequest->BufferSize = dwBufferSize; + ReadConsoleOutputRequest->BufferCoord = dwBufferCoord; + ReadConsoleOutputRequest->ReadRegion = *lpReadRegion; /* Call the server */ - CsrClientCallServer(&Request, + CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, READ_CONSOLE_OUTPUT), - sizeof(CSR_API_MESSAGE)); - DPRINT("Server returned: %x\n", Request.Status); + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepReadConsoleOutput), + sizeof(CSRSS_READ_CONSOLE_OUTPUT)); + DPRINT("Server returned: %x\n", ApiMessage.Status); /* Check for success*/ - if (NT_SUCCESS(Request.Status)) + if (NT_SUCCESS(ApiMessage.Status)) { /* Copy into the buffer */ DPRINT("Copying to buffer\n"); - SizeX = Request.Data.ReadConsoleOutputRequest.ReadRegion.Right - - Request.Data.ReadConsoleOutputRequest.ReadRegion.Left + 1; - SizeY = Request.Data.ReadConsoleOutputRequest.ReadRegion.Bottom - - Request.Data.ReadConsoleOutputRequest.ReadRegion.Top + 1; + SizeX = ReadConsoleOutputRequest->ReadRegion.Right - + ReadConsoleOutputRequest->ReadRegion.Left + 1; + SizeY = ReadConsoleOutputRequest->ReadRegion.Bottom - + ReadConsoleOutputRequest->ReadRegion.Top + 1; RtlCopyMemory(lpBuffer, - Request.Data.ReadConsoleOutputRequest.CharInfo, + ReadConsoleOutputRequest->CharInfo, sizeof(CHAR_INFO) * SizeX * SizeY); } else { /* Error out */ - BaseSetLastNTError(Request.Status); + BaseSetLastNTError(ApiMessage.Status); } /* Return the read region */ - DPRINT("read region: %lx\n", Request.Data.ReadConsoleOutputRequest.ReadRegion); - *lpReadRegion = Request.Data.ReadConsoleOutputRequest.ReadRegion; + DPRINT("read region: %lx\n", ReadConsoleOutputRequest->ReadRegion); + *lpReadRegion = ReadConsoleOutputRequest->ReadRegion; /* Release the capture buffer */ CsrFreeCaptureBuffer(CaptureBuffer); /* Return TRUE or FALSE */ - return NT_SUCCESS(Request.Status); + return NT_SUCCESS(ApiMessage.Status); } static BOOL -IntReadConsoleOutputCharacter(HANDLE hConsoleOutput, - PVOID lpCharacter, - DWORD nLength, - COORD dwReadCoord, - LPDWORD lpNumberOfCharsRead, - BOOL bUnicode) -{ - PCSR_API_MESSAGE Request; - ULONG CsrRequest; +IntReadConsoleOutputCode(HANDLE hConsoleOutput, + USHORT CodeType, + PVOID pCode, + DWORD nLength, + COORD dwReadCoord, + LPDWORD lpNumberOfCodesRead) +{ NTSTATUS Status; - ULONG SizeBytes, CharSize; - DWORD CharsRead = 0; - - CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); - - nLength = min(nLength, CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR / CharSize); - SizeBytes = nLength * CharSize; - - Request = RtlAllocateHeap(RtlGetProcessHeap(), 0, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR) + SizeBytes)); - if (Request == NULL) - { + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_READ_CONSOLE_OUTPUT_CODE ReadConsoleOutputCodeRequest = &ApiMessage.Data.ReadConsoleOutputCodeRequest; + PCSR_CAPTURE_BUFFER CaptureBuffer; + ULONG SizeBytes, CodeSize; + DWORD /*CodesRead = 0,*/ BytesRead; + + /* Determine the needed size */ + switch (CodeType) + { + case CODE_ASCII: + CodeSize = sizeof(CHAR); + break; + + case CODE_UNICODE: + CodeSize = sizeof(WCHAR); + break; + + case CODE_ATTRIBUTE: + CodeSize = sizeof(WORD); + break; + + default: + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + SizeBytes = nLength * CodeSize; + + /* Allocate a Capture Buffer */ + CaptureBuffer = CsrAllocateCaptureBuffer(1, SizeBytes); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); SetLastError(ERROR_NOT_ENOUGH_MEMORY); return FALSE; } - CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, READ_CONSOLE_OUTPUT_CHAR); - Request->Data.ReadConsoleOutputCharRequest.ReadCoord = dwReadCoord; - - while (nLength > 0) - { - DWORD BytesRead; - - Request->Data.ReadConsoleOutputCharRequest.ConsoleHandle = hConsoleOutput; - Request->Data.ReadConsoleOutputCharRequest.Unicode = bUnicode; - Request->Data.ReadConsoleOutputCharRequest.NumCharsToRead = nLength; - SizeBytes = Request->Data.ReadConsoleOutputCharRequest.NumCharsToRead * CharSize; - - Status = CsrClientCallServer(Request, - NULL, - CsrRequest, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR) + SizeBytes)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Request->Status)) + /* Allocate space in the Buffer */ + CsrAllocateMessagePointer(CaptureBuffer, + SizeBytes, + (PVOID*)&ReadConsoleOutputCodeRequest->pCode.pCode); + + /* Start reading */ + ReadConsoleOutputCodeRequest->ConsoleHandle = hConsoleOutput; + ReadConsoleOutputCodeRequest->CodeType = CodeType; + ReadConsoleOutputCodeRequest->ReadCoord = dwReadCoord; + + // while (nLength > 0) + { + ReadConsoleOutputCodeRequest->NumCodesToRead = nLength; + // SizeBytes = ReadConsoleOutputCodeRequest->NumCodesToRead * CodeSize; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepReadConsoleOutputString), + sizeof(CSRSS_READ_CONSOLE_OUTPUT_CODE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); BaseSetLastNTError(Status); - break; + CsrFreeCaptureBuffer(CaptureBuffer); + return FALSE; } - BytesRead = Request->Data.ReadConsoleOutputCharRequest.CharsRead * CharSize; - memcpy(lpCharacter, Request->Data.ReadConsoleOutputCharRequest.String, BytesRead); - lpCharacter = (PVOID)((ULONG_PTR)lpCharacter + (ULONG_PTR)BytesRead); - CharsRead += Request->Data.ReadConsoleOutputCharRequest.CharsRead; - nLength -= Request->Data.ReadConsoleOutputCharRequest.CharsRead; - - Request->Data.ReadConsoleOutputCharRequest.ReadCoord = Request->Data.ReadConsoleOutputCharRequest.EndCoord; - } - - if (lpNumberOfCharsRead != NULL) - { - *lpNumberOfCharsRead = CharsRead; - } - - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + BytesRead = ReadConsoleOutputCodeRequest->CodesRead * CodeSize; + memcpy(pCode, ReadConsoleOutputCodeRequest->pCode.pCode, BytesRead); + // pCode = (PVOID)((ULONG_PTR)pCode + /*(ULONG_PTR)*/BytesRead); + // nLength -= ReadConsoleOutputCodeRequest->CodesRead; + // CodesRead += ReadConsoleOutputCodeRequest->CodesRead; + + ReadConsoleOutputCodeRequest->ReadCoord = ReadConsoleOutputCodeRequest->EndCoord; + } + + if (lpNumberOfCodesRead != NULL) + *lpNumberOfCodesRead = /*CodesRead;*/ ReadConsoleOutputCodeRequest->CodesRead; + + CsrFreeCaptureBuffer(CaptureBuffer); return TRUE; } @@ -818,10 +813,12 @@ DWORD nLength, LPDWORD lpNumberOfEventsRead) { - return IntPeekConsoleInput(hConsoleInput, - lpBuffer, nLength, - lpNumberOfEventsRead, - TRUE); + return IntGetConsoleInput(hConsoleInput, + FALSE, + lpBuffer, + nLength, + lpNumberOfEventsRead, + TRUE); } @@ -837,11 +834,12 @@ DWORD nLength, LPDWORD lpNumberOfEventsRead) { - return IntPeekConsoleInput(hConsoleInput, - lpBuffer, - nLength, - lpNumberOfEventsRead, - FALSE); + return IntGetConsoleInput(hConsoleInput, + FALSE, + lpBuffer, + nLength, + lpNumberOfEventsRead, + FALSE); } @@ -857,11 +855,12 @@ DWORD nLength, LPDWORD lpNumberOfEventsRead) { - return IntReadConsoleInput(hConsoleInput, - lpBuffer, - nLength, - lpNumberOfEventsRead, - TRUE); + return IntGetConsoleInput(hConsoleInput, + TRUE, + lpBuffer, + nLength, + lpNumberOfEventsRead, + TRUE); } @@ -877,11 +876,12 @@ DWORD nLength, LPDWORD lpNumberOfEventsRead) { - return IntReadConsoleInput(hConsoleInput, - lpBuffer, - nLength, - lpNumberOfEventsRead, - FALSE); + return IntGetConsoleInput(hConsoleInput, + TRUE, + lpBuffer, + nLength, + lpNumberOfEventsRead, + FALSE); } @@ -960,12 +960,12 @@ COORD dwReadCoord, LPDWORD lpNumberOfCharsRead) { - return IntReadConsoleOutputCharacter(hConsoleOutput, - (PVOID)lpCharacter, - nLength, - dwReadCoord, - lpNumberOfCharsRead, - TRUE); + return IntReadConsoleOutputCode(hConsoleOutput, + CODE_UNICODE, + lpCharacter, + nLength, + dwReadCoord, + lpNumberOfCharsRead); } @@ -982,12 +982,12 @@ COORD dwReadCoord, LPDWORD lpNumberOfCharsRead) { - return IntReadConsoleOutputCharacter(hConsoleOutput, - (PVOID)lpCharacter, - nLength, - dwReadCoord, - lpNumberOfCharsRead, - FALSE); + return IntReadConsoleOutputCode(hConsoleOutput, + CODE_ASCII, + lpCharacter, + nLength, + dwReadCoord, + lpNumberOfCharsRead); } @@ -1004,60 +1004,12 @@ COORD dwReadCoord, LPDWORD lpNumberOfAttrsRead) { - PCSR_API_MESSAGE Request; - ULONG CsrRequest; - NTSTATUS Status; - DWORD Size; - - if (lpNumberOfAttrsRead != NULL) - *lpNumberOfAttrsRead = nLength; - - Request = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_ATTRIB) - + min (nLength, CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB / sizeof(WORD)) * sizeof(WORD))); - if (Request == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, READ_CONSOLE_OUTPUT_ATTRIB); - - while (nLength != 0) - { - Request->Data.ReadConsoleOutputAttribRequest.ConsoleHandle = hConsoleOutput; - Request->Data.ReadConsoleOutputAttribRequest.ReadCoord = dwReadCoord; - - if (nLength > CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB / sizeof(WORD)) - Size = CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB / sizeof(WCHAR); - else - Size = nLength; - - Request->Data.ReadConsoleOutputAttribRequest.NumAttrsToRead = Size; - - Status = CsrClientCallServer(Request, - NULL, - CsrRequest, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_ATTRIB) + Size * sizeof(WORD))); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Request->Status)) - { - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - BaseSetLastNTError(Status); - return FALSE; - } - - memcpy(lpAttribute, Request->Data.ReadConsoleOutputAttribRequest.Attribute, Size * sizeof(WORD)); - lpAttribute += Size; - nLength -= Size; - Request->Data.ReadConsoleOutputAttribRequest.ReadCoord = Request->Data.ReadConsoleOutputAttribRequest.EndCoord; - } - - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - - return TRUE; + return IntReadConsoleOutputCode(hConsoleOutput, + CODE_ATTRIBUTE, + lpAttribute, + nLength, + dwReadCoord, + lpNumberOfAttrsRead); } Modified: branches/ros-csrss/include/reactos/subsys/win/conmsg.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
============================================================================== --- branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original) +++ branches/ros-csrss/include/reactos/subsys/win/conmsg.h [iso-8859-1] Sat Nov 17 21:39:41 2012 @@ -25,7 +25,7 @@ ConsolepWriteConsoleInput, ConsolepReadConsoleOutput, ConsolepWriteConsoleOutput, - // ConsolepReadConsoleOutputString, + ConsolepReadConsoleOutputString, // ConsolepWriteConsoleOutputString, // ConsolepFillConsoleOutput, ConsolepGetMode, @@ -147,7 +147,10 @@ WORD NrCharactersToRead; WORD NrCharactersRead; HANDLE EventHandle; + PVOID Buffer; + ULONG BufferSize; + UNICODE_STRING ExeName; DWORD CtrlWakeupMask; DWORD ControlKeyState; @@ -206,15 +209,6 @@ { HANDLE ConsoleHandle; BOOL Unicode; - INPUT_RECORD Input; - BOOL MoreEvents; - HANDLE Event; -} CSRSS_READ_INPUT, *PCSRSS_READ_INPUT; - -typedef struct -{ - HANDLE ConsoleHandle; - BOOL Unicode; WORD Length; COORD Coord; COORD EndCoord; @@ -312,34 +306,55 @@ CHAR_INFO Fill; } CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER, *PCSRSS_SCROLL_CONSOLE_SCREEN_BUFFER; -typedef struct -{ - HANDLE ConsoleHandle; - BOOL Unicode; - DWORD NumCharsToRead; + +/* + * An attribute or a character are instances of the same entity, namely + * a "code" (what would be called an (ANSI) escape sequence). Therefore + * encode them inside the same structure. + */ +typedef enum _CODE_TYPE +{ + CODE_ASCII = 0x01, + CODE_UNICODE = 0x02, + CODE_ATTRIBUTE = 0x03 +} CODE_TYPE; + +typedef struct +{ + HANDLE ConsoleHandle; + CODE_TYPE CodeType; + + DWORD NumCodesToRead; COORD ReadCoord; COORD EndCoord; - DWORD CharsRead; - CHAR String[0]; -} CSRSS_READ_CONSOLE_OUTPUT_CHAR, *PCSRSS_READ_CONSOLE_OUTPUT_CHAR; - -typedef struct -{ - HANDLE ConsoleHandle; - DWORD NumAttrsToRead; - COORD ReadCoord; - COORD EndCoord; - WORD Attribute[0]; -} CSRSS_READ_CONSOLE_OUTPUT_ATTRIB, *PCSRSS_READ_CONSOLE_OUTPUT_ATTRIB; - - -typedef struct -{ - HANDLE ConsoleHandle; - BOOL Unicode; + + DWORD CodesRead; + + union + { + PVOID pCode; + PCHAR AsciiChar; + PWCHAR UnicodeChar; + PWORD Attribute; + } pCode; // Either a pointer to a character or to an attribute. +} CSRSS_READ_CONSOLE_OUTPUT_CODE, *PCSRSS_READ_CONSOLE_OUTPUT_CODE; + + +typedef struct +{ + HANDLE ConsoleHandle; + BOOL Unicode; + BOOL bRead; // TRUE --> Read ; FALSE --> Peek + DWORD Length; INPUT_RECORD* InputRecord; -} CSRSS_PEEK_CONSOLE_INPUT, *PCSRSS_PEEK_CONSOLE_INPUT; + + /** For Read **/ + ULONG InputsRead; + // INPUT_RECORD Input; + BOOL MoreEvents; + HANDLE Event; +} CSRSS_GET_CONSOLE_INPUT, *PCSRSS_GET_CONSOLE_INPUT; typedef struct { @@ -557,14 +572,12 @@ union { CSRSS_WRITE_CONSOLE WriteConsoleRequest; - CSRSS_READ_CONSOLE ReadConsoleRequest; CSRSS_ALLOC_CONSOLE AllocConsoleRequest; CSRSS_FREE_CONSOLE FreeConsoleRequest; CSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest; CSRSS_SET_CURSOR SetCursorRequest; CSRSS_FILL_OUTPUT FillOutputRequest; CSRSS_FILL_OUTPUT_ATTRIB FillOutputAttribRequest; - CSRSS_READ_INPUT ReadInputRequest; CSRSS_WRITE_CONSOLE_OUTPUT_CHAR WriteConsoleOutputCharRequest; CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest; CSRSS_GET_CURSOR_INFO GetCursorInfoRequest; @@ -579,10 +592,6 @@ CSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest; CSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest; CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER ScrollConsoleScreenBufferRequest; - CSRSS_READ_CONSOLE_OUTPUT_CHAR ReadConsoleOutputCharRequest; - CSRSS_READ_CONSOLE_OUTPUT_ATTRIB ReadConsoleOutputAttribRequest; - CSRSS_PEEK_CONSOLE_INPUT PeekConsoleInputRequest; - CSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest; CSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest; CSRSS_GET_INPUT_HANDLE GetInputHandleRequest; CSRSS_GET_OUTPUT_HANDLE GetOutputHandleRequest; @@ -594,12 +603,20 @@ CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest; CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest; + /* Read */ + CSRSS_READ_CONSOLE ReadConsoleRequest; // SrvReadConsole / ReadConsole + CSRSS_GET_CONSOLE_INPUT GetConsoleInputRequest; // SrvGetConsoleInput / PeekConsoleInput & ReadConsoleInput + CSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest; // SrvReadConsoleOutput / ReadConsoleOutput + CSRSS_READ_CONSOLE_OUTPUT_CODE ReadConsoleOutputCodeRequest; // SrvReadConsoleOutputString / ReadConsoleOutputAttribute & ReadConsoleOutputCharacter + + /* Aliases */ CSRSS_CONSOLE_ALIAS ConsoleAlias; CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAliases; CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength; CSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes; CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength; + /* History */ CSRSS_GET_COMMAND_HISTORY GetCommandHistory; CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength; CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory; Modified: branches/ros-csrss/win32ss/user/consrv/coninput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] Sat Nov 17 21:39:41 2012 @@ -211,16 +211,16 @@ if (NotChar) LastVirtualKey = msg->wParam; - DPRINT ("csrss: %s %s %s %s %02x %02x '%lc' %04x\n", - Down ? "down" : "up ", - (msg->message == WM_CHAR || msg->message == WM_SYSCHAR) ? - "char" : "key ", - Fake ? "fake" : "real", - NotChar ? "notc" : "char", - VirtualScanCode, - VirtualKeyCode, - (UnicodeChar >= L' ') ? UnicodeChar : L'.', - ShiftState); + DPRINT("CONSRV: %s %s %s %s %02x %02x '%lc' %04x\n", + Down ? "down" : "up ", + (msg->message == WM_CHAR || msg->message == WM_SYSCHAR) ? + "char" : "key ", + Fake ? "fake" : "real", + NotChar ? "notc" : "char", + VirtualScanCode, + VirtualKeyCode, + (UnicodeChar >= L' ') ? UnicodeChar : L'.', + ShiftState); if (Fake) return; @@ -232,13 +232,15 @@ (er.Event.KeyEvent.wVirtualKeyCode == 'C')) && (er.Event.KeyEvent.dwControlKeyState & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED) || KeyState[VK_CONTROL] & 0x80)) { - PCSR_PROCESS current; + PCONSOLE_PROCESS_DATA current; PLIST_ENTRY current_entry; + DPRINT1("Console_Api Ctrl-C\n"); + current_entry = Console->ProcessList.Flink; while (current_entry != &Console->ProcessList) { - current = CONTAINING_RECORD(current_entry, CSR_PROCESS, ConsoleLink); + current = CONTAINING_RECORD(current_entry, CONSOLE_PROCESS_DATA, ConsoleLink); current_entry = current_entry->Flink; ConioConsoleCtrlEvent((DWORD)CTRL_C_EVENT, current); } @@ -293,70 +295,164 @@ CSR_API(SrvGetConsoleInput) { NTSTATUS Status; - PCSRSS_PEEK_CONSOLE_INPUT PeekConsoleInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.PeekConsoleInputRequest; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCSRSS_GET_CONSOLE_INPUT GetConsoleInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetConsoleInputRequest; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); + PCSRSS_CONSOLE Console; + PLIST_ENTRY CurrentInput; + ConsoleInput* Input; + + DWORD Length; + PINPUT_RECORD InputRecord; + + DPRINT("SrvGetConsoleInput\n"); + + Status = ConioLockConsole(ProcessData, GetConsoleInputRequest->ConsoleHandle, &Console, GENERIC_READ); + if(!NT_SUCCESS(Status)) return Status; + + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&GetConsoleInputRequest->InputRecord, + GetConsoleInputRequest->Length, + sizeof(INPUT_RECORD))) + { + return STATUS_INVALID_PARAMETER; + } + + InputRecord = GetConsoleInputRequest->InputRecord; + Length = GetConsoleInputRequest->Length; + +/* + if (!Win32CsrValidateBuffer(ProcessData->Process, InputRecord, Length, sizeof(INPUT_RECORD))) + { + ConioUnlockConsole(Console); + return STATUS_ACCESS_VIOLATION; + } +*/ + + if (GetConsoleInputRequest->bRead) // Read input. + { + GetConsoleInputRequest->Event = ProcessData->ConsoleEvent; + + while (Length > 0) + { + BOOLEAN Done = FALSE; + + // GetConsoleInputRequest->Event = ProcessData->ConsoleEvent; + + /* only get input if there is any */ + CurrentInput = Console->InputEvents.Flink; + while (CurrentInput != &Console->InputEvents) + { + Input = CONTAINING_RECORD(CurrentInput, ConsoleInput, ListEntry); + CurrentInput = CurrentInput->Flink; + + if (Done) + { + GetConsoleInputRequest->MoreEvents = TRUE; + break; + } + + RemoveEntryList(&Input->ListEntry); + + if (!Done) + { + GetConsoleInputRequest->InputsRead++; + *InputRecord = Input->InputEvent; + /* HACK */ Length--; + + // GetConsoleInputRequest->Input = Input->InputEvent; + if (GetConsoleInputRequest->Unicode == FALSE) + { + // ConioInputEventToAnsi(Console, &GetConsoleInputRequest->Input); + ConioInputEventToAnsi(Console, InputRecord); + } + + InputRecord++; + Done = TRUE; + } + + HeapFree(ConSrvHeap, 0, Input); + } + + if (Done) + Status = STATUS_SUCCESS; + else + Status = STATUS_PENDING; + + if (IsListEmpty(&Console->InputEvents)) + { + ResetEvent(Console->ActiveEvent); + } + + if (Status == STATUS_PENDING) + { + if (GetConsoleInputRequest->InputsRead == 0) + { + Status = NtWaitForSingleObject(GetConsoleInputRequest->Event, FALSE, 0); + if (!NT_SUCCESS(Status)) + { + // BaseSetLastNTError(Status); + break; + } + } + else + { + /* nothing more to read (waiting for more input??), let's just bail */ + break; + } + } + else // Status != STATUS_PENDING ; == STATUS_SUCCESS + { + if (!GetConsoleInputRequest->MoreEvents) + { + /* nothing more to read, bail */ + break; + } + } + } + } + else // Peek input. + { + UINT NumInputs = 0; + + if (!IsListEmpty(&Console->InputEvents)) + { + CurrentInput = Console->InputEvents.Flink; + + while (CurrentInput != &Console->InputEvents && NumInputs < Length) + { + Input = CONTAINING_RECORD(CurrentInput, ConsoleInput, ListEntry); + + ++NumInputs; + *InputRecord = Input->InputEvent; + + if (GetConsoleInputRequest->Unicode == FALSE) + { + ConioInputEventToAnsi(Console, InputRecord); + } + + InputRecord++; + CurrentInput = CurrentInput->Flink; + } + } + + GetConsoleInputRequest->Length = NumInputs; + + Status = STATUS_SUCCESS; + } + + ConioUnlockConsole(Console); + + return Status; +} + +CSR_API(SrvWriteConsoleInput) +{ + NTSTATUS Status; + PCSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleInputRequest; + PINPUT_RECORD InputRecord; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); PCSRSS_CONSOLE Console; DWORD Length; - PLIST_ENTRY CurrentItem; - PINPUT_RECORD InputRecord; - ConsoleInput* Item; - UINT NumItems; - - DPRINT("SrvGetConsoleInput\n"); - - Status = ConioLockConsole(ProcessData, PeekConsoleInputRequest->ConsoleHandle, &Console, GENERIC_READ); - if(! NT_SUCCESS(Status)) - { - return Status; - } - - InputRecord = PeekConsoleInputRequest->InputRecord; - Length = PeekConsoleInputRequest->Length; - - if (!Win32CsrValidateBuffer(ProcessData, InputRecord, Length, sizeof(INPUT_RECORD))) - { - ConioUnlockConsole(Console); - return STATUS_ACCESS_VIOLATION; - } - - NumItems = 0; - - if (! IsListEmpty(&Console->InputEvents)) - { - CurrentItem = Console->InputEvents.Flink; - - while (CurrentItem != &Console->InputEvents && NumItems < Length) - { - Item = CONTAINING_RECORD(CurrentItem, ConsoleInput, ListEntry); - - ++NumItems; - *InputRecord = Item->InputEvent; - - if (PeekConsoleInputRequest->Unicode == FALSE) - { - ConioInputEventToAnsi(Console, InputRecord); - } - - InputRecord++; - CurrentItem = CurrentItem->Flink; - } - } - - ConioUnlockConsole(Console); - - PeekConsoleInputRequest->Length = NumItems; - - return STATUS_SUCCESS; -} - -CSR_API(SrvWriteConsoleInput) -{ - PCSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleInputRequest; - PINPUT_RECORD InputRecord; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; - PCSRSS_CONSOLE Console; - NTSTATUS Status; - DWORD Length; DWORD i; DPRINT("SrvWriteConsoleInput\n"); @@ -370,7 +466,7 @@ InputRecord = WriteConsoleInputRequest->InputRecord; Length = WriteConsoleInputRequest->Length; - if (!Win32CsrValidateBuffer(ProcessData, InputRecord, Length, sizeof(INPUT_RECORD))) + if (!Win32CsrValidateBuffer(ProcessData->Process, InputRecord, Length, sizeof(INPUT_RECORD))) { ConioUnlockConsole(Console); return STATUS_ACCESS_VIOLATION; @@ -398,6 +494,7 @@ CSR_API(SrvReadConsole) { + NTSTATUS Status; PCSRSS_READ_CONSOLE ReadConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleRequest; PLIST_ENTRY CurrentEntry; ConsoleInput *Input; @@ -405,31 +502,63 @@ PWCHAR UnicodeBuffer; ULONG i = 0; ULONG nNumberOfCharsToRead, CharSize; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); PCSRSS_CONSOLE Console; - NTSTATUS Status; DPRINT("SrvReadConsole\n"); CharSize = (ReadConsoleRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR)); nNumberOfCharsToRead = ReadConsoleRequest->NrCharactersToRead; + + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&ReadConsoleRequest->Buffer, + ReadConsoleRequest->BufferSize, + sizeof(BYTE))) + { + return STATUS_INVALID_PARAMETER; + } Buffer = (PCHAR)ReadConsoleRequest->Buffer; UnicodeBuffer = (PWCHAR)Buffer; - if (!Win32CsrValidateBuffer(ProcessData, Buffer, nNumberOfCharsToRead, CharSize)) + +/* + if (!Win32CsrValidateBuffer(ProcessData->Process, Buffer, nNumberOfCharsToRead, CharSize)) return STATUS_ACCESS_VIOLATION; - - if (ReadConsoleRequest->NrCharactersRead * sizeof(WCHAR) > nNumberOfCharsToRead * CharSize) - return STATUS_INVALID_PARAMETER; +*/ Status = ConioLockConsole(ProcessData, ReadConsoleRequest->ConsoleHandle, &Console, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } + if (!NT_SUCCESS(Status)) return Status; + + Status = STATUS_SUCCESS; ReadConsoleRequest->EventHandle = ProcessData->ConsoleEvent; + +/*** HACK: Enclosing do { ... } while (...) loop coming from kernel32 ***/ +do +{ + if (Status == STATUS_PENDING) + { + Status = NtWaitForSingleObject(ReadConsoleRequest->EventHandle, + FALSE, + 0); + if (!NT_SUCCESS(Status)) + { + DPRINT1("Wait for console input failed!\n"); + break; + } + } +/******/ + + if (ReadConsoleRequest->NrCharactersRead * sizeof(WCHAR) > nNumberOfCharsToRead * CharSize) + { + // return STATUS_INVALID_PARAMETER; + Status = STATUS_INVALID_PARAMETER; + break; + // goto done; + } + + // ReadConsoleRequest->EventHandle = ProcessData->ConsoleEvent; Status = STATUS_PENDING; /* we haven't read anything (yet) */ if (Console->Mode & ENABLE_LINE_INPUT) @@ -531,92 +660,32 @@ } done: ReadConsoleRequest->NrCharactersRead = i; + +/******/ +} +while (Status == STATUS_PENDING); +/*** HACK: Enclosing do { ... } while (...) loop coming from kernel32 ***/ + ConioUnlockConsole(Console); return Status; } -CSR_API(CsrReadInputEvent) -{ - PCSRSS_READ_INPUT ReadInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadInputRequest; - PLIST_ENTRY CurrentEntry; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; - PCSRSS_CONSOLE Console; +CSR_API(SrvFlushConsoleInputBuffer) +{ NTSTATUS Status; - BOOLEAN Done = FALSE; - ConsoleInput *Input; - - DPRINT("CsrReadInputEvent\n"); - - ReadInputRequest->Event = ProcessData->ConsoleEvent; - - Status = ConioLockConsole(ProcessData, ReadInputRequest->ConsoleHandle, &Console, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - - /* only get input if there is any */ - CurrentEntry = Console->InputEvents.Flink; - while (CurrentEntry != &Console->InputEvents) - { - Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry); - CurrentEntry = CurrentEntry->Flink; - - if (Done) - { - ReadInputRequest->MoreEvents = TRUE; - break; - } - - RemoveEntryList(&Input->ListEntry); - - if (!Done) - { - ReadInputRequest->Input = Input->InputEvent; - if (ReadInputRequest->Unicode == FALSE) - { - ConioInputEventToAnsi(Console, &ReadInputRequest->Input); - } - Done = TRUE; - } - - HeapFree(ConSrvHeap, 0, Input); - } - - if (Done) - Status = STATUS_SUCCESS; - else - Status = STATUS_PENDING; - - if (IsListEmpty(&Console->InputEvents)) - { - ResetEvent(Console->ActiveEvent); - } - - ConioUnlockConsole(Console); - - return Status; -} - -CSR_API(SrvFlushConsoleInputBuffer) -{ PCSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FlushInputBufferRequest; PLIST_ENTRY CurrentEntry; PCSRSS_CONSOLE Console; ConsoleInput* Input; - NTSTATUS Status; DPRINT("SrvFlushConsoleInputBuffer\n"); - Status = ConioLockConsole(CsrGetClientThread()->Process, + Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), FlushInputBufferRequest->ConsoleInput, &Console, GENERIC_WRITE); - if(! NT_SUCCESS(Status)) - { - return Status; - } + if(!NT_SUCCESS(Status)) return Status; /* Discard all entries in the input event queue */ while (!IsListEmpty(&Console->InputEvents)) @@ -638,24 +707,21 @@ NTSTATUS Status; PCSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetNumInputEventsRequest; PCSRSS_CONSOLE Console; - PLIST_ENTRY CurrentItem; + PLIST_ENTRY CurrentInput; DWORD NumEvents; DPRINT("SrvGetConsoleNumberOfInputEvents\n"); - Status = ConioLockConsole(CsrGetClientThread()->Process, GetNumInputEventsRequest->ConsoleHandle, &Console, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - - CurrentItem = Console->InputEvents.Flink; + Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), GetNumInputEventsRequest->ConsoleHandle, &Console, GENERIC_READ); + if (!NT_SUCCESS(Status)) return Status; + + CurrentInput = Console->InputEvents.Flink; NumEvents = 0; /* If there are any events ... */ - while (CurrentItem != &Console->InputEvents) - { - CurrentItem = CurrentItem->Flink; + while (CurrentInput != &Console->InputEvents) + { + CurrentInput = CurrentInput->Flink; NumEvents++; } Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Sat Nov 17 21:39:41 2012 @@ -436,7 +436,7 @@ CSR_API(SrvReadConsoleOutput) { PCSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleOutputRequest; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); PCHAR_INFO CharInfo; PCHAR_INFO CurCharInfo; PCSRSS_SCREEN_BUFFER Buff; @@ -453,26 +453,32 @@ DPRINT("SrvReadConsoleOutput\n"); - Status = ConioLockScreenBuffer(ProcessData, ReadConsoleOutputRequest->ConsoleHandle, &Buff, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - CharInfo = ReadConsoleOutputRequest->CharInfo; ReadRegion = ReadConsoleOutputRequest->ReadRegion; BufferSize = ReadConsoleOutputRequest->BufferSize; BufferCoord = ReadConsoleOutputRequest->BufferCoord; + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&ReadConsoleOutputRequest->CharInfo, + BufferSize.X * BufferSize.Y, + sizeof(CHAR_INFO))) + { + return STATUS_INVALID_PARAMETER; + } +/* + if (!Win32CsrValidateBuffer(ProcessData->Process, CharInfo, + BufferSize.X * BufferSize.Y, sizeof(CHAR_INFO))) + { + ConioUnlockScreenBuffer(Buff); + return STATUS_ACCESS_VIOLATION; + } +*/ + + Status = ConioLockScreenBuffer(ProcessData, ReadConsoleOutputRequest->ConsoleHandle, &Buff, GENERIC_READ); + if (!NT_SUCCESS(Status)) return Status; + /* FIXME: Is this correct? */ CodePage = ProcessData->Console->OutputCodePage; - - if (!Win32CsrValidateBuffer(ProcessData, CharInfo, - BufferSize.X * BufferSize.Y, sizeof(CHAR_INFO))) - { - ConioUnlockScreenBuffer(Buff); - return STATUS_ACCESS_VIOLATION; - } SizeY = min(BufferSize.Y - BufferCoord.Y, ConioRectHeight(&ReadRegion)); SizeX = min(BufferSize.X - BufferCoord.X, ConioRectWidth(&ReadRegion)); @@ -480,7 +486,7 @@ ReadRegion.Right = ReadRegion.Left + SizeX; ConioInitRect(&ScreenRect, 0, 0, Buff->MaxY, Buff->MaxX); - if (! ConioGetIntersection(&ReadRegion, &ScreenRect, &ReadRegion)) + if (!ConioGetIntersection(&ReadRegion, &ScreenRect, &ReadRegion)) { ConioUnlockScreenBuffer(Buff); return STATUS_SUCCESS; @@ -495,6 +501,7 @@ { if (ReadConsoleOutputRequest->Unicode) { + // ConsoleAnsiCharToUnicodeChar(ProcessData->Console, (PCHAR)Ptr++, &CurCharInfo->Char.UnicodeChar); MultiByteToWideChar(CodePage, 0, (PCHAR)Ptr++, 1, &CurCharInfo->Char.UnicodeChar, 1); @@ -691,45 +698,82 @@ return STATUS_SUCCESS; } -CSR_API(CsrReadConsoleOutputChar) -{ - NTSTATUS Status; - PCSRSS_READ_CONSOLE_OUTPUT_CHAR ReadConsoleOutputCharRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleOutputCharRequest; +CSR_API(SrvReadConsoleOutputString) +{ + NTSTATUS Status; + PCSRSS_READ_CONSOLE_OUTPUT_CODE ReadConsoleOutputCodeRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleOutputCodeRequest; PCSRSS_CONSOLE Console; PCSRSS_SCREEN_BUFFER Buff; + USHORT CodeType; DWORD Xpos, Ypos; - PCHAR ReadBuffer; + PVOID ReadBuffer; DWORD i; - ULONG CharSize; - CHAR Char; - - DPRINT("CsrReadConsoleOutputChar\n"); - - ReadBuffer = ReadConsoleOutputCharRequest->String; - - CharSize = (ReadConsoleOutputCharRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR)); - - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, ReadConsoleOutputCharRequest->ConsoleHandle, &Buff, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } + ULONG CodeSize; + BYTE Code; + + DPRINT("SrvReadConsoleOutputString\n"); + + ReadBuffer = ReadConsoleOutputCodeRequest->pCode.pCode; + + CodeType = ReadConsoleOutputCodeRequest->CodeType; + switch (CodeType) + { + case CODE_ASCII: + CodeSize = sizeof(CHAR); + break; + + case CODE_UNICODE: + CodeSize = sizeof(WCHAR); + break; + + case CODE_ATTRIBUTE: + CodeSize = sizeof(WORD); + break; + + default: + return STATUS_INVALID_PARAMETER; + } + + Status = ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process), ReadConsoleOutputCodeRequest->ConsoleHandle, &Buff, GENERIC_READ); + if (!NT_SUCCESS(Status)) return Status; + Console = Buff->Header.Console; - Xpos = ReadConsoleOutputCharRequest->ReadCoord.X; - Ypos = (ReadConsoleOutputCharRequest->ReadCoord.Y + Buff->VirtualY) % Buff->MaxY; - - for (i = 0; i < ReadConsoleOutputCharRequest->NumCharsToRead; ++i) - { - Char = Buff->Buffer[(Xpos * 2) + (Ypos * 2 * Buff->MaxX)]; - - if(ReadConsoleOutputCharRequest->Unicode) - { - ConsoleAnsiCharToUnicodeChar(Console, (WCHAR*)ReadBuffer, &Char); - ReadBuffer += sizeof(WCHAR); - } - else - *(ReadBuffer++) = Char; + Xpos = ReadConsoleOutputCodeRequest->ReadCoord.X; + Ypos = (ReadConsoleOutputCodeRequest->ReadCoord.Y + Buff->VirtualY) % Buff->MaxY; + + /* + * MSDN (ReadConsoleOutputAttribute and ReadConsoleOutputCharacter) : + * + * If the number of attributes (resp. characters) to be read from extends + * beyond the end of the specified screen buffer row, attributes (resp. + * characters) are read from the next row. If the number of attributes + * (resp. characters) to be read from extends beyond the end of the console + * screen buffer, attributes (resp. characters) up to the end of the console + * screen buffer are read. + * + * TODO: Do NOT loop up to NumCodesToRead, but stop before + * if we are going to overflow... + */ + for (i = 0; i < ReadConsoleOutputCodeRequest->NumCodesToRead; ++i) + { + Code = Buff->Buffer[2 * (Xpos + Ypos * Buff->MaxX) + (CodeType == CODE_ATTRIBUTE ? 1 : 0)]; + + switch (CodeType) + { + case CODE_UNICODE: + ConsoleAnsiCharToUnicodeChar(Console, (PWCHAR)ReadBuffer, (PCHAR)&Code); + break; + + case CODE_ASCII: + *(PCHAR)ReadBuffer = (CHAR)Code; + break; + + case CODE_ATTRIBUTE: + *(PWORD)ReadBuffer = (WORD)Code; + break; + } + ReadBuffer = (PVOID)((ULONG_PTR)ReadBuffer + CodeSize); Xpos++; @@ -745,78 +789,28 @@ } } - *ReadBuffer = 0; - ReadConsoleOutputCharRequest->EndCoord.X = Xpos; - ReadConsoleOutputCharRequest->EndCoord.Y = (Ypos - Buff->VirtualY + Buff->MaxY) % Buff->MaxY; + switch (CodeType) + { + case CODE_UNICODE: + *(PWCHAR)ReadBuffer = 0; + break; + + case CODE_ASCII: + *(PCHAR)ReadBuffer = 0; + break; + + case CODE_ATTRIBUTE: + *(PWORD)ReadBuffer = 0; + break; + } + + ReadConsoleOutputCodeRequest->EndCoord.X = Xpos; + ReadConsoleOutputCodeRequest->EndCoord.Y = (Ypos - Buff->VirtualY + Buff->MaxY) % Buff->MaxY; ConioUnlockScreenBuffer(Buff); - ReadConsoleOutputCharRequest->CharsRead = (DWORD)((ULONG_PTR)ReadBuffer - (ULONG_PTR)ReadConsoleOutputCharRequest->String) / CharSize; - if (ReadConsoleOutputCharRequest->CharsRead * CharSize + CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR) > sizeof(CSR_API_MESSAGE)) - { - DPRINT1("Length won't fit in message\n"); - return STATUS_BUFFER_TOO_SMALL; - } - - return STATUS_SUCCESS; -} - -CSR_API(CsrReadConsoleOutputAttrib) -{ - NTSTATUS Status; - PCSRSS_READ_CONSOLE_OUTPUT_ATTRIB ReadConsoleOutputAttribRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleOutputAttribRequest; - PCSRSS_SCREEN_BUFFER Buff; - DWORD Xpos, Ypos; - PWORD ReadBuffer; - DWORD i; - DWORD CurrentLength; - - DPRINT("CsrReadConsoleOutputAttrib\n"); - - ReadBuffer = ReadConsoleOutputAttribRequest->Attribute; - - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, ReadConsoleOutputAttribRequest->ConsoleHandle, &Buff, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - - Xpos = ReadConsoleOutputAttribRequest->ReadCoord.X; - Ypos = (ReadConsoleOutputAttribRequest->ReadCoord.Y + Buff->VirtualY) % Buff->MaxY; - - for (i = 0; i < ReadConsoleOutputAttribRequest->NumAttrsToRead; ++i) - { - *ReadBuffer = Buff->Buffer[(Xpos * 2) + (Ypos * 2 * Buff->MaxX) + 1]; - - ReadBuffer++; - Xpos++; - - if (Xpos == Buff->MaxX) - { - Xpos = 0; - Ypos++; - - if (Ypos == Buff->MaxY) - { - Ypos = 0; - } - } - } - - *ReadBuffer = 0; - - ReadConsoleOutputAttribRequest->EndCoord.X = Xpos; - ReadConsoleOutputAttribRequest->EndCoord.Y = (Ypos - Buff->VirtualY + Buff->MaxY) % Buff->MaxY; - - ConioUnlockScreenBuffer(Buff); - - CurrentLength = CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_ATTRIB) - + ReadConsoleOutputAttribRequest->NumAttrsToRead * sizeof(WORD); - if (CurrentLength > sizeof(CSR_API_MESSAGE)) - { - DPRINT1("Length won't fit in message\n"); - return STATUS_BUFFER_TOO_SMALL; - } + ReadConsoleOutputCodeRequest->CodesRead = (DWORD)((ULONG_PTR)ReadBuffer - (ULONG_PTR)ReadConsoleOutputCodeRequest->pCode.pCode) / CodeSize; + // <= ReadConsoleOutputCodeRequest->NumCodesToRead return STATUS_SUCCESS; }
11 years, 11 months
1
0
0
0
[hbelusca] 57720: [CONSRV] Use CsrValidateMessageBuffer instead of Win32CsrValidateBuffer.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Nov 17 20:05:52 2012 New Revision: 57720 URL:
http://svn.reactos.org/svn/reactos?rev=57720&view=rev
Log: [CONSRV] Use CsrValidateMessageBuffer instead of Win32CsrValidateBuffer. Modified: branches/ros-csrss/win32ss/user/consrv/lineinput.c Modified: branches/ros-csrss/win32ss/user/consrv/lineinput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/l…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/lineinput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/lineinput.c [iso-8859-1] Sat Nov 17 20:05:52 2012 @@ -152,21 +152,30 @@ CSR_API(SrvGetConsoleCommandHistoryLength) { PCSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistoryLength; - PCSR_PROCESS Process = CsrGetClientThread()->Process; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); PCSRSS_CONSOLE Console; NTSTATUS Status; PHISTORY_BUFFER Hist; ULONG Length = 0; INT i; - if (!Win32CsrValidateBuffer(Process, + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&GetCommandHistoryLength->ExeName.Buffer, + GetCommandHistoryLength->ExeName.Length, + sizeof(BYTE))) + { + return STATUS_INVALID_PARAMETER; + } +/* + if (!Win32CsrValidateBuffer(ProcessData->Process, GetCommandHistoryLength->ExeName.Buffer, GetCommandHistoryLength->ExeName.Length, 1)) { return STATUS_ACCESS_VIOLATION; } - - Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(Process), &Console); +*/ + + Status = ConioConsoleFromProcessData(ProcessData, &Console); if (NT_SUCCESS(Status)) { Hist = HistoryFindBuffer(Console, &GetCommandHistoryLength->ExeName); @@ -184,7 +193,7 @@ CSR_API(SrvGetConsoleCommandHistory) { PCSRSS_GET_COMMAND_HISTORY GetCommandHistory = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetCommandHistory; - PCSR_PROCESS Process = CsrGetClientThread()->Process; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); PCSRSS_CONSOLE Console; NTSTATUS Status; PHISTORY_BUFFER Hist; @@ -192,15 +201,28 @@ ULONG BufferSize = GetCommandHistory->Length; INT i; - if (!Win32CsrValidateBuffer(Process, Buffer, BufferSize, 1) || - !Win32CsrValidateBuffer(Process, + if ( !CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&GetCommandHistory->History, + GetCommandHistory->Length, + sizeof(BYTE)) || + !CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&GetCommandHistory->ExeName.Buffer, + GetCommandHistory->ExeName.Length, + sizeof(BYTE)) ) + { + return STATUS_INVALID_PARAMETER; + } +/* + if (!Win32CsrValidateBuffer(ProcessData->Process, Buffer, BufferSize, 1) || + !Win32CsrValidateBuffer(ProcessData->Process, GetCommandHistory->ExeName.Buffer, GetCommandHistory->ExeName.Length, 1)) { return STATUS_ACCESS_VIOLATION; } - - Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(Process), &Console); +*/ + + Status = ConioConsoleFromProcessData(ProcessData, &Console); if (NT_SUCCESS(Status)) { Hist = HistoryFindBuffer(Console, &GetCommandHistory->ExeName); @@ -228,19 +250,28 @@ CSR_API(SrvExpungeConsoleCommandHistory) { PCSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ExpungeCommandHistory; - PCSR_PROCESS Process = CsrGetClientThread()->Process; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); PCSRSS_CONSOLE Console; PHISTORY_BUFFER Hist; NTSTATUS Status; - if (!Win32CsrValidateBuffer(Process, + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&ExpungeCommandHistory->ExeName.Buffer, + ExpungeCommandHistory->ExeName.Length, + sizeof(BYTE))) + { + return STATUS_INVALID_PARAMETER; + } +/* + if (!Win32CsrValidateBuffer(ProcessData->Process, ExpungeCommandHistory->ExeName.Buffer, ExpungeCommandHistory->ExeName.Length, 1)) { return STATUS_ACCESS_VIOLATION; } - - Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(Process), &Console); +*/ + + Status = ConioConsoleFromProcessData(ProcessData, &Console); if (NT_SUCCESS(Status)) { Hist = HistoryFindBuffer(Console, &ExpungeCommandHistory->ExeName); @@ -253,21 +284,30 @@ CSR_API(SrvSetConsoleNumberOfCommands) { PCSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryNumberCommands; - PCSR_PROCESS Process = CsrGetClientThread()->Process; + PCONSOLE_PROCESS_DATA ProcessData = ConsoleGetPerProcessData(CsrGetClientThread()->Process); PCSRSS_CONSOLE Console; PHISTORY_BUFFER Hist; NTSTATUS Status; UINT MaxEntries = SetHistoryNumberCommands->NumCommands; PUNICODE_STRING OldEntryList, NewEntryList; - if (!Win32CsrValidateBuffer(Process, + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID*)&SetHistoryNumberCommands->ExeName.Buffer, + SetHistoryNumberCommands->ExeName.Length, + sizeof(BYTE))) + { + return STATUS_INVALID_PARAMETER; + } +/* + if (!Win32CsrValidateBuffer(ProcessData->Process, SetHistoryNumberCommands->ExeName.Buffer, SetHistoryNumberCommands->ExeName.Length, 1)) { return STATUS_ACCESS_VIOLATION; } - - Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(Process), &Console); +*/ + + Status = ConioConsoleFromProcessData(ProcessData, &Console); if (NT_SUCCESS(Status)) { Hist = HistoryFindBuffer(Console, &SetHistoryNumberCommands->ExeName);
11 years, 11 months
1
0
0
0
[janderwald] 57719: - Fix build - Partly revert 57718
by janderwald@svn.reactos.org
Author: janderwald Date: Sat Nov 17 16:01:29 2012 New Revision: 57719 URL:
http://svn.reactos.org/svn/reactos?rev=57719&view=rev
Log: - Fix build - Partly revert 57718 Modified: trunk/reactos/base/applications/cmdutils/doskey/CMakeLists.txt trunk/reactos/base/applications/cmdutils/doskey/doskey.c trunk/reactos/base/system/diskpart/CMakeLists.txt trunk/reactos/base/system/diskpart/diskpart.c Modified: trunk/reactos/base/applications/cmdutils/doskey/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/doskey/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/doskey/CMakeLists.txt [iso-8859-1] Sat Nov 17 16:01:29 2012 @@ -3,6 +3,6 @@ add_executable(doskey doskey.c doskey.rc) -set_module_type(doskey win32cui) +set_module_type(doskey win32cui UNICODE) add_importlibs(doskey user32 msvcrt kernel32) add_cd_file(TARGET doskey DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/cmdutils/doskey/doskey.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/doskey/doskey.c [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/doskey/doskey.c [iso-8859-1] Sat Nov 17 16:01:29 2012 @@ -72,19 +72,19 @@ temp = *nameend; *nameend = L'\0'; /* Don't allow spaces in the name, since such a macro would be unusable */ - if (!wcschr(name, L' ') && AddConsoleAlias(name, text, pszExeName)) + if (!wcschr(name, L' ') && AddConsoleAliasW(name, text, pszExeName)) return 0; *nameend = temp; } - LoadString(GetModuleHandle(NULL), IDS_INVALID_MACRO_DEF, szStringBuf, MAX_STRING); + LoadStringW(GetModuleHandle(NULL), IDS_INVALID_MACRO_DEF, szStringBuf, MAX_STRING); wprintf(szStringBuf, definition); return 1; } static VOID PrintMacros(LPWSTR pszExeName, LPWSTR Indent) { - DWORD Length = GetConsoleAliasesLength(pszExeName); + DWORD Length = GetConsoleAliasesLengthW(pszExeName); PBYTE AliasBuf; WCHAR *Alias; WCHAR *AliasEnd; @@ -96,7 +96,7 @@ Alias = (WCHAR *)AliasBuf; AliasEnd = (WCHAR *)&AliasBuf[Length]; - if (GetConsoleAliases(Alias, Length * sizeof(BYTE), pszExeName)) + if (GetConsoleAliasesW(Alias, Length * sizeof(BYTE), pszExeName)) for (; Alias < AliasEnd; Alias += wcslen(Alias) + 1) wprintf(L"%s%s\n", Indent, Alias); @@ -117,7 +117,7 @@ ExeName = (WCHAR *)ExeNameBuf; ExeNameEnd = (WCHAR *)&ExeNameBuf[Length]; - if (GetConsoleAliasExes(ExeName, Length * sizeof(BYTE))) + if (GetConsoleAliasExesW(ExeName, Length * sizeof(BYTE))) { for (; ExeName < ExeNameEnd; ExeName += wcslen(ExeName) + 1) { @@ -199,7 +199,7 @@ /* Get the full command line using GetCommandLine(). We can't just use argv, * because then a parameter like "gotoroot=cd \" wouldn't be passed completely. */ - pArgEnd = GetCommandLine(); + pArgEnd = GetCommandLineW(); hKernel32 = LoadLibraryW(L"kernel32.dll"); /* Get function pointers */ @@ -222,7 +222,7 @@ if (!wcscmp(pArgStart, L"/?")) { - LoadString(GetModuleHandle(NULL), IDS_HELP, szStringBuf, MAX_STRING); + LoadStringW(GetModuleHandle(NULL), IDS_HELP, szStringBuf, MAX_STRING); wprintf(szStringBuf); break; } Modified: trunk/reactos/base/system/diskpart/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/CMake…
============================================================================== --- trunk/reactos/base/system/diskpart/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/CMakeLists.txt [iso-8859-1] Sat Nov 17 16:01:29 2012 @@ -41,7 +41,7 @@ uniqueid.c diskpart.rc) -set_module_type(diskpart win32cui) +set_module_type(diskpart win32cui UNICODE) add_importlibs(diskpart user32 msvcrt kernel32) if(MSVC) add_importlibs(diskpart ntdll) Modified: trunk/reactos/base/system/diskpart/diskpart.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/diskp…
============================================================================== --- trunk/reactos/base/system/diskpart/diskpart.c [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/diskpart.c [iso-8859-1] Sat Nov 17 16:01:29 2012 @@ -31,7 +31,7 @@ DWORD comp_size = MAX_STRING_SIZE; /* Get the name of the computer for us and change the value of comp_name */ - GetComputerName(szComputerName, &comp_size); + GetComputerNameW(szComputerName, &comp_size); /* TODO: Remove this section of code when program becomes stable enough for production use. */ wprintf(L"\n*WARNING*: This program is incomplete and may not work properly.\n");
11 years, 11 months
1
0
0
0
[janderwald] 57718: - Don't compile apps with Unicode as ReactOS console screenbuffer is not supporting this yet - fixes #CORE-6495, #CORE-6786
by janderwald@svn.reactos.org
Author: janderwald Date: Sat Nov 17 15:50:39 2012 New Revision: 57718 URL:
http://svn.reactos.org/svn/reactos?rev=57718&view=rev
Log: - Don't compile apps with Unicode as ReactOS console screenbuffer is not supporting this yet - fixes #CORE-6495, #CORE-6786 Modified: trunk/reactos/base/applications/cmdutils/doskey/CMakeLists.txt trunk/reactos/base/applications/sc/CMakeLists.txt trunk/reactos/base/system/diskpart/CMakeLists.txt Modified: trunk/reactos/base/applications/cmdutils/doskey/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/cmdutils…
============================================================================== --- trunk/reactos/base/applications/cmdutils/doskey/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/cmdutils/doskey/CMakeLists.txt [iso-8859-1] Sat Nov 17 15:50:39 2012 @@ -3,6 +3,6 @@ add_executable(doskey doskey.c doskey.rc) -set_module_type(doskey win32cui UNICODE) +set_module_type(doskey win32cui) add_importlibs(doskey user32 msvcrt kernel32) add_cd_file(TARGET doskey DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/applications/sc/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/sc/CMake…
============================================================================== --- trunk/reactos/base/applications/sc/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/applications/sc/CMakeLists.txt [iso-8859-1] Sat Nov 17 15:50:39 2012 @@ -14,7 +14,7 @@ add_executable(sc ${SOURCE}) -set_module_type(sc win32cui UNICODE) +set_module_type(sc win32cui) add_importlibs(sc advapi32 msvcrt kernel32) add_pch(sc sc.h) add_cd_file(TARGET sc DESTINATION reactos/system32 FOR all) Modified: trunk/reactos/base/system/diskpart/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/system/diskpart/CMake…
============================================================================== --- trunk/reactos/base/system/diskpart/CMakeLists.txt [iso-8859-1] (original) +++ trunk/reactos/base/system/diskpart/CMakeLists.txt [iso-8859-1] Sat Nov 17 15:50:39 2012 @@ -41,7 +41,7 @@ uniqueid.c diskpart.rc) -set_module_type(diskpart win32cui UNICODE) +set_module_type(diskpart win32cui) add_importlibs(diskpart user32 msvcrt kernel32) if(MSVC) add_importlibs(diskpart ntdll)
11 years, 11 months
1
0
0
0
[hbelusca] 57717: [CONSRV] Code reorganization only, no code changes.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Sat Nov 17 15:41:31 2012 New Revision: 57717 URL:
http://svn.reactos.org/svn/reactos?rev=57717&view=rev
Log: [CONSRV] Code reorganization only, no code changes. Modified: branches/ros-csrss/win32ss/user/consrv/coninput.c branches/ros-csrss/win32ss/user/consrv/conoutput.c Modified: branches/ros-csrss/win32ss/user/consrv/coninput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] Sat Nov 17 15:41:31 2012 @@ -6,7 +6,7 @@ * PROGRAMMERS: */ -/* INCLUDES ******************************************************************/ +/* INCLUDES *******************************************************************/ #include "consrv.h" #include "conio.h" @@ -15,7 +15,8 @@ #define NDEBUG #include <debug.h> -/* GLOBALS *******************************************************************/ + +/* GLOBALS ********************************************************************/ #define ConsoleInputUnicodeCharToAnsiChar(Console, dChar, sWChar) \ WideCharToMultiByte((Console)->CodePage, 0, (sWChar), 1, (dChar), 1, NULL, NULL) @@ -23,147 +24,8 @@ #define ConsoleInputAnsiCharToUnicodeChar(Console, dWChar, sChar) \ MultiByteToWideChar((Console)->CodePage, 0, (sChar), 1, (dWChar), 1) -/* FUNCTIONS *****************************************************************/ - -CSR_API(SrvReadConsole) -{ - PCSRSS_READ_CONSOLE ReadConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleRequest; - PLIST_ENTRY CurrentEntry; - ConsoleInput *Input; - PCHAR Buffer; - PWCHAR UnicodeBuffer; - ULONG i = 0; - ULONG nNumberOfCharsToRead, CharSize; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; - PCSRSS_CONSOLE Console; - NTSTATUS Status; - - DPRINT("SrvReadConsole\n"); - - CharSize = (ReadConsoleRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR)); - - nNumberOfCharsToRead = ReadConsoleRequest->NrCharactersToRead; - - Buffer = (PCHAR)ReadConsoleRequest->Buffer; - UnicodeBuffer = (PWCHAR)Buffer; - if (!Win32CsrValidateBuffer(ProcessData, Buffer, nNumberOfCharsToRead, CharSize)) - return STATUS_ACCESS_VIOLATION; - - if (ReadConsoleRequest->NrCharactersRead * sizeof(WCHAR) > nNumberOfCharsToRead * CharSize) - return STATUS_INVALID_PARAMETER; - - Status = ConioLockConsole(ProcessData, ReadConsoleRequest->ConsoleHandle, - &Console, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - ReadConsoleRequest->EventHandle = ProcessData->ConsoleEvent; - - Status = STATUS_PENDING; /* we haven't read anything (yet) */ - if (Console->Mode & ENABLE_LINE_INPUT) - { - if (Console->LineBuffer == NULL) - { - /* Starting a new line */ - Console->LineMaxSize = max(256, nNumberOfCharsToRead); - Console->LineBuffer = HeapAlloc(ConSrvHeap, 0, Console->LineMaxSize * sizeof(WCHAR)); - if (Console->LineBuffer == NULL) - { - Status = STATUS_NO_MEMORY; - goto done; - } - Console->LineComplete = FALSE; - Console->LineUpPressed = FALSE; - Console->LineInsertToggle = 0; - Console->LineWakeupMask = ReadConsoleRequest->CtrlWakeupMask; - Console->LineSize = ReadConsoleRequest->NrCharactersRead; - Console->LinePos = Console->LineSize; - /* pre-filling the buffer is only allowed in the Unicode API, - * so we don't need to worry about conversion */ - memcpy(Console->LineBuffer, Buffer, Console->LineSize * sizeof(WCHAR)); - if (Console->LineSize == Console->LineMaxSize) - { - Console->LineComplete = TRUE; - Console->LinePos = 0; - } - } - - /* If we don't have a complete line yet, process the pending input */ - while (!Console->LineComplete && !IsListEmpty(&Console->InputEvents)) - { - /* remove input event from queue */ - CurrentEntry = RemoveHeadList(&Console->InputEvents); - if (IsListEmpty(&Console->InputEvents)) - { - ResetEvent(Console->ActiveEvent); - } - Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry); - - /* only pay attention to key down */ - if (KEY_EVENT == Input->InputEvent.EventType - && Input->InputEvent.Event.KeyEvent.bKeyDown) - { - LineInputKeyDown(Console, &Input->InputEvent.Event.KeyEvent); - ReadConsoleRequest->ControlKeyState = Input->InputEvent.Event.KeyEvent.dwControlKeyState; - } - HeapFree(ConSrvHeap, 0, Input); - } - - /* Check if we have a complete line to read from */ - if (Console->LineComplete) - { - while (i < nNumberOfCharsToRead && Console->LinePos != Console->LineSize) - { - WCHAR Char = Console->LineBuffer[Console->LinePos++]; - if (ReadConsoleRequest->Unicode) - UnicodeBuffer[i++] = Char; - else - ConsoleInputUnicodeCharToAnsiChar(Console, &Buffer[i++], &Char); - } - if (Console->LinePos == Console->LineSize) - { - /* Entire line has been read */ - HeapFree(ConSrvHeap, 0, Console->LineBuffer); - Console->LineBuffer = NULL; - } - Status = STATUS_SUCCESS; - } - } - else - { - /* Character input */ - while (i < nNumberOfCharsToRead && !IsListEmpty(&Console->InputEvents)) - { - /* remove input event from queue */ - CurrentEntry = RemoveHeadList(&Console->InputEvents); - if (IsListEmpty(&Console->InputEvents)) - { - ResetEvent(Console->ActiveEvent); - } - Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry); - - /* only pay attention to valid ascii chars, on key down */ - if (KEY_EVENT == Input->InputEvent.EventType - && Input->InputEvent.Event.KeyEvent.bKeyDown - && Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar != L'\0') - { - WCHAR Char = Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar; - if (ReadConsoleRequest->Unicode) - UnicodeBuffer[i++] = Char; - else - ConsoleInputUnicodeCharToAnsiChar(Console, &Buffer[i++], &Char); - Status = STATUS_SUCCESS; /* did read something */ - } - HeapFree(ConSrvHeap, 0, Input); - } - } -done: - ReadConsoleRequest->NrCharactersRead = i; - ConioUnlockConsole(Console); - - return Status; -} + +/* PRIVATE FUNCTIONS **********************************************************/ static VOID FASTCALL ConioInputEventToAnsi(PCSRSS_CONSOLE Console, PINPUT_RECORD InputEvent) @@ -425,135 +287,8 @@ ConioProcessChar(Console, &er); } -CSR_API(CsrReadInputEvent) -{ - PCSRSS_READ_INPUT ReadInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadInputRequest; - PLIST_ENTRY CurrentEntry; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; - PCSRSS_CONSOLE Console; - NTSTATUS Status; - BOOLEAN Done = FALSE; - ConsoleInput *Input; - - DPRINT("CsrReadInputEvent\n"); - - ReadInputRequest->Event = ProcessData->ConsoleEvent; - - Status = ConioLockConsole(ProcessData, ReadInputRequest->ConsoleHandle, &Console, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - - /* only get input if there is any */ - CurrentEntry = Console->InputEvents.Flink; - while (CurrentEntry != &Console->InputEvents) - { - Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry); - CurrentEntry = CurrentEntry->Flink; - - if (Done) - { - ReadInputRequest->MoreEvents = TRUE; - break; - } - - RemoveEntryList(&Input->ListEntry); - - if (!Done) - { - ReadInputRequest->Input = Input->InputEvent; - if (ReadInputRequest->Unicode == FALSE) - { - ConioInputEventToAnsi(Console, &ReadInputRequest->Input); - } - Done = TRUE; - } - - HeapFree(ConSrvHeap, 0, Input); - } - - if (Done) - Status = STATUS_SUCCESS; - else - Status = STATUS_PENDING; - - if (IsListEmpty(&Console->InputEvents)) - { - ResetEvent(Console->ActiveEvent); - } - - ConioUnlockConsole(Console); - - return Status; -} - -CSR_API(SrvFlushConsoleInputBuffer) -{ - PCSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FlushInputBufferRequest; - PLIST_ENTRY CurrentEntry; - PCSRSS_CONSOLE Console; - ConsoleInput* Input; - NTSTATUS Status; - - DPRINT("SrvFlushConsoleInputBuffer\n"); - - Status = ConioLockConsole(CsrGetClientThread()->Process, - FlushInputBufferRequest->ConsoleInput, - &Console, - GENERIC_WRITE); - if(! NT_SUCCESS(Status)) - { - return Status; - } - - /* Discard all entries in the input event queue */ - while (!IsListEmpty(&Console->InputEvents)) - { - CurrentEntry = RemoveHeadList(&Console->InputEvents); - Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry); - /* Destroy the event */ - HeapFree(ConSrvHeap, 0, Input); - } - ResetEvent(Console->ActiveEvent); - - ConioUnlockConsole(Console); - - return STATUS_SUCCESS; -} - -CSR_API(SrvGetConsoleNumberOfInputEvents) -{ - NTSTATUS Status; - PCSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetNumInputEventsRequest; - PCSRSS_CONSOLE Console; - PLIST_ENTRY CurrentItem; - DWORD NumEvents; - - DPRINT("SrvGetConsoleNumberOfInputEvents\n"); - - Status = ConioLockConsole(CsrGetClientThread()->Process, GetNumInputEventsRequest->ConsoleHandle, &Console, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - - CurrentItem = Console->InputEvents.Flink; - NumEvents = 0; - - /* If there are any events ... */ - while (CurrentItem != &Console->InputEvents) - { - CurrentItem = CurrentItem->Flink; - NumEvents++; - } - - ConioUnlockConsole(Console); - - GetNumInputEventsRequest->NumInputEvents = NumEvents; - - return STATUS_SUCCESS; -} + +/* PUBLIC APIS ****************************************************************/ CSR_API(SrvGetConsoleInput) { @@ -661,4 +396,274 @@ return Status; } +CSR_API(SrvReadConsole) +{ + PCSRSS_READ_CONSOLE ReadConsoleRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleRequest; + PLIST_ENTRY CurrentEntry; + ConsoleInput *Input; + PCHAR Buffer; + PWCHAR UnicodeBuffer; + ULONG i = 0; + ULONG nNumberOfCharsToRead, CharSize; + PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCSRSS_CONSOLE Console; + NTSTATUS Status; + + DPRINT("SrvReadConsole\n"); + + CharSize = (ReadConsoleRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR)); + + nNumberOfCharsToRead = ReadConsoleRequest->NrCharactersToRead; + + Buffer = (PCHAR)ReadConsoleRequest->Buffer; + UnicodeBuffer = (PWCHAR)Buffer; + if (!Win32CsrValidateBuffer(ProcessData, Buffer, nNumberOfCharsToRead, CharSize)) + return STATUS_ACCESS_VIOLATION; + + if (ReadConsoleRequest->NrCharactersRead * sizeof(WCHAR) > nNumberOfCharsToRead * CharSize) + return STATUS_INVALID_PARAMETER; + + Status = ConioLockConsole(ProcessData, ReadConsoleRequest->ConsoleHandle, + &Console, GENERIC_READ); + if (! NT_SUCCESS(Status)) + { + return Status; + } + ReadConsoleRequest->EventHandle = ProcessData->ConsoleEvent; + + Status = STATUS_PENDING; /* we haven't read anything (yet) */ + if (Console->Mode & ENABLE_LINE_INPUT) + { + if (Console->LineBuffer == NULL) + { + /* Starting a new line */ + Console->LineMaxSize = max(256, nNumberOfCharsToRead); + Console->LineBuffer = HeapAlloc(ConSrvHeap, 0, Console->LineMaxSize * sizeof(WCHAR)); + if (Console->LineBuffer == NULL) + { + Status = STATUS_NO_MEMORY; + goto done; + } + Console->LineComplete = FALSE; + Console->LineUpPressed = FALSE; + Console->LineInsertToggle = 0; + Console->LineWakeupMask = ReadConsoleRequest->CtrlWakeupMask; + Console->LineSize = ReadConsoleRequest->NrCharactersRead; + Console->LinePos = Console->LineSize; + /* pre-filling the buffer is only allowed in the Unicode API, + * so we don't need to worry about conversion */ + memcpy(Console->LineBuffer, Buffer, Console->LineSize * sizeof(WCHAR)); + if (Console->LineSize == Console->LineMaxSize) + { + Console->LineComplete = TRUE; + Console->LinePos = 0; + } + } + + /* If we don't have a complete line yet, process the pending input */ + while (!Console->LineComplete && !IsListEmpty(&Console->InputEvents)) + { + /* remove input event from queue */ + CurrentEntry = RemoveHeadList(&Console->InputEvents); + if (IsListEmpty(&Console->InputEvents)) + { + ResetEvent(Console->ActiveEvent); + } + Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry); + + /* only pay attention to key down */ + if (KEY_EVENT == Input->InputEvent.EventType + && Input->InputEvent.Event.KeyEvent.bKeyDown) + { + LineInputKeyDown(Console, &Input->InputEvent.Event.KeyEvent); + ReadConsoleRequest->ControlKeyState = Input->InputEvent.Event.KeyEvent.dwControlKeyState; + } + HeapFree(ConSrvHeap, 0, Input); + } + + /* Check if we have a complete line to read from */ + if (Console->LineComplete) + { + while (i < nNumberOfCharsToRead && Console->LinePos != Console->LineSize) + { + WCHAR Char = Console->LineBuffer[Console->LinePos++]; + if (ReadConsoleRequest->Unicode) + UnicodeBuffer[i++] = Char; + else + ConsoleInputUnicodeCharToAnsiChar(Console, &Buffer[i++], &Char); + } + if (Console->LinePos == Console->LineSize) + { + /* Entire line has been read */ + HeapFree(ConSrvHeap, 0, Console->LineBuffer); + Console->LineBuffer = NULL; + } + Status = STATUS_SUCCESS; + } + } + else + { + /* Character input */ + while (i < nNumberOfCharsToRead && !IsListEmpty(&Console->InputEvents)) + { + /* remove input event from queue */ + CurrentEntry = RemoveHeadList(&Console->InputEvents); + if (IsListEmpty(&Console->InputEvents)) + { + ResetEvent(Console->ActiveEvent); + } + Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry); + + /* only pay attention to valid ascii chars, on key down */ + if (KEY_EVENT == Input->InputEvent.EventType + && Input->InputEvent.Event.KeyEvent.bKeyDown + && Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar != L'\0') + { + WCHAR Char = Input->InputEvent.Event.KeyEvent.uChar.UnicodeChar; + if (ReadConsoleRequest->Unicode) + UnicodeBuffer[i++] = Char; + else + ConsoleInputUnicodeCharToAnsiChar(Console, &Buffer[i++], &Char); + Status = STATUS_SUCCESS; /* did read something */ + } + HeapFree(ConSrvHeap, 0, Input); + } + } +done: + ReadConsoleRequest->NrCharactersRead = i; + ConioUnlockConsole(Console); + + return Status; +} + +CSR_API(CsrReadInputEvent) +{ + PCSRSS_READ_INPUT ReadInputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadInputRequest; + PLIST_ENTRY CurrentEntry; + PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCSRSS_CONSOLE Console; + NTSTATUS Status; + BOOLEAN Done = FALSE; + ConsoleInput *Input; + + DPRINT("CsrReadInputEvent\n"); + + ReadInputRequest->Event = ProcessData->ConsoleEvent; + + Status = ConioLockConsole(ProcessData, ReadInputRequest->ConsoleHandle, &Console, GENERIC_READ); + if (! NT_SUCCESS(Status)) + { + return Status; + } + + /* only get input if there is any */ + CurrentEntry = Console->InputEvents.Flink; + while (CurrentEntry != &Console->InputEvents) + { + Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry); + CurrentEntry = CurrentEntry->Flink; + + if (Done) + { + ReadInputRequest->MoreEvents = TRUE; + break; + } + + RemoveEntryList(&Input->ListEntry); + + if (!Done) + { + ReadInputRequest->Input = Input->InputEvent; + if (ReadInputRequest->Unicode == FALSE) + { + ConioInputEventToAnsi(Console, &ReadInputRequest->Input); + } + Done = TRUE; + } + + HeapFree(ConSrvHeap, 0, Input); + } + + if (Done) + Status = STATUS_SUCCESS; + else + Status = STATUS_PENDING; + + if (IsListEmpty(&Console->InputEvents)) + { + ResetEvent(Console->ActiveEvent); + } + + ConioUnlockConsole(Console); + + return Status; +} + +CSR_API(SrvFlushConsoleInputBuffer) +{ + PCSRSS_FLUSH_INPUT_BUFFER FlushInputBufferRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FlushInputBufferRequest; + PLIST_ENTRY CurrentEntry; + PCSRSS_CONSOLE Console; + ConsoleInput* Input; + NTSTATUS Status; + + DPRINT("SrvFlushConsoleInputBuffer\n"); + + Status = ConioLockConsole(CsrGetClientThread()->Process, + FlushInputBufferRequest->ConsoleInput, + &Console, + GENERIC_WRITE); + if(! NT_SUCCESS(Status)) + { + return Status; + } + + /* Discard all entries in the input event queue */ + while (!IsListEmpty(&Console->InputEvents)) + { + CurrentEntry = RemoveHeadList(&Console->InputEvents); + Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry); + /* Destroy the event */ + HeapFree(ConSrvHeap, 0, Input); + } + ResetEvent(Console->ActiveEvent); + + ConioUnlockConsole(Console); + + return STATUS_SUCCESS; +} + +CSR_API(SrvGetConsoleNumberOfInputEvents) +{ + NTSTATUS Status; + PCSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetNumInputEventsRequest; + PCSRSS_CONSOLE Console; + PLIST_ENTRY CurrentItem; + DWORD NumEvents; + + DPRINT("SrvGetConsoleNumberOfInputEvents\n"); + + Status = ConioLockConsole(CsrGetClientThread()->Process, GetNumInputEventsRequest->ConsoleHandle, &Console, GENERIC_READ); + if (! NT_SUCCESS(Status)) + { + return Status; + } + + CurrentItem = Console->InputEvents.Flink; + NumEvents = 0; + + /* If there are any events ... */ + while (CurrentItem != &Console->InputEvents) + { + CurrentItem = CurrentItem->Flink; + NumEvents++; + } + + ConioUnlockConsole(Console); + + GetNumInputEventsRequest->NumInputEvents = NumEvents; + + return STATUS_SUCCESS; +} + /* EOF */ Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Sat Nov 17 15:41:31 2012 @@ -6,7 +6,7 @@ * PROGRAMMERS: */ -/* INCLUDES ******************************************************************/ +/* INCLUDES *******************************************************************/ #include "consrv.h" #include "conio.h" @@ -14,13 +14,16 @@ #define NDEBUG #include <debug.h> -/* GLOBALS *******************************************************************/ + +/* GLOBALS ********************************************************************/ #define ConioInitRect(Rect, top, left, bottom, right) \ - ((Rect)->Top) = top; \ - ((Rect)->Left) = left; \ - ((Rect)->Bottom) = bottom; \ - ((Rect)->Right) = right +do { \ + ((Rect)->Top) = top; \ + ((Rect)->Left) = left; \ + ((Rect)->Bottom) = bottom; \ + ((Rect)->Right) = right; \ +} while(0) #define ConioIsRectEmpty(Rect) \ (((Rect)->Left > (Rect)->Right) || ((Rect)->Top > (Rect)->Bottom)) @@ -31,7 +34,8 @@ #define ConsoleAnsiCharToUnicodeChar(Console, dWChar, sChar) \ MultiByteToWideChar((Console)->OutputCodePage, 0, (sChar), 1, (dWChar), 1) -/* FUNCTIONS *****************************************************************/ + +/* PRIVATE FUNCTIONS **********************************************************/ PBYTE FASTCALL ConioCoordToPointer(PCSRSS_SCREEN_BUFFER Buff, ULONG X, ULONG Y) @@ -294,8 +298,10 @@ return TRUE; } -/* Move from one rectangle to another. We must be careful about the order that - * this is done, to avoid overwriting parts of the source before they are moved. */ +/* + * Move from one rectangle to another. We must be careful about the order that + * this is done, to avoid overwriting parts of the source before they are moved. + */ static VOID FASTCALL ConioMoveRegion(PCSRSS_SCREEN_BUFFER ScreenBuffer, SMALL_RECT *SrcRegion, @@ -356,6 +362,162 @@ } } +VOID WINAPI +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(ConSrvHeap, 0, Buffer->Buffer); + HeapFree(ConSrvHeap, 0, Buffer); +} + +VOID FASTCALL +ConioDrawConsole(PCSRSS_CONSOLE Console) +{ + SMALL_RECT Region; + + ConioInitRect(&Region, 0, 0, Console->Size.Y - 1, Console->Size.X - 1); + + ConioDrawRegion(Console, &Region); +} + +static VOID FASTCALL +ConioComputeUpdateRect(PCSRSS_SCREEN_BUFFER Buff, SMALL_RECT *UpdateRect, COORD *Start, UINT Length) +{ + if (Buff->MaxX <= Start->X + Length) + { + UpdateRect->Left = 0; + } + else + { + UpdateRect->Left = Start->X; + } + if (Buff->MaxX <= Start->X + Length) + { + UpdateRect->Right = Buff->MaxX - 1; + } + else + { + UpdateRect->Right = Start->X + Length - 1; + } + UpdateRect->Top = Start->Y; + UpdateRect->Bottom = Start->Y+ (Start->X + Length - 1) / Buff->MaxX; + if (Buff->MaxY <= UpdateRect->Bottom) + { + UpdateRect->Bottom = Buff->MaxY - 1; + } +} + +DWORD FASTCALL +ConioEffectiveCursorSize(PCSRSS_CONSOLE Console, DWORD Scale) +{ + DWORD Size = (Console->ActiveBuffer->CursorInfo.dwSize * Scale + 99) / 100; + /* If line input in progress, perhaps adjust for insert toggle */ + if (Console->LineBuffer && !Console->LineComplete && Console->LineInsertToggle) + return (Size * 2 <= Scale) ? (Size * 2) : (Size / 2); + return Size; +} + + +/* PUBLIC APIS ****************************************************************/ + +CSR_API(SrvReadConsoleOutput) +{ + PCSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleOutputRequest; + PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; + PCHAR_INFO CharInfo; + PCHAR_INFO CurCharInfo; + PCSRSS_SCREEN_BUFFER Buff; + DWORD SizeX, SizeY; + NTSTATUS Status; + COORD BufferSize; + COORD BufferCoord; + SMALL_RECT ReadRegion; + SMALL_RECT ScreenRect; + DWORD i; + PBYTE Ptr; + LONG X, Y; + UINT CodePage; + + DPRINT("SrvReadConsoleOutput\n"); + + Status = ConioLockScreenBuffer(ProcessData, ReadConsoleOutputRequest->ConsoleHandle, &Buff, GENERIC_READ); + if (! NT_SUCCESS(Status)) + { + return Status; + } + + CharInfo = ReadConsoleOutputRequest->CharInfo; + ReadRegion = ReadConsoleOutputRequest->ReadRegion; + BufferSize = ReadConsoleOutputRequest->BufferSize; + BufferCoord = ReadConsoleOutputRequest->BufferCoord; + + /* FIXME: Is this correct? */ + CodePage = ProcessData->Console->OutputCodePage; + + if (!Win32CsrValidateBuffer(ProcessData, CharInfo, + BufferSize.X * BufferSize.Y, sizeof(CHAR_INFO))) + { + ConioUnlockScreenBuffer(Buff); + return STATUS_ACCESS_VIOLATION; + } + + SizeY = min(BufferSize.Y - BufferCoord.Y, ConioRectHeight(&ReadRegion)); + SizeX = min(BufferSize.X - BufferCoord.X, ConioRectWidth(&ReadRegion)); + ReadRegion.Bottom = ReadRegion.Top + SizeY; + ReadRegion.Right = ReadRegion.Left + SizeX; + + ConioInitRect(&ScreenRect, 0, 0, Buff->MaxY, Buff->MaxX); + if (! ConioGetIntersection(&ReadRegion, &ScreenRect, &ReadRegion)) + { + ConioUnlockScreenBuffer(Buff); + return STATUS_SUCCESS; + } + + for (i = 0, Y = ReadRegion.Top; Y < ReadRegion.Bottom; ++i, ++Y) + { + CurCharInfo = CharInfo + (i * BufferSize.X); + + Ptr = ConioCoordToPointer(Buff, ReadRegion.Left, Y); + for (X = ReadRegion.Left; X < ReadRegion.Right; ++X) + { + if (ReadConsoleOutputRequest->Unicode) + { + MultiByteToWideChar(CodePage, 0, + (PCHAR)Ptr++, 1, + &CurCharInfo->Char.UnicodeChar, 1); + } + else + { + CurCharInfo->Char.AsciiChar = *Ptr++; + } + CurCharInfo->Attributes = *Ptr++; + ++CurCharInfo; + } + } + + ConioUnlockScreenBuffer(Buff); + + ReadConsoleOutputRequest->ReadRegion.Right = ReadRegion.Left + SizeX - 1; + ReadConsoleOutputRequest->ReadRegion.Bottom = ReadRegion.Top + SizeY - 1; + ReadConsoleOutputRequest->ReadRegion.Left = ReadRegion.Left; + ReadConsoleOutputRequest->ReadRegion.Top = ReadRegion.Top; + + return STATUS_SUCCESS; +} + CSR_API(SrvWriteConsole) { NTSTATUS Status; @@ -441,139 +603,222 @@ return Status; } -VOID WINAPI -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(ConSrvHeap, 0, Buffer->Buffer); - HeapFree(ConSrvHeap, 0, Buffer); -} - -VOID FASTCALL -ConioDrawConsole(PCSRSS_CONSOLE Console) -{ - SMALL_RECT Region; - - ConioInitRect(&Region, 0, 0, Console->Size.Y - 1, Console->Size.X - 1); - - ConioDrawRegion(Console, &Region); -} - -CSR_API(SrvGetConsoleScreenBufferInfo) // CsrGetScreenBufferInfo -{ - NTSTATUS Status; - PCSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ScreenBufferInfoRequest; +CSR_API(SrvWriteConsoleOutput) +{ + PCSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleOutputRequest; + SHORT i, X, Y, SizeX, SizeY; + PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; PCSRSS_CONSOLE Console; PCSRSS_SCREEN_BUFFER Buff; - PCONSOLE_SCREEN_BUFFER_INFO pInfo; - - DPRINT("SrvGetConsoleScreenBufferInfo\n"); - - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, ScreenBufferInfoRequest->ConsoleHandle, &Buff, GENERIC_READ); + SMALL_RECT ScreenBuffer; + CHAR_INFO* CurCharInfo; + SMALL_RECT WriteRegion; + CHAR_INFO* CharInfo; + COORD BufferCoord; + COORD BufferSize; + NTSTATUS Status; + PBYTE Ptr; + + DPRINT("SrvWriteConsoleOutput\n"); + + Status = ConioLockScreenBuffer(ProcessData, + WriteConsoleOutputRequest->ConsoleHandle, + &Buff, + GENERIC_WRITE); if (! NT_SUCCESS(Status)) { return Status; } Console = Buff->Header.Console; - pInfo = &ScreenBufferInfoRequest->Info; - pInfo->dwSize.X = Buff->MaxX; - pInfo->dwSize.Y = Buff->MaxY; - pInfo->dwCursorPosition.X = Buff->CurrentX; - pInfo->dwCursorPosition.Y = Buff->CurrentY; - pInfo->wAttributes = Buff->DefaultAttrib; - pInfo->srWindow.Left = Buff->ShowX; - pInfo->srWindow.Right = Buff->ShowX + Console->Size.X - 1; - pInfo->srWindow.Top = Buff->ShowY; - pInfo->srWindow.Bottom = Buff->ShowY + Console->Size.Y - 1; - pInfo->dwMaximumWindowSize.X = Buff->MaxX; - pInfo->dwMaximumWindowSize.Y = Buff->MaxY; - ConioUnlockScreenBuffer(Buff); - - return STATUS_SUCCESS; -} - -CSR_API(SrvSetConsoleCursor) -{ - NTSTATUS Status; - PCSRSS_SET_CURSOR SetCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorRequest; + + BufferSize = WriteConsoleOutputRequest->BufferSize; + BufferCoord = WriteConsoleOutputRequest->BufferCoord; + CharInfo = WriteConsoleOutputRequest->CharInfo; + if (!Win32CsrValidateBuffer(ProcessData, CharInfo, + BufferSize.X * BufferSize.Y, sizeof(CHAR_INFO))) + { + ConioUnlockScreenBuffer(Buff); + return STATUS_ACCESS_VIOLATION; + } + WriteRegion = WriteConsoleOutputRequest->WriteRegion; + + SizeY = min(BufferSize.Y - BufferCoord.Y, ConioRectHeight(&WriteRegion)); + SizeX = min(BufferSize.X - BufferCoord.X, ConioRectWidth(&WriteRegion)); + WriteRegion.Bottom = WriteRegion.Top + SizeY - 1; + WriteRegion.Right = WriteRegion.Left + SizeX - 1; + + /* Make sure WriteRegion is inside the screen buffer */ + ConioInitRect(&ScreenBuffer, 0, 0, Buff->MaxY - 1, Buff->MaxX - 1); + if (! ConioGetIntersection(&WriteRegion, &ScreenBuffer, &WriteRegion)) + { + ConioUnlockScreenBuffer(Buff); + + /* It is okay to have a WriteRegion completely outside the screen buffer. + No data is written then. */ + return STATUS_SUCCESS; + } + + for (i = 0, Y = WriteRegion.Top; Y <= WriteRegion.Bottom; i++, Y++) + { + CurCharInfo = CharInfo + (i + BufferCoord.Y) * BufferSize.X + BufferCoord.X; + Ptr = ConioCoordToPointer(Buff, WriteRegion.Left, Y); + for (X = WriteRegion.Left; X <= WriteRegion.Right; X++) + { + CHAR AsciiChar; + if (WriteConsoleOutputRequest->Unicode) + { + ConsoleUnicodeCharToAnsiChar(Console, &AsciiChar, &CurCharInfo->Char.UnicodeChar); + } + else + { + AsciiChar = CurCharInfo->Char.AsciiChar; + } + *Ptr++ = AsciiChar; + *Ptr++ = CurCharInfo->Attributes; + CurCharInfo++; + } + } + + ConioDrawRegion(Console, &WriteRegion); + + ConioUnlockScreenBuffer(Buff); + + WriteConsoleOutputRequest->WriteRegion.Right = WriteRegion.Left + SizeX - 1; + WriteConsoleOutputRequest->WriteRegion.Bottom = WriteRegion.Top + SizeY - 1; + WriteConsoleOutputRequest->WriteRegion.Left = WriteRegion.Left; + WriteConsoleOutputRequest->WriteRegion.Top = WriteRegion.Top; + + return STATUS_SUCCESS; +} + +CSR_API(CsrReadConsoleOutputChar) +{ + NTSTATUS Status; + PCSRSS_READ_CONSOLE_OUTPUT_CHAR ReadConsoleOutputCharRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleOutputCharRequest; PCSRSS_CONSOLE Console; PCSRSS_SCREEN_BUFFER Buff; - LONG OldCursorX, OldCursorY; - LONG NewCursorX, NewCursorY; - - DPRINT("SrvSetConsoleCursor\n"); - - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, SetCursorRequest->ConsoleHandle, &Buff, GENERIC_WRITE); + DWORD Xpos, Ypos; + PCHAR ReadBuffer; + DWORD i; + ULONG CharSize; + CHAR Char; + + DPRINT("CsrReadConsoleOutputChar\n"); + + ReadBuffer = ReadConsoleOutputCharRequest->String; + + CharSize = (ReadConsoleOutputCharRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR)); + + Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, ReadConsoleOutputCharRequest->ConsoleHandle, &Buff, GENERIC_READ); if (! NT_SUCCESS(Status)) { return Status; } Console = Buff->Header.Console; - NewCursorX = SetCursorRequest->Position.X; - NewCursorY = SetCursorRequest->Position.Y; - if (NewCursorX < 0 || NewCursorX >= Buff->MaxX || - NewCursorY < 0 || NewCursorY >= Buff->MaxY) - { - ConioUnlockScreenBuffer(Buff); - return STATUS_INVALID_PARAMETER; - } - OldCursorX = Buff->CurrentX; - OldCursorY = Buff->CurrentY; - Buff->CurrentX = NewCursorX; - Buff->CurrentY = NewCursorY; - if (Buff == Console->ActiveBuffer) - { - if (! ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY)) - { - ConioUnlockScreenBuffer(Buff); - return STATUS_UNSUCCESSFUL; - } - } - - ConioUnlockScreenBuffer(Buff); - - return STATUS_SUCCESS; -} - -static VOID FASTCALL -ConioComputeUpdateRect(PCSRSS_SCREEN_BUFFER Buff, SMALL_RECT *UpdateRect, COORD *Start, UINT Length) -{ - if (Buff->MaxX <= Start->X + Length) - { - UpdateRect->Left = 0; - } - else - { - UpdateRect->Left = Start->X; - } - if (Buff->MaxX <= Start->X + Length) - { - UpdateRect->Right = Buff->MaxX - 1; - } - else - { - UpdateRect->Right = Start->X + Length - 1; - } - UpdateRect->Top = Start->Y; - UpdateRect->Bottom = Start->Y+ (Start->X + Length - 1) / Buff->MaxX; - if (Buff->MaxY <= UpdateRect->Bottom) - { - UpdateRect->Bottom = Buff->MaxY - 1; - } + Xpos = ReadConsoleOutputCharRequest->ReadCoord.X; + Ypos = (ReadConsoleOutputCharRequest->ReadCoord.Y + Buff->VirtualY) % Buff->MaxY; + + for (i = 0; i < ReadConsoleOutputCharRequest->NumCharsToRead; ++i) + { + Char = Buff->Buffer[(Xpos * 2) + (Ypos * 2 * Buff->MaxX)]; + + if(ReadConsoleOutputCharRequest->Unicode) + { + ConsoleAnsiCharToUnicodeChar(Console, (WCHAR*)ReadBuffer, &Char); + ReadBuffer += sizeof(WCHAR); + } + else + *(ReadBuffer++) = Char; + + Xpos++; + + if (Xpos == Buff->MaxX) + { + Xpos = 0; + Ypos++; + + if (Ypos == Buff->MaxY) + { + Ypos = 0; + } + } + } + + *ReadBuffer = 0; + ReadConsoleOutputCharRequest->EndCoord.X = Xpos; + ReadConsoleOutputCharRequest->EndCoord.Y = (Ypos - Buff->VirtualY + Buff->MaxY) % Buff->MaxY; + + ConioUnlockScreenBuffer(Buff); + + ReadConsoleOutputCharRequest->CharsRead = (DWORD)((ULONG_PTR)ReadBuffer - (ULONG_PTR)ReadConsoleOutputCharRequest->String) / CharSize; + if (ReadConsoleOutputCharRequest->CharsRead * CharSize + CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR) > sizeof(CSR_API_MESSAGE)) + { + DPRINT1("Length won't fit in message\n"); + return STATUS_BUFFER_TOO_SMALL; + } + + return STATUS_SUCCESS; +} + +CSR_API(CsrReadConsoleOutputAttrib) +{ + NTSTATUS Status; + PCSRSS_READ_CONSOLE_OUTPUT_ATTRIB ReadConsoleOutputAttribRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleOutputAttribRequest; + PCSRSS_SCREEN_BUFFER Buff; + DWORD Xpos, Ypos; + PWORD ReadBuffer; + DWORD i; + DWORD CurrentLength; + + DPRINT("CsrReadConsoleOutputAttrib\n"); + + ReadBuffer = ReadConsoleOutputAttribRequest->Attribute; + + Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, ReadConsoleOutputAttribRequest->ConsoleHandle, &Buff, GENERIC_READ); + if (! NT_SUCCESS(Status)) + { + return Status; + } + + Xpos = ReadConsoleOutputAttribRequest->ReadCoord.X; + Ypos = (ReadConsoleOutputAttribRequest->ReadCoord.Y + Buff->VirtualY) % Buff->MaxY; + + for (i = 0; i < ReadConsoleOutputAttribRequest->NumAttrsToRead; ++i) + { + *ReadBuffer = Buff->Buffer[(Xpos * 2) + (Ypos * 2 * Buff->MaxX) + 1]; + + ReadBuffer++; + Xpos++; + + if (Xpos == Buff->MaxX) + { + Xpos = 0; + Ypos++; + + if (Ypos == Buff->MaxY) + { + Ypos = 0; + } + } + } + + *ReadBuffer = 0; + + ReadConsoleOutputAttribRequest->EndCoord.X = Xpos; + ReadConsoleOutputAttribRequest->EndCoord.Y = (Ypos - Buff->VirtualY + Buff->MaxY) % Buff->MaxY; + + ConioUnlockScreenBuffer(Buff); + + CurrentLength = CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_ATTRIB) + + ReadConsoleOutputAttribRequest->NumAttrsToRead * sizeof(WORD); + if (CurrentLength > sizeof(CSR_API_MESSAGE)) + { + DPRINT1("Length won't fit in message\n"); + return STATUS_BUFFER_TOO_SMALL; + } + + return STATUS_SUCCESS; } CSR_API(CsrWriteConsoleOutputChar) @@ -675,6 +920,72 @@ return Status; } +CSR_API(CsrWriteConsoleOutputAttrib) +{ + PCSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleOutputAttribRequest; + PCSRSS_CONSOLE Console; + PCSRSS_SCREEN_BUFFER Buff; + PUCHAR Buffer; + PWORD Attribute; + int X, Y, Length; + NTSTATUS Status; + SMALL_RECT UpdateRect; + + DPRINT("CsrWriteConsoleOutputAttrib\n"); + + if (ApiMessage->Header.u1.s1.TotalLength + < CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB) + + WriteConsoleOutputAttribRequest->Length * sizeof(WORD)) + { + DPRINT1("Invalid ApiMessage size\n"); + return STATUS_INVALID_PARAMETER; + } + + Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, + WriteConsoleOutputAttribRequest->ConsoleHandle, + &Buff, + GENERIC_WRITE); + if (! NT_SUCCESS(Status)) + { + return Status; + } + Console = Buff->Header.Console; + + X = WriteConsoleOutputAttribRequest->Coord.X; + Y = (WriteConsoleOutputAttribRequest->Coord.Y + Buff->VirtualY) % Buff->MaxY; + Length = WriteConsoleOutputAttribRequest->Length; + Buffer = &Buff->Buffer[2 * (Y * Buff->MaxX + X) + 1]; + Attribute = WriteConsoleOutputAttribRequest->Attribute; + while (Length--) + { + *Buffer = (UCHAR)(*Attribute++); + Buffer += 2; + if (++X == Buff->MaxX) + { + if (++Y == Buff->MaxY) + { + Y = 0; + Buffer = Buff->Buffer + 1; + } + X = 0; + } + } + + if (Buff == Console->ActiveBuffer) + { + ConioComputeUpdateRect(Buff, &UpdateRect, &WriteConsoleOutputAttribRequest->Coord, + WriteConsoleOutputAttribRequest->Length); + ConioDrawRegion(Console, &UpdateRect); + } + + WriteConsoleOutputAttribRequest->EndCoord.X = X; + WriteConsoleOutputAttribRequest->EndCoord.Y = (Y + Buff->MaxY - Buff->VirtualY) % Buff->MaxY; + + ConioUnlockScreenBuffer(Buff); + + return STATUS_SUCCESS; +} + CSR_API(CsrFillOutputChar) { NTSTATUS Status; @@ -732,72 +1043,6 @@ return STATUS_SUCCESS; } -CSR_API(CsrWriteConsoleOutputAttrib) -{ - PCSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB WriteConsoleOutputAttribRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleOutputAttribRequest; - PCSRSS_CONSOLE Console; - PCSRSS_SCREEN_BUFFER Buff; - PUCHAR Buffer; - PWORD Attribute; - int X, Y, Length; - NTSTATUS Status; - SMALL_RECT UpdateRect; - - DPRINT("CsrWriteConsoleOutputAttrib\n"); - - if (ApiMessage->Header.u1.s1.TotalLength - < CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB) - + WriteConsoleOutputAttribRequest->Length * sizeof(WORD)) - { - DPRINT1("Invalid ApiMessage size\n"); - return STATUS_INVALID_PARAMETER; - } - - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, - WriteConsoleOutputAttribRequest->ConsoleHandle, - &Buff, - GENERIC_WRITE); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Console = Buff->Header.Console; - - X = WriteConsoleOutputAttribRequest->Coord.X; - Y = (WriteConsoleOutputAttribRequest->Coord.Y + Buff->VirtualY) % Buff->MaxY; - Length = WriteConsoleOutputAttribRequest->Length; - Buffer = &Buff->Buffer[2 * (Y * Buff->MaxX + X) + 1]; - Attribute = WriteConsoleOutputAttribRequest->Attribute; - while (Length--) - { - *Buffer = (UCHAR)(*Attribute++); - Buffer += 2; - if (++X == Buff->MaxX) - { - if (++Y == Buff->MaxY) - { - Y = 0; - Buffer = Buff->Buffer + 1; - } - X = 0; - } - } - - if (Buff == Console->ActiveBuffer) - { - ConioComputeUpdateRect(Buff, &UpdateRect, &WriteConsoleOutputAttribRequest->Coord, - WriteConsoleOutputAttribRequest->Length); - ConioDrawRegion(Console, &UpdateRect); - } - - WriteConsoleOutputAttribRequest->EndCoord.X = X; - WriteConsoleOutputAttribRequest->EndCoord.Y = (Y + Buff->MaxY - Buff->VirtualY) % Buff->MaxY; - - ConioUnlockScreenBuffer(Buff); - - return STATUS_SUCCESS; -} - CSR_API(CsrFillOutputAttrib) { PCSRSS_FILL_OUTPUT_ATTRIB FillOutputAttribRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FillOutputAttribRequest; @@ -850,16 +1095,6 @@ return STATUS_SUCCESS; } -DWORD FASTCALL -ConioEffectiveCursorSize(PCSRSS_CONSOLE Console, DWORD Scale) -{ - DWORD Size = (Console->ActiveBuffer->CursorInfo.dwSize * Scale + 99) / 100; - /* If line input in progress, perhaps adjust for insert toggle */ - if (Console->LineBuffer && !Console->LineComplete && Console->LineInsertToggle) - return (Size * 2 <= Scale) ? (Size * 2) : (Size / 2); - return Size; -} - CSR_API(SrvGetConsoleCursorInfo) { NTSTATUS Status; @@ -916,6 +1151,50 @@ Buff->CursorInfo.bVisible = Visible; if (! ConioSetCursorInfo(Console, Buff)) + { + ConioUnlockScreenBuffer(Buff); + return STATUS_UNSUCCESSFUL; + } + } + + ConioUnlockScreenBuffer(Buff); + + return STATUS_SUCCESS; +} + +CSR_API(SrvSetConsoleCursorPosition) +{ + NTSTATUS Status; + PCSRSS_SET_CURSOR SetCursorRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetCursorRequest; + PCSRSS_CONSOLE Console; + PCSRSS_SCREEN_BUFFER Buff; + LONG OldCursorX, OldCursorY; + LONG NewCursorX, NewCursorY; + + DPRINT("SrvSetConsoleCursorPosition\n"); + + Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, SetCursorRequest->ConsoleHandle, &Buff, GENERIC_WRITE); + if (! NT_SUCCESS(Status)) + { + return Status; + } + Console = Buff->Header.Console; + + NewCursorX = SetCursorRequest->Position.X; + NewCursorY = SetCursorRequest->Position.Y; + if (NewCursorX < 0 || NewCursorX >= Buff->MaxX || + NewCursorY < 0 || NewCursorY >= Buff->MaxY) + { + ConioUnlockScreenBuffer(Buff); + return STATUS_INVALID_PARAMETER; + } + OldCursorX = Buff->CurrentX; + OldCursorY = Buff->CurrentY; + Buff->CurrentX = NewCursorX; + Buff->CurrentY = NewCursorY; + if (Buff == Console->ActiveBuffer) + { + if (! ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY)) { ConioUnlockScreenBuffer(Buff); return STATUS_UNSUCCESSFUL; @@ -1023,6 +1302,39 @@ return Status; } +CSR_API(SrvGetConsoleScreenBufferInfo) // CsrGetScreenBufferInfo +{ + NTSTATUS Status; + PCSRSS_SCREEN_BUFFER_INFO ScreenBufferInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ScreenBufferInfoRequest; + PCSRSS_CONSOLE Console; + PCSRSS_SCREEN_BUFFER Buff; + PCONSOLE_SCREEN_BUFFER_INFO pInfo; + + DPRINT("SrvGetConsoleScreenBufferInfo\n"); + + Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, ScreenBufferInfoRequest->ConsoleHandle, &Buff, GENERIC_READ); + if (! NT_SUCCESS(Status)) + { + return Status; + } + Console = Buff->Header.Console; + pInfo = &ScreenBufferInfoRequest->Info; + pInfo->dwSize.X = Buff->MaxX; + pInfo->dwSize.Y = Buff->MaxY; + pInfo->dwCursorPosition.X = Buff->CurrentX; + pInfo->dwCursorPosition.Y = Buff->CurrentY; + pInfo->wAttributes = Buff->DefaultAttrib; + pInfo->srWindow.Left = Buff->ShowX; + pInfo->srWindow.Right = Buff->ShowX + Console->Size.X - 1; + pInfo->srWindow.Top = Buff->ShowY; + pInfo->srWindow.Bottom = Buff->ShowY + Console->Size.Y - 1; + pInfo->dwMaximumWindowSize.X = Buff->MaxX; + pInfo->dwMaximumWindowSize.Y = Buff->MaxY; + ConioUnlockScreenBuffer(Buff); + + return STATUS_SUCCESS; +} + CSR_API(SrvSetConsoleActiveScreenBuffer) { NTSTATUS Status; @@ -1056,94 +1368,6 @@ ConioDrawConsole(Console); ConioUnlockScreenBuffer(Buff); - - return STATUS_SUCCESS; -} - -CSR_API(SrvWriteConsoleOutput) -{ - PCSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleOutputRequest; - SHORT i, X, Y, SizeX, SizeY; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; - PCSRSS_CONSOLE Console; - PCSRSS_SCREEN_BUFFER Buff; - SMALL_RECT ScreenBuffer; - CHAR_INFO* CurCharInfo; - SMALL_RECT WriteRegion; - CHAR_INFO* CharInfo; - COORD BufferCoord; - COORD BufferSize; - NTSTATUS Status; - PBYTE Ptr; - - DPRINT("SrvWriteConsoleOutput\n"); - - Status = ConioLockScreenBuffer(ProcessData, - WriteConsoleOutputRequest->ConsoleHandle, - &Buff, - GENERIC_WRITE); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Console = Buff->Header.Console; - - BufferSize = WriteConsoleOutputRequest->BufferSize; - BufferCoord = WriteConsoleOutputRequest->BufferCoord; - CharInfo = WriteConsoleOutputRequest->CharInfo; - if (!Win32CsrValidateBuffer(ProcessData, CharInfo, - BufferSize.X * BufferSize.Y, sizeof(CHAR_INFO))) - { - ConioUnlockScreenBuffer(Buff); - return STATUS_ACCESS_VIOLATION; - } - WriteRegion = WriteConsoleOutputRequest->WriteRegion; - - SizeY = min(BufferSize.Y - BufferCoord.Y, ConioRectHeight(&WriteRegion)); - SizeX = min(BufferSize.X - BufferCoord.X, ConioRectWidth(&WriteRegion)); - WriteRegion.Bottom = WriteRegion.Top + SizeY - 1; - WriteRegion.Right = WriteRegion.Left + SizeX - 1; - - /* Make sure WriteRegion is inside the screen buffer */ - ConioInitRect(&ScreenBuffer, 0, 0, Buff->MaxY - 1, Buff->MaxX - 1); - if (! ConioGetIntersection(&WriteRegion, &ScreenBuffer, &WriteRegion)) - { - ConioUnlockScreenBuffer(Buff); - - /* It is okay to have a WriteRegion completely outside the screen buffer. - No data is written then. */ - return STATUS_SUCCESS; - } - - for (i = 0, Y = WriteRegion.Top; Y <= WriteRegion.Bottom; i++, Y++) - { - CurCharInfo = CharInfo + (i + BufferCoord.Y) * BufferSize.X + BufferCoord.X; - Ptr = ConioCoordToPointer(Buff, WriteRegion.Left, Y); - for (X = WriteRegion.Left; X <= WriteRegion.Right; X++) - { - CHAR AsciiChar; - if (WriteConsoleOutputRequest->Unicode) - { - ConsoleUnicodeCharToAnsiChar(Console, &AsciiChar, &CurCharInfo->Char.UnicodeChar); - } - else - { - AsciiChar = CurCharInfo->Char.AsciiChar; - } - *Ptr++ = AsciiChar; - *Ptr++ = CurCharInfo->Attributes; - CurCharInfo++; - } - } - - ConioDrawRegion(Console, &WriteRegion); - - ConioUnlockScreenBuffer(Buff); - - WriteConsoleOutputRequest->WriteRegion.Right = WriteRegion.Left + SizeX - 1; - WriteConsoleOutputRequest->WriteRegion.Bottom = WriteRegion.Top + SizeY - 1; - WriteConsoleOutputRequest->WriteRegion.Left = WriteRegion.Left; - WriteConsoleOutputRequest->WriteRegion.Top = WriteRegion.Top; return STATUS_SUCCESS; } @@ -1242,221 +1466,6 @@ return STATUS_SUCCESS; } -CSR_API(CsrReadConsoleOutputChar) -{ - NTSTATUS Status; - PCSRSS_READ_CONSOLE_OUTPUT_CHAR ReadConsoleOutputCharRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleOutputCharRequest; - PCSRSS_CONSOLE Console; - PCSRSS_SCREEN_BUFFER Buff; - DWORD Xpos, Ypos; - PCHAR ReadBuffer; - DWORD i; - ULONG CharSize; - CHAR Char; - - DPRINT("CsrReadConsoleOutputChar\n"); - - ReadBuffer = ReadConsoleOutputCharRequest->String; - - CharSize = (ReadConsoleOutputCharRequest->Unicode ? sizeof(WCHAR) : sizeof(CHAR)); - - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, ReadConsoleOutputCharRequest->ConsoleHandle, &Buff, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - Console = Buff->Header.Console; - - Xpos = ReadConsoleOutputCharRequest->ReadCoord.X; - Ypos = (ReadConsoleOutputCharRequest->ReadCoord.Y + Buff->VirtualY) % Buff->MaxY; - - for (i = 0; i < ReadConsoleOutputCharRequest->NumCharsToRead; ++i) - { - Char = Buff->Buffer[(Xpos * 2) + (Ypos * 2 * Buff->MaxX)]; - - if(ReadConsoleOutputCharRequest->Unicode) - { - ConsoleAnsiCharToUnicodeChar(Console, (WCHAR*)ReadBuffer, &Char); - ReadBuffer += sizeof(WCHAR); - } - else - *(ReadBuffer++) = Char; - - Xpos++; - - if (Xpos == Buff->MaxX) - { - Xpos = 0; - Ypos++; - - if (Ypos == Buff->MaxY) - { - Ypos = 0; - } - } - } - - *ReadBuffer = 0; - ReadConsoleOutputCharRequest->EndCoord.X = Xpos; - ReadConsoleOutputCharRequest->EndCoord.Y = (Ypos - Buff->VirtualY + Buff->MaxY) % Buff->MaxY; - - ConioUnlockScreenBuffer(Buff); - - ReadConsoleOutputCharRequest->CharsRead = (DWORD)((ULONG_PTR)ReadBuffer - (ULONG_PTR)ReadConsoleOutputCharRequest->String) / CharSize; - if (ReadConsoleOutputCharRequest->CharsRead * CharSize + CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR) > sizeof(CSR_API_MESSAGE)) - { - DPRINT1("Length won't fit in message\n"); - return STATUS_BUFFER_TOO_SMALL; - } - - return STATUS_SUCCESS; -} - -CSR_API(CsrReadConsoleOutputAttrib) -{ - NTSTATUS Status; - PCSRSS_READ_CONSOLE_OUTPUT_ATTRIB ReadConsoleOutputAttribRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleOutputAttribRequest; - PCSRSS_SCREEN_BUFFER Buff; - DWORD Xpos, Ypos; - PWORD ReadBuffer; - DWORD i; - DWORD CurrentLength; - - DPRINT("CsrReadConsoleOutputAttrib\n"); - - ReadBuffer = ReadConsoleOutputAttribRequest->Attribute; - - Status = ConioLockScreenBuffer(CsrGetClientThread()->Process, ReadConsoleOutputAttribRequest->ConsoleHandle, &Buff, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - - Xpos = ReadConsoleOutputAttribRequest->ReadCoord.X; - Ypos = (ReadConsoleOutputAttribRequest->ReadCoord.Y + Buff->VirtualY) % Buff->MaxY; - - for (i = 0; i < ReadConsoleOutputAttribRequest->NumAttrsToRead; ++i) - { - *ReadBuffer = Buff->Buffer[(Xpos * 2) + (Ypos * 2 * Buff->MaxX) + 1]; - - ReadBuffer++; - Xpos++; - - if (Xpos == Buff->MaxX) - { - Xpos = 0; - Ypos++; - - if (Ypos == Buff->MaxY) - { - Ypos = 0; - } - } - } - - *ReadBuffer = 0; - - ReadConsoleOutputAttribRequest->EndCoord.X = Xpos; - ReadConsoleOutputAttribRequest->EndCoord.Y = (Ypos - Buff->VirtualY + Buff->MaxY) % Buff->MaxY; - - ConioUnlockScreenBuffer(Buff); - - CurrentLength = CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_ATTRIB) - + ReadConsoleOutputAttribRequest->NumAttrsToRead * sizeof(WORD); - if (CurrentLength > sizeof(CSR_API_MESSAGE)) - { - DPRINT1("Length won't fit in message\n"); - return STATUS_BUFFER_TOO_SMALL; - } - - return STATUS_SUCCESS; -} - -CSR_API(SrvReadConsoleOutput) -{ - PCSRSS_READ_CONSOLE_OUTPUT ReadConsoleOutputRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleOutputRequest; - PCSR_PROCESS ProcessData = CsrGetClientThread()->Process; - PCHAR_INFO CharInfo; - PCHAR_INFO CurCharInfo; - PCSRSS_SCREEN_BUFFER Buff; - DWORD SizeX, SizeY; - NTSTATUS Status; - COORD BufferSize; - COORD BufferCoord; - SMALL_RECT ReadRegion; - SMALL_RECT ScreenRect; - DWORD i; - PBYTE Ptr; - LONG X, Y; - UINT CodePage; - - DPRINT("SrvReadConsoleOutput\n"); - - Status = ConioLockScreenBuffer(ProcessData, ReadConsoleOutputRequest->ConsoleHandle, &Buff, GENERIC_READ); - if (! NT_SUCCESS(Status)) - { - return Status; - } - - CharInfo = ReadConsoleOutputRequest->CharInfo; - ReadRegion = ReadConsoleOutputRequest->ReadRegion; - BufferSize = ReadConsoleOutputRequest->BufferSize; - BufferCoord = ReadConsoleOutputRequest->BufferCoord; - - /* FIXME: Is this correct? */ - CodePage = ProcessData->Console->OutputCodePage; - - if (!Win32CsrValidateBuffer(ProcessData, CharInfo, - BufferSize.X * BufferSize.Y, sizeof(CHAR_INFO))) - { - ConioUnlockScreenBuffer(Buff); - return STATUS_ACCESS_VIOLATION; - } - - SizeY = min(BufferSize.Y - BufferCoord.Y, ConioRectHeight(&ReadRegion)); - SizeX = min(BufferSize.X - BufferCoord.X, ConioRectWidth(&ReadRegion)); - ReadRegion.Bottom = ReadRegion.Top + SizeY; - ReadRegion.Right = ReadRegion.Left + SizeX; - - ConioInitRect(&ScreenRect, 0, 0, Buff->MaxY, Buff->MaxX); - if (! ConioGetIntersection(&ReadRegion, &ScreenRect, &ReadRegion)) - { - ConioUnlockScreenBuffer(Buff); - return STATUS_SUCCESS; - } - - for (i = 0, Y = ReadRegion.Top; Y < ReadRegion.Bottom; ++i, ++Y) - { - CurCharInfo = CharInfo + (i * BufferSize.X); - - Ptr = ConioCoordToPointer(Buff, ReadRegion.Left, Y); - for (X = ReadRegion.Left; X < ReadRegion.Right; ++X) - { - if (ReadConsoleOutputRequest->Unicode) - { - MultiByteToWideChar(CodePage, 0, - (PCHAR)Ptr++, 1, - &CurCharInfo->Char.UnicodeChar, 1); - } - else - { - CurCharInfo->Char.AsciiChar = *Ptr++; - } - CurCharInfo->Attributes = *Ptr++; - ++CurCharInfo; - } - } - - ConioUnlockScreenBuffer(Buff); - - ReadConsoleOutputRequest->ReadRegion.Right = ReadRegion.Left + SizeX - 1; - ReadConsoleOutputRequest->ReadRegion.Bottom = ReadRegion.Top + SizeY - 1; - ReadConsoleOutputRequest->ReadRegion.Left = ReadRegion.Left; - ReadConsoleOutputRequest->ReadRegion.Top = ReadRegion.Top; - - return STATUS_SUCCESS; -} - CSR_API(SrvSetConsoleScreenBufferSize) { NTSTATUS Status;
11 years, 11 months
1
0
0
0
[jimtabor] 57716: [PSDK|User32] - Fix error return for future wine Win.c test_map_points tests. - Add missing error code.
by jimtabor@svn.reactos.org
Author: jimtabor Date: Fri Nov 16 23:23:49 2012 New Revision: 57716 URL:
http://svn.reactos.org/svn/reactos?rev=57716&view=rev
Log: [PSDK|User32] - Fix error return for future wine Win.c test_map_points tests. - Add missing error code. Modified: trunk/reactos/include/psdk/winerror.h trunk/reactos/win32ss/user/user32/misc/misc.c Modified: trunk/reactos/include/psdk/winerror.h URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/psdk/winerror.h?re…
============================================================================== --- trunk/reactos/include/psdk/winerror.h [iso-8859-1] (original) +++ trunk/reactos/include/psdk/winerror.h [iso-8859-1] Fri Nov 16 23:23:49 2012 @@ -838,6 +838,7 @@ #define ERROR_REQUIRES_INTERACTIVE_WINDOWSTATION 1459 #define ERROR_TIMEOUT 1460 #define ERROR_INVALID_MONITOR_HANDLE 1461 +#define ERROR_INCORRECT_SIZE 1462 #define ERROR_EVENTLOG_FILE_CORRUPT 1500 #define ERROR_EVENTLOG_CANT_START 1501 #define ERROR_LOG_FILE_FULL 1502 Modified: trunk/reactos/win32ss/user/user32/misc/misc.c URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/misc/m…
============================================================================== --- trunk/reactos/win32ss/user/user32/misc/misc.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/misc/misc.c [iso-8859-1] Fri Nov 16 23:23:49 2012 @@ -281,6 +281,8 @@ { INT Index; USHORT generation; + + if (!handle) return NULL; Index = (((UINT_PTR)handle & 0xffff) - FIRST_USER_HANDLE) >> 1; @@ -435,21 +437,14 @@ FASTCALL ValidateHwnd(HWND hwnd) { - PWND Wnd; PCLIENTINFO ClientInfo = GetWin32ClientInfo(); ASSERT(ClientInfo != NULL); /* See if the window is cached */ - if (hwnd == ClientInfo->CallbackWnd.hWnd) + if (hwnd && hwnd == ClientInfo->CallbackWnd.hWnd) return ClientInfo->CallbackWnd.pWnd; - Wnd = ValidateHandle((HANDLE)hwnd, otWindow); - if (Wnd != NULL) - { - return Wnd; - } - - return NULL; + return ValidateHandle((HANDLE)hwnd, otWindow); } //
11 years, 11 months
1
0
0
0
← Newer
1
...
4
5
6
7
8
9
10
...
13
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
Results per page:
10
25
50
100
200