ReactOS.org
Sign In
Sign Up
Sign In
Sign Up
Manage this list
×
Keyboard Shortcuts
Thread View
j
: Next unread message
k
: Previous unread message
j a
: Jump to all threads
j l
: Jump to MailingList overview
2024
December
November
October
September
August
July
June
May
April
March
February
January
2023
December
November
October
September
August
July
June
May
April
March
February
January
2022
December
November
October
September
August
July
June
May
April
March
February
January
2021
December
November
October
September
August
July
June
May
April
March
February
January
2020
December
November
October
September
August
July
June
May
April
March
February
January
2019
December
November
October
September
August
July
June
May
April
March
February
January
2018
December
November
October
September
August
July
June
May
April
March
February
January
2017
December
November
October
September
August
July
June
May
April
March
February
January
2016
December
November
October
September
August
July
June
May
April
March
February
January
2015
December
November
October
September
August
July
June
May
April
March
February
January
2014
December
November
October
September
August
July
June
May
April
March
February
January
2013
December
November
October
September
August
July
June
May
April
March
February
January
2012
December
November
October
September
August
July
June
May
April
March
February
January
2011
December
November
October
September
August
July
June
May
April
March
February
January
2010
December
November
October
September
August
July
June
May
April
March
February
January
2009
December
November
October
September
August
July
June
May
April
March
February
January
2008
December
November
October
September
August
July
June
May
April
March
February
January
2007
December
November
October
September
August
July
June
May
April
March
February
January
2006
December
November
October
September
August
July
June
May
April
March
February
January
2005
December
November
October
September
August
July
June
May
April
March
February
January
2004
December
November
October
September
August
July
June
May
April
March
February
List overview
Download
Ros-diffs
November 2012
----- 2024 -----
December 2024
November 2024
October 2024
September 2024
August 2024
July 2024
June 2024
May 2024
April 2024
March 2024
February 2024
January 2024
----- 2023 -----
December 2023
November 2023
October 2023
September 2023
August 2023
July 2023
June 2023
May 2023
April 2023
March 2023
February 2023
January 2023
----- 2022 -----
December 2022
November 2022
October 2022
September 2022
August 2022
July 2022
June 2022
May 2022
April 2022
March 2022
February 2022
January 2022
----- 2021 -----
December 2021
November 2021
October 2021
September 2021
August 2021
July 2021
June 2021
May 2021
April 2021
March 2021
February 2021
January 2021
----- 2020 -----
December 2020
November 2020
October 2020
September 2020
August 2020
July 2020
June 2020
May 2020
April 2020
March 2020
February 2020
January 2020
----- 2019 -----
December 2019
November 2019
October 2019
September 2019
August 2019
July 2019
June 2019
May 2019
April 2019
March 2019
February 2019
January 2019
----- 2018 -----
December 2018
November 2018
October 2018
September 2018
August 2018
July 2018
June 2018
May 2018
April 2018
March 2018
February 2018
January 2018
----- 2017 -----
December 2017
November 2017
October 2017
September 2017
August 2017
July 2017
June 2017
May 2017
April 2017
March 2017
February 2017
January 2017
----- 2016 -----
December 2016
November 2016
October 2016
September 2016
August 2016
July 2016
June 2016
May 2016
April 2016
March 2016
February 2016
January 2016
----- 2015 -----
December 2015
November 2015
October 2015
September 2015
August 2015
July 2015
June 2015
May 2015
April 2015
March 2015
February 2015
January 2015
----- 2014 -----
December 2014
November 2014
October 2014
September 2014
August 2014
July 2014
June 2014
May 2014
April 2014
March 2014
February 2014
January 2014
----- 2013 -----
December 2013
November 2013
October 2013
September 2013
August 2013
July 2013
June 2013
May 2013
April 2013
March 2013
February 2013
January 2013
----- 2012 -----
December 2012
November 2012
October 2012
September 2012
August 2012
July 2012
June 2012
May 2012
April 2012
March 2012
February 2012
January 2012
----- 2011 -----
December 2011
November 2011
October 2011
September 2011
August 2011
July 2011
June 2011
May 2011
April 2011
March 2011
February 2011
January 2011
----- 2010 -----
December 2010
November 2010
October 2010
September 2010
August 2010
July 2010
June 2010
May 2010
April 2010
March 2010
February 2010
January 2010
----- 2009 -----
December 2009
November 2009
October 2009
September 2009
August 2009
July 2009
June 2009
May 2009
April 2009
March 2009
February 2009
January 2009
----- 2008 -----
December 2008
November 2008
October 2008
September 2008
August 2008
July 2008
June 2008
May 2008
April 2008
March 2008
February 2008
January 2008
----- 2007 -----
December 2007
November 2007
October 2007
September 2007
August 2007
July 2007
June 2007
May 2007
April 2007
March 2007
February 2007
January 2007
----- 2006 -----
December 2006
November 2006
October 2006
September 2006
August 2006
July 2006
June 2006
May 2006
April 2006
March 2006
February 2006
January 2006
----- 2005 -----
December 2005
November 2005
October 2005
September 2005
August 2005
July 2005
June 2005
May 2005
April 2005
March 2005
February 2005
January 2005
----- 2004 -----
December 2004
November 2004
October 2004
September 2004
August 2004
July 2004
June 2004
May 2004
April 2004
March 2004
February 2004
ros-diffs@reactos.org
11 participants
124 discussions
Start a n
N
ew thread
[hbelusca] 57715: [KERNEL32/CONSRV] Fix compilation.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Nov 15 23:13:23 2012 New Revision: 57715 URL:
http://svn.reactos.org/svn/reactos?rev=57715&view=rev
Log: [KERNEL32/CONSRV] Fix compilation. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/alias.c branches/ros-csrss/win32ss/user/consrv/alias.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/alias.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/alias.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/alias.c [iso-8859-1] Thu Nov 15 23:13:23 2012 @@ -66,19 +66,19 @@ CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)lpSource, ConsoleAlias->SourceLength, - &ConsoleAlias->Source); + (PVOID*)&ConsoleAlias->Source); CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)lpExeName, ConsoleAlias->ExeLength, - &ConsoleAlias->Exe); + (PVOID*)&ConsoleAlias->Exe); if (lpTarget) /* The target can be optional */ { CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)lpTarget, ConsoleAlias->TargetLength, - &ConsoleAlias->Target); + (PVOID*)&ConsoleAlias->Target); } else { @@ -182,12 +182,12 @@ CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)lpSource, ConsoleAlias->SourceLength, - &ConsoleAlias->Source); + (PVOID*)&ConsoleAlias->Source); CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)lpExeName, ConsoleAlias->ExeLength, - &ConsoleAlias->Exe); + (PVOID*)&ConsoleAlias->Exe); /* Allocate space for the target buffer */ CsrAllocateMessagePointer(CaptureBuffer, Modified: branches/ros-csrss/win32ss/user/consrv/alias.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/a…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/alias.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/alias.c [iso-8859-1] Thu Nov 15 23:13:23 2012 @@ -298,15 +298,15 @@ DPRINT("SrvAddConsoleAlias entered ApiMessage %p\n", ApiMessage); if ( !CsrValidateMessageBuffer(ApiMessage, - &ConsoleAlias->Source, + (PVOID*)&ConsoleAlias->Source, ConsoleAlias->SourceLength, sizeof(BYTE)) || !CsrValidateMessageBuffer(ApiMessage, - &ConsoleAlias->Target, + (PVOID*)&ConsoleAlias->Target, ConsoleAlias->TargetLength, sizeof(BYTE)) || !CsrValidateMessageBuffer(ApiMessage, - &ConsoleAlias->Exe, + (PVOID*)&ConsoleAlias->Exe, ConsoleAlias->ExeLength, sizeof(BYTE)) ) { @@ -383,15 +383,15 @@ DPRINT("SrvGetConsoleAlias entered ApiMessage %p\n", ApiMessage); if ( !CsrValidateMessageBuffer(ApiMessage, - &ConsoleAlias->Source, + (PVOID*)&ConsoleAlias->Source, ConsoleAlias->SourceLength, sizeof(BYTE)) || !CsrValidateMessageBuffer(ApiMessage, - &ConsoleAlias->Target, + (PVOID*)&ConsoleAlias->Target, ConsoleAlias->TargetLength, sizeof(BYTE)) || !CsrValidateMessageBuffer(ApiMessage, - &ConsoleAlias->Exe, + (PVOID*)&ConsoleAlias->Exe, ConsoleAlias->ExeLength, sizeof(BYTE)) ) {
12 years, 1 month
1
0
0
0
[hbelusca] 57714: [KERNEL32/CONSRV] - Use a standard win32 thread function for the ConsoleControlDispatcher thread, instead of a custom PCONTROLDISPATCHER one. - Deactivate debug outputs in console...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Nov 15 23:06:49 2012 New Revision: 57714 URL:
http://svn.reactos.org/svn/reactos?rev=57714&view=rev
Log: [KERNEL32/CONSRV] - Use a standard win32 thread function for the ConsoleControlDispatcher thread, instead of a custom PCONTROLDISPATCHER one. - Deactivate debug outputs in console.c, which were activated by error in r57706. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c branches/ros-csrss/include/reactos/subsys/win/conmsg.h 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] Thu Nov 15 23:06:49 2012 @@ -15,7 +15,7 @@ #include <k32.h> -// #define NDEBUG +#define NDEBUG #include <debug.h> extern RTL_CRITICAL_SECTION ConsoleLock; @@ -66,16 +66,16 @@ return TRUE; } -__declspec(noreturn) -VOID -CALLBACK -ConsoleControlDispatcher(DWORD CodeAndFlag) +DWORD +WINAPI +ConsoleControlDispatcher(IN LPVOID lpThreadParameter) { DWORD nExitCode = 0; + DWORD CodeAndFlag = PtrToUlong(lpThreadParameter); DWORD nCode = CodeAndFlag & MAXLONG; UINT i; EXCEPTION_RECORD erException; - + DPRINT("Console Dispatcher Active: %lx %lx\n", CodeAndFlag, nCode); SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST); @@ -92,7 +92,7 @@ erException.ExceptionRecord = NULL; erException.ExceptionAddress = DefaultConsoleCtrlHandler; erException.NumberParameters = 0; - + _SEH2_TRY { RtlRaiseException(&erException); @@ -100,7 +100,7 @@ _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER) { RtlEnterCriticalSection(&ConsoleLock); - + if ((nCode != CTRL_C_EVENT) || (NtCurrentPeb()->ProcessParameters->ConsoleFlags != 1)) { @@ -109,14 +109,13 @@ if (CtrlHandlers[i - 1](nCode)) break; } } - + RtlLeaveCriticalSection(&ConsoleLock); } _SEH2_END; - + ExitThread(0); } - break; } @@ -124,25 +123,22 @@ case CTRL_LOGOFF_EVENT: case CTRL_SHUTDOWN_EVENT: break; - + case 3: - ExitThread(0); break; - + case 4: - ExitProcess(CONTROL_C_EXIT); break; default: - ASSERT(FALSE); break; } - + ASSERT(ConsoleInitialized); - + RtlEnterCriticalSection(&ConsoleLock); nExitCode = 0; if ((nCode != CTRL_C_EVENT) || (NtCurrentPeb()->ProcessParameters->ConsoleFlags != 1)) @@ -172,9 +168,10 @@ } } } - + RtlLeaveCriticalSection(&ConsoleLock); ExitThread(nExitCode); + return STATUS_SUCCESS; } 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] Thu Nov 15 23:06:49 2012 @@ -153,12 +153,10 @@ DWORD ControlKeyState; } CSRSS_READ_CONSOLE, *PCSRSS_READ_CONSOLE; -typedef VOID (CALLBACK *PCONTROLDISPATCHER)(DWORD); - -typedef struct -{ - PCONTROLDISPATCHER CtrlDispatcher; - BOOLEAN ConsoleNeeded; +typedef struct +{ + LPTHREAD_START_ROUTINE CtrlDispatcher; + BOOL ConsoleNeeded; INT ShowCmd; HANDLE Console; HANDLE InputHandle; @@ -308,7 +306,7 @@ HANDLE ConsoleHandle; BOOL Unicode; SMALL_RECT ScrollRectangle; - BOOLEAN UseClipRectangle; + BOOL UseClipRectangle; SMALL_RECT ClipRectangle; COORD DestinationOrigin; CHAR_INFO Fill;
12 years, 1 month
1
0
0
0
[hbelusca] 57713: [KERNEL32] - Move console-related Vista+ functions from client/vista.c to a dedicated client/console/vista.c file, and add it to compilation. - Move some helper functions from con...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Nov 15 22:34:44 2012 New Revision: 57713 URL:
http://svn.reactos.org/svn/reactos?rev=57713&view=rev
Log: [KERNEL32] - Move console-related Vista+ functions from client/vista.c to a dedicated client/console/vista.c file, and add it to compilation. - Move some helper functions from console.c to history.c. - Use the new api index names in history.c. [CONSRV] - Merge CSRSS_GET_HISTORY_INFO and PCSRSS_SET_HISTORY_INFO structures declarations into CSRSS_HISTORY_INFO, and therefore use only one member of it inside CONSOLE_API_MESSAGE structure. - WORD --> UINT for few structure members related to history information. Added: branches/ros-csrss/dll/win32/kernel32/client/console/vista.c (with props) Modified: branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt branches/ros-csrss/dll/win32/kernel32/client/console/console.c branches/ros-csrss/dll/win32/kernel32/client/console/history.c branches/ros-csrss/dll/win32/kernel32/client/vista.c branches/ros-csrss/include/reactos/subsys/win/conmsg.h branches/ros-csrss/win32ss/user/consrv/conio.h branches/ros-csrss/win32ss/user/consrv/guiconsole.c branches/ros-csrss/win32ss/user/consrv/lineinput.c Modified: branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/CM…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt [iso-8859-1] Thu Nov 15 22:34:44 2012 @@ -42,6 +42,7 @@ client/console/console.c client/console/history.c client/console/readwrite.c + client/console/vista.c client/file/backup.c client/file/cnotify.c client/file/copy.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] Thu Nov 15 22:34:44 2012 @@ -177,37 +177,6 @@ ExitThread(nExitCode); } -/* Get the size needed to copy a string to a capture buffer, including alignment */ -static ULONG -IntStringSize(LPCVOID String, - BOOL Unicode) -{ - ULONG Size = (Unicode ? wcslen(String) : strlen(String)) * sizeof(WCHAR); - return (Size + 3) & -4; -} - -/* Copy a string to a capture buffer */ -static VOID -IntCaptureMessageString(PCSR_CAPTURE_BUFFER CaptureBuffer, - LPCVOID String, - BOOL Unicode, - PUNICODE_STRING RequestString) -{ - ULONG Size; - if (Unicode) - { - Size = wcslen(String) * sizeof(WCHAR); - CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)String, Size, (PVOID *)&RequestString->Buffer); - } - else - { - Size = strlen(String); - CsrAllocateMessagePointer(CaptureBuffer, Size * sizeof(WCHAR), (PVOID *)&RequestString->Buffer); - Size = MultiByteToWideChar(CP_ACP, 0, String, Size, RequestString->Buffer, Size * sizeof(WCHAR)) - * sizeof(WCHAR); - } - RequestString->Length = RequestString->MaximumLength = Size; -} /* FUNCTIONS ******************************************************************/ Modified: branches/ros-csrss/dll/win32/kernel32/client/console/history.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/history.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/history.c [iso-8859-1] Thu Nov 15 22:34:44 2012 @@ -16,12 +16,47 @@ /* PRIVATE FUNCTIONS **********************************************************/ +/* Get the size needed to copy a string to a capture buffer, including alignment */ +static ULONG +IntStringSize(LPCVOID String, + BOOL Unicode) +{ + ULONG Size = (Unicode ? wcslen(String) : strlen(String)) * sizeof(WCHAR); + return (Size + 3) & -4; +} + + +/* Copy a string to a capture buffer */ +static VOID +IntCaptureMessageString(PCSR_CAPTURE_BUFFER CaptureBuffer, + LPCVOID String, + BOOL Unicode, + PUNICODE_STRING RequestString) +{ + ULONG Size; + if (Unicode) + { + Size = wcslen(String) * sizeof(WCHAR); + CsrCaptureMessageBuffer(CaptureBuffer, (PVOID)String, Size, (PVOID *)&RequestString->Buffer); + } + else + { + Size = strlen(String); + CsrAllocateMessagePointer(CaptureBuffer, Size * sizeof(WCHAR), (PVOID *)&RequestString->Buffer); + Size = MultiByteToWideChar(CP_ACP, 0, String, Size, RequestString->Buffer, Size * sizeof(WCHAR)) + * sizeof(WCHAR); + } + RequestString->Length = RequestString->MaximumLength = Size; +} + + static BOOL IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOL bUnicode) { - CSR_API_MESSAGE Request; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory = &ApiMessage.Data.ExpungeCommandHistory; PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) { @@ -38,16 +73,16 @@ } IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, - &Request.Data.ExpungeCommandHistory.ExeName); - - Status = CsrClientCallServer(&Request, + &ExpungeCommandHistory->ExeName); + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, EXPUNGE_COMMAND_HISTORY), - sizeof(CSR_API_MESSAGE)); + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepExpungeCommandHistory), + sizeof(CSRSS_EXPUNGE_COMMAND_HISTORY)); CsrFreeCaptureBuffer(CaptureBuffer); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return FALSE; @@ -60,9 +95,10 @@ static DWORD IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName, BOOL bUnicode) { - CSR_API_MESSAGE Request; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_GET_COMMAND_HISTORY GetCommandHistory = &ApiMessage.Data.GetCommandHistory; PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; DWORD HistoryLength = cbHistory * (bUnicode ? 1 : sizeof(WCHAR)); if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) @@ -81,16 +117,16 @@ } IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, - &Request.Data.GetCommandHistory.ExeName); - Request.Data.GetCommandHistory.Length = HistoryLength; + &GetCommandHistory->ExeName); + GetCommandHistory->Length = HistoryLength; CsrAllocateMessagePointer(CaptureBuffer, HistoryLength, - (PVOID*)&Request.Data.GetCommandHistory.History); - - Status = CsrClientCallServer(&Request, + (PVOID*)&GetCommandHistory->History); + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_COMMAND_HISTORY), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistory), + sizeof(CSRSS_GET_COMMAND_HISTORY)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { CsrFreeCaptureBuffer(CaptureBuffer); BaseSetLastNTError(Status); @@ -100,30 +136,32 @@ if (bUnicode) { memcpy(lpHistory, - Request.Data.GetCommandHistory.History, - Request.Data.GetCommandHistory.Length); + GetCommandHistory->History, + GetCommandHistory->Length); } else { WideCharToMultiByte(CP_ACP, 0, - Request.Data.GetCommandHistory.History, - Request.Data.GetCommandHistory.Length / sizeof(WCHAR), + GetCommandHistory->History, + GetCommandHistory->Length / sizeof(WCHAR), lpHistory, cbHistory, NULL, NULL); } CsrFreeCaptureBuffer(CaptureBuffer); - return Request.Data.GetCommandHistory.Length; + + return GetCommandHistory->Length; } static DWORD IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode) { - CSR_API_MESSAGE Request; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength = &ApiMessage.Data.GetCommandHistoryLength; PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) { @@ -140,22 +178,22 @@ } IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, - &Request.Data.GetCommandHistoryLength.ExeName); - - Status = CsrClientCallServer(&Request, + &GetCommandHistoryLength->ExeName); + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_COMMAND_HISTORY_LENGTH), - sizeof(CSR_API_MESSAGE)); + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetCommandHistoryLength), + sizeof(CSRSS_GET_COMMAND_HISTORY_LENGTH)); CsrFreeCaptureBuffer(CaptureBuffer); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return 0; } - return Request.Data.GetCommandHistoryLength.Length; + return GetCommandHistoryLength->Length; } @@ -164,9 +202,10 @@ LPCVOID lpExeName, BOOL bUnicode) { - CSR_API_MESSAGE Request; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands = &ApiMessage.Data.SetHistoryNumberCommands; PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) { @@ -183,17 +222,17 @@ } IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, - &Request.Data.SetHistoryNumberCommands.ExeName); - Request.Data.SetHistoryNumberCommands.NumCommands = dwNumCommands; - - Status = CsrClientCallServer(&Request, + &SetHistoryNumberCommands->ExeName); + SetHistoryNumberCommands->NumCommands = dwNumCommands; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_HISTORY_NUMBER_COMMANDS), - sizeof(CSR_API_MESSAGE)); + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetNumberOfCommands), + sizeof(CSRSS_SET_HISTORY_NUMBER_COMMANDS)); CsrFreeCaptureBuffer(CaptureBuffer); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return FALSE; Added: branches/ros-csrss/dll/win32/kernel32/client/console/vista.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/vista.c (added) +++ branches/ros-csrss/dll/win32/kernel32/client/console/vista.c [iso-8859-1] Thu Nov 15 22:34:44 2012 @@ -1,0 +1,177 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * PURPOSE: Vista functions + * PROGRAMMER: Thomas Weidenmueller (w3seek(a)reactos.com) + * Hermes Belusca-Maito (hermes.belusca(a)sfr.fr) + */ + +/* INCLUDES *******************************************************************/ + +#include <k32.h> + +#define NDEBUG +#include <debug.h> + + +/* PUBLIC FUNCTIONS ***********************************************************/ + +#if _WIN32_WINNT >= 0x600 + +/*-------------------------------------------------------------- + * GetConsoleHistoryInfo + * + * @implemented + */ +BOOL +WINAPI +GetConsoleHistoryInfo(PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo) +{ + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_HISTORY_INFO HistoryInfoRequest = &ApiMessage.Data.HistoryInfoRequest; + + if (lpConsoleHistoryInfo->cbSize != sizeof(CONSOLE_HISTORY_INFO)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetHistory), + sizeof(CSRSS_HISTORY_INFO)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + lpConsoleHistoryInfo->HistoryBufferSize = HistoryInfoRequest->HistoryBufferSize; + lpConsoleHistoryInfo->NumberOfHistoryBuffers = HistoryInfoRequest->NumberOfHistoryBuffers; + lpConsoleHistoryInfo->dwFlags = HistoryInfoRequest->dwFlags; + + return TRUE; +} + + +/*-------------------------------------------------------------- + * SetConsoleHistoryInfo + * + * @implemented + */ +BOOL +WINAPI +SetConsoleHistoryInfo(IN PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo) +{ + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_HISTORY_INFO HistoryInfoRequest = &ApiMessage.Data.HistoryInfoRequest; + + if (lpConsoleHistoryInfo->cbSize != sizeof(CONSOLE_HISTORY_INFO)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + HistoryInfoRequest->HistoryBufferSize = lpConsoleHistoryInfo->HistoryBufferSize; + HistoryInfoRequest->NumberOfHistoryBuffers = lpConsoleHistoryInfo->NumberOfHistoryBuffers; + HistoryInfoRequest->dwFlags = lpConsoleHistoryInfo->dwFlags; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetHistory), + sizeof(CSRSS_HISTORY_INFO)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + return TRUE; +} + + +/*-------------------------------------------------------------- + * GetConsoleOriginalTitleW + * + * @unimplemented + */ +DWORD +WINAPI +GetConsoleOriginalTitleW(OUT LPWSTR lpConsoleTitle, + IN DWORD nSize) +{ + DPRINT1("GetConsoleOriginalTitleW(0x%p, 0x%x) UNIMPLEMENTED!\n", lpConsoleTitle, nSize); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + + +/*-------------------------------------------------------------- + * GetConsoleOriginalTitleA + * + * @unimplemented + */ +DWORD +WINAPI +GetConsoleOriginalTitleA(OUT LPSTR lpConsoleTitle, + IN DWORD nSize) +{ + DPRINT1("GetConsoleOriginalTitleA(0x%p, 0x%x) UNIMPLEMENTED!\n", lpConsoleTitle, nSize); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return 0; +} + + +/*-------------------------------------------------------------- + * GetConsoleScreenBufferInfoEx + * + * @unimplemented + */ +BOOL +WINAPI +GetConsoleScreenBufferInfoEx(IN HANDLE hConsoleOutput, + OUT PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx) +{ + DPRINT1("GetConsoleScreenBufferInfoEx(0x%p, 0x%p) UNIMPLEMENTED!\n", hConsoleOutput, lpConsoleScreenBufferInfoEx); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/*-------------------------------------------------------------- + * SetConsoleScreenBufferInfoEx + * + * @unimplemented + */ +BOOL +WINAPI +SetConsoleScreenBufferInfoEx(IN HANDLE hConsoleOutput, + IN PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx) +{ + DPRINT1("SetConsoleScreenBufferInfoEx(0x%p, 0x%p) UNIMPLEMENTED!\n", hConsoleOutput, lpConsoleScreenBufferInfoEx); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + + +/*-------------------------------------------------------------- + * GetCurrentConsoleFontEx + * + * @unimplemented + */ +BOOL +WINAPI +GetCurrentConsoleFontEx(IN HANDLE hConsoleOutput, + IN BOOL bMaximumWindow, + OUT PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx) +{ + DPRINT1("GetCurrentConsoleFontEx(0x%p, 0x%x, 0x%p) UNIMPLEMENTED!\n", hConsoleOutput, bMaximumWindow, lpConsoleCurrentFontEx); + SetLastError(ERROR_CALL_NOT_IMPLEMENTED); + return FALSE; +} + +#endif + +/* EOF */ Propchange: branches/ros-csrss/dll/win32/kernel32/client/console/vista.c ------------------------------------------------------------------------------ svn:eol-style = native Modified: branches/ros-csrss/dll/win32/kernel32/client/vista.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/vista.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/vista.c [iso-8859-1] Thu Nov 15 22:34:44 2012 @@ -1,8 +1,11 @@ -/* COPYRIGHT: See COPYING in the top level directory +/* + * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * PURPOSE: Vista functions * PROGRAMMER: Thomas Weidenmueller <w3seek(a)reactos.com> */ + +/* INCLUDES *******************************************************************/ #include <k32.h> @@ -101,8 +104,8 @@ * @implemented */ BOOL WINAPI InitializeCriticalSectionEx(OUT LPCRITICAL_SECTION lpCriticalSection, - IN DWORD dwSpinCount, - IN DWORD flags ) + IN DWORD dwSpinCount, + IN DWORD flags) { NTSTATUS Status; @@ -122,7 +125,6 @@ /* Success */ return TRUE; } - /* @@ -228,6 +230,7 @@ return Result; } + /* * @unimplemented */ @@ -307,160 +310,6 @@ { UNIMPLEMENTED; return E_FAIL; -} - -/*-------------------------------------------------------------- - * GetConsoleHistoryInfo - * - * @implemented - */ -BOOL -WINAPI -GetConsoleHistoryInfo(PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo) -{ - NTSTATUS Status; - CONSOLE_API_MESSAGE ApiMessage; - PCSRSS_GET_HISTORY_INFO GetHistoryInfo = &ApiMessage.Data.GetHistoryInfo; - - if (lpConsoleHistoryInfo->cbSize != sizeof(CONSOLE_HISTORY_INFO)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, - NULL, - CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetHistory), - sizeof(CSRSS_GET_HISTORY_INFO)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - - lpConsoleHistoryInfo->HistoryBufferSize = GetHistoryInfo->HistoryBufferSize; - lpConsoleHistoryInfo->NumberOfHistoryBuffers = GetHistoryInfo->NumberOfHistoryBuffers; - lpConsoleHistoryInfo->dwFlags = GetHistoryInfo->dwFlags; - - return TRUE; -} - - -/*-------------------------------------------------------------- - * SetConsoleHistoryInfo - * - * @implemented - */ -BOOL -WINAPI -SetConsoleHistoryInfo(IN PCONSOLE_HISTORY_INFO lpConsoleHistoryInfo) -{ - NTSTATUS Status; - CONSOLE_API_MESSAGE ApiMessage; - PCSRSS_SET_HISTORY_INFO SetHistoryInfo = &ApiMessage.Data.SetHistoryInfo; - - if (lpConsoleHistoryInfo->cbSize != sizeof(CONSOLE_HISTORY_INFO)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - SetHistoryInfo->HistoryBufferSize = lpConsoleHistoryInfo->HistoryBufferSize; - SetHistoryInfo->NumberOfHistoryBuffers = lpConsoleHistoryInfo->NumberOfHistoryBuffers; - SetHistoryInfo->dwFlags = lpConsoleHistoryInfo->dwFlags; - - Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, - NULL, - CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetHistory), - sizeof(CSRSS_SET_HISTORY_INFO)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - - return TRUE; -} - - -/*-------------------------------------------------------------- - * GetConsoleOriginalTitleW - * - * @unimplemented - */ -DWORD -WINAPI -GetConsoleOriginalTitleW(OUT LPWSTR lpConsoleTitle, - IN DWORD nSize) -{ - DPRINT1("GetConsoleOriginalTitleW(0x%p, 0x%x) UNIMPLEMENTED!\n", lpConsoleTitle, nSize); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -/*-------------------------------------------------------------- - * GetConsoleOriginalTitleA - * - * @unimplemented - */ -DWORD -WINAPI -GetConsoleOriginalTitleA(OUT LPSTR lpConsoleTitle, - IN DWORD nSize) -{ - DPRINT1("GetConsoleOriginalTitleA(0x%p, 0x%x) UNIMPLEMENTED!\n", lpConsoleTitle, nSize); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return 0; -} - - -/*-------------------------------------------------------------- - * GetConsoleScreenBufferInfoEx - * - * @unimplemented - */ -BOOL -WINAPI -GetConsoleScreenBufferInfoEx(IN HANDLE hConsoleOutput, - OUT PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx) -{ - DPRINT1("GetConsoleScreenBufferInfoEx(0x%p, 0x%p) UNIMPLEMENTED!\n", hConsoleOutput, lpConsoleScreenBufferInfoEx); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/*-------------------------------------------------------------- - * SetConsoleScreenBufferInfoEx - * - * @unimplemented - */ -BOOL -WINAPI -SetConsoleScreenBufferInfoEx(IN HANDLE hConsoleOutput, - IN PCONSOLE_SCREEN_BUFFER_INFOEX lpConsoleScreenBufferInfoEx) -{ - DPRINT1("SetConsoleScreenBufferInfoEx(0x%p, 0x%p) UNIMPLEMENTED!\n", hConsoleOutput, lpConsoleScreenBufferInfoEx); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; -} - - -/*-------------------------------------------------------------- - * GetCurrentConsoleFontEx - * - * @unimplemented - */ -BOOL -WINAPI -GetCurrentConsoleFontEx(IN HANDLE hConsoleOutput, - IN BOOL bMaximumWindow, - OUT PCONSOLE_FONT_INFOEX lpConsoleCurrentFontEx) -{ - DPRINT1("GetCurrentConsoleFontEx(0x%p, 0x%x, 0x%p) UNIMPLEMENTED!\n", hConsoleOutput, bMaximumWindow, lpConsoleCurrentFontEx); - SetLastError(ERROR_CALL_NOT_IMPLEMENTED); - return FALSE; } @@ -701,6 +550,7 @@ return Ret; } + /* * @unimplemented */ @@ -721,6 +571,7 @@ UNIMPLEMENTED; return 0; } + /* * @implemented @@ -789,6 +640,7 @@ return Ret; } + /* * @unimplemented */ 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] Thu Nov 15 22:34:44 2012 @@ -468,19 +468,19 @@ typedef struct { UNICODE_STRING ExeName; + PWCHAR History; + DWORD Length; +} CSRSS_GET_COMMAND_HISTORY, *PCSRSS_GET_COMMAND_HISTORY; + +typedef struct +{ + UNICODE_STRING ExeName; DWORD Length; } CSRSS_GET_COMMAND_HISTORY_LENGTH, *PCSRSS_GET_COMMAND_HISTORY_LENGTH; typedef struct { UNICODE_STRING ExeName; - PWCHAR History; - DWORD Length; -} CSRSS_GET_COMMAND_HISTORY, *PCSRSS_GET_COMMAND_HISTORY; - -typedef struct -{ - UNICODE_STRING ExeName; } CSRSS_EXPUNGE_COMMAND_HISTORY, *PCSRSS_EXPUNGE_COMMAND_HISTORY; typedef struct @@ -491,11 +491,10 @@ typedef struct { - DWORD HistoryBufferSize; - DWORD NumberOfHistoryBuffers; + UINT HistoryBufferSize; + UINT NumberOfHistoryBuffers; DWORD dwFlags; -} CSRSS_GET_HISTORY_INFO, *PCSRSS_GET_HISTORY_INFO, - CSRSS_SET_HISTORY_INFO, *PCSRSS_SET_HISTORY_INFO;; +} CSRSS_HISTORY_INFO, *PCSRSS_HISTORY_INFO; @@ -607,8 +606,7 @@ CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength; CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory; CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands; - CSRSS_GET_HISTORY_INFO GetHistoryInfo; - CSRSS_SET_HISTORY_INFO SetHistoryInfo; + CSRSS_HISTORY_INFO HistoryInfoRequest; CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent; CSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest; Modified: branches/ros-csrss/win32ss/user/consrv/conio.h URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] Thu Nov 15 22:34:44 2012 @@ -63,8 +63,8 @@ BOOLEAN LineInsertToggle; /* replace character over cursor instead of inserting */ ULONG LineWakeupMask; /* bitmap of which control characters will end line input */ LIST_ENTRY HistoryBuffers; - WORD HistoryBufferSize; /* size for newly created history buffers */ - WORD NumberOfHistoryBuffers; /* maximum number of history buffers allowed */ + UINT HistoryBufferSize; /* size for newly created history buffers */ + UINT NumberOfHistoryBuffers; /* maximum number of history buffers allowed */ BOOLEAN HistoryNoDup; /* remove old duplicate history entries */ LIST_ENTRY BufferList; /* List of all screen buffers for this console */ PCSRSS_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer */ Modified: branches/ros-csrss/win32ss/user/consrv/guiconsole.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/g…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] Thu Nov 15 22:34:44 2012 @@ -434,8 +434,7 @@ } else { - DWORD Temp = Console->NumberOfHistoryBuffers; - RegSetValueExW(hKey, L"NumberOfHistoryBuffers", 0, REG_DWORD, (const BYTE *)&Temp, sizeof(DWORD)); + RegSetValueExW(hKey, L"NumberOfHistoryBuffers", 0, REG_DWORD, (const BYTE *)&Console->NumberOfHistoryBuffers, sizeof(DWORD)); } if (Console->HistoryBufferSize == 50) @@ -444,8 +443,7 @@ } else { - DWORD Temp = Console->HistoryBufferSize; - RegSetValueExW(hKey, L"HistoryBufferSize", 0, REG_DWORD, (const BYTE *)&Temp, sizeof(DWORD)); + RegSetValueExW(hKey, L"HistoryBufferSize", 0, REG_DWORD, (const BYTE *)&Console->HistoryBufferSize, sizeof(DWORD)); } if (GuiData->FullScreen == FALSE) @@ -457,7 +455,7 @@ RegSetValueExW(hKey, L"FullScreen", 0, REG_DWORD, (const BYTE *)&GuiData->FullScreen, sizeof(DWORD)); } - if ( GuiData->QuickEdit == FALSE) + if (GuiData->QuickEdit == FALSE) { RegDeleteKeyW(hKey, L"QuickEdit"); } 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] Thu Nov 15 22:34:44 2012 @@ -17,9 +17,9 @@ typedef struct tagHISTORY_BUFFER { LIST_ENTRY ListEntry; - WORD Position; - WORD MaxEntries; - WORD NumEntries; + UINT Position; + UINT MaxEntries; + UINT NumEntries; PUNICODE_STRING Entries; UNICODE_STRING ExeName; } HISTORY_BUFFER, *PHISTORY_BUFFER; @@ -257,7 +257,7 @@ PCSRSS_CONSOLE Console; PHISTORY_BUFFER Hist; NTSTATUS Status; - WORD MaxEntries = SetHistoryNumberCommands->NumCommands; + UINT MaxEntries = SetHistoryNumberCommands->NumCommands; PUNICODE_STRING OldEntryList, NewEntryList; if (!Win32CsrValidateBuffer(Process, @@ -302,14 +302,14 @@ CSR_API(SrvGetConsoleHistory) { - PCSRSS_GET_HISTORY_INFO GetHistoryInfo = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetHistoryInfo; + PCSRSS_HISTORY_INFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest; PCSRSS_CONSOLE Console; NTSTATUS Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console); if (NT_SUCCESS(Status)) { - GetHistoryInfo->HistoryBufferSize = Console->HistoryBufferSize; - GetHistoryInfo->NumberOfHistoryBuffers = Console->NumberOfHistoryBuffers; - GetHistoryInfo->dwFlags = Console->HistoryNoDup; + HistoryInfoRequest->HistoryBufferSize = Console->HistoryBufferSize; + HistoryInfoRequest->NumberOfHistoryBuffers = Console->NumberOfHistoryBuffers; + HistoryInfoRequest->dwFlags = Console->HistoryNoDup; ConioUnlockConsole(Console); } return Status; @@ -317,14 +317,14 @@ CSR_API(SrvSetConsoleHistory) { - PCSRSS_SET_HISTORY_INFO SetHistoryInfo = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetHistoryInfo; + PCSRSS_HISTORY_INFO HistoryInfoRequest = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest; PCSRSS_CONSOLE Console; NTSTATUS Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console); if (NT_SUCCESS(Status)) { - Console->HistoryBufferSize = (WORD)SetHistoryInfo->HistoryBufferSize; - Console->NumberOfHistoryBuffers = (WORD)SetHistoryInfo->NumberOfHistoryBuffers; - Console->HistoryNoDup = SetHistoryInfo->dwFlags & HISTORY_NO_DUP_FLAG; + Console->HistoryBufferSize = HistoryInfoRequest->HistoryBufferSize; + Console->NumberOfHistoryBuffers = HistoryInfoRequest->NumberOfHistoryBuffers; + Console->HistoryNoDup = HistoryInfoRequest->dwFlags & HISTORY_NO_DUP_FLAG; ConioUnlockConsole(Console); } return Status;
12 years, 1 month
1
0
0
0
[hbelusca] 57712: [KERNEL32/CONSRV] - Use capture buffers to pass (variable-length) strings to the console server. - Merge the CSRSS_ADD_CONSOLE_ALIAS and CSRSS_GET_CONSOLE_ALIAS structures into a ...
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Nov 15 21:02:01 2012 New Revision: 57712 URL:
http://svn.reactos.org/svn/reactos?rev=57712&view=rev
Log: [KERNEL32/CONSRV] - Use capture buffers to pass (variable-length) strings to the console server. - Merge the CSRSS_ADD_CONSOLE_ALIAS and CSRSS_GET_CONSOLE_ALIAS structures into a unique structure CSRSS_CONSOLE_ALIAS. TODO: Check what happens to the "/ sizeof(WCHAR);" in GetConsoleAliasesW. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/alias.c branches/ros-csrss/include/reactos/subsys/win/conmsg.h branches/ros-csrss/win32ss/user/consrv/alias.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/alias.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/alias.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/alias.c [iso-8859-1] Thu Nov 15 21:02:01 2012 @@ -1,8 +1,8 @@ /* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: dll/win32/kernel32/client/console/console.c - * PURPOSE: Win32 server console functions + * FILE: dll/win32/kernel32/client/console/alias.c + * PURPOSE: Win32 Console Client Alias support functions * PROGRAMMERS: David Welch (welch(a)cwcom.net) (welch(a)mcmail.com) * Christoph von Wittich (christoph_vw(a)reactos.org) * Johannes Anderwald (janderwald(a)reactos.org) @@ -15,10 +15,11 @@ #define NDEBUG #include <debug.h> + /* FUNCTIONS ******************************************************************/ /* - * @unimplemented + * @implemented */ BOOL WINAPI @@ -26,54 +27,77 @@ LPCWSTR lpTarget, LPCWSTR lpExeName) { - PCSR_API_MESSAGE Request; NTSTATUS Status; - ULONG SourceLength; - ULONG TargetLength = 0; - ULONG ExeLength; - ULONG Size; - ULONG RequestLength; - WCHAR * Ptr; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_CONSOLE_ALIAS ConsoleAlias = &ApiMessage.Data.ConsoleAlias; + PCSR_CAPTURE_BUFFER CaptureBuffer; + ULONG CapturedStrings; DPRINT("AddConsoleAliasW enterd with lpSource %S lpTarget %S lpExeName %S\n", lpSource, lpTarget, lpExeName); - ExeLength = wcslen(lpExeName) + 1; - SourceLength = wcslen(lpSource)+ 1; - if (lpTarget) - TargetLength = wcslen(lpTarget) + 1; - - Size = (ExeLength + SourceLength + TargetLength) * sizeof(WCHAR); - RequestLength = sizeof(CSR_API_MESSAGE) + Size; - - Request = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, RequestLength); - Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE)); - - wcscpy(Ptr, lpSource); - Request->Data.AddConsoleAlias.SourceLength = SourceLength; - Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE) + SourceLength * sizeof(WCHAR)); - - wcscpy(Ptr, lpExeName); - Request->Data.AddConsoleAlias.ExeLength = ExeLength; - Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE) + (ExeLength + SourceLength)* sizeof(WCHAR)); - - if (lpTarget) /* target can be optional */ - wcscpy(Ptr, lpTarget); - - Request->Data.AddConsoleAlias.TargetLength = TargetLength; - - Status = CsrClientCallServer(Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, ADD_CONSOLE_ALIAS), - RequestLength); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) + /* Determine the needed sizes */ + ConsoleAlias->SourceLength = (wcslen(lpSource ) + 1) * sizeof(WCHAR); + ConsoleAlias->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR); + CapturedStrings = 2; + + if (lpTarget) /* The target can be optional */ + { + ConsoleAlias->TargetLength = (wcslen(lpTarget) + 1) * sizeof(WCHAR); + CapturedStrings++; + } + else + { + ConsoleAlias->TargetLength = 0; + } + + /* Allocate a Capture Buffer */ + CaptureBuffer = CsrAllocateCaptureBuffer(CapturedStrings, + ConsoleAlias->SourceLength + + ConsoleAlias->ExeLength + + ConsoleAlias->TargetLength); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + /* Capture the strings */ + CsrCaptureMessageBuffer(CaptureBuffer, + (PVOID)lpSource, + ConsoleAlias->SourceLength, + &ConsoleAlias->Source); + + CsrCaptureMessageBuffer(CaptureBuffer, + (PVOID)lpExeName, + ConsoleAlias->ExeLength, + &ConsoleAlias->Exe); + + if (lpTarget) /* The target can be optional */ + { + CsrCaptureMessageBuffer(CaptureBuffer, + (PVOID)lpTarget, + ConsoleAlias->TargetLength, + &ConsoleAlias->Target); + } + else + { + ConsoleAlias->Target = NULL; + } + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepAddAlias), + sizeof(CSRSS_CONSOLE_ALIAS)); + + CsrFreeCaptureBuffer(CaptureBuffer); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); - RtlFreeHeap(GetProcessHeap(), 0, Request); return FALSE; } - RtlFreeHeap(GetProcessHeap(), 0, Request); return TRUE; } @@ -93,21 +117,21 @@ BOOL bRetVal; if (lpSource) - BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*) &lpSourceW); + BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*)&lpSourceW); if (lpTarget) - BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*) &lpTargetW); + BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*)&lpTargetW); if (lpExeName) - BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW); + BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*)&lpExeNameW); bRetVal = AddConsoleAliasW(lpSourceW, lpTargetW, lpExeNameW); /* Clean up */ if (lpSourceW) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpSourceW); + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpSourceW); if (lpTargetW) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpTargetW); + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpTargetW); if (lpExeNameW) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpExeNameW); + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpExeNameW); return bRetVal; } @@ -123,16 +147,12 @@ DWORD TargetBufferLength, LPWSTR lpExeName) { - PCSR_API_MESSAGE Request; + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_CONSOLE_ALIAS ConsoleAlias = &ApiMessage.Data.ConsoleAlias; PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; - ULONG Size; - ULONG ExeLength; - ULONG SourceLength; - ULONG RequestLength; - WCHAR * Ptr; - - DPRINT("GetConsoleAliasW entered lpSource %S lpExeName %S\n", lpSource, lpExeName); + + DPRINT("GetConsoleAliasW entered with lpSource %S lpExeName %S\n", lpSource, lpExeName); if (lpTargetBuffer == NULL) { @@ -140,63 +160,61 @@ return 0; } - ExeLength = wcslen(lpExeName) + 1; - SourceLength = wcslen(lpSource) + 1; - - Size = (ExeLength + SourceLength) * sizeof(WCHAR); - - RequestLength = Size + sizeof(CSR_API_MESSAGE); - Request = RtlAllocateHeap(GetProcessHeap(), 0, RequestLength); - if (Request == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - CaptureBuffer = CsrAllocateCaptureBuffer(1, TargetBufferLength); + /* Determine the needed sizes */ + ConsoleAlias->SourceLength = (wcslen(lpSource ) + 1) * sizeof(WCHAR); + ConsoleAlias->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR); + + ConsoleAlias->Target = NULL; + ConsoleAlias->TargetLength = TargetBufferLength; + + /* Allocate a Capture Buffer */ + CaptureBuffer = CsrAllocateCaptureBuffer(3, ConsoleAlias->SourceLength + + ConsoleAlias->ExeLength + + ConsoleAlias->TargetLength); if (!CaptureBuffer) { DPRINT1("CsrAllocateCaptureBuffer failed!\n"); - RtlFreeHeap(GetProcessHeap(), 0, Request); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - Request->Data.GetConsoleAlias.TargetBuffer = NULL; - + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + /* Capture the strings */ CsrCaptureMessageBuffer(CaptureBuffer, - NULL, - TargetBufferLength, - (PVOID*)&Request->Data.GetConsoleAlias.TargetBuffer); - - Request->Data.GetConsoleAlias.TargetBufferLength = TargetBufferLength; - - Ptr = (LPWSTR)((ULONG_PTR)Request + sizeof(CSR_API_MESSAGE)); - wcscpy(Ptr, lpSource); - Ptr += SourceLength; - wcscpy(Ptr, lpExeName); - - Request->Data.GetConsoleAlias.ExeLength = ExeLength; - Request->Data.GetConsoleAlias.SourceLength = SourceLength; - - Status = CsrClientCallServer(Request, + (PVOID)lpSource, + ConsoleAlias->SourceLength, + &ConsoleAlias->Source); + + CsrCaptureMessageBuffer(CaptureBuffer, + (PVOID)lpExeName, + ConsoleAlias->ExeLength, + &ConsoleAlias->Exe); + + /* Allocate space for the target buffer */ + CsrAllocateMessagePointer(CaptureBuffer, + ConsoleAlias->TargetLength, + (PVOID*)&ConsoleAlias->Target); + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIAS), - sizeof(CSR_API_MESSAGE) + Size); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) - { - RtlFreeHeap(GetProcessHeap(), 0, Request); + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAlias), + sizeof(CSRSS_CONSOLE_ALIAS)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { CsrFreeCaptureBuffer(CaptureBuffer); BaseSetLastNTError(Status); return 0; } - wcscpy(lpTargetBuffer, Request->Data.GetConsoleAlias.TargetBuffer); - RtlFreeHeap(GetProcessHeap(), 0, Request); + /* Copy the returned target string into the user buffer */ + // wcscpy(lpTargetBuffer, ConsoleAlias->Target); + memcpy(lpTargetBuffer, + ConsoleAlias->Target, + ConsoleAlias->TargetLength); + + /* Release the capture buffer and exits */ CsrFreeCaptureBuffer(CaptureBuffer); - return Request->Data.GetConsoleAlias.BytesWritten; + return ConsoleAlias->TargetLength; } @@ -272,158 +290,67 @@ */ DWORD WINAPI -GetConsoleAliasExesW(LPWSTR lpExeNameBuffer, - DWORD ExeNameBufferLength) -{ - CSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; - - DPRINT("GetConsoleAliasExesW entered\n"); - - CaptureBuffer = CsrAllocateCaptureBuffer(1, ExeNameBufferLength); - if (!CaptureBuffer) - { - DPRINT1("CsrAllocateCaptureBuffer failed!\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - CsrAllocateMessagePointer(CaptureBuffer, - ExeNameBufferLength, - (PVOID*)&Request.Data.GetConsoleAliasesExes.ExeNames); - Request.Data.GetConsoleAliasesExes.Length = ExeNameBufferLength; - - Status = CsrClientCallServer(&Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIASES_EXES), - sizeof(CSR_API_MESSAGE)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - CsrFreeCaptureBuffer(CaptureBuffer); - return 0; - } - - memcpy(lpExeNameBuffer, - Request.Data.GetConsoleAliasesExes.ExeNames, - Request.Data.GetConsoleAliasesExes.BytesWritten); - - CsrFreeCaptureBuffer(CaptureBuffer); - return Request.Data.GetConsoleAliasesExes.BytesWritten; -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasExesA(LPSTR lpExeNameBuffer, - DWORD ExeNameBufferLength) -{ - LPWSTR lpwExeNameBuffer; - DWORD dwResult; - - DPRINT("GetConsoleAliasExesA entered\n"); - - lpwExeNameBuffer = HeapAlloc(GetProcessHeap(), 0, ExeNameBufferLength * sizeof(WCHAR)); - - dwResult = GetConsoleAliasExesW(lpwExeNameBuffer, ExeNameBufferLength * sizeof(WCHAR)); - - if (dwResult) - dwResult = WideCharToMultiByte(CP_ACP, 0, lpwExeNameBuffer, dwResult / sizeof(WCHAR), lpExeNameBuffer, ExeNameBufferLength, NULL, NULL); - - HeapFree(GetProcessHeap(), 0, lpwExeNameBuffer); - return dwResult; -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasExesLengthW(VOID) -{ - CSR_API_MESSAGE Request; - NTSTATUS Status; - - DPRINT("GetConsoleAliasExesLengthW entered\n"); - - Request.Data.GetConsoleAliasesExesLength.Length = 0; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIASES_EXES_LENGTH), - sizeof(CSR_API_MESSAGE)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return 0; - } - - return Request.Data.GetConsoleAliasesExesLength.Length; -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasExesLengthA(VOID) -{ - DWORD dwLength; - - DPRINT("GetConsoleAliasExesLengthA entered\n"); - - dwLength = GetConsoleAliasExesLengthW(); - - if (dwLength) - dwLength /= sizeof(WCHAR); - - return dwLength; -} - - -/* - * @implemented - */ -DWORD -WINAPI GetConsoleAliasesW(LPWSTR AliasBuffer, DWORD AliasBufferLength, LPWSTR ExeName) { - CSR_API_MESSAGE Request; NTSTATUS Status; - DWORD dwLength; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAliases = &ApiMessage.Data.GetAllConsoleAliases; + PCSR_CAPTURE_BUFFER CaptureBuffer; DPRINT("GetConsoleAliasesW entered\n"); - dwLength = GetConsoleAliasesLengthW(ExeName); - if (!dwLength || dwLength > AliasBufferLength) - return 0; - - Request.Data.GetAllConsoleAlias.AliasBuffer = AliasBuffer; - Request.Data.GetAllConsoleAlias.AliasBufferLength = AliasBufferLength; - Request.Data.GetAllConsoleAlias.lpExeName = ExeName; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_ALL_CONSOLE_ALIASES), - sizeof(CSR_API_MESSAGE)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + /* Determine the needed sizes */ + GetAllConsoleAliases->ExeLength = GetConsoleAliasesLengthW(ExeName); + if (GetAllConsoleAliases->ExeLength == 0 || + GetAllConsoleAliases->ExeLength > AliasBufferLength) + { + return 0; + } + + GetAllConsoleAliases->AliasesBufferLength = AliasBufferLength; + + /* Allocate a Capture Buffer */ + CaptureBuffer = CsrAllocateCaptureBuffer(2, GetAllConsoleAliases->ExeLength + + GetAllConsoleAliases->AliasesBufferLength); + if (!CaptureBuffer) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + /* Capture the exe name and allocate space for the aliases buffer */ + CsrCaptureMessageBuffer(CaptureBuffer, + (PVOID)ExeName, + GetAllConsoleAliases->ExeLength, + (PVOID*)&GetAllConsoleAliases->ExeName); + + CsrAllocateMessagePointer(CaptureBuffer, + GetAllConsoleAliases->AliasesBufferLength, + (PVOID*)&GetAllConsoleAliases->AliasesBuffer); + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliases), + sizeof(CSRSS_GET_ALL_CONSOLE_ALIASES)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return 0; } - return Request.Data.GetAllConsoleAlias.BytesWritten / sizeof(WCHAR); + /* Copy the returned aliases string into the user buffer */ + // wcscpy(AliasBuffer, GetAllConsoleAliases->AliasesBuffer); + memcpy(AliasBuffer, + GetAllConsoleAliases->AliasesBuffer, + GetAllConsoleAliases->AliasesBufferLength); + + /* Release the capture buffer and exits */ + CsrFreeCaptureBuffer(CaptureBuffer); + + return GetAllConsoleAliases->AliasesBufferLength; // / sizeof(WCHAR); (original code) } @@ -443,17 +370,17 @@ DPRINT("GetConsoleAliasesA entered\n"); if (ExeName) - BasepAnsiStringToHeapUnicodeString(ExeName, (LPWSTR*) &lpwExeName); + BasepAnsiStringToHeapUnicodeString(ExeName, (LPWSTR*)&lpwExeName); lpwAliasBuffer = HeapAlloc(GetProcessHeap(), 0, AliasBufferLength * sizeof(WCHAR)); - dwRetVal = GetConsoleAliasesW(lpwAliasBuffer, AliasBufferLength, lpwExeName); + dwRetVal = GetConsoleAliasesW(lpwAliasBuffer, AliasBufferLength * sizeof(WCHAR), lpwExeName); if (lpwExeName) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpwExeName); + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpwExeName); if (dwRetVal) - dwRetVal = WideCharToMultiByte(CP_ACP, 0, lpwAliasBuffer, dwRetVal, AliasBuffer, AliasBufferLength, NULL, NULL); + dwRetVal = WideCharToMultiByte(CP_ACP, 0, lpwAliasBuffer, dwRetVal /**/ / sizeof(WCHAR) /**/, AliasBuffer, AliasBufferLength, NULL, NULL); HeapFree(GetProcessHeap(), 0, lpwAliasBuffer); return dwRetVal; @@ -467,26 +394,51 @@ WINAPI GetConsoleAliasesLengthW(LPWSTR lpExeName) { - CSR_API_MESSAGE Request; NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength = &ApiMessage.Data.GetAllConsoleAliasesLength; + PCSR_CAPTURE_BUFFER CaptureBuffer; DPRINT("GetConsoleAliasesLengthW entered\n"); - Request.Data.GetAllConsoleAliasesLength.lpExeName = lpExeName; - Request.Data.GetAllConsoleAliasesLength.Length = 0; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_ALL_CONSOLE_ALIASES_LENGTH), - sizeof(CSR_API_MESSAGE)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + if (lpExeName == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + GetAllConsoleAliasesLength->ExeLength = (wcslen(lpExeName) + 1) * sizeof(WCHAR); + GetAllConsoleAliasesLength->Length = 0; + + /* Allocate a Capture Buffer */ + CaptureBuffer = CsrAllocateCaptureBuffer(1, GetAllConsoleAliasesLength->ExeLength); + if (!CaptureBuffer) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + /* Capture the exe name */ + CsrCaptureMessageBuffer(CaptureBuffer, + (PVOID)lpExeName, + GetAllConsoleAliasesLength->ExeLength, + (PVOID)&GetAllConsoleAliasesLength->ExeName); + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasesLength), + sizeof(CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH)); + + CsrFreeCaptureBuffer(CaptureBuffer); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) { BaseSetLastNTError(Status); return 0; } - return Request.Data.GetAllConsoleAliasesLength.Length; + return GetAllConsoleAliasesLength->Length; } @@ -501,7 +453,7 @@ LPWSTR lpExeNameW = NULL; if (lpExeName) - BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW); + BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*)&lpExeNameW); dwRetVal = GetConsoleAliasesLengthW(lpExeNameW); if (dwRetVal) @@ -509,9 +461,138 @@ /* Clean up */ if (lpExeNameW) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpExeNameW); + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*)lpExeNameW); return dwRetVal; } + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasExesW(LPWSTR lpExeNameBuffer, + DWORD ExeNameBufferLength) +{ + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes = &ApiMessage.Data.GetConsoleAliasesExes; + PCSR_CAPTURE_BUFFER CaptureBuffer; + + DPRINT("GetConsoleAliasExesW entered\n"); + + /* Allocate a Capture Buffer */ + CaptureBuffer = CsrAllocateCaptureBuffer(1, ExeNameBufferLength); + if (!CaptureBuffer) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + GetConsoleAliasesExes->Length = ExeNameBufferLength; + + /* Allocate space for the exe name buffer */ + CsrAllocateMessagePointer(CaptureBuffer, + ExeNameBufferLength, + (PVOID*)&GetConsoleAliasesExes->ExeNames); + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExes), + sizeof(CSRSS_GET_CONSOLE_ALIASES_EXES)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + CsrFreeCaptureBuffer(CaptureBuffer); + BaseSetLastNTError(Status); + return 0; + } + + /* Copy the returned target string into the user buffer */ + memcpy(lpExeNameBuffer, + GetConsoleAliasesExes->ExeNames, + GetConsoleAliasesExes->Length); + + /* Release the capture buffer and exits */ + CsrFreeCaptureBuffer(CaptureBuffer); + + return GetConsoleAliasesExes->Length; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasExesA(LPSTR lpExeNameBuffer, + DWORD ExeNameBufferLength) +{ + LPWSTR lpwExeNameBuffer; + DWORD dwResult; + + DPRINT("GetConsoleAliasExesA entered\n"); + + lpwExeNameBuffer = HeapAlloc(GetProcessHeap(), 0, ExeNameBufferLength * sizeof(WCHAR)); + + dwResult = GetConsoleAliasExesW(lpwExeNameBuffer, ExeNameBufferLength * sizeof(WCHAR)); + + if (dwResult) + dwResult = WideCharToMultiByte(CP_ACP, 0, lpwExeNameBuffer, dwResult / sizeof(WCHAR), lpExeNameBuffer, ExeNameBufferLength, NULL, NULL); + + HeapFree(GetProcessHeap(), 0, lpwExeNameBuffer); + return dwResult; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasExesLengthW(VOID) +{ + NTSTATUS Status; + CONSOLE_API_MESSAGE ApiMessage; + PCSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength = &ApiMessage.Data.GetConsoleAliasesExesLength; + + DPRINT("GetConsoleAliasExesLengthW entered\n"); + + GetConsoleAliasesExesLength->Length = 0; + + Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage, + NULL, + CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetAliasExesLength), + sizeof(CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH)); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = ApiMessage.Status)) + { + BaseSetLastNTError(Status); + return 0; + } + + return GetConsoleAliasesExesLength->Length; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasExesLengthA(VOID) +{ + DWORD dwLength; + + DPRINT("GetConsoleAliasExesLengthA entered\n"); + + dwLength = GetConsoleAliasExesLengthW(); + + if (dwLength) + dwLength /= sizeof(WCHAR); + + return dwLength; +} + /* EOF */ 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] Thu Nov 15 21:02:01 2012 @@ -416,39 +416,41 @@ HICON WindowIcon; } CSRSS_SET_CONSOLE_ICON, *PCSRSS_SET_CONSOLE_ICON; -typedef struct -{ - ULONG SourceLength; - ULONG ExeLength; - ULONG TargetLength; -} CSRSS_ADD_CONSOLE_ALIAS, *PCSRSS_ADD_CONSOLE_ALIAS; - -typedef struct -{ - ULONG SourceLength; - ULONG ExeLength; - ULONG BytesWritten; - ULONG TargetBufferLength; - PVOID TargetBuffer; -} CSRSS_GET_CONSOLE_ALIAS, *PCSRSS_GET_CONSOLE_ALIAS; - -typedef struct -{ - LPWSTR lpExeName; - DWORD BytesWritten; - DWORD AliasBufferLength; - LPWSTR AliasBuffer; + + + + + + + + +typedef struct +{ + ULONG SourceLength; + ULONG TargetLength; // Also used for storing the number of bytes written. + ULONG ExeLength; + LPWSTR Source; + LPWSTR Target; + LPWSTR Exe; +} CSRSS_CONSOLE_ALIAS, *PCSRSS_CONSOLE_ALIAS; + +typedef struct +{ + DWORD ExeLength; + DWORD AliasesBufferLength; + LPWSTR ExeName; + LPWSTR AliasesBuffer; } CSRSS_GET_ALL_CONSOLE_ALIASES, *PCSRSS_GET_ALL_CONSOLE_ALIASES; typedef struct { - LPWSTR lpExeName; - DWORD Length; + DWORD Length; + DWORD ExeLength; + LPWSTR ExeName; } CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH, *PCSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH; typedef struct { - DWORD BytesWritten; DWORD Length; LPWSTR ExeNames; } CSRSS_GET_CONSOLE_ALIASES_EXES, *PCSRSS_GET_CONSOLE_ALIASES_EXES; @@ -458,28 +460,10 @@ DWORD Length; } CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH, *PCSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH; -typedef struct -{ - DWORD Event; - DWORD ProcessGroup; -} CSRSS_GENERATE_CTRL_EVENT, *PCSRSS_GENERATE_CTRL_EVENT; - -typedef struct -{ - HANDLE ConsoleHandle; - DWORD NumInputEvents; -} CSRSS_GET_NUM_INPUT_EVENTS, *PCSRSS_GET_NUM_INPUT_EVENTS; - -typedef struct -{ - HANDLE OutputHandle; - COORD Size; -} CSRSS_SET_SCREEN_BUFFER_SIZE, *PCSRSS_SET_SCREEN_BUFFER_SIZE; - -typedef struct -{ - CONSOLE_SELECTION_INFO Info; -} CSRSS_GET_CONSOLE_SELECTION_INFO, *PCSRSS_GET_CONSOLE_SELECTION_INFO; + + + + typedef struct { @@ -512,6 +496,38 @@ DWORD dwFlags; } CSRSS_GET_HISTORY_INFO, *PCSRSS_GET_HISTORY_INFO, CSRSS_SET_HISTORY_INFO, *PCSRSS_SET_HISTORY_INFO;; + + + + + + + + + + +typedef struct +{ + DWORD Event; + DWORD ProcessGroup; +} CSRSS_GENERATE_CTRL_EVENT, *PCSRSS_GENERATE_CTRL_EVENT; + +typedef struct +{ + HANDLE ConsoleHandle; + DWORD NumInputEvents; +} CSRSS_GET_NUM_INPUT_EVENTS, *PCSRSS_GET_NUM_INPUT_EVENTS; + +typedef struct +{ + HANDLE OutputHandle; + COORD Size; +} CSRSS_SET_SCREEN_BUFFER_SIZE, *PCSRSS_SET_SCREEN_BUFFER_SIZE; + +typedef struct +{ + CONSOLE_SELECTION_INFO Info; +} CSRSS_GET_CONSOLE_SELECTION_INFO, *PCSRSS_GET_CONSOLE_SELECTION_INFO; typedef struct { @@ -580,22 +596,24 @@ CSRSS_SETGET_CONSOLE_HW_STATE ConsoleHardwareStateRequest; CSRSS_GET_CONSOLE_WINDOW GetConsoleWindowRequest; CSRSS_SET_CONSOLE_ICON SetConsoleIconRequest; - CSRSS_ADD_CONSOLE_ALIAS AddConsoleAlias; - CSRSS_GET_CONSOLE_ALIAS GetConsoleAlias; - CSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAlias; + + 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; + + CSRSS_GET_COMMAND_HISTORY GetCommandHistory; + CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength; + CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory; + CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands; + CSRSS_GET_HISTORY_INFO GetHistoryInfo; + CSRSS_SET_HISTORY_INFO SetHistoryInfo; + CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent; CSRSS_GET_NUM_INPUT_EVENTS GetNumInputEventsRequest; CSRSS_SET_SCREEN_BUFFER_SIZE SetScreenBufferSize; CSRSS_GET_CONSOLE_SELECTION_INFO GetConsoleSelectionInfo; - CSRSS_GET_COMMAND_HISTORY_LENGTH GetCommandHistoryLength; - CSRSS_GET_COMMAND_HISTORY GetCommandHistory; - CSRSS_EXPUNGE_COMMAND_HISTORY ExpungeCommandHistory; - CSRSS_SET_HISTORY_NUMBER_COMMANDS SetHistoryNumberCommands; - CSRSS_GET_HISTORY_INFO GetHistoryInfo; - CSRSS_SET_HISTORY_INFO SetHistoryInfo; CSRSS_GET_CONSOLE_CP GetConsoleCodePage; CSRSS_SET_CONSOLE_CP SetConsoleCodePage; CSRSS_GET_CONSOLE_OUTPUT_CP GetConsoleOutputCodePage; Modified: branches/ros-csrss/win32ss/user/consrv/alias.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/a…
============================================================================== --- branches/ros-csrss/win32ss/user/consrv/alias.c [iso-8859-1] (original) +++ branches/ros-csrss/win32ss/user/consrv/alias.c [iso-8859-1] Thu Nov 15 21:02:01 2012 @@ -7,7 +7,7 @@ * Johannes Anderwald */ -/* INCLUDES ******************************************************************/ +/* INCLUDES *******************************************************************/ #include "consrv.h" #include "conio.h" @@ -16,21 +16,24 @@ #include <debug.h> +/* TYPES **********************************************************************/ + typedef struct tagALIAS_ENTRY { LPCWSTR lpSource; LPCWSTR lpTarget; - struct tagALIAS_ENTRY * Next; + struct tagALIAS_ENTRY* Next; } ALIAS_ENTRY, *PALIAS_ENTRY; typedef struct tagALIAS_HEADER { LPCWSTR lpExeName; PALIAS_ENTRY Data; - struct tagALIAS_HEADER * Next; - + struct tagALIAS_HEADER* Next; } ALIAS_HEADER, *PALIAS_HEADER; + +/* PRIVATE FUNCTIONS **********************************************************/ static PALIAS_HEADER @@ -99,7 +102,7 @@ while(RootHeader) { INT diff; - DPRINT("IntGetAliasEntry>lpSource %S\n", RootHeader->lpSource); + DPRINT("IntGetAliasEntry->lpSource %S\n", RootHeader->lpSource); diff = _wcsicmp(RootHeader->lpSource, lpSrcName); if (!diff) return RootHeader; @@ -111,7 +114,6 @@ } return NULL; } - VOID IntInsertAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY NewEntry) @@ -218,6 +220,7 @@ } return 0; } + UINT IntGetAllConsoleAliases(PALIAS_HEADER Header, LPWSTR TargetBuffer, UINT TargetBufferLength) { @@ -244,6 +247,7 @@ TargetBuffer[Offset] = L'\0'; return Offset * sizeof(WCHAR); } + VOID IntDeleteAliasEntry(PALIAS_HEADER Header, PALIAS_ENTRY Entry) { @@ -261,11 +265,13 @@ LastLink = &CurEntry->Next; } } + VOID IntDeleteAllAliases(PALIAS_HEADER RootHeader) { PALIAS_HEADER Header, NextHeader; PALIAS_ENTRY Entry, NextEntry; + for (Header = RootHeader; Header; Header = NextHeader) { NextHeader = Header->Next; @@ -278,33 +284,47 @@ } } + +/* PUBLIC SERVER APIS *********************************************************/ + CSR_API(SrvAddConsoleAlias) { - PCSRSS_ADD_CONSOLE_ALIAS AddConsoleAlias = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.AddConsoleAlias; + PCSRSS_CONSOLE_ALIAS ConsoleAlias = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAlias; PCSRSS_CONSOLE Console; PALIAS_HEADER Header; PALIAS_ENTRY Entry; - WCHAR * lpExeName; - WCHAR * lpSource; - WCHAR * lpTarget; - //ULONG TotalLength; - //WCHAR * Ptr; - - //TotalLength = AddConsoleAlias->SourceLength + AddConsoleAlias->ExeLength + AddConsoleAlias->TargetLength; - //Ptr = (WCHAR*)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE)); - - lpSource = (WCHAR*)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE)); - lpExeName = (WCHAR*)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE) + AddConsoleAlias->SourceLength * sizeof(WCHAR)); - lpTarget = (AddConsoleAlias->TargetLength != 0 ? lpExeName + AddConsoleAlias->ExeLength : NULL); - - DPRINT("SrvAddConsoleAlias entered ApiMessage %p lpSource %p lpExeName %p lpTarget %p\n", ApiMessage, lpSource, lpExeName, lpTarget); + LPWSTR lpSource, lpTarget, lpExeName; + + DPRINT("SrvAddConsoleAlias entered ApiMessage %p\n", ApiMessage); + + if ( !CsrValidateMessageBuffer(ApiMessage, + &ConsoleAlias->Source, + ConsoleAlias->SourceLength, + sizeof(BYTE)) || + !CsrValidateMessageBuffer(ApiMessage, + &ConsoleAlias->Target, + ConsoleAlias->TargetLength, + sizeof(BYTE)) || + !CsrValidateMessageBuffer(ApiMessage, + &ConsoleAlias->Exe, + ConsoleAlias->ExeLength, + sizeof(BYTE)) ) + { + return STATUS_INVALID_PARAMETER; + } + + lpSource = ConsoleAlias->Source; + lpTarget = (ConsoleAlias->TargetLength != 0 ? ConsoleAlias->Target : NULL); + lpExeName = ConsoleAlias->Exe; + + DPRINT("SrvAddConsoleAlias lpSource %p lpExeName %p lpTarget %p\n", lpSource, lpExeName, lpTarget); if (lpExeName == NULL || lpSource == NULL) { return STATUS_INVALID_PARAMETER; } - ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console); + ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console); if (!NT_SUCCESS(ApiMessage->Status)) { return ApiMessage->Status; @@ -322,7 +342,7 @@ IntInsertAliasHeader(&Console->Aliases, Header); } - if (lpTarget == NULL) // delete the entry + if (lpTarget == NULL) // Delete the entry { Entry = IntGetAliasEntry(Header, lpSource); if (Entry) @@ -353,30 +373,45 @@ CSR_API(SrvGetConsoleAlias) { - PCSRSS_GET_CONSOLE_ALIAS GetConsoleAlias = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetConsoleAlias; + PCSRSS_CONSOLE_ALIAS ConsoleAlias = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleAlias; PCSRSS_CONSOLE Console; PALIAS_HEADER Header; PALIAS_ENTRY Entry; UINT Length; - WCHAR * lpExeName; - WCHAR * lpSource; - WCHAR * lpTarget; - - lpSource = (LPWSTR)((ULONG_PTR)ApiMessage + sizeof(CSR_API_MESSAGE)); - lpExeName = lpSource + GetConsoleAlias->SourceLength; - lpTarget = GetConsoleAlias->TargetBuffer; - - - DPRINT("SrvGetConsoleAlias entered lpExeName %p lpSource %p TargetBuffer %p TargetBufferLength %u\n", - lpExeName, lpSource, lpTarget, GetConsoleAlias->TargetBufferLength); - - if (GetConsoleAlias->ExeLength == 0 || lpTarget == NULL || - GetConsoleAlias->TargetBufferLength == 0 || GetConsoleAlias->SourceLength == 0) - { - return STATUS_INVALID_PARAMETER; - } - - ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console); + LPWSTR lpSource, lpTarget, lpExeName; + + DPRINT("SrvGetConsoleAlias entered ApiMessage %p\n", ApiMessage); + + if ( !CsrValidateMessageBuffer(ApiMessage, + &ConsoleAlias->Source, + ConsoleAlias->SourceLength, + sizeof(BYTE)) || + !CsrValidateMessageBuffer(ApiMessage, + &ConsoleAlias->Target, + ConsoleAlias->TargetLength, + sizeof(BYTE)) || + !CsrValidateMessageBuffer(ApiMessage, + &ConsoleAlias->Exe, + ConsoleAlias->ExeLength, + sizeof(BYTE)) ) + { + return STATUS_INVALID_PARAMETER; + } + + lpSource = ConsoleAlias->Source; + lpTarget = ConsoleAlias->Target; + lpExeName = ConsoleAlias->Exe; + + DPRINT("SrvGetConsoleAlias lpExeName %p lpSource %p TargetBuffer %p TargetLength %u\n", + lpExeName, lpSource, lpTarget, ConsoleAlias->TargetLength); + + if (ConsoleAlias->ExeLength == 0 || lpTarget == NULL || + ConsoleAlias->TargetLength == 0 || ConsoleAlias->SourceLength == 0) + { + return STATUS_INVALID_PARAMETER; + } + + ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console); if (!NT_SUCCESS(ApiMessage->Status)) { return ApiMessage->Status; @@ -396,71 +431,87 @@ return STATUS_INVALID_PARAMETER; } - Length = (wcslen(Entry->lpTarget)+1) * sizeof(WCHAR); - if (Length > GetConsoleAlias->TargetBufferLength) + Length = (wcslen(Entry->lpTarget) + 1) * sizeof(WCHAR); + if (Length > ConsoleAlias->TargetLength) { ConioUnlockConsole(Console); return STATUS_BUFFER_TOO_SMALL; } +/* if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process, lpTarget, - GetConsoleAlias->TargetBufferLength, 1)) + ConsoleAlias->TargetLength, 1)) { ConioUnlockConsole(Console); return STATUS_ACCESS_VIOLATION; } +*/ wcscpy(lpTarget, Entry->lpTarget); - GetConsoleAlias->BytesWritten = Length; + ConsoleAlias->TargetLength = Length; ConioUnlockConsole(Console); return STATUS_SUCCESS; } CSR_API(SrvGetConsoleAliases) { - PCSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAlias = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllConsoleAlias; + PCSRSS_GET_ALL_CONSOLE_ALIASES GetAllConsoleAliases = &((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetAllConsoleAliases; PCSRSS_CONSOLE Console; ULONG BytesWritten; PALIAS_HEADER Header; - if (GetAllConsoleAlias->lpExeName == NULL) - { - return STATUS_INVALID_PARAMETER; - } - - ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console); + if ( !CsrValidateMessageBuffer(ApiMessage, + (PVOID)&GetAllConsoleAliases->ExeName, + GetAllConsoleAliases->ExeLength, + sizeof(BYTE)) || + !CsrValidateMessageBuffer(ApiMessage, + (PVOID)&GetAllConsoleAliases->AliasesBuffer, + GetAllConsoleAliases->AliasesBufferLength, + sizeof(BYTE)) ) + { + return STATUS_INVALID_PARAMETER; + } + + if (GetAllConsoleAliases->ExeName == NULL) + { + return STATUS_INVALID_PARAMETER; + } + + ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console); if (!NT_SUCCESS(ApiMessage->Status)) { return ApiMessage->Status; } - Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAlias->lpExeName); + Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAliases->ExeName); if (!Header) { ConioUnlockConsole(Console); return STATUS_INVALID_PARAMETER; } - if (IntGetAllConsoleAliasesLength(Header) > GetAllConsoleAlias->AliasBufferLength) + if (IntGetAllConsoleAliasesLength(Header) > GetAllConsoleAliases->AliasesBufferLength) { ConioUnlockConsole(Console); return STATUS_BUFFER_OVERFLOW; } +/* if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process, - GetAllConsoleAlias->AliasBuffer, - GetAllConsoleAlias->AliasBufferLength, + GetAllConsoleAliases->AliasesBuffer, + GetAllConsoleAliases->AliasesBufferLength, 1)) { ConioUnlockConsole(Console); return STATUS_ACCESS_VIOLATION; } +*/ BytesWritten = IntGetAllConsoleAliases(Header, - GetAllConsoleAlias->AliasBuffer, - GetAllConsoleAlias->AliasBufferLength); - - GetAllConsoleAlias->BytesWritten = BytesWritten; + GetAllConsoleAliases->AliasesBuffer, + GetAllConsoleAliases->AliasesBufferLength); + + GetAllConsoleAliases->AliasesBufferLength = BytesWritten; ConioUnlockConsole(Console); return STATUS_SUCCESS; } @@ -472,18 +523,26 @@ PALIAS_HEADER Header; UINT Length; - if (GetAllConsoleAliasesLength->lpExeName == NULL) - { - return STATUS_INVALID_PARAMETER; - } - - ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console); + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID)&GetAllConsoleAliasesLength->ExeName, + GetAllConsoleAliasesLength->ExeLength, + sizeof(BYTE))) + { + return STATUS_INVALID_PARAMETER; + } + + if (GetAllConsoleAliasesLength->ExeName == NULL) + { + return STATUS_INVALID_PARAMETER; + } + + ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console); if (!NT_SUCCESS(ApiMessage->Status)) { return ApiMessage->Status; } - Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAliasesLength->lpExeName); + Header = IntFindAliasHeader(Console->Aliases, GetAllConsoleAliasesLength->ExeName); if (!Header) { ConioUnlockConsole(Console); @@ -505,7 +564,15 @@ DPRINT("SrvGetConsoleAliasExes entered\n"); - ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console); + if (!CsrValidateMessageBuffer(ApiMessage, + (PVOID)&GetConsoleAliasesExes->ExeNames, + GetConsoleAliasesExes->Length, + sizeof(BYTE))) + { + return STATUS_INVALID_PARAMETER; + } + + ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console); if (!NT_SUCCESS(ApiMessage->Status)) { return ApiMessage->Status; @@ -525,6 +592,7 @@ return STATUS_INVALID_PARAMETER; } +/* if (!Win32CsrValidateBuffer(CsrGetClientThread()->Process, GetConsoleAliasesExes->ExeNames, GetConsoleAliasesExes->Length, @@ -533,12 +601,13 @@ ConioUnlockConsole(Console); return STATUS_ACCESS_VIOLATION; } +*/ BytesWritten = IntGetConsoleAliasesExes(Console->Aliases, GetConsoleAliasesExes->ExeNames, GetConsoleAliasesExes->Length); - GetConsoleAliasesExes->BytesWritten = BytesWritten; + GetConsoleAliasesExes->Length = BytesWritten; ConioUnlockConsole(Console); return STATUS_SUCCESS; } @@ -549,7 +618,7 @@ PCSRSS_CONSOLE Console; DPRINT("SrvGetConsoleAliasExesLength entered\n"); - ApiMessage->Status = ConioConsoleFromProcessData(CsrGetClientThread()->Process, &Console); + ApiMessage->Status = ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console); if (NT_SUCCESS(ApiMessage->Status)) { GetConsoleAliasesExesLength->Length = IntGetConsoleAliasesExesLength(Console->Aliases); @@ -557,3 +626,5 @@ } return ApiMessage->Status; } + +/* EOF */
12 years, 1 month
1
0
0
0
[hbelusca] 57711: [KERNEL32] - Move all the read/write related functions to an appropriate source file and add it to compilation. - Fix credits for alias.c
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Nov 15 18:06:17 2012 New Revision: 57711 URL:
http://svn.reactos.org/svn/reactos?rev=57711&view=rev
Log: [KERNEL32] - Move all the read/write related functions to an appropriate source file and add it to compilation. - Fix credits for alias.c Added: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c (with props) Modified: branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt branches/ros-csrss/dll/win32/kernel32/client/console/alias.c branches/ros-csrss/dll/win32/kernel32/client/console/console.c Modified: branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/CM…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt [iso-8859-1] Thu Nov 15 18:06:17 2012 @@ -41,6 +41,7 @@ client/console/alias.c client/console/console.c client/console/history.c + client/console/readwrite.c client/file/backup.c client/file/cnotify.c client/file/copy.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/alias.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/alias.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/alias.c [iso-8859-1] Thu Nov 15 18:06:17 2012 @@ -3,7 +3,8 @@ * PROJECT: ReactOS system libraries * FILE: dll/win32/kernel32/client/console/console.c * PURPOSE: Win32 server console functions - * PROGRAMMERS: Christoph von Wittich (christoph_vw(a)reactos.org) + * PROGRAMMERS: David Welch (welch(a)cwcom.net) (welch(a)mcmail.com) + * Christoph von Wittich (christoph_vw(a)reactos.org) * Johannes Anderwald (janderwald(a)reactos.org) */ 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] Thu Nov 15 18:06:17 2012 @@ -266,8 +266,6 @@ } - - /* * @unimplemented */ @@ -794,257 +792,6 @@ } -static -BOOL -IntWriteConsole(HANDLE hConsoleOutput, - PVOID lpBuffer, - DWORD nNumberOfCharsToWrite, - LPDWORD lpNumberOfCharsWritten, - LPVOID lpReserved, - BOOL bUnicode) -{ - PCSR_API_MESSAGE Request; - ULONG CsrRequest; - NTSTATUS Status; - USHORT nChars; - ULONG SizeBytes, CharSize; - DWORD Written = 0; - - CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); - Request = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE) + min(nNumberOfCharsToWrite, - CSRSS_MAX_WRITE_CONSOLE / CharSize) * CharSize)); - if (Request == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE); - - while (nNumberOfCharsToWrite > 0) - { - Request->Data.WriteConsoleRequest.ConsoleHandle = hConsoleOutput; - Request->Data.WriteConsoleRequest.Unicode = bUnicode; - - nChars = (USHORT)min(nNumberOfCharsToWrite, CSRSS_MAX_WRITE_CONSOLE / CharSize); - Request->Data.WriteConsoleRequest.NrCharactersToWrite = nChars; - - SizeBytes = nChars * CharSize; - - memcpy(Request->Data.WriteConsoleRequest.Buffer, lpBuffer, SizeBytes); - - Status = CsrClientCallServer(Request, - NULL, - CsrRequest, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE) + SizeBytes)); - - if (Status == STATUS_PENDING) - { - WaitForSingleObject(Request->Data.WriteConsoleRequest.UnpauseEvent, INFINITE); - CloseHandle(Request->Data.WriteConsoleRequest.UnpauseEvent); - continue; - } - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) - { - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - BaseSetLastNTError(Status); - return FALSE; - } - - nNumberOfCharsToWrite -= nChars; - lpBuffer = (PVOID)((ULONG_PTR)lpBuffer + (ULONG_PTR)SizeBytes); - Written += Request->Data.WriteConsoleRequest.NrCharactersWritten; - } - - if (lpNumberOfCharsWritten != NULL) - { - *lpNumberOfCharsWritten = Written; - } - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - - return TRUE; -} - - -/*-------------------------------------------------------------- - * WriteConsoleA - * - * @implemented - */ -BOOL -WINAPI -WriteConsoleA(HANDLE hConsoleOutput, - CONST VOID *lpBuffer, - DWORD nNumberOfCharsToWrite, - LPDWORD lpNumberOfCharsWritten, - LPVOID lpReserved) -{ - return IntWriteConsole(hConsoleOutput, - (PVOID)lpBuffer, - nNumberOfCharsToWrite, - lpNumberOfCharsWritten, - lpReserved, - FALSE); -} - - -/*-------------------------------------------------------------- - * WriteConsoleW - * - * @implemented - */ -BOOL -WINAPI -WriteConsoleW(HANDLE hConsoleOutput, - CONST VOID *lpBuffer, - DWORD nNumberOfCharsToWrite, - LPDWORD lpNumberOfCharsWritten, - LPVOID lpReserved) -{ - return IntWriteConsole(hConsoleOutput, - (PVOID)lpBuffer, - nNumberOfCharsToWrite, - lpNumberOfCharsWritten, - lpReserved, - TRUE); -} - - -static -BOOL -IntReadConsole(HANDLE hConsoleInput, - PVOID lpBuffer, - DWORD nNumberOfCharsToRead, - LPDWORD lpNumberOfCharsRead, - PCONSOLE_READCONSOLE_CONTROL pInputControl, - BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - ULONG CsrRequest; - PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status = STATUS_SUCCESS; - ULONG CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); - - CaptureBuffer = CsrAllocateCaptureBuffer(1, nNumberOfCharsToRead * CharSize); - if (CaptureBuffer == NULL) - { - DPRINT1("CsrAllocateCaptureBuffer failed!\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - 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; - if (pInputControl && pInputControl->nLength == sizeof(CONSOLE_READCONSOLE_CONTROL)) - { - Request.Data.ReadConsoleRequest.NrCharactersRead = pInputControl->nInitialChars; - memcpy(Request.Data.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) - { - 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); - 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; -} - - -/*-------------------------------------------------------------- - * ReadConsoleA - * - * @implemented - */ -BOOL -WINAPI -ReadConsoleA(HANDLE hConsoleInput, - LPVOID lpBuffer, - DWORD nNumberOfCharsToRead, - LPDWORD lpNumberOfCharsRead, - PCONSOLE_READCONSOLE_CONTROL pInputControl) -{ - return IntReadConsole(hConsoleInput, - lpBuffer, - nNumberOfCharsToRead, - lpNumberOfCharsRead, - NULL, - FALSE); -} - - -/*-------------------------------------------------------------- - * ReadConsoleW - * - * @implemented - */ -BOOL -WINAPI -ReadConsoleW(HANDLE hConsoleInput, - LPVOID lpBuffer, - DWORD nNumberOfCharsToRead, - LPDWORD lpNumberOfCharsRead, - PCONSOLE_READCONSOLE_CONTROL pInputControl) -{ - return IntReadConsole(hConsoleInput, - lpBuffer, - nNumberOfCharsToRead, - lpNumberOfCharsRead, - pInputControl, - TRUE); -} - - /*-------------------------------------------------------------- * AllocConsole * @@ -1181,1078 +928,6 @@ BaseSetLastNTError(Status); return FALSE; } - - return TRUE; -} - - -static -BOOL -IntFillConsoleOutputCharacter(HANDLE hConsoleOutput, - PVOID cCharacter, - DWORD nLength, - COORD dwWriteCoord, - LPDWORD lpNumberOfCharsWritten, - BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.FillOutputRequest.ConsoleHandle = hConsoleOutput; - Request.Data.FillOutputRequest.Unicode = bUnicode; - - if(bUnicode) - Request.Data.FillOutputRequest.Char.UnicodeChar = *((WCHAR*)cCharacter); - else - Request.Data.FillOutputRequest.Char.AsciiChar = *((CHAR*)cCharacter); - - Request.Data.FillOutputRequest.Position = dwWriteCoord; - Request.Data.FillOutputRequest.Length = (WORD)nLength; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, FILL_OUTPUT), - sizeof(CSR_API_MESSAGE)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - - if(lpNumberOfCharsWritten != NULL) - { - *lpNumberOfCharsWritten = Request.Data.FillOutputRequest.NrCharactersWritten; - } - - return TRUE; -} - -/*-------------------------------------------------------------- - * FillConsoleOutputCharacterA - * - * @implemented - */ -BOOL -WINAPI -FillConsoleOutputCharacterA(HANDLE hConsoleOutput, - CHAR cCharacter, - DWORD nLength, - COORD dwWriteCoord, - LPDWORD lpNumberOfCharsWritten) -{ - return IntFillConsoleOutputCharacter(hConsoleOutput, - &cCharacter, - nLength, - dwWriteCoord, - lpNumberOfCharsWritten, - FALSE); -} - - -/*-------------------------------------------------------------- - * FillConsoleOutputCharacterW - * - * @implemented - */ -BOOL -WINAPI -FillConsoleOutputCharacterW(HANDLE hConsoleOutput, - WCHAR cCharacter, - DWORD nLength, - COORD dwWriteCoord, - LPDWORD lpNumberOfCharsWritten) -{ - return IntFillConsoleOutputCharacter(hConsoleOutput, - &cCharacter, - nLength, - dwWriteCoord, - lpNumberOfCharsWritten, - 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); -} - -/*-------------------------------------------------------------- - * PeekConsoleInputA - * - * @implemented - */ -BOOL -WINAPI -PeekConsoleInputA(HANDLE hConsoleInput, - PINPUT_RECORD lpBuffer, - DWORD nLength, - LPDWORD lpNumberOfEventsRead) -{ - return IntPeekConsoleInput(hConsoleInput, - lpBuffer, - nLength, - lpNumberOfEventsRead, - FALSE); -} - - -/*-------------------------------------------------------------- - * PeekConsoleInputW - * - * @implemented - */ -BOOL -WINAPI -PeekConsoleInputW(HANDLE hConsoleInput, - PINPUT_RECORD lpBuffer, - DWORD nLength, - LPDWORD lpNumberOfEventsRead) -{ - return IntPeekConsoleInput(hConsoleInput, - lpBuffer, nLength, - lpNumberOfEventsRead, - TRUE); -} - - -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)) - { - 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; - } - } - else if (Status == STATUS_PENDING) - { - 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; - } - } - else - { - lpBuffer[Read++] = Request.Data.ReadInputRequest.Input; - nLength--; - - if (!Request.Data.ReadInputRequest.MoreEvents) - { - /* nothing more to read, bail */ - break; - } - } - } - - if (lpNumberOfEventsRead != NULL) - { - *lpNumberOfEventsRead = Read; - } - - return (Read > 0); -} - - -/*-------------------------------------------------------------- - * ReadConsoleInputA - * - * @implemented - */ -BOOL -WINAPI -ReadConsoleInputA(HANDLE hConsoleInput, - PINPUT_RECORD lpBuffer, - DWORD nLength, - LPDWORD lpNumberOfEventsRead) -{ - return IntReadConsoleInput(hConsoleInput, - lpBuffer, - nLength, - lpNumberOfEventsRead, - FALSE); -} - - -/*-------------------------------------------------------------- - * ReadConsoleInputW - * - * @implemented - */ -BOOL -WINAPI -ReadConsoleInputW(HANDLE hConsoleInput, - PINPUT_RECORD lpBuffer, - DWORD nLength, - LPDWORD lpNumberOfEventsRead) -{ - return IntReadConsoleInput(hConsoleInput, - lpBuffer, - nLength, - lpNumberOfEventsRead, - TRUE); -} - - -static -BOOL -IntWriteConsoleInput(HANDLE hConsoleInput, - PINPUT_RECORD lpBuffer, - DWORD nLength, - LPDWORD lpNumberOfEventsWritten, - BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - DWORD Size; - - if (lpBuffer == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - Size = nLength * sizeof(INPUT_RECORD); - - /* Allocate a Capture Buffer */ - DPRINT("IntWriteConsoleInput: %lx %p\n", Size, lpNumberOfEventsWritten); - 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, - lpBuffer, - Size, - (PVOID*)&Request.Data.WriteConsoleInputRequest.InputRecord); - - /* Set up the data to send to the Console Server */ - Request.Data.WriteConsoleInputRequest.ConsoleHandle = hConsoleInput; - Request.Data.WriteConsoleInputRequest.Unicode = bUnicode; - Request.Data.WriteConsoleInputRequest.Length = nLength; - - /* Call the server */ - CsrClientCallServer(&Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_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.WriteConsoleInputRequest.Length); - *lpNumberOfEventsWritten = Request.Data.WriteConsoleInputRequest.Length; - } - else - { - /* Error out */ - *lpNumberOfEventsWritten = 0; - BaseSetLastNTError(Request.Status); - } - - /* Release the capture buffer */ - CsrFreeCaptureBuffer(CaptureBuffer); - - /* Return TRUE or FALSE */ - return NT_SUCCESS(Request.Status); -} - - -/*-------------------------------------------------------------- - * WriteConsoleInputA - * - * @implemented - */ -BOOL -WINAPI -WriteConsoleInputA(HANDLE hConsoleInput, - CONST INPUT_RECORD *lpBuffer, - DWORD nLength, - LPDWORD lpNumberOfEventsWritten) -{ - return IntWriteConsoleInput(hConsoleInput, - (PINPUT_RECORD)lpBuffer, - nLength, - lpNumberOfEventsWritten, - FALSE); -} - - -/*-------------------------------------------------------------- - * WriteConsoleInputW - * - * @implemented - */ -BOOL -WINAPI -WriteConsoleInputW(HANDLE hConsoleInput, - CONST INPUT_RECORD *lpBuffer, - DWORD nLength, - LPDWORD lpNumberOfEventsWritten) -{ - return IntWriteConsoleInput(hConsoleInput, - (PINPUT_RECORD)lpBuffer, - nLength, - lpNumberOfEventsWritten, - TRUE); -} - - -static -BOOL -IntReadConsoleOutput(HANDLE hConsoleOutput, - PCHAR_INFO lpBuffer, - COORD dwBufferSize, - COORD dwBufferCoord, - PSMALL_RECT lpReadRegion, - BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - DWORD Size, SizeX, SizeY; - - if (lpBuffer == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - Size = dwBufferSize.X * dwBufferSize.Y * sizeof(CHAR_INFO); - - /* Allocate a Capture Buffer */ - DPRINT("IntReadConsoleOutput: %lx %p\n", Size, lpReadRegion); - CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); - if (CaptureBuffer == NULL) - { - DPRINT1("CsrAllocateCaptureBuffer failed with size 0x%x!\n", Size); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - /* Allocate space in the Buffer */ - CsrCaptureMessageBuffer(CaptureBuffer, - NULL, - Size, - (PVOID*)&Request.Data.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; - - /* Call the server */ - CsrClientCallServer(&Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, READ_CONSOLE_OUTPUT), - sizeof(CSR_API_MESSAGE)); - DPRINT("Server returned: %x\n", Request.Status); - - /* Check for success*/ - if (NT_SUCCESS(Request.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; - RtlCopyMemory(lpBuffer, - Request.Data.ReadConsoleOutputRequest.CharInfo, - sizeof(CHAR_INFO) * SizeX * SizeY); - } - else - { - /* Error out */ - BaseSetLastNTError(Request.Status); - } - - /* Return the read region */ - DPRINT("read region: %lx\n", Request.Data.ReadConsoleOutputRequest.ReadRegion); - *lpReadRegion = Request.Data.ReadConsoleOutputRequest.ReadRegion; - - /* Release the capture buffer */ - CsrFreeCaptureBuffer(CaptureBuffer); - - /* Return TRUE or FALSE */ - return NT_SUCCESS(Request.Status); -} - -/*-------------------------------------------------------------- - * ReadConsoleOutputA - * - * @implemented - */ -BOOL -WINAPI -ReadConsoleOutputA(HANDLE hConsoleOutput, - PCHAR_INFO lpBuffer, - COORD dwBufferSize, - COORD dwBufferCoord, - PSMALL_RECT lpReadRegion) -{ - return IntReadConsoleOutput(hConsoleOutput, - lpBuffer, - dwBufferSize, - dwBufferCoord, - lpReadRegion, - FALSE); -} - - -/*-------------------------------------------------------------- - * ReadConsoleOutputW - * - * @implemented - */ -BOOL -WINAPI -ReadConsoleOutputW(HANDLE hConsoleOutput, - PCHAR_INFO lpBuffer, - COORD dwBufferSize, - COORD dwBufferCoord, - PSMALL_RECT lpReadRegion) -{ - return IntReadConsoleOutput(hConsoleOutput, - lpBuffer, - dwBufferSize, - dwBufferCoord, - lpReadRegion, - TRUE); -} - - -static -BOOL -IntWriteConsoleOutput(HANDLE hConsoleOutput, - CONST CHAR_INFO *lpBuffer, - COORD dwBufferSize, - COORD dwBufferCoord, - PSMALL_RECT lpWriteRegion, - BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - ULONG Size; - - Size = dwBufferSize.Y * dwBufferSize.X * sizeof(CHAR_INFO); - - /* Allocate a Capture Buffer */ - DPRINT("IntWriteConsoleOutput: %lx %p\n", Size, lpWriteRegion); - 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.WriteConsoleOutputRequest.CharInfo); - - /* Copy from the buffer */ - RtlCopyMemory(Request.Data.WriteConsoleOutputRequest.CharInfo, lpBuffer, Size); - - /* Set up the data to send to the Console Server */ - Request.Data.WriteConsoleOutputRequest.ConsoleHandle = hConsoleOutput; - Request.Data.WriteConsoleOutputRequest.Unicode = bUnicode; - Request.Data.WriteConsoleOutputRequest.BufferSize = dwBufferSize; - Request.Data.WriteConsoleOutputRequest.BufferCoord = dwBufferCoord; - Request.Data.WriteConsoleOutputRequest.WriteRegion = *lpWriteRegion; - - /* Call the server */ - CsrClientCallServer(&Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE_OUTPUT), - sizeof(CSR_API_MESSAGE)); - DPRINT("Server returned: %x\n", Request.Status); - - /* Check for success*/ - if (!NT_SUCCESS(Request.Status)) - { - /* Error out */ - BaseSetLastNTError(Request.Status); - } - - /* Return the read region */ - DPRINT("read region: %lx\n", Request.Data.WriteConsoleOutputRequest.WriteRegion); - *lpWriteRegion = Request.Data.WriteConsoleOutputRequest.WriteRegion; - - /* Release the capture buffer */ - CsrFreeCaptureBuffer(CaptureBuffer); - - /* Return TRUE or FALSE */ - return NT_SUCCESS(Request.Status); -} - -/*-------------------------------------------------------------- - * WriteConsoleOutputA - * - * @implemented - */ -BOOL -WINAPI -WriteConsoleOutputA(HANDLE hConsoleOutput, - CONST CHAR_INFO *lpBuffer, - COORD dwBufferSize, - COORD dwBufferCoord, - PSMALL_RECT lpWriteRegion) -{ - return IntWriteConsoleOutput(hConsoleOutput, - lpBuffer, - dwBufferSize, - dwBufferCoord, - lpWriteRegion, - FALSE); -} - - -/*-------------------------------------------------------------- - * WriteConsoleOutputW - * - * @implemented - */ -BOOL -WINAPI -WriteConsoleOutputW(HANDLE hConsoleOutput, - CONST CHAR_INFO *lpBuffer, - COORD dwBufferSize, - COORD dwBufferCoord, - PSMALL_RECT lpWriteRegion) -{ - return IntWriteConsoleOutput(hConsoleOutput, - lpBuffer, - dwBufferSize, - dwBufferCoord, - lpWriteRegion, - TRUE); -} - - -static -BOOL -IntReadConsoleOutputCharacter(HANDLE hConsoleOutput, - PVOID lpCharacter, - DWORD nLength, - COORD dwReadCoord, - LPDWORD lpNumberOfCharsRead, - BOOL bUnicode) -{ - PCSR_API_MESSAGE Request; - ULONG CsrRequest; - 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) - { - 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)) - { - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - BaseSetLastNTError(Status); - break; - } - - 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); - - return TRUE; -} - - -/*-------------------------------------------------------------- - * ReadConsoleOutputCharacterA - * - * @implemented - */ -BOOL -WINAPI -ReadConsoleOutputCharacterA(HANDLE hConsoleOutput, - LPSTR lpCharacter, - DWORD nLength, - COORD dwReadCoord, - LPDWORD lpNumberOfCharsRead) -{ - return IntReadConsoleOutputCharacter(hConsoleOutput, - (PVOID)lpCharacter, - nLength, - dwReadCoord, - lpNumberOfCharsRead, - FALSE); -} - - -/*-------------------------------------------------------------- - * ReadConsoleOutputCharacterW - * - * @implemented - */ -BOOL -WINAPI -ReadConsoleOutputCharacterW(HANDLE hConsoleOutput, - LPWSTR lpCharacter, - DWORD nLength, - COORD dwReadCoord, - LPDWORD lpNumberOfCharsRead) -{ - return IntReadConsoleOutputCharacter(hConsoleOutput, - (PVOID)lpCharacter, - nLength, - dwReadCoord, - lpNumberOfCharsRead, - TRUE); -} - - -/*-------------------------------------------------------------- - * ReadConsoleOutputAttribute - * - * @implemented - */ -BOOL -WINAPI -ReadConsoleOutputAttribute(HANDLE hConsoleOutput, - LPWORD lpAttribute, - DWORD nLength, - 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; -} - - -static -BOOL -IntWriteConsoleOutputCharacter(HANDLE hConsoleOutput, - PVOID lpCharacter, - DWORD nLength, - COORD dwWriteCoord, - LPDWORD lpNumberOfCharsWritten, - BOOL bUnicode) -{ - PCSR_API_MESSAGE Request; - ULONG CsrRequest; - NTSTATUS Status; - ULONG CharSize, nChars; - //ULONG SizeBytes; - DWORD Written = 0; - - CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); - - nChars = min(nLength, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR / CharSize); - //SizeBytes = nChars * CharSize; - - Request = RtlAllocateHeap(RtlGetProcessHeap(), 0, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_CHAR) - + min (nChars, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR / CharSize) * CharSize)); - if (Request == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE_OUTPUT_CHAR); - Request->Data.WriteConsoleOutputCharRequest.Coord = dwWriteCoord; - - while (nLength > 0) - { - DWORD BytesWrite; - - Request->Data.WriteConsoleOutputCharRequest.ConsoleHandle = hConsoleOutput; - Request->Data.WriteConsoleOutputCharRequest.Unicode = bUnicode; - Request->Data.WriteConsoleOutputCharRequest.Length = (WORD)min(nLength, nChars); - BytesWrite = Request->Data.WriteConsoleOutputCharRequest.Length * CharSize; - - memcpy(Request->Data.WriteConsoleOutputCharRequest.String, lpCharacter, BytesWrite); - - Status = CsrClientCallServer(Request, - NULL, - CsrRequest, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_CHAR) + BytesWrite)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) - { - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - BaseSetLastNTError(Status); - return FALSE; - } - - nLength -= Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten; - lpCharacter = (PVOID)((ULONG_PTR)lpCharacter + (ULONG_PTR)(Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten * CharSize)); - Written += Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten; - - Request->Data.WriteConsoleOutputCharRequest.Coord = Request->Data.WriteConsoleOutputCharRequest.EndCoord; - } - - if (lpNumberOfCharsWritten != NULL) - { - *lpNumberOfCharsWritten = Written; - } - - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - - return TRUE; -} - - -/*-------------------------------------------------------------- - * WriteConsoleOutputCharacterA - * - * @implemented - */ -BOOL -WINAPI -WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, - LPCSTR lpCharacter, - DWORD nLength, - COORD dwWriteCoord, - LPDWORD lpNumberOfCharsWritten) -{ - return IntWriteConsoleOutputCharacter(hConsoleOutput, - (PVOID)lpCharacter, - nLength, - dwWriteCoord, - lpNumberOfCharsWritten, - FALSE); -} - - -/*-------------------------------------------------------------- - * WriteConsoleOutputCharacterW - * - * @implemented - */ -BOOL -WINAPI -WriteConsoleOutputCharacterW(HANDLE hConsoleOutput, - LPCWSTR lpCharacter, - DWORD nLength, - COORD dwWriteCoord, - LPDWORD lpNumberOfCharsWritten) -{ - return IntWriteConsoleOutputCharacter(hConsoleOutput, - (PVOID)lpCharacter, - nLength, - dwWriteCoord, - lpNumberOfCharsWritten, - TRUE); -} - - -/*-------------------------------------------------------------- - * WriteConsoleOutputAttribute - * - * @implemented - */ -BOOL -WINAPI -WriteConsoleOutputAttribute(HANDLE hConsoleOutput, - CONST WORD *lpAttribute, - DWORD nLength, - COORD dwWriteCoord, - LPDWORD lpNumberOfAttrsWritten) -{ - PCSR_API_MESSAGE Request; - ULONG CsrRequest; - NTSTATUS Status; - WORD Size; - - Request = RtlAllocateHeap(RtlGetProcessHeap(), - 0, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB) - + min(nLength, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB / sizeof(WORD)) * sizeof(WORD))); - if (Request == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE_OUTPUT_ATTRIB); - Request->Data.WriteConsoleOutputAttribRequest.Coord = dwWriteCoord; - - if (lpNumberOfAttrsWritten) - *lpNumberOfAttrsWritten = nLength; - while (nLength) - { - Size = (WORD)min(nLength, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB / sizeof(WORD)); - Request->Data.WriteConsoleOutputAttribRequest.ConsoleHandle = hConsoleOutput; - Request->Data.WriteConsoleOutputAttribRequest.Length = Size; - memcpy(Request->Data.WriteConsoleOutputAttribRequest.Attribute, lpAttribute, Size * sizeof(WORD)); - - Status = CsrClientCallServer(Request, - NULL, - CsrRequest, - max(sizeof(CSR_API_MESSAGE), - CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB) + Size * sizeof(WORD))); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) - { - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - BaseSetLastNTError (Status); - return FALSE; - } - nLength -= Size; - lpAttribute += Size; - Request->Data.WriteConsoleOutputAttribRequest.Coord = Request->Data.WriteConsoleOutputAttribRequest.EndCoord; - } - - RtlFreeHeap(RtlGetProcessHeap(), 0, Request); - - return TRUE; -} - - -/*-------------------------------------------------------------- - * FillConsoleOutputAttribute - * - * @implemented - */ -BOOL -WINAPI -FillConsoleOutputAttribute(HANDLE hConsoleOutput, - WORD wAttribute, - DWORD nLength, - COORD dwWriteCoord, - LPDWORD lpNumberOfAttrsWritten) -{ - CSR_API_MESSAGE Request; - NTSTATUS Status; - - Request.Data.FillOutputAttribRequest.ConsoleHandle = hConsoleOutput; - Request.Data.FillOutputAttribRequest.Attribute = (CHAR)wAttribute; - Request.Data.FillOutputAttribRequest.Coord = dwWriteCoord; - Request.Data.FillOutputAttribRequest.Length = (WORD)nLength; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, FILL_OUTPUT_ATTRIB), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError ( Status ); - return FALSE; - } - - if (lpNumberOfAttrsWritten) - *lpNumberOfAttrsWritten = nLength; return TRUE; } @@ -3176,7 +1851,6 @@ } - /*-------------------------------------------------------------- * GetConsoleSelectionInfo * @@ -3200,7 +1874,6 @@ *lpConsoleSelectionInfo = Request.Data.GetConsoleSelectionInfo.Info; return TRUE; } - /*-------------------------------------------------------------- @@ -3466,10 +2139,9 @@ return FALSE; } - -BOOL -WINAPI -ReadConsoleInputExA(HANDLE hConsole, LPVOID lpBuffer, DWORD dwLen, LPDWORD Unknown1, DWORD Unknown2) +BOOL +WINAPI +RegisterConsoleIME(HWND hWnd, LPDWORD ThreadId) { STUB; return FALSE; @@ -3477,7 +2149,7 @@ BOOL WINAPI -ReadConsoleInputExW(HANDLE hConsole, LPVOID lpBuffer, DWORD dwLen, LPDWORD Unknown1, DWORD Unknown2) +RegisterConsoleOS2(BOOL bUnknown) { STUB; return FALSE; @@ -3485,7 +2157,7 @@ BOOL WINAPI -RegisterConsoleIME(HWND hWnd, LPDWORD ThreadId) +SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2) { STUB; return FALSE; @@ -3493,7 +2165,7 @@ BOOL WINAPI -RegisterConsoleOS2(BOOL bUnknown) +SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4) { STUB; return FALSE; @@ -3501,7 +2173,7 @@ BOOL WINAPI -SetConsoleCursorMode(HANDLE hConsole, BOOL Unknown1, BOOL Unknown2) +SetConsoleNlsMode(HANDLE hConsole, DWORD dwMode) { STUB; return FALSE; @@ -3509,7 +2181,7 @@ BOOL WINAPI -SetConsoleLocalEUDC(DWORD Unknown1, DWORD Unknown2, DWORD Unknown3, DWORD Unknown4) +SetConsoleOS2OemFormat(BOOL bUnknown) { STUB; return FALSE; @@ -3517,56 +2189,40 @@ BOOL WINAPI -SetConsoleNlsMode(HANDLE hConsole, DWORD dwMode) +UnregisterConsoleIME(VOID) { STUB; return FALSE; } -BOOL -WINAPI -SetConsoleOS2OemFormat(BOOL bUnknown) + +/* + * @unimplemented + */ +BOOL WINAPI GetConsoleKeyboardLayoutNameA(LPSTR name) +{ + STUB; + return 0; +} + +/* + * @unimplemented + */ +BOOL WINAPI GetConsoleKeyboardLayoutNameW(LPWSTR name) +{ + STUB; + return 0; +} + +/* + * @unimplemented + */ +BOOL +WINAPI +SetLastConsoleEventActive(VOID) { STUB; return FALSE; } -BOOL -WINAPI -UnregisterConsoleIME(VOID) -{ - STUB; - return FALSE; -} - - -/* - * @unimplemented - */ -BOOL WINAPI GetConsoleKeyboardLayoutNameA(LPSTR name) -{ - STUB; - return 0; -} - -/* - * @unimplemented - */ -BOOL WINAPI GetConsoleKeyboardLayoutNameW(LPWSTR name) -{ - STUB; - return 0; -} - -/* - * @unimplemented - */ -BOOL -WINAPI -SetLastConsoleEventActive(VOID) -{ - STUB; - return FALSE; -} - /* EOF */ Added: 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 (added) +++ branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] Thu Nov 15 18:06:17 2012 @@ -1,0 +1,1385 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: dll/win32/kernel32/client/console/readwrite.c + * PURPOSE: Win32 Console Client read-write functions + * PROGRAMMERS: Emanuele Aliberti + * Marty Dill + * Filip Navara (xnavara(a)volny.cz) + * Thomas Weidenmueller (w3seek(a)reactos.org) + * Jeffrey Morlan + */ + +/* INCLUDES *******************************************************************/ + +#include <k32.h> + +#define NDEBUG +#include <debug.h> + + +/* PRIVATE FUNCTIONS **********************************************************/ + +/****************** + * Read functions * + ******************/ + +static +BOOL +IntReadConsole(HANDLE hConsoleInput, + PVOID lpBuffer, + DWORD nNumberOfCharsToRead, + LPDWORD lpNumberOfCharsRead, + PCONSOLE_READCONSOLE_CONTROL pInputControl, + BOOL bUnicode) +{ + CSR_API_MESSAGE Request; + ULONG CsrRequest; + PCSR_CAPTURE_BUFFER CaptureBuffer; + NTSTATUS Status = STATUS_SUCCESS; + ULONG CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + + CaptureBuffer = CsrAllocateCaptureBuffer(1, nNumberOfCharsToRead * CharSize); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + 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; + if (pInputControl && pInputControl->nLength == sizeof(CONSOLE_READCONSOLE_CONTROL)) + { + Request.Data.ReadConsoleRequest.NrCharactersRead = pInputControl->nInitialChars; + memcpy(Request.Data.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) + { + 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); + 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)) + { + 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; + } + } + else if (Status == STATUS_PENDING) + { + 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; + } + } + else + { + lpBuffer[Read++] = Request.Data.ReadInputRequest.Input; + nLength--; + + if (!Request.Data.ReadInputRequest.MoreEvents) + { + /* nothing more to read, bail */ + break; + } + } + } + + if (lpNumberOfEventsRead != NULL) + { + *lpNumberOfEventsRead = Read; + } + + return (Read > 0); +} + + +static +BOOL +IntReadConsoleOutput(HANDLE hConsoleOutput, + PCHAR_INFO lpBuffer, + COORD dwBufferSize, + COORD dwBufferCoord, + PSMALL_RECT lpReadRegion, + BOOL bUnicode) +{ + CSR_API_MESSAGE Request; + PCSR_CAPTURE_BUFFER CaptureBuffer; + DWORD Size, SizeX, SizeY; + + if (lpBuffer == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + Size = dwBufferSize.X * dwBufferSize.Y * sizeof(CHAR_INFO); + + /* Allocate a Capture Buffer */ + DPRINT("IntReadConsoleOutput: %lx %p\n", Size, lpReadRegion); + CaptureBuffer = CsrAllocateCaptureBuffer(1, Size); + if (CaptureBuffer == NULL) + { + DPRINT1("CsrAllocateCaptureBuffer failed with size 0x%x!\n", Size); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + /* Allocate space in the Buffer */ + CsrCaptureMessageBuffer(CaptureBuffer, + NULL, + Size, + (PVOID*)&Request.Data.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; + + /* Call the server */ + CsrClientCallServer(&Request, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, READ_CONSOLE_OUTPUT), + sizeof(CSR_API_MESSAGE)); + DPRINT("Server returned: %x\n", Request.Status); + + /* Check for success*/ + if (NT_SUCCESS(Request.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; + RtlCopyMemory(lpBuffer, + Request.Data.ReadConsoleOutputRequest.CharInfo, + sizeof(CHAR_INFO) * SizeX * SizeY); + } + else + { + /* Error out */ + BaseSetLastNTError(Request.Status); + } + + /* Return the read region */ + DPRINT("read region: %lx\n", Request.Data.ReadConsoleOutputRequest.ReadRegion); + *lpReadRegion = Request.Data.ReadConsoleOutputRequest.ReadRegion; + + /* Release the capture buffer */ + CsrFreeCaptureBuffer(CaptureBuffer); + + /* Return TRUE or FALSE */ + return NT_SUCCESS(Request.Status); +} + + +static +BOOL +IntReadConsoleOutputCharacter(HANDLE hConsoleOutput, + PVOID lpCharacter, + DWORD nLength, + COORD dwReadCoord, + LPDWORD lpNumberOfCharsRead, + BOOL bUnicode) +{ + PCSR_API_MESSAGE Request; + ULONG CsrRequest; + 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) + { + 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)) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + BaseSetLastNTError(Status); + break; + } + + 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); + + return TRUE; +} + + +/******************* + * Write functions * + *******************/ + +static +BOOL +IntWriteConsole(HANDLE hConsoleOutput, + PVOID lpBuffer, + DWORD nNumberOfCharsToWrite, + LPDWORD lpNumberOfCharsWritten, + LPVOID lpReserved, + BOOL bUnicode) +{ + PCSR_API_MESSAGE Request; + ULONG CsrRequest; + NTSTATUS Status; + USHORT nChars; + ULONG SizeBytes, CharSize; + DWORD Written = 0; + + CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + Request = RtlAllocateHeap(RtlGetProcessHeap(), + 0, + max(sizeof(CSR_API_MESSAGE), + CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE) + min(nNumberOfCharsToWrite, + CSRSS_MAX_WRITE_CONSOLE / CharSize) * CharSize)); + if (Request == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE); + + while (nNumberOfCharsToWrite > 0) + { + Request->Data.WriteConsoleRequest.ConsoleHandle = hConsoleOutput; + Request->Data.WriteConsoleRequest.Unicode = bUnicode; + + nChars = (USHORT)min(nNumberOfCharsToWrite, CSRSS_MAX_WRITE_CONSOLE / CharSize); + Request->Data.WriteConsoleRequest.NrCharactersToWrite = nChars; + + SizeBytes = nChars * CharSize; + + memcpy(Request->Data.WriteConsoleRequest.Buffer, lpBuffer, SizeBytes); + + Status = CsrClientCallServer(Request, + NULL, + CsrRequest, + max(sizeof(CSR_API_MESSAGE), + CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE) + SizeBytes)); + + if (Status == STATUS_PENDING) + { + WaitForSingleObject(Request->Data.WriteConsoleRequest.UnpauseEvent, INFINITE); + CloseHandle(Request->Data.WriteConsoleRequest.UnpauseEvent); + continue; + } + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + BaseSetLastNTError(Status); + return FALSE; + } + + nNumberOfCharsToWrite -= nChars; + lpBuffer = (PVOID)((ULONG_PTR)lpBuffer + (ULONG_PTR)SizeBytes); + Written += Request->Data.WriteConsoleRequest.NrCharactersWritten; + } + + if (lpNumberOfCharsWritten != NULL) + { + *lpNumberOfCharsWritten = Written; + } + RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + + return TRUE; +} + + +static +BOOL +IntWriteConsoleInput(HANDLE hConsoleInput, + PINPUT_RECORD lpBuffer, + DWORD nLength, + LPDWORD lpNumberOfEventsWritten, + BOOL bUnicode) +{ + CSR_API_MESSAGE Request; + PCSR_CAPTURE_BUFFER CaptureBuffer; + DWORD Size; + + if (lpBuffer == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + Size = nLength * sizeof(INPUT_RECORD); + + /* Allocate a Capture Buffer */ + DPRINT("IntWriteConsoleInput: %lx %p\n", Size, lpNumberOfEventsWritten); + 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, + lpBuffer, + Size, + (PVOID*)&Request.Data.WriteConsoleInputRequest.InputRecord); + + /* Set up the data to send to the Console Server */ + Request.Data.WriteConsoleInputRequest.ConsoleHandle = hConsoleInput; + Request.Data.WriteConsoleInputRequest.Unicode = bUnicode; + Request.Data.WriteConsoleInputRequest.Length = nLength; + + /* Call the server */ + CsrClientCallServer(&Request, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_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.WriteConsoleInputRequest.Length); + *lpNumberOfEventsWritten = Request.Data.WriteConsoleInputRequest.Length; + } + else + { + /* Error out */ + *lpNumberOfEventsWritten = 0; + BaseSetLastNTError(Request.Status); + } + + /* Release the capture buffer */ + CsrFreeCaptureBuffer(CaptureBuffer); + + /* Return TRUE or FALSE */ + return NT_SUCCESS(Request.Status); +} + + +static +BOOL +IntWriteConsoleOutput(HANDLE hConsoleOutput, + CONST CHAR_INFO *lpBuffer, + COORD dwBufferSize, + COORD dwBufferCoord, + PSMALL_RECT lpWriteRegion, + BOOL bUnicode) +{ + CSR_API_MESSAGE Request; + PCSR_CAPTURE_BUFFER CaptureBuffer; + ULONG Size; + + Size = dwBufferSize.Y * dwBufferSize.X * sizeof(CHAR_INFO); + + /* Allocate a Capture Buffer */ + DPRINT("IntWriteConsoleOutput: %lx %p\n", Size, lpWriteRegion); + 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.WriteConsoleOutputRequest.CharInfo); + + /* Copy from the buffer */ + RtlCopyMemory(Request.Data.WriteConsoleOutputRequest.CharInfo, lpBuffer, Size); + + /* Set up the data to send to the Console Server */ + Request.Data.WriteConsoleOutputRequest.ConsoleHandle = hConsoleOutput; + Request.Data.WriteConsoleOutputRequest.Unicode = bUnicode; + Request.Data.WriteConsoleOutputRequest.BufferSize = dwBufferSize; + Request.Data.WriteConsoleOutputRequest.BufferCoord = dwBufferCoord; + Request.Data.WriteConsoleOutputRequest.WriteRegion = *lpWriteRegion; + + /* Call the server */ + CsrClientCallServer(&Request, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE_OUTPUT), + sizeof(CSR_API_MESSAGE)); + DPRINT("Server returned: %x\n", Request.Status); + + /* Check for success*/ + if (!NT_SUCCESS(Request.Status)) + { + /* Error out */ + BaseSetLastNTError(Request.Status); + } + + /* Return the read region */ + DPRINT("read region: %lx\n", Request.Data.WriteConsoleOutputRequest.WriteRegion); + *lpWriteRegion = Request.Data.WriteConsoleOutputRequest.WriteRegion; + + /* Release the capture buffer */ + CsrFreeCaptureBuffer(CaptureBuffer); + + /* Return TRUE or FALSE */ + return NT_SUCCESS(Request.Status); +} + + +static +BOOL +IntWriteConsoleOutputCharacter(HANDLE hConsoleOutput, + PVOID lpCharacter, + DWORD nLength, + COORD dwWriteCoord, + LPDWORD lpNumberOfCharsWritten, + BOOL bUnicode) +{ + PCSR_API_MESSAGE Request; + ULONG CsrRequest; + NTSTATUS Status; + ULONG CharSize, nChars; + //ULONG SizeBytes; + DWORD Written = 0; + + CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); + + nChars = min(nLength, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR / CharSize); + //SizeBytes = nChars * CharSize; + + Request = RtlAllocateHeap(RtlGetProcessHeap(), 0, + max(sizeof(CSR_API_MESSAGE), + CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_CHAR) + + min (nChars, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR / CharSize) * CharSize)); + if (Request == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE_OUTPUT_CHAR); + Request->Data.WriteConsoleOutputCharRequest.Coord = dwWriteCoord; + + while (nLength > 0) + { + DWORD BytesWrite; + + Request->Data.WriteConsoleOutputCharRequest.ConsoleHandle = hConsoleOutput; + Request->Data.WriteConsoleOutputCharRequest.Unicode = bUnicode; + Request->Data.WriteConsoleOutputCharRequest.Length = (WORD)min(nLength, nChars); + BytesWrite = Request->Data.WriteConsoleOutputCharRequest.Length * CharSize; + + memcpy(Request->Data.WriteConsoleOutputCharRequest.String, lpCharacter, BytesWrite); + + Status = CsrClientCallServer(Request, + NULL, + CsrRequest, + max(sizeof(CSR_API_MESSAGE), + CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_CHAR) + BytesWrite)); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + BaseSetLastNTError(Status); + return FALSE; + } + + nLength -= Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten; + lpCharacter = (PVOID)((ULONG_PTR)lpCharacter + (ULONG_PTR)(Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten * CharSize)); + Written += Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten; + + Request->Data.WriteConsoleOutputCharRequest.Coord = Request->Data.WriteConsoleOutputCharRequest.EndCoord; + } + + if (lpNumberOfCharsWritten != NULL) + { + *lpNumberOfCharsWritten = Written; + } + + RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + + return TRUE; +} + + +static +BOOL +IntFillConsoleOutputCharacter(HANDLE hConsoleOutput, + PVOID cCharacter, + DWORD nLength, + COORD dwWriteCoord, + LPDWORD lpNumberOfCharsWritten, + BOOL bUnicode) +{ + CSR_API_MESSAGE Request; + NTSTATUS Status; + + Request.Data.FillOutputRequest.ConsoleHandle = hConsoleOutput; + Request.Data.FillOutputRequest.Unicode = bUnicode; + + if(bUnicode) + Request.Data.FillOutputRequest.Char.UnicodeChar = *((WCHAR*)cCharacter); + else + Request.Data.FillOutputRequest.Char.AsciiChar = *((CHAR*)cCharacter); + + Request.Data.FillOutputRequest.Position = dwWriteCoord; + Request.Data.FillOutputRequest.Length = (WORD)nLength; + + Status = CsrClientCallServer(&Request, + NULL, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, FILL_OUTPUT), + sizeof(CSR_API_MESSAGE)); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + if(lpNumberOfCharsWritten != NULL) + { + *lpNumberOfCharsWritten = Request.Data.FillOutputRequest.NrCharactersWritten; + } + + return TRUE; +} + + +/* FUNCTIONS ******************************************************************/ + +/****************** + * Read functions * + ******************/ + +/*-------------------------------------------------------------- + * ReadConsoleW + * + * @implemented + */ +BOOL +WINAPI +ReadConsoleW(HANDLE hConsoleInput, + LPVOID lpBuffer, + DWORD nNumberOfCharsToRead, + LPDWORD lpNumberOfCharsRead, + PCONSOLE_READCONSOLE_CONTROL pInputControl) +{ + return IntReadConsole(hConsoleInput, + lpBuffer, + nNumberOfCharsToRead, + lpNumberOfCharsRead, + pInputControl, + TRUE); +} + + +/*-------------------------------------------------------------- + * ReadConsoleA + * + * @implemented + */ +BOOL +WINAPI +ReadConsoleA(HANDLE hConsoleInput, + LPVOID lpBuffer, + DWORD nNumberOfCharsToRead, + LPDWORD lpNumberOfCharsRead, + PCONSOLE_READCONSOLE_CONTROL pInputControl) +{ + return IntReadConsole(hConsoleInput, + lpBuffer, + nNumberOfCharsToRead, + lpNumberOfCharsRead, + NULL, + FALSE); +} + + +/*-------------------------------------------------------------- + * PeekConsoleInputW + * + * @implemented + */ +BOOL +WINAPI +PeekConsoleInputW(HANDLE hConsoleInput, + PINPUT_RECORD lpBuffer, + DWORD nLength, + LPDWORD lpNumberOfEventsRead) +{ + return IntPeekConsoleInput(hConsoleInput, + lpBuffer, nLength, + lpNumberOfEventsRead, + TRUE); +} + + +/*-------------------------------------------------------------- + * PeekConsoleInputA + * + * @implemented + */ +BOOL +WINAPI +PeekConsoleInputA(HANDLE hConsoleInput, + PINPUT_RECORD lpBuffer, + DWORD nLength, + LPDWORD lpNumberOfEventsRead) +{ + return IntPeekConsoleInput(hConsoleInput, + lpBuffer, + nLength, + lpNumberOfEventsRead, + FALSE); +} + + +/*-------------------------------------------------------------- + * ReadConsoleInputW + * + * @implemented + */ +BOOL +WINAPI +ReadConsoleInputW(HANDLE hConsoleInput, + PINPUT_RECORD lpBuffer, + DWORD nLength, + LPDWORD lpNumberOfEventsRead) +{ + return IntReadConsoleInput(hConsoleInput, + lpBuffer, + nLength, + lpNumberOfEventsRead, + TRUE); +} + + +/*-------------------------------------------------------------- + * ReadConsoleInputA + * + * @implemented + */ +BOOL +WINAPI +ReadConsoleInputA(HANDLE hConsoleInput, + PINPUT_RECORD lpBuffer, + DWORD nLength, + LPDWORD lpNumberOfEventsRead) +{ + return IntReadConsoleInput(hConsoleInput, + lpBuffer, + nLength, + lpNumberOfEventsRead, + FALSE); +} + + +BOOL +WINAPI +ReadConsoleInputExW(HANDLE hConsole, LPVOID lpBuffer, DWORD dwLen, LPDWORD Unknown1, DWORD Unknown2) +{ + STUB; + return FALSE; +} + + +BOOL +WINAPI +ReadConsoleInputExA(HANDLE hConsole, LPVOID lpBuffer, DWORD dwLen, LPDWORD Unknown1, DWORD Unknown2) +{ + STUB; + return FALSE; +} + + +/*-------------------------------------------------------------- + * ReadConsoleOutputW + * + * @implemented + */ +BOOL +WINAPI +ReadConsoleOutputW(HANDLE hConsoleOutput, + PCHAR_INFO lpBuffer, + COORD dwBufferSize, + COORD dwBufferCoord, + PSMALL_RECT lpReadRegion) +{ + return IntReadConsoleOutput(hConsoleOutput, + lpBuffer, + dwBufferSize, + dwBufferCoord, + lpReadRegion, + TRUE); +} + + +/*-------------------------------------------------------------- + * ReadConsoleOutputA + * + * @implemented + */ +BOOL +WINAPI +ReadConsoleOutputA(HANDLE hConsoleOutput, + PCHAR_INFO lpBuffer, + COORD dwBufferSize, + COORD dwBufferCoord, + PSMALL_RECT lpReadRegion) +{ + return IntReadConsoleOutput(hConsoleOutput, + lpBuffer, + dwBufferSize, + dwBufferCoord, + lpReadRegion, + FALSE); +} + + +/*-------------------------------------------------------------- + * ReadConsoleOutputCharacterW + * + * @implemented + */ +BOOL +WINAPI +ReadConsoleOutputCharacterW(HANDLE hConsoleOutput, + LPWSTR lpCharacter, + DWORD nLength, + COORD dwReadCoord, + LPDWORD lpNumberOfCharsRead) +{ + return IntReadConsoleOutputCharacter(hConsoleOutput, + (PVOID)lpCharacter, + nLength, + dwReadCoord, + lpNumberOfCharsRead, + TRUE); +} + + +/*-------------------------------------------------------------- + * ReadConsoleOutputCharacterA + * + * @implemented + */ +BOOL +WINAPI +ReadConsoleOutputCharacterA(HANDLE hConsoleOutput, + LPSTR lpCharacter, + DWORD nLength, + COORD dwReadCoord, + LPDWORD lpNumberOfCharsRead) +{ + return IntReadConsoleOutputCharacter(hConsoleOutput, + (PVOID)lpCharacter, + nLength, + dwReadCoord, + lpNumberOfCharsRead, + FALSE); +} + + +/*-------------------------------------------------------------- + * ReadConsoleOutputAttribute + * + * @implemented + */ +BOOL +WINAPI +ReadConsoleOutputAttribute(HANDLE hConsoleOutput, + LPWORD lpAttribute, + DWORD nLength, + 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; +} + + +/******************* + * Write functions * + *******************/ + +/*-------------------------------------------------------------- + * WriteConsoleW + * + * @implemented + */ +BOOL +WINAPI +WriteConsoleW(HANDLE hConsoleOutput, + CONST VOID *lpBuffer, + DWORD nNumberOfCharsToWrite, + LPDWORD lpNumberOfCharsWritten, + LPVOID lpReserved) +{ + return IntWriteConsole(hConsoleOutput, + (PVOID)lpBuffer, + nNumberOfCharsToWrite, + lpNumberOfCharsWritten, + lpReserved, + TRUE); +} + + +/*-------------------------------------------------------------- + * WriteConsoleA + * + * @implemented + */ +BOOL +WINAPI +WriteConsoleA(HANDLE hConsoleOutput, + CONST VOID *lpBuffer, + DWORD nNumberOfCharsToWrite, + LPDWORD lpNumberOfCharsWritten, + LPVOID lpReserved) +{ + return IntWriteConsole(hConsoleOutput, + (PVOID)lpBuffer, + nNumberOfCharsToWrite, + lpNumberOfCharsWritten, + lpReserved, + FALSE); +} + + +/*-------------------------------------------------------------- + * WriteConsoleInputW + * + * @implemented + */ +BOOL +WINAPI +WriteConsoleInputW(HANDLE hConsoleInput, + CONST INPUT_RECORD *lpBuffer, + DWORD nLength, + LPDWORD lpNumberOfEventsWritten) +{ + return IntWriteConsoleInput(hConsoleInput, + (PINPUT_RECORD)lpBuffer, + nLength, + lpNumberOfEventsWritten, + TRUE); +} + + +/*-------------------------------------------------------------- + * WriteConsoleInputA + * + * @implemented + */ +BOOL +WINAPI +WriteConsoleInputA(HANDLE hConsoleInput, + CONST INPUT_RECORD *lpBuffer, + DWORD nLength, + LPDWORD lpNumberOfEventsWritten) +{ + return IntWriteConsoleInput(hConsoleInput, + (PINPUT_RECORD)lpBuffer, + nLength, + lpNumberOfEventsWritten, + FALSE); +} + + +/*-------------------------------------------------------------- + * WriteConsoleOutputW + * + * @implemented + */ +BOOL +WINAPI +WriteConsoleOutputW(HANDLE hConsoleOutput, + CONST CHAR_INFO *lpBuffer, + COORD dwBufferSize, + COORD dwBufferCoord, + PSMALL_RECT lpWriteRegion) +{ + return IntWriteConsoleOutput(hConsoleOutput, + lpBuffer, + dwBufferSize, + dwBufferCoord, + lpWriteRegion, + TRUE); +} + + +/*-------------------------------------------------------------- + * WriteConsoleOutputA + * + * @implemented + */ +BOOL +WINAPI +WriteConsoleOutputA(HANDLE hConsoleOutput, + CONST CHAR_INFO *lpBuffer, + COORD dwBufferSize, + COORD dwBufferCoord, + PSMALL_RECT lpWriteRegion) +{ + return IntWriteConsoleOutput(hConsoleOutput, + lpBuffer, + dwBufferSize, + dwBufferCoord, + lpWriteRegion, + FALSE); +} + + +/*-------------------------------------------------------------- + * WriteConsoleOutputCharacterW + * + * @implemented + */ +BOOL +WINAPI +WriteConsoleOutputCharacterW(HANDLE hConsoleOutput, + LPCWSTR lpCharacter, + DWORD nLength, + COORD dwWriteCoord, + LPDWORD lpNumberOfCharsWritten) +{ + return IntWriteConsoleOutputCharacter(hConsoleOutput, + (PVOID)lpCharacter, + nLength, + dwWriteCoord, + lpNumberOfCharsWritten, + TRUE); +} + + +/*-------------------------------------------------------------- + * WriteConsoleOutputCharacterA + * + * @implemented + */ +BOOL +WINAPI +WriteConsoleOutputCharacterA(HANDLE hConsoleOutput, + LPCSTR lpCharacter, + DWORD nLength, + COORD dwWriteCoord, + LPDWORD lpNumberOfCharsWritten) +{ + return IntWriteConsoleOutputCharacter(hConsoleOutput, + (PVOID)lpCharacter, + nLength, + dwWriteCoord, + lpNumberOfCharsWritten, + FALSE); +} + + +/*-------------------------------------------------------------- + * WriteConsoleOutputAttribute + * + * @implemented + */ +BOOL +WINAPI +WriteConsoleOutputAttribute(HANDLE hConsoleOutput, + CONST WORD *lpAttribute, + DWORD nLength, + COORD dwWriteCoord, + LPDWORD lpNumberOfAttrsWritten) +{ + PCSR_API_MESSAGE Request; + ULONG CsrRequest; + NTSTATUS Status; + WORD Size; + + Request = RtlAllocateHeap(RtlGetProcessHeap(), + 0, + max(sizeof(CSR_API_MESSAGE), + CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB) + + min(nLength, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB / sizeof(WORD)) * sizeof(WORD))); + if (Request == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + CsrRequest = CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE_OUTPUT_ATTRIB); + Request->Data.WriteConsoleOutputAttribRequest.Coord = dwWriteCoord; + + if (lpNumberOfAttrsWritten) + *lpNumberOfAttrsWritten = nLength; + while (nLength) + { + Size = (WORD)min(nLength, CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB / sizeof(WORD)); + Request->Data.WriteConsoleOutputAttribRequest.ConsoleHandle = hConsoleOutput; + Request->Data.WriteConsoleOutputAttribRequest.Length = Size; + memcpy(Request->Data.WriteConsoleOutputAttribRequest.Attribute, lpAttribute, Size * sizeof(WORD)); + + Status = CsrClientCallServer(Request, + NULL, + CsrRequest, + max(sizeof(CSR_API_MESSAGE), + CSR_API_MESSAGE_HEADER_SIZE(CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB) + Size * sizeof(WORD))); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) + { + RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + BaseSetLastNTError (Status); + return FALSE; + } + nLength -= Size; + lpAttribute += Size; + Request->Data.WriteConsoleOutputAttribRequest.Coord = Request->Data.WriteConsoleOutputAttribRequest.EndCoord; + } + + RtlFreeHeap(RtlGetProcessHeap(), 0, Request); + + return TRUE; +} + + +/*-------------------------------------------------------------- + * FillConsoleOutputCharacterW + * + * @implemented + */ +BOOL +WINAPI +FillConsoleOutputCharacterW(HANDLE hConsoleOutput, + WCHAR cCharacter, + DWORD nLength, + COORD dwWriteCoord, + LPDWORD lpNumberOfCharsWritten) +{ + return IntFillConsoleOutputCharacter(hConsoleOutput, + &cCharacter, + nLength, + dwWriteCoord, + lpNumberOfCharsWritten, + TRUE); +} + + +/*-------------------------------------------------------------- + * FillConsoleOutputCharacterA + * + * @implemented + */ +BOOL +WINAPI +FillConsoleOutputCharacterA(HANDLE hConsoleOutput, + CHAR cCharacter, + DWORD nLength, + COORD dwWriteCoord, + LPDWORD lpNumberOfCharsWritten) +{ + return IntFillConsoleOutputCharacter(hConsoleOutput, + &cCharacter, + nLength, + dwWriteCoord, + lpNumberOfCharsWritten, + FALSE); +} + + +/*-------------------------------------------------------------- + * FillConsoleOutputAttribute + * + * @implemented + */ +BOOL +WINAPI +FillConsoleOutputAttribute(HANDLE hConsoleOutput, + WORD wAttribute, + DWORD nLength, + COORD dwWriteCoord, + LPDWORD lpNumberOfAttrsWritten) +{ + CSR_API_MESSAGE Request; + NTSTATUS Status; + + Request.Data.FillOutputAttribRequest.ConsoleHandle = hConsoleOutput; + Request.Data.FillOutputAttribRequest.Attribute = (CHAR)wAttribute; + Request.Data.FillOutputAttribRequest.Coord = dwWriteCoord; + Request.Data.FillOutputAttribRequest.Length = (WORD)nLength; + + Status = CsrClientCallServer(&Request, + NULL, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, FILL_OUTPUT_ATTRIB), + sizeof(CSR_API_MESSAGE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + BaseSetLastNTError ( Status ); + return FALSE; + } + + if (lpNumberOfAttrsWritten) + *lpNumberOfAttrsWritten = nLength; + + return TRUE; +} + +/* EOF */ Propchange: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c ------------------------------------------------------------------------------ svn:eol-style = native
12 years, 1 month
1
0
0
0
[hbelusca] 57710: [KERNEL32] Compile alias.c and history.c.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Nov 15 17:13:53 2012 New Revision: 57710 URL:
http://svn.reactos.org/svn/reactos?rev=57710&view=rev
Log: [KERNEL32] Compile alias.c and history.c. Modified: branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt Modified: branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/CM…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/CMakeLists.txt [iso-8859-1] Thu Nov 15 17:13:53 2012 @@ -38,7 +38,9 @@ client/version.c client/virtmem.c client/vista.c + client/console/alias.c client/console/console.c + client/console/history.c client/file/backup.c client/file/cnotify.c client/file/copy.c
12 years, 1 month
1
0
0
0
[hbelusca] 57709: [KERNEL32] - Move history-functions to a dedicated source file. The functions were created in r47580 and therefore update the description header of the file.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Nov 15 17:09:51 2012 New Revision: 57709 URL:
http://svn.reactos.org/svn/reactos?rev=57709&view=rev
Log: [KERNEL32] - Move history-functions to a dedicated source file. The functions were created in r47580 and therefore update the description header of the file. Added: branches/ros-csrss/dll/win32/kernel32/client/console/history.c (with props) Modified: branches/ros-csrss/dll/win32/kernel32/client/console/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] Thu Nov 15 17:09:51 2012 @@ -266,211 +266,6 @@ } -static BOOL -IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; - - if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode)); - if (!CaptureBuffer) - { - DPRINT1("CsrAllocateCaptureBuffer failed!\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, - &Request.Data.ExpungeCommandHistory.ExeName); - - Status = CsrClientCallServer(&Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, EXPUNGE_COMMAND_HISTORY), - sizeof(CSR_API_MESSAGE)); - - CsrFreeCaptureBuffer(CaptureBuffer); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - - return TRUE; -} - -/* - * @implemented (Undocumented) - */ -BOOL -WINAPI -ExpungeConsoleCommandHistoryW(LPCWSTR lpExeName) -{ - return IntExpungeConsoleCommandHistory(lpExeName, TRUE); -} - -/* - * @implemented (Undocumented) - */ -BOOL -WINAPI -ExpungeConsoleCommandHistoryA(LPCSTR lpExeName) -{ - return IntExpungeConsoleCommandHistory(lpExeName, FALSE); -} - - -static DWORD -IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName, BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; - DWORD HistoryLength = cbHistory * (bUnicode ? 1 : sizeof(WCHAR)); - - if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - CaptureBuffer = CsrAllocateCaptureBuffer(2, IntStringSize(lpExeName, bUnicode) + - HistoryLength); - if (!CaptureBuffer) - { - DPRINT1("CsrAllocateCaptureBuffer failed!\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, - &Request.Data.GetCommandHistory.ExeName); - Request.Data.GetCommandHistory.Length = HistoryLength; - CsrAllocateMessagePointer(CaptureBuffer, HistoryLength, - (PVOID*)&Request.Data.GetCommandHistory.History); - - Status = CsrClientCallServer(&Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_COMMAND_HISTORY), - sizeof(CSR_API_MESSAGE)); - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - CsrFreeCaptureBuffer(CaptureBuffer); - BaseSetLastNTError(Status); - return 0; - } - - if (bUnicode) - { - memcpy(lpHistory, - Request.Data.GetCommandHistory.History, - Request.Data.GetCommandHistory.Length); - } - else - { - WideCharToMultiByte(CP_ACP, 0, - Request.Data.GetCommandHistory.History, - Request.Data.GetCommandHistory.Length / sizeof(WCHAR), - lpHistory, - cbHistory, - NULL, NULL); - } - - CsrFreeCaptureBuffer(CaptureBuffer); - return Request.Data.GetCommandHistory.Length; -} - -/* - * @implemented (Undocumented) - */ -DWORD -WINAPI -GetConsoleCommandHistoryW(LPWSTR lpHistory, - DWORD cbHistory, - LPCWSTR lpExeName) -{ - return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, TRUE); -} - -/* - * @implemented (Undocumented) - */ -DWORD -WINAPI -GetConsoleCommandHistoryA(LPSTR lpHistory, - DWORD cbHistory, - LPCSTR lpExeName) -{ - return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, FALSE); -} - - -static DWORD -IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; - - if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode)); - if (!CaptureBuffer) - { - DPRINT1("CsrAllocateCaptureBuffer failed!\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, - &Request.Data.GetCommandHistoryLength.ExeName); - - Status = CsrClientCallServer(&Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_COMMAND_HISTORY_LENGTH), - sizeof(CSR_API_MESSAGE)); - - CsrFreeCaptureBuffer(CaptureBuffer); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return 0; - } - - return Request.Data.GetCommandHistoryLength.Length; -} - -/* - * @implemented (Undocumented) - */ -DWORD -WINAPI -GetConsoleCommandHistoryLengthW(LPCWSTR lpExeName) -{ - return IntGetConsoleCommandHistoryLength(lpExeName, TRUE); -} - -/* - * @implemented (Undocumented) - */ -DWORD -WINAPI -GetConsoleCommandHistoryLengthA(LPCSTR lpExeName) -{ - return IntGetConsoleCommandHistoryLength(lpExeName, FALSE) / sizeof(WCHAR); -} /* @@ -799,72 +594,6 @@ DPRINT1("SetConsoleMenuClose(0x%x) UNIMPLEMENTED!\n", Unknown0); SetLastError(ERROR_CALL_NOT_IMPLEMENTED); return FALSE; -} - - -static BOOL -IntSetConsoleNumberOfCommands(DWORD dwNumCommands, - LPCVOID lpExeName, - BOOL bUnicode) -{ - CSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; - - if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) - { - SetLastError(ERROR_INVALID_PARAMETER); - return FALSE; - } - - CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode)); - if (!CaptureBuffer) - { - DPRINT1("CsrAllocateCaptureBuffer failed!\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return FALSE; - } - - IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, - &Request.Data.SetHistoryNumberCommands.ExeName); - Request.Data.SetHistoryNumberCommands.NumCommands = dwNumCommands; - - Status = CsrClientCallServer(&Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_HISTORY_NUMBER_COMMANDS), - sizeof(CSR_API_MESSAGE)); - - CsrFreeCaptureBuffer(CaptureBuffer); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return FALSE; - } - - return TRUE; -} - -/* - * @implemented (Undocumented) - */ -BOOL -WINAPI -SetConsoleNumberOfCommandsA(DWORD dwNumCommands, - LPCWSTR lpExeName) -{ - return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, FALSE); -} - -/* - * @implemented (Undocumented) - */ -BOOL -WINAPI -SetConsoleNumberOfCommandsW(DWORD dwNumCommands, - LPCSTR lpExeName) -{ - return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, TRUE); } @@ -3840,16 +3569,4 @@ return FALSE; } -/* - * @unimplemented - */ -BOOL -WINAPI -SetConsoleCommandHistoryMode(IN DWORD dwMode) -{ - STUB; - return FALSE; -} - - /* EOF */ Added: branches/ros-csrss/dll/win32/kernel32/client/console/history.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/history.c (added) +++ branches/ros-csrss/dll/win32/kernel32/client/console/history.c [iso-8859-1] Thu Nov 15 17:09:51 2012 @@ -1,0 +1,313 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: dll/win32/kernel32/client/console/history.c + * PURPOSE: Win32 Console Client history functions + * PROGRAMMERS: Jeffrey Morlan + */ + +/* INCLUDES *******************************************************************/ + +#include <k32.h> + +#define NDEBUG +#include <debug.h> + + +/* PRIVATE FUNCTIONS **********************************************************/ + +static BOOL +IntExpungeConsoleCommandHistory(LPCVOID lpExeName, BOOL bUnicode) +{ + CSR_API_MESSAGE Request; + PCSR_CAPTURE_BUFFER CaptureBuffer; + NTSTATUS Status; + + if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode)); + if (!CaptureBuffer) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, + &Request.Data.ExpungeCommandHistory.ExeName); + + Status = CsrClientCallServer(&Request, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, EXPUNGE_COMMAND_HISTORY), + sizeof(CSR_API_MESSAGE)); + + CsrFreeCaptureBuffer(CaptureBuffer); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + return TRUE; +} + + +static DWORD +IntGetConsoleCommandHistory(LPVOID lpHistory, DWORD cbHistory, LPCVOID lpExeName, BOOL bUnicode) +{ + CSR_API_MESSAGE Request; + PCSR_CAPTURE_BUFFER CaptureBuffer; + NTSTATUS Status; + DWORD HistoryLength = cbHistory * (bUnicode ? 1 : sizeof(WCHAR)); + + if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + CaptureBuffer = CsrAllocateCaptureBuffer(2, IntStringSize(lpExeName, bUnicode) + + HistoryLength); + if (!CaptureBuffer) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, + &Request.Data.GetCommandHistory.ExeName); + Request.Data.GetCommandHistory.Length = HistoryLength; + CsrAllocateMessagePointer(CaptureBuffer, HistoryLength, + (PVOID*)&Request.Data.GetCommandHistory.History); + + Status = CsrClientCallServer(&Request, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_COMMAND_HISTORY), + sizeof(CSR_API_MESSAGE)); + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + CsrFreeCaptureBuffer(CaptureBuffer); + BaseSetLastNTError(Status); + return 0; + } + + if (bUnicode) + { + memcpy(lpHistory, + Request.Data.GetCommandHistory.History, + Request.Data.GetCommandHistory.Length); + } + else + { + WideCharToMultiByte(CP_ACP, 0, + Request.Data.GetCommandHistory.History, + Request.Data.GetCommandHistory.Length / sizeof(WCHAR), + lpHistory, + cbHistory, + NULL, NULL); + } + + CsrFreeCaptureBuffer(CaptureBuffer); + return Request.Data.GetCommandHistory.Length; +} + + +static DWORD +IntGetConsoleCommandHistoryLength(LPCVOID lpExeName, BOOL bUnicode) +{ + CSR_API_MESSAGE Request; + PCSR_CAPTURE_BUFFER CaptureBuffer; + NTSTATUS Status; + + if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode)); + if (!CaptureBuffer) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, + &Request.Data.GetCommandHistoryLength.ExeName); + + Status = CsrClientCallServer(&Request, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_COMMAND_HISTORY_LENGTH), + sizeof(CSR_API_MESSAGE)); + + CsrFreeCaptureBuffer(CaptureBuffer); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + BaseSetLastNTError(Status); + return 0; + } + + return Request.Data.GetCommandHistoryLength.Length; +} + + +static BOOL +IntSetConsoleNumberOfCommands(DWORD dwNumCommands, + LPCVOID lpExeName, + BOOL bUnicode) +{ + CSR_API_MESSAGE Request; + PCSR_CAPTURE_BUFFER CaptureBuffer; + NTSTATUS Status; + + if (lpExeName == NULL || !(bUnicode ? *(PWCHAR)lpExeName : *(PCHAR)lpExeName)) + { + SetLastError(ERROR_INVALID_PARAMETER); + return FALSE; + } + + CaptureBuffer = CsrAllocateCaptureBuffer(1, IntStringSize(lpExeName, bUnicode)); + if (!CaptureBuffer) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return FALSE; + } + + IntCaptureMessageString(CaptureBuffer, lpExeName, bUnicode, + &Request.Data.SetHistoryNumberCommands.ExeName); + Request.Data.SetHistoryNumberCommands.NumCommands = dwNumCommands; + + Status = CsrClientCallServer(&Request, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, SET_HISTORY_NUMBER_COMMANDS), + sizeof(CSR_API_MESSAGE)); + + CsrFreeCaptureBuffer(CaptureBuffer); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + BaseSetLastNTError(Status); + return FALSE; + } + + return TRUE; +} + + +/* FUNCTIONS ******************************************************************/ + +/* + * @implemented (Undocumented) + */ +BOOL +WINAPI +ExpungeConsoleCommandHistoryW(LPCWSTR lpExeName) +{ + return IntExpungeConsoleCommandHistory(lpExeName, TRUE); +} + + +/* + * @implemented (Undocumented) + */ +BOOL +WINAPI +ExpungeConsoleCommandHistoryA(LPCSTR lpExeName) +{ + return IntExpungeConsoleCommandHistory(lpExeName, FALSE); +} + + +/* + * @implemented (Undocumented) + */ +DWORD +WINAPI +GetConsoleCommandHistoryW(LPWSTR lpHistory, + DWORD cbHistory, + LPCWSTR lpExeName) +{ + return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, TRUE); +} + + +/* + * @implemented (Undocumented) + */ +DWORD +WINAPI +GetConsoleCommandHistoryA(LPSTR lpHistory, + DWORD cbHistory, + LPCSTR lpExeName) +{ + return IntGetConsoleCommandHistory(lpHistory, cbHistory, lpExeName, FALSE); +} + + +/* + * @implemented (Undocumented) + */ +DWORD +WINAPI +GetConsoleCommandHistoryLengthW(LPCWSTR lpExeName) +{ + return IntGetConsoleCommandHistoryLength(lpExeName, TRUE); +} + + +/* + * @implemented (Undocumented) + */ +DWORD +WINAPI +GetConsoleCommandHistoryLengthA(LPCSTR lpExeName) +{ + return IntGetConsoleCommandHistoryLength(lpExeName, FALSE) / sizeof(WCHAR); +} + + +/* + * @implemented (Undocumented) + */ +BOOL +WINAPI +SetConsoleNumberOfCommandsW(DWORD dwNumCommands, + LPCSTR lpExeName) +{ + return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, TRUE); +} + + +/* + * @implemented (Undocumented) + */ +BOOL +WINAPI +SetConsoleNumberOfCommandsA(DWORD dwNumCommands, + LPCWSTR lpExeName) +{ + return IntSetConsoleNumberOfCommands(dwNumCommands, lpExeName, FALSE); +} + + +/* + * @unimplemented + */ +BOOL +WINAPI +SetConsoleCommandHistoryMode(IN DWORD dwMode) +{ + STUB; + return FALSE; +} + +/* EOF */ Propchange: branches/ros-csrss/dll/win32/kernel32/client/console/history.c ------------------------------------------------------------------------------ svn:eol-style = native
12 years, 1 month
1
0
0
0
[hbelusca] 57708: Fix header (no code changes).
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Nov 15 16:53:30 2012 New Revision: 57708 URL:
http://svn.reactos.org/svn/reactos?rev=57708&view=rev
Log: Fix header (no code changes). Modified: branches/ros-csrss/dll/win32/kernel32/client/console/alias.c Modified: branches/ros-csrss/dll/win32/kernel32/client/console/alias.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/alias.c [iso-8859-1] (original) +++ branches/ros-csrss/dll/win32/kernel32/client/console/alias.c [iso-8859-1] Thu Nov 15 16:53:30 2012 @@ -5,7 +5,6 @@ * PURPOSE: Win32 server console functions * PROGRAMMERS: Christoph von Wittich (christoph_vw(a)reactos.org) * Johannes Anderwald (janderwald(a)reactos.org) - * */ /* INCLUDES *******************************************************************/
12 years, 1 month
1
0
0
0
[hbelusca] 57707: [KERNEL32] - Move alias-functions to a dedicated file. The names of the programmers were retrieved via svn information (see r32093 and r32118).
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Nov 15 16:51:29 2012 New Revision: 57707 URL:
http://svn.reactos.org/svn/reactos?rev=57707&view=rev
Log: [KERNEL32] - Move alias-functions to a dedicated file. The names of the programmers were retrieved via svn information (see r32093 and r32118). Added: branches/ros-csrss/dll/win32/kernel32/client/console/alias.c (with props) Modified: branches/ros-csrss/dll/win32/kernel32/client/console/console.c Added: branches/ros-csrss/dll/win32/kernel32/client/console/alias.c URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
============================================================================== --- branches/ros-csrss/dll/win32/kernel32/client/console/alias.c (added) +++ branches/ros-csrss/dll/win32/kernel32/client/console/alias.c [iso-8859-1] Thu Nov 15 16:51:29 2012 @@ -1,0 +1,517 @@ +/* + * COPYRIGHT: See COPYING in the top level directory + * PROJECT: ReactOS system libraries + * FILE: dll/win32/kernel32/client/console/console.c + * PURPOSE: Win32 server console functions + * PROGRAMMERS: Christoph von Wittich (christoph_vw(a)reactos.org) + * Johannes Anderwald (janderwald(a)reactos.org) + * + */ + +/* INCLUDES *******************************************************************/ + +#include <k32.h> + +#define NDEBUG +#include <debug.h> + +/* FUNCTIONS ******************************************************************/ + +/* + * @unimplemented + */ +BOOL +WINAPI +AddConsoleAliasW(LPCWSTR lpSource, + LPCWSTR lpTarget, + LPCWSTR lpExeName) +{ + PCSR_API_MESSAGE Request; + NTSTATUS Status; + ULONG SourceLength; + ULONG TargetLength = 0; + ULONG ExeLength; + ULONG Size; + ULONG RequestLength; + WCHAR * Ptr; + + DPRINT("AddConsoleAliasW enterd with lpSource %S lpTarget %S lpExeName %S\n", lpSource, lpTarget, lpExeName); + + ExeLength = wcslen(lpExeName) + 1; + SourceLength = wcslen(lpSource)+ 1; + if (lpTarget) + TargetLength = wcslen(lpTarget) + 1; + + Size = (ExeLength + SourceLength + TargetLength) * sizeof(WCHAR); + RequestLength = sizeof(CSR_API_MESSAGE) + Size; + + Request = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, RequestLength); + Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE)); + + wcscpy(Ptr, lpSource); + Request->Data.AddConsoleAlias.SourceLength = SourceLength; + Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE) + SourceLength * sizeof(WCHAR)); + + wcscpy(Ptr, lpExeName); + Request->Data.AddConsoleAlias.ExeLength = ExeLength; + Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE) + (ExeLength + SourceLength)* sizeof(WCHAR)); + + if (lpTarget) /* target can be optional */ + wcscpy(Ptr, lpTarget); + + Request->Data.AddConsoleAlias.TargetLength = TargetLength; + + Status = CsrClientCallServer(Request, + NULL, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, ADD_CONSOLE_ALIAS), + RequestLength); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) + { + BaseSetLastNTError(Status); + RtlFreeHeap(GetProcessHeap(), 0, Request); + return FALSE; + } + + RtlFreeHeap(GetProcessHeap(), 0, Request); + return TRUE; +} + + +/* + * @implemented + */ +BOOL +WINAPI +AddConsoleAliasA(LPCSTR lpSource, + LPCSTR lpTarget, + LPCSTR lpExeName) +{ + LPWSTR lpSourceW = NULL; + LPWSTR lpTargetW = NULL; + LPWSTR lpExeNameW = NULL; + BOOL bRetVal; + + if (lpSource) + BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*) &lpSourceW); + if (lpTarget) + BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*) &lpTargetW); + if (lpExeName) + BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW); + + bRetVal = AddConsoleAliasW(lpSourceW, lpTargetW, lpExeNameW); + + /* Clean up */ + if (lpSourceW) + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpSourceW); + if (lpTargetW) + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpTargetW); + if (lpExeNameW) + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpExeNameW); + + return bRetVal; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasW(LPWSTR lpSource, + LPWSTR lpTargetBuffer, + DWORD TargetBufferLength, + LPWSTR lpExeName) +{ + PCSR_API_MESSAGE Request; + PCSR_CAPTURE_BUFFER CaptureBuffer; + NTSTATUS Status; + ULONG Size; + ULONG ExeLength; + ULONG SourceLength; + ULONG RequestLength; + WCHAR * Ptr; + + DPRINT("GetConsoleAliasW entered lpSource %S lpExeName %S\n", lpSource, lpExeName); + + if (lpTargetBuffer == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + ExeLength = wcslen(lpExeName) + 1; + SourceLength = wcslen(lpSource) + 1; + + Size = (ExeLength + SourceLength) * sizeof(WCHAR); + + RequestLength = Size + sizeof(CSR_API_MESSAGE); + Request = RtlAllocateHeap(GetProcessHeap(), 0, RequestLength); + if (Request == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + CaptureBuffer = CsrAllocateCaptureBuffer(1, TargetBufferLength); + if (!CaptureBuffer) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + RtlFreeHeap(GetProcessHeap(), 0, Request); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + Request->Data.GetConsoleAlias.TargetBuffer = NULL; + + CsrCaptureMessageBuffer(CaptureBuffer, + NULL, + TargetBufferLength, + (PVOID*)&Request->Data.GetConsoleAlias.TargetBuffer); + + Request->Data.GetConsoleAlias.TargetBufferLength = TargetBufferLength; + + Ptr = (LPWSTR)((ULONG_PTR)Request + sizeof(CSR_API_MESSAGE)); + wcscpy(Ptr, lpSource); + Ptr += SourceLength; + wcscpy(Ptr, lpExeName); + + Request->Data.GetConsoleAlias.ExeLength = ExeLength; + Request->Data.GetConsoleAlias.SourceLength = SourceLength; + + Status = CsrClientCallServer(Request, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIAS), + sizeof(CSR_API_MESSAGE) + Size); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) + { + RtlFreeHeap(GetProcessHeap(), 0, Request); + CsrFreeCaptureBuffer(CaptureBuffer); + BaseSetLastNTError(Status); + return 0; + } + + wcscpy(lpTargetBuffer, Request->Data.GetConsoleAlias.TargetBuffer); + RtlFreeHeap(GetProcessHeap(), 0, Request); + CsrFreeCaptureBuffer(CaptureBuffer); + + return Request->Data.GetConsoleAlias.BytesWritten; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasA(LPSTR lpSource, + LPSTR lpTargetBuffer, + DWORD TargetBufferLength, + LPSTR lpExeName) +{ + LPWSTR lpwSource; + LPWSTR lpwExeName; + LPWSTR lpwTargetBuffer; + UINT dwSourceSize; + UINT dwExeNameSize; + UINT dwResult; + + DPRINT("GetConsoleAliasA entered\n"); + + if (lpTargetBuffer == NULL) + { + SetLastError(ERROR_INVALID_PARAMETER); + return 0; + } + + dwSourceSize = (strlen(lpSource)+1) * sizeof(WCHAR); + lpwSource = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSourceSize); + if (lpwSource == NULL) + { + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + MultiByteToWideChar(CP_ACP, 0, lpSource, -1, lpwSource, dwSourceSize); + + dwExeNameSize = (strlen(lpExeName)+1) * sizeof(WCHAR); + lpwExeName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwExeNameSize); + if (lpwExeName == NULL) + { + HeapFree(GetProcessHeap(), 0, lpwSource); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + MultiByteToWideChar(CP_ACP, 0, lpExeName, -1, lpwExeName, dwExeNameSize); + + lpwTargetBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, TargetBufferLength * sizeof(WCHAR)); + if (lpwTargetBuffer == NULL) + { + HeapFree(GetProcessHeap(), 0, lpwSource); + HeapFree(GetProcessHeap(), 0, lpwExeName); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + dwResult = GetConsoleAliasW(lpwSource, lpwTargetBuffer, TargetBufferLength * sizeof(WCHAR), lpwExeName); + + HeapFree(GetProcessHeap(), 0, lpwSource); + HeapFree(GetProcessHeap(), 0, lpwExeName); + + if (dwResult) + dwResult = WideCharToMultiByte(CP_ACP, 0, lpwTargetBuffer, dwResult / sizeof(WCHAR), lpTargetBuffer, TargetBufferLength, NULL, NULL); + + HeapFree(GetProcessHeap(), 0, lpwTargetBuffer); + + return dwResult; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasExesW(LPWSTR lpExeNameBuffer, + DWORD ExeNameBufferLength) +{ + CSR_API_MESSAGE Request; + PCSR_CAPTURE_BUFFER CaptureBuffer; + NTSTATUS Status; + + DPRINT("GetConsoleAliasExesW entered\n"); + + CaptureBuffer = CsrAllocateCaptureBuffer(1, ExeNameBufferLength); + if (!CaptureBuffer) + { + DPRINT1("CsrAllocateCaptureBuffer failed!\n"); + SetLastError(ERROR_NOT_ENOUGH_MEMORY); + return 0; + } + + CsrAllocateMessagePointer(CaptureBuffer, + ExeNameBufferLength, + (PVOID*)&Request.Data.GetConsoleAliasesExes.ExeNames); + Request.Data.GetConsoleAliasesExes.Length = ExeNameBufferLength; + + Status = CsrClientCallServer(&Request, + CaptureBuffer, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIASES_EXES), + sizeof(CSR_API_MESSAGE)); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + BaseSetLastNTError(Status); + CsrFreeCaptureBuffer(CaptureBuffer); + return 0; + } + + memcpy(lpExeNameBuffer, + Request.Data.GetConsoleAliasesExes.ExeNames, + Request.Data.GetConsoleAliasesExes.BytesWritten); + + CsrFreeCaptureBuffer(CaptureBuffer); + return Request.Data.GetConsoleAliasesExes.BytesWritten; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasExesA(LPSTR lpExeNameBuffer, + DWORD ExeNameBufferLength) +{ + LPWSTR lpwExeNameBuffer; + DWORD dwResult; + + DPRINT("GetConsoleAliasExesA entered\n"); + + lpwExeNameBuffer = HeapAlloc(GetProcessHeap(), 0, ExeNameBufferLength * sizeof(WCHAR)); + + dwResult = GetConsoleAliasExesW(lpwExeNameBuffer, ExeNameBufferLength * sizeof(WCHAR)); + + if (dwResult) + dwResult = WideCharToMultiByte(CP_ACP, 0, lpwExeNameBuffer, dwResult / sizeof(WCHAR), lpExeNameBuffer, ExeNameBufferLength, NULL, NULL); + + HeapFree(GetProcessHeap(), 0, lpwExeNameBuffer); + return dwResult; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasExesLengthW(VOID) +{ + CSR_API_MESSAGE Request; + NTSTATUS Status; + + DPRINT("GetConsoleAliasExesLengthW entered\n"); + + Request.Data.GetConsoleAliasesExesLength.Length = 0; + + Status = CsrClientCallServer(&Request, + NULL, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIASES_EXES_LENGTH), + sizeof(CSR_API_MESSAGE)); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + BaseSetLastNTError(Status); + return 0; + } + + return Request.Data.GetConsoleAliasesExesLength.Length; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasExesLengthA(VOID) +{ + DWORD dwLength; + + DPRINT("GetConsoleAliasExesLengthA entered\n"); + + dwLength = GetConsoleAliasExesLengthW(); + + if (dwLength) + dwLength /= sizeof(WCHAR); + + return dwLength; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasesW(LPWSTR AliasBuffer, + DWORD AliasBufferLength, + LPWSTR ExeName) +{ + CSR_API_MESSAGE Request; + NTSTATUS Status; + DWORD dwLength; + + DPRINT("GetConsoleAliasesW entered\n"); + + dwLength = GetConsoleAliasesLengthW(ExeName); + if (!dwLength || dwLength > AliasBufferLength) + return 0; + + Request.Data.GetAllConsoleAlias.AliasBuffer = AliasBuffer; + Request.Data.GetAllConsoleAlias.AliasBufferLength = AliasBufferLength; + Request.Data.GetAllConsoleAlias.lpExeName = ExeName; + + Status = CsrClientCallServer(&Request, + NULL, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_ALL_CONSOLE_ALIASES), + sizeof(CSR_API_MESSAGE)); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + BaseSetLastNTError(Status); + return 0; + } + + return Request.Data.GetAllConsoleAlias.BytesWritten / sizeof(WCHAR); +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasesA(LPSTR AliasBuffer, + DWORD AliasBufferLength, + LPSTR ExeName) +{ + DWORD dwRetVal = 0; + LPWSTR lpwExeName = NULL; + LPWSTR lpwAliasBuffer; + + DPRINT("GetConsoleAliasesA entered\n"); + + if (ExeName) + BasepAnsiStringToHeapUnicodeString(ExeName, (LPWSTR*) &lpwExeName); + + lpwAliasBuffer = HeapAlloc(GetProcessHeap(), 0, AliasBufferLength * sizeof(WCHAR)); + + dwRetVal = GetConsoleAliasesW(lpwAliasBuffer, AliasBufferLength, lpwExeName); + + if (lpwExeName) + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpwExeName); + + if (dwRetVal) + dwRetVal = WideCharToMultiByte(CP_ACP, 0, lpwAliasBuffer, dwRetVal, AliasBuffer, AliasBufferLength, NULL, NULL); + + HeapFree(GetProcessHeap(), 0, lpwAliasBuffer); + return dwRetVal; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasesLengthW(LPWSTR lpExeName) +{ + CSR_API_MESSAGE Request; + NTSTATUS Status; + + DPRINT("GetConsoleAliasesLengthW entered\n"); + + Request.Data.GetAllConsoleAliasesLength.lpExeName = lpExeName; + Request.Data.GetAllConsoleAliasesLength.Length = 0; + + Status = CsrClientCallServer(&Request, + NULL, + CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_ALL_CONSOLE_ALIASES_LENGTH), + sizeof(CSR_API_MESSAGE)); + + if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) + { + BaseSetLastNTError(Status); + return 0; + } + + return Request.Data.GetAllConsoleAliasesLength.Length; +} + + +/* + * @implemented + */ +DWORD +WINAPI +GetConsoleAliasesLengthA(LPSTR lpExeName) +{ + DWORD dwRetVal = 0; + LPWSTR lpExeNameW = NULL; + + if (lpExeName) + BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW); + + dwRetVal = GetConsoleAliasesLengthW(lpExeNameW); + if (dwRetVal) + dwRetVal /= sizeof(WCHAR); + + /* Clean up */ + if (lpExeNameW) + RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpExeNameW); + + return dwRetVal; +} + +/* EOF */ Propchange: branches/ros-csrss/dll/win32/kernel32/client/console/alias.c ------------------------------------------------------------------------------ svn:eol-style = native 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] Thu Nov 15 16:51:29 2012 @@ -209,103 +209,7 @@ RequestString->Length = RequestString->MaximumLength = Size; } -/* FUNCTIONS *****************************************************************/ - -/* - * @implemented - */ -BOOL -WINAPI -AddConsoleAliasA(LPCSTR lpSource, - LPCSTR lpTarget, - LPCSTR lpExeName) -{ - LPWSTR lpSourceW = NULL; - LPWSTR lpTargetW = NULL; - LPWSTR lpExeNameW = NULL; - BOOL bRetVal; - - if (lpSource) - BasepAnsiStringToHeapUnicodeString(lpSource, (LPWSTR*) &lpSourceW); - if (lpTarget) - BasepAnsiStringToHeapUnicodeString(lpTarget, (LPWSTR*) &lpTargetW); - if (lpExeName) - BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW); - - bRetVal = AddConsoleAliasW(lpSourceW, lpTargetW, lpExeNameW); - - /* Clean up */ - if (lpSourceW) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpSourceW); - if (lpTargetW) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpTargetW); - if (lpExeNameW) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpExeNameW); - - return bRetVal; -} - - -/* - * @unimplemented - */ -BOOL -WINAPI -AddConsoleAliasW(LPCWSTR lpSource, - LPCWSTR lpTarget, - LPCWSTR lpExeName) -{ - PCSR_API_MESSAGE Request; - NTSTATUS Status; - ULONG SourceLength; - ULONG TargetLength = 0; - ULONG ExeLength; - ULONG Size; - ULONG RequestLength; - WCHAR * Ptr; - - DPRINT("AddConsoleAliasW enterd with lpSource %S lpTarget %S lpExeName %S\n", lpSource, lpTarget, lpExeName); - - ExeLength = wcslen(lpExeName) + 1; - SourceLength = wcslen(lpSource)+ 1; - if (lpTarget) - TargetLength = wcslen(lpTarget) + 1; - - Size = (ExeLength + SourceLength + TargetLength) * sizeof(WCHAR); - RequestLength = sizeof(CSR_API_MESSAGE) + Size; - - Request = RtlAllocateHeap(GetProcessHeap(), HEAP_ZERO_MEMORY, RequestLength); - Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE)); - - wcscpy(Ptr, lpSource); - Request->Data.AddConsoleAlias.SourceLength = SourceLength; - Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE) + SourceLength * sizeof(WCHAR)); - - wcscpy(Ptr, lpExeName); - Request->Data.AddConsoleAlias.ExeLength = ExeLength; - Ptr = (WCHAR*)(((ULONG_PTR)Request) + sizeof(CSR_API_MESSAGE) + (ExeLength + SourceLength)* sizeof(WCHAR)); - - if (lpTarget) /* target can be optional */ - wcscpy(Ptr, lpTarget); - - Request->Data.AddConsoleAlias.TargetLength = TargetLength; - - Status = CsrClientCallServer(Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, ADD_CONSOLE_ALIAS), - RequestLength); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) - { - BaseSetLastNTError(Status); - RtlFreeHeap(GetProcessHeap(), 0, Request); - return FALSE; - } - - RtlFreeHeap(GetProcessHeap(), 0, Request); - return TRUE; -} - +/* FUNCTIONS ******************************************************************/ /* * @unimplemented (Undocumented) @@ -420,406 +324,6 @@ ExpungeConsoleCommandHistoryA(LPCSTR lpExeName) { return IntExpungeConsoleCommandHistory(lpExeName, FALSE); -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasW(LPWSTR lpSource, - LPWSTR lpTargetBuffer, - DWORD TargetBufferLength, - LPWSTR lpExeName) -{ - PCSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; - ULONG Size; - ULONG ExeLength; - ULONG SourceLength; - ULONG RequestLength; - WCHAR * Ptr; - - DPRINT("GetConsoleAliasW entered lpSource %S lpExeName %S\n", lpSource, lpExeName); - - if (lpTargetBuffer == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - ExeLength = wcslen(lpExeName) + 1; - SourceLength = wcslen(lpSource) + 1; - - Size = (ExeLength + SourceLength) * sizeof(WCHAR); - - RequestLength = Size + sizeof(CSR_API_MESSAGE); - Request = RtlAllocateHeap(GetProcessHeap(), 0, RequestLength); - if (Request == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - CaptureBuffer = CsrAllocateCaptureBuffer(1, TargetBufferLength); - if (!CaptureBuffer) - { - DPRINT1("CsrAllocateCaptureBuffer failed!\n"); - RtlFreeHeap(GetProcessHeap(), 0, Request); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - Request->Data.GetConsoleAlias.TargetBuffer = NULL; - - CsrCaptureMessageBuffer(CaptureBuffer, - NULL, - TargetBufferLength, - (PVOID*)&Request->Data.GetConsoleAlias.TargetBuffer); - - Request->Data.GetConsoleAlias.TargetBufferLength = TargetBufferLength; - - Ptr = (LPWSTR)((ULONG_PTR)Request + sizeof(CSR_API_MESSAGE)); - wcscpy(Ptr, lpSource); - Ptr += SourceLength; - wcscpy(Ptr, lpExeName); - - Request->Data.GetConsoleAlias.ExeLength = ExeLength; - Request->Data.GetConsoleAlias.SourceLength = SourceLength; - - Status = CsrClientCallServer(Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIAS), - sizeof(CSR_API_MESSAGE) + Size); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request->Status)) - { - RtlFreeHeap(GetProcessHeap(), 0, Request); - CsrFreeCaptureBuffer(CaptureBuffer); - BaseSetLastNTError(Status); - return 0; - } - - wcscpy(lpTargetBuffer, Request->Data.GetConsoleAlias.TargetBuffer); - RtlFreeHeap(GetProcessHeap(), 0, Request); - CsrFreeCaptureBuffer(CaptureBuffer); - - return Request->Data.GetConsoleAlias.BytesWritten; -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasA(LPSTR lpSource, - LPSTR lpTargetBuffer, - DWORD TargetBufferLength, - LPSTR lpExeName) -{ - LPWSTR lpwSource; - LPWSTR lpwExeName; - LPWSTR lpwTargetBuffer; - UINT dwSourceSize; - UINT dwExeNameSize; - UINT dwResult; - - DPRINT("GetConsoleAliasA entered\n"); - - if (lpTargetBuffer == NULL) - { - SetLastError(ERROR_INVALID_PARAMETER); - return 0; - } - - dwSourceSize = (strlen(lpSource)+1) * sizeof(WCHAR); - lpwSource = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwSourceSize); - if (lpwSource == NULL) - { - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - MultiByteToWideChar(CP_ACP, 0, lpSource, -1, lpwSource, dwSourceSize); - - dwExeNameSize = (strlen(lpExeName)+1) * sizeof(WCHAR); - lpwExeName = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, dwExeNameSize); - if (lpwExeName == NULL) - { - HeapFree(GetProcessHeap(), 0, lpwSource); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - MultiByteToWideChar(CP_ACP, 0, lpExeName, -1, lpwExeName, dwExeNameSize); - - lpwTargetBuffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, TargetBufferLength * sizeof(WCHAR)); - if (lpwTargetBuffer == NULL) - { - HeapFree(GetProcessHeap(), 0, lpwSource); - HeapFree(GetProcessHeap(), 0, lpwExeName); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - dwResult = GetConsoleAliasW(lpwSource, lpwTargetBuffer, TargetBufferLength * sizeof(WCHAR), lpwExeName); - - HeapFree(GetProcessHeap(), 0, lpwSource); - HeapFree(GetProcessHeap(), 0, lpwExeName); - - if (dwResult) - dwResult = WideCharToMultiByte(CP_ACP, 0, lpwTargetBuffer, dwResult / sizeof(WCHAR), lpTargetBuffer, TargetBufferLength, NULL, NULL); - - HeapFree(GetProcessHeap(), 0, lpwTargetBuffer); - - return dwResult; -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasExesW(LPWSTR lpExeNameBuffer, - DWORD ExeNameBufferLength) -{ - CSR_API_MESSAGE Request; - PCSR_CAPTURE_BUFFER CaptureBuffer; - NTSTATUS Status; - - DPRINT("GetConsoleAliasExesW entered\n"); - - CaptureBuffer = CsrAllocateCaptureBuffer(1, ExeNameBufferLength); - if (!CaptureBuffer) - { - DPRINT1("CsrAllocateCaptureBuffer failed!\n"); - SetLastError(ERROR_NOT_ENOUGH_MEMORY); - return 0; - } - - CsrAllocateMessagePointer(CaptureBuffer, - ExeNameBufferLength, - (PVOID*)&Request.Data.GetConsoleAliasesExes.ExeNames); - Request.Data.GetConsoleAliasesExes.Length = ExeNameBufferLength; - - Status = CsrClientCallServer(&Request, - CaptureBuffer, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIASES_EXES), - sizeof(CSR_API_MESSAGE)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - CsrFreeCaptureBuffer(CaptureBuffer); - return 0; - } - - memcpy(lpExeNameBuffer, - Request.Data.GetConsoleAliasesExes.ExeNames, - Request.Data.GetConsoleAliasesExes.BytesWritten); - - CsrFreeCaptureBuffer(CaptureBuffer); - return Request.Data.GetConsoleAliasesExes.BytesWritten; -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasExesA(LPSTR lpExeNameBuffer, - DWORD ExeNameBufferLength) -{ - LPWSTR lpwExeNameBuffer; - DWORD dwResult; - - DPRINT("GetConsoleAliasExesA entered\n"); - - lpwExeNameBuffer = HeapAlloc(GetProcessHeap(), 0, ExeNameBufferLength * sizeof(WCHAR)); - - dwResult = GetConsoleAliasExesW(lpwExeNameBuffer, ExeNameBufferLength * sizeof(WCHAR)); - - if (dwResult) - dwResult = WideCharToMultiByte(CP_ACP, 0, lpwExeNameBuffer, dwResult / sizeof(WCHAR), lpExeNameBuffer, ExeNameBufferLength, NULL, NULL); - - HeapFree(GetProcessHeap(), 0, lpwExeNameBuffer); - return dwResult; -} - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasExesLengthW(VOID) -{ - CSR_API_MESSAGE Request; - NTSTATUS Status; - - DPRINT("GetConsoleAliasExesLengthW entered\n"); - - Request.Data.GetConsoleAliasesExesLength.Length = 0; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_CONSOLE_ALIASES_EXES_LENGTH), - sizeof(CSR_API_MESSAGE)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return 0; - } - - return Request.Data.GetConsoleAliasesExesLength.Length; -} - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasExesLengthA(VOID) -{ - DWORD dwLength; - - DPRINT("GetConsoleAliasExesLengthA entered\n"); - - dwLength = GetConsoleAliasExesLengthW(); - - if (dwLength) - dwLength /= sizeof(WCHAR); - - return dwLength; -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasesW(LPWSTR AliasBuffer, - DWORD AliasBufferLength, - LPWSTR ExeName) -{ - CSR_API_MESSAGE Request; - NTSTATUS Status; - DWORD dwLength; - - DPRINT("GetConsoleAliasesW entered\n"); - - dwLength = GetConsoleAliasesLengthW(ExeName); - if (!dwLength || dwLength > AliasBufferLength) - return 0; - - Request.Data.GetAllConsoleAlias.AliasBuffer = AliasBuffer; - Request.Data.GetAllConsoleAlias.AliasBufferLength = AliasBufferLength; - Request.Data.GetAllConsoleAlias.lpExeName = ExeName; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_ALL_CONSOLE_ALIASES), - sizeof(CSR_API_MESSAGE)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return 0; - } - - return Request.Data.GetAllConsoleAlias.BytesWritten / sizeof(WCHAR); -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasesA(LPSTR AliasBuffer, - DWORD AliasBufferLength, - LPSTR ExeName) -{ - DWORD dwRetVal = 0; - LPWSTR lpwExeName = NULL; - LPWSTR lpwAliasBuffer; - - DPRINT("GetConsoleAliasesA entered\n"); - - if (ExeName) - BasepAnsiStringToHeapUnicodeString(ExeName, (LPWSTR*) &lpwExeName); - - lpwAliasBuffer = HeapAlloc(GetProcessHeap(), 0, AliasBufferLength * sizeof(WCHAR)); - - dwRetVal = GetConsoleAliasesW(lpwAliasBuffer, AliasBufferLength, lpwExeName); - - if (lpwExeName) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpwExeName); - - if (dwRetVal) - dwRetVal = WideCharToMultiByte(CP_ACP, 0, lpwAliasBuffer, dwRetVal, AliasBuffer, AliasBufferLength, NULL, NULL); - - HeapFree(GetProcessHeap(), 0, lpwAliasBuffer); - return dwRetVal; -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasesLengthW(LPWSTR lpExeName) -{ - CSR_API_MESSAGE Request; - NTSTATUS Status; - - DPRINT("GetConsoleAliasesLengthW entered\n"); - - Request.Data.GetAllConsoleAliasesLength.lpExeName = lpExeName; - Request.Data.GetAllConsoleAliasesLength.Length = 0; - - Status = CsrClientCallServer(&Request, - NULL, - CSR_CREATE_API_NUMBER(CSR_CONSOLE, GET_ALL_CONSOLE_ALIASES_LENGTH), - sizeof(CSR_API_MESSAGE)); - - if (!NT_SUCCESS(Status) || !NT_SUCCESS(Status = Request.Status)) - { - BaseSetLastNTError(Status); - return 0; - } - - return Request.Data.GetAllConsoleAliasesLength.Length; -} - - -/* - * @implemented - */ -DWORD -WINAPI -GetConsoleAliasesLengthA(LPSTR lpExeName) -{ - DWORD dwRetVal = 0; - LPWSTR lpExeNameW = NULL; - - if (lpExeName) - BasepAnsiStringToHeapUnicodeString(lpExeName, (LPWSTR*) &lpExeNameW); - - dwRetVal = GetConsoleAliasesLengthW(lpExeNameW); - if (dwRetVal) - dwRetVal /= sizeof(WCHAR); - - /* Clean up */ - if (lpExeNameW) - RtlFreeHeap(GetProcessHeap(), 0, (LPWSTR*) lpExeNameW); - - return dwRetVal; }
12 years, 1 month
1
0
0
0
[hbelusca] 57706: [KERNEL32] Fix some comments formatting.
by hbelusca@svn.reactos.org
Author: hbelusca Date: Thu Nov 15 16:29:21 2012 New Revision: 57706 URL:
http://svn.reactos.org/svn/reactos?rev=57706&view=rev
Log: [KERNEL32] Fix some comments formatting. Modified: branches/ros-csrss/dll/win32/kernel32/client/console/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] Thu Nov 15 16:29:21 2012 @@ -1,29 +1,28 @@ -/* $Id: console.c 55081 2012-01-22 22:27:08Z gadamopoulos $ - * +/* * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries - * FILE: dll/win32/kernel32/misc/console.c + * FILE: dll/win32/kernel32/client/console/console.c * PURPOSE: Win32 server console functions * PROGRAMMER: James Tabor - * <jimtabor(a)adsl-64-217-116-74.dsl.hstntx.swbell.net> + * <jimtabor(a)adsl-64-217-116-74.dsl.hstntx.swbell.net> * UPDATE HISTORY: * 199901?? ?? Created * 19990204 EA SetConsoleTitleA - * 19990306 EA Stubs - */ - -/* INCLUDES ******************************************************************/ + * 19990306 EA Stubs + */ + +/* INCLUDES *******************************************************************/ #include <k32.h> -#define NDEBUG +// #define NDEBUG #include <debug.h> extern RTL_CRITICAL_SECTION ConsoleLock; extern BOOL ConsoleInitialized; extern BOOL WINAPI IsDebuggerPresent(VOID); -/* GLOBALS *******************************************************************/ +/* GLOBALS ********************************************************************/ PHANDLER_ROUTINE InitialHandler[1]; PHANDLER_ROUTINE* CtrlHandlers; @@ -33,7 +32,7 @@ #define INPUTEXENAME_BUFLEN 256 static WCHAR InputExeName[INPUTEXENAME_BUFLEN]; -/* Default Console Control Handler *******************************************/ +/* Default Console Control Handler ********************************************/ BOOL WINAPI
12 years, 1 month
1
0
0
0
← Newer
1
...
5
6
7
8
9
10
11
12
13
Older →
Jump to page:
1
2
3
4
5
6
7
8
9
10
11
12
13
Results per page:
10
25
50
100
200