Author: hbelusca
Date: Sun Apr 20 11:25:38 2014
New Revision: 62833
URL:
http://svn.reactos.org/svn/reactos?rev=62833&view=rev
Log:
[KERNEL32][CONSRV]
Make kernel32 / winsrv console CSR structures Win2k3-compliant.
The aim is to be able to put our kernel32.dll or winsrv.dll on win2k3, and vice-versa.
Part 2/X
CORE-7931
Modified:
trunk/reactos/dll/win32/kernel32/client/console/console.c
trunk/reactos/include/reactos/subsys/win/conmsg.h
trunk/reactos/win32ss/user/winsrv/consrv/condrv/coninput.c
trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c
trunk/reactos/win32ss/user/winsrv/consrv/condrv/text.c
trunk/reactos/win32ss/user/winsrv/consrv/coninput.c
trunk/reactos/win32ss/user/winsrv/consrv/conoutput.c
trunk/reactos/win32ss/user/winsrv/consrv/console.c
trunk/reactos/win32ss/user/winsrv/consrv/handle.c
trunk/reactos/win32ss/user/winsrv/consrv/include/conio.h
Modified: trunk/reactos/dll/win32/kernel32/client/console/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/client/…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/client/console/console.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/client/console/console.c [iso-8859-1] Sun Apr 20
11:25:38 2014
@@ -277,7 +277,6 @@
BOOL bInheritHandle,
DWORD dwOptions)
{
- NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_DUPLICATEHANDLE DuplicateHandleRequest =
&ApiMessage.Data.DuplicateHandleRequest;
@@ -285,26 +284,27 @@
(!(dwOptions & DUPLICATE_SAME_ACCESS) &&
(dwDesiredAccess & ~(GENERIC_READ | GENERIC_WRITE))) )
{
- SetLastError (ERROR_INVALID_PARAMETER);
+ SetLastError(ERROR_INVALID_PARAMETER);
return INVALID_HANDLE_VALUE;
}
- DuplicateHandleRequest->ConsoleHandle = hConsole;
- DuplicateHandleRequest->Access = dwDesiredAccess;
- DuplicateHandleRequest->Inheritable = bInheritHandle;
- DuplicateHandleRequest->Options = dwOptions;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepDuplicateHandle),
- sizeof(CONSOLE_DUPLICATEHANDLE));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ DuplicateHandleRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ DuplicateHandleRequest->SourceHandle = hConsole;
+ DuplicateHandleRequest->DesiredAccess = dwDesiredAccess;
+ DuplicateHandleRequest->InheritHandle = bInheritHandle;
+ DuplicateHandleRequest->Options = dwOptions;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepDuplicateHandle),
+ sizeof(*DuplicateHandleRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return INVALID_HANDLE_VALUE;
}
- return DuplicateHandleRequest->ConsoleHandle;
+ return DuplicateHandleRequest->TargetHandle;
}
@@ -337,6 +337,7 @@
}
*lpModeFlags = GetDisplayModeRequest->DisplayMode; // ModeFlags
+
return TRUE;
}
@@ -407,6 +408,7 @@
*Flags = HardwareStateRequest->Flags;
*State = HardwareStateRequest->State;
+
return TRUE;
}
@@ -496,16 +498,15 @@
BOOL bInheritHandle,
DWORD dwShareMode)
{
- NTSTATUS Status = STATUS_SUCCESS;
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_OPENCONSOLE OpenConsoleRequest = &ApiMessage.Data.OpenConsoleRequest;
CONSOLE_HANDLE_TYPE HandleType;
- if (wsName && 0 == _wcsicmp(wsName, BaseConInputFileName))
+ if (wsName && (_wcsicmp(wsName, BaseConInputFileName) == 0))
{
HandleType = HANDLE_INPUT;
}
- else if (wsName && 0 == _wcsicmp(wsName, BaseConOutputFileName))
+ else if (wsName && (_wcsicmp(wsName, BaseConOutputFileName) == 0))
{
HandleType = HANDLE_OUTPUT;
}
@@ -522,22 +523,23 @@
return INVALID_HANDLE_VALUE;
}
- OpenConsoleRequest->HandleType = HandleType;
- OpenConsoleRequest->Access = dwDesiredAccess;
- OpenConsoleRequest->Inheritable = bInheritHandle;
- OpenConsoleRequest->ShareMode = dwShareMode;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepOpenConsole),
- sizeof(CONSOLE_OPENCONSOLE));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ OpenConsoleRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ OpenConsoleRequest->HandleType = HandleType;
+ OpenConsoleRequest->DesiredAccess = dwDesiredAccess;
+ OpenConsoleRequest->InheritHandle = bInheritHandle;
+ OpenConsoleRequest->ShareMode = dwShareMode;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepOpenConsole),
+ sizeof(*OpenConsoleRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return INVALID_HANDLE_VALUE;
}
- return OpenConsoleRequest->ConsoleHandle;
+ return OpenConsoleRequest->Handle;
}
@@ -1082,19 +1084,20 @@
SetConsoleCursorPosition(HANDLE hConsoleOutput,
COORD dwCursorPosition)
{
- NTSTATUS Status;
- CONSOLE_API_MESSAGE ApiMessage;
-
- ApiMessage.Data.SetCursorPositionRequest.OutputHandle = hConsoleOutput;
- ApiMessage.Data.SetCursorPositionRequest.Position = dwCursorPosition;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetCursorPosition),
- sizeof(CONSOLE_SETCURSORPOSITION));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_SETCURSORPOSITION SetCursorPositionRequest =
&ApiMessage.Data.SetCursorPositionRequest;
+
+ SetCursorPositionRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ SetCursorPositionRequest->OutputHandle = hConsoleOutput;
+ SetCursorPositionRequest->Position = dwCursorPosition;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetCursorPosition),
+ sizeof(*SetCursorPositionRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return FALSE;
}
@@ -1112,7 +1115,6 @@
GetConsoleMode(HANDLE hConsoleHandle,
LPDWORD lpMode)
{
- NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest =
&ApiMessage.Data.ConsoleModeRequest;
@@ -1122,19 +1124,51 @@
return FALSE;
}
- ConsoleModeRequest->ConsoleHandle = hConsoleHandle;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetMode),
- sizeof(CONSOLE_GETSETCONSOLEMODE));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
- return FALSE;
- }
-
- *lpMode = ConsoleModeRequest->ConsoleMode;
+ ConsoleModeRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ ConsoleModeRequest->Handle = hConsoleHandle;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetMode),
+ sizeof(*ConsoleModeRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
+ return FALSE;
+ }
+
+ *lpMode = ConsoleModeRequest->Mode;
+
+ return TRUE;
+}
+
+
+/*--------------------------------------------------------------
+ * SetConsoleMode
+ *
+ * @implemented
+ */
+BOOL
+WINAPI
+SetConsoleMode(HANDLE hConsoleHandle,
+ DWORD dwMode)
+{
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest =
&ApiMessage.Data.ConsoleModeRequest;
+
+ ConsoleModeRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ ConsoleModeRequest->Handle = hConsoleHandle;
+ ConsoleModeRequest->Mode = dwMode;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetMode),
+ sizeof(*ConsoleModeRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
+ return FALSE;
+ }
return TRUE;
}
@@ -1150,20 +1184,20 @@
GetNumberOfConsoleInputEvents(HANDLE hConsoleInput,
LPDWORD lpNumberOfEvents)
{
- NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest =
&ApiMessage.Data.GetNumInputEventsRequest;
- GetNumInputEventsRequest->InputHandle = hConsoleInput;
- GetNumInputEventsRequest->NumInputEvents = 0;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetNumberOfInputEvents),
- sizeof(CONSOLE_GETNUMINPUTEVENTS));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ GetNumInputEventsRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ GetNumInputEventsRequest->InputHandle = hConsoleInput;
+ GetNumInputEventsRequest->NumberOfEvents = 0;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetNumberOfInputEvents),
+ sizeof(*GetNumInputEventsRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return FALSE;
}
@@ -1173,7 +1207,7 @@
return FALSE;
}
- *lpNumberOfEvents = GetNumInputEventsRequest->NumInputEvents;
+ *lpNumberOfEvents = GetNumInputEventsRequest->NumberOfEvents;
return TRUE;
}
@@ -1188,21 +1222,21 @@
WINAPI
GetLargestConsoleWindowSize(HANDLE hConsoleOutput)
{
- NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETLARGESTWINDOWSIZE GetLargestWindowSizeRequest =
&ApiMessage.Data.GetLargestWindowSizeRequest;
- GetLargestWindowSizeRequest->OutputHandle = hConsoleOutput;
+ GetLargestWindowSizeRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ GetLargestWindowSizeRequest->OutputHandle = hConsoleOutput;
GetLargestWindowSizeRequest->Size.X = 0;
GetLargestWindowSizeRequest->Size.Y = 0;
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetLargestWindowSize),
- sizeof(CONSOLE_GETLARGESTWINDOWSIZE));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetLargestWindowSize),
+ sizeof(*GetLargestWindowSizeRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
}
DPRINT1("GetLargestConsoleWindowSize, X = %d, Y = %d\n",
GetLargestWindowSizeRequest->Size.X, GetLargestWindowSizeRequest->Size.Y);
@@ -1220,8 +1254,8 @@
GetConsoleCursorInfo(HANDLE hConsoleOutput,
PCONSOLE_CURSOR_INFO lpConsoleCursorInfo)
{
- NTSTATUS Status;
- CONSOLE_API_MESSAGE ApiMessage;
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_GETSETCURSORINFO CursorInfoRequest =
&ApiMessage.Data.CursorInfoRequest;
if (!lpConsoleCursorInfo)
{
@@ -1233,19 +1267,51 @@
return FALSE;
}
- ApiMessage.Data.CursorInfoRequest.OutputHandle = hConsoleOutput;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetCursorInfo),
- sizeof(CONSOLE_GETSETCURSORINFO));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
- return FALSE;
- }
-
- *lpConsoleCursorInfo = ApiMessage.Data.CursorInfoRequest.Info;
+ CursorInfoRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ CursorInfoRequest->OutputHandle = hConsoleOutput;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetCursorInfo),
+ sizeof(*CursorInfoRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
+ return FALSE;
+ }
+
+ *lpConsoleCursorInfo = CursorInfoRequest->Info;
+
+ return TRUE;
+}
+
+
+/*--------------------------------------------------------------
+ * SetConsoleCursorInfo
+ *
+ * @implemented
+ */
+BOOL
+WINAPI
+SetConsoleCursorInfo(HANDLE hConsoleOutput,
+ CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
+{
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_GETSETCURSORINFO CursorInfoRequest =
&ApiMessage.Data.CursorInfoRequest;
+
+ CursorInfoRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ CursorInfoRequest->OutputHandle = hConsoleOutput;
+ CursorInfoRequest->Info = *lpConsoleCursorInfo;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetCursorInfo),
+ sizeof(*CursorInfoRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
+ return FALSE;
+ }
return TRUE;
}
@@ -1267,37 +1333,6 @@
/*--------------------------------------------------------------
- * SetConsoleMode
- *
- * @implemented
- */
-BOOL
-WINAPI
-SetConsoleMode(HANDLE hConsoleHandle,
- DWORD dwMode)
-{
- NTSTATUS Status;
- CONSOLE_API_MESSAGE ApiMessage;
- PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest =
&ApiMessage.Data.ConsoleModeRequest;
-
- ConsoleModeRequest->ConsoleHandle = hConsoleHandle;
- ConsoleModeRequest->ConsoleMode = dwMode;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetMode),
- sizeof(CONSOLE_GETSETCONSOLEMODE));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*--------------------------------------------------------------
* SetConsoleActiveScreenBuffer
*
* @implemented
@@ -1306,18 +1341,19 @@
WINAPI
SetConsoleActiveScreenBuffer(HANDLE hConsoleOutput)
{
- NTSTATUS Status;
- CONSOLE_API_MESSAGE ApiMessage;
-
- ApiMessage.Data.SetScreenBufferRequest.OutputHandle = hConsoleOutput;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetActiveScreenBuffer),
- sizeof(CONSOLE_SETACTIVESCREENBUFFER));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_SETACTIVESCREENBUFFER SetScreenBufferRequest =
&ApiMessage.Data.SetScreenBufferRequest;
+
+ SetScreenBufferRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ SetScreenBufferRequest->OutputHandle = hConsoleOutput;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetActiveScreenBuffer),
+ sizeof(*SetScreenBufferRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return FALSE;
}
@@ -1334,18 +1370,19 @@
WINAPI
FlushConsoleInputBuffer(HANDLE hConsoleInput)
{
- NTSTATUS Status;
- CONSOLE_API_MESSAGE ApiMessage;
-
- ApiMessage.Data.FlushInputBufferRequest.InputHandle = hConsoleInput;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepFlushInputBuffer),
- sizeof(CONSOLE_FLUSHINPUTBUFFER));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest =
&ApiMessage.Data.FlushInputBufferRequest;
+
+ FlushInputBufferRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ FlushInputBufferRequest->InputHandle = hConsoleInput;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepFlushInputBuffer),
+ sizeof(*FlushInputBufferRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return FALSE;
}
@@ -1363,49 +1400,20 @@
SetConsoleScreenBufferSize(HANDLE hConsoleOutput,
COORD dwSize)
{
- NTSTATUS Status;
- CONSOLE_API_MESSAGE ApiMessage;
-
- ApiMessage.Data.SetScreenBufferSizeRequest.OutputHandle = hConsoleOutput;
- ApiMessage.Data.SetScreenBufferSizeRequest.Size = dwSize;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetScreenBufferSize),
- sizeof(CONSOLE_SETSCREENBUFFERSIZE));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-/*--------------------------------------------------------------
- * SetConsoleCursorInfo
- *
- * @implemented
- */
-BOOL
-WINAPI
-SetConsoleCursorInfo(HANDLE hConsoleOutput,
- CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo)
-{
- NTSTATUS Status;
- CONSOLE_API_MESSAGE ApiMessage;
-
- ApiMessage.Data.CursorInfoRequest.OutputHandle = hConsoleOutput;
- ApiMessage.Data.CursorInfoRequest.Info = *lpConsoleCursorInfo;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetCursorInfo),
- sizeof(CONSOLE_GETSETCURSORINFO));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest =
&ApiMessage.Data.SetScreenBufferSizeRequest;
+
+ SetScreenBufferSizeRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ SetScreenBufferSizeRequest->OutputHandle = hConsoleOutput;
+ SetScreenBufferSizeRequest->Size = dwSize;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetScreenBufferSize),
+ sizeof(*SetScreenBufferSizeRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return FALSE;
}
@@ -1513,7 +1521,6 @@
BOOL bAbsolute,
CONST SMALL_RECT *lpConsoleWindow)
{
- NTSTATUS Status;
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_SETWINDOWINFO SetWindowInfoRequest =
&ApiMessage.Data.SetWindowInfoRequest;
@@ -1523,17 +1530,18 @@
return FALSE;
}
- SetWindowInfoRequest->OutputHandle = hConsoleOutput;
- SetWindowInfoRequest->Absolute = bAbsolute;
- SetWindowInfoRequest->WindowRect = *lpConsoleWindow;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetWindowInfo),
- sizeof(CONSOLE_SETWINDOWINFO));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ SetWindowInfoRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ SetWindowInfoRequest->OutputHandle = hConsoleOutput;
+ SetWindowInfoRequest->Absolute = bAbsolute;
+ SetWindowInfoRequest->WindowRect = *lpConsoleWindow;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetWindowInfo),
+ sizeof(*SetWindowInfoRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return FALSE;
}
@@ -1551,19 +1559,20 @@
SetConsoleTextAttribute(HANDLE hConsoleOutput,
WORD wAttributes)
{
- NTSTATUS Status;
- CONSOLE_API_MESSAGE ApiMessage;
-
- ApiMessage.Data.SetTextAttribRequest.OutputHandle = hConsoleOutput;
- ApiMessage.Data.SetTextAttribRequest.Attrib = wAttributes;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetTextAttribute),
- sizeof(CONSOLE_SETTEXTATTRIB));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_SETTEXTATTRIB SetTextAttribRequest =
&ApiMessage.Data.SetTextAttribRequest;
+
+ SetTextAttribRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ SetTextAttribRequest->OutputHandle = hConsoleOutput;
+ SetTextAttribRequest->Attributes = wAttributes;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetTextAttribute),
+ sizeof(*SetTextAttribRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return FALSE;
}
@@ -1677,8 +1686,8 @@
GenerateConsoleCtrlEvent(DWORD dwCtrlEvent,
DWORD dwProcessGroupId)
{
- NTSTATUS Status;
- CONSOLE_API_MESSAGE ApiMessage;
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCONSOLE_GENERATECTRLEVENT GenerateCtrlEventRequest =
&ApiMessage.Data.GenerateCtrlEventRequest;
if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT)
{
@@ -1686,16 +1695,17 @@
return FALSE;
}
- ApiMessage.Data.GenerateCtrlEventRequest.Event = dwCtrlEvent;
- ApiMessage.Data.GenerateCtrlEventRequest.ProcessGroup = dwProcessGroupId;
-
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- NULL,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGenerateCtrlEvent),
- sizeof(CONSOLE_GENERATECTRLEVENT));
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
+ GenerateCtrlEventRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ GenerateCtrlEventRequest->CtrlEvent = dwCtrlEvent;
+ GenerateCtrlEventRequest->ProcessGroupId = dwProcessGroupId;
+
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ NULL,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGenerateCtrlEvent),
+ sizeof(*GenerateCtrlEventRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
return FALSE;
}
@@ -1704,16 +1714,18 @@
static DWORD
-IntGetConsoleTitle(LPVOID lpConsoleTitle, DWORD nSize, BOOL bUnicode)
-{
- NTSTATUS Status;
+IntGetConsoleTitle(LPVOID lpConsoleTitle, DWORD dwNumChars, BOOLEAN bUnicode)
+{
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
- if (nSize == 0) return 0;
-
- TitleRequest->Length = nSize * (bUnicode ? 1 : sizeof(WCHAR));
+ if (dwNumChars == 0) return 0;
+
+ TitleRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ TitleRequest->Length = dwNumChars * (bUnicode ? sizeof(WCHAR) :
sizeof(CHAR));
+ TitleRequest->Unicode = bUnicode;
+
CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
if (CaptureBuffer == NULL)
{
@@ -1726,42 +1738,32 @@
TitleRequest->Length,
(PVOID*)&TitleRequest->Title);
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- CaptureBuffer,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepGetTitle),
- sizeof(CONSOLE_GETSETCONSOLETITLE));
- if (!NT_SUCCESS(Status))
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ CaptureBuffer,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepGetTitle),
+ sizeof(*TitleRequest));
+ if (!NT_SUCCESS(ApiMessage.Status))
{
CsrFreeCaptureBuffer(CaptureBuffer);
- BaseSetLastNTError(Status);
+ BaseSetLastNTError(ApiMessage.Status);
return 0;
}
- if (bUnicode)
- {
- if (nSize >= sizeof(WCHAR))
- wcscpy((LPWSTR)lpConsoleTitle, TitleRequest->Title);
- }
- else
- {
- if (nSize < TitleRequest->Length / sizeof(WCHAR) ||
- !WideCharToMultiByte(CP_ACP, // ANSI code page
- 0, // performance and mapping flags
- TitleRequest->Title, // address of wide-character
string
- -1, // number of characters in string
- (LPSTR)lpConsoleTitle, // address of buffer for new
string
- nSize, // size of buffer
- NULL, // FAST
- NULL))
- {
- /* Yes, if the buffer isn't big enough, it returns 0... Bad API */
- *(LPSTR)lpConsoleTitle = '\0';
- TitleRequest->Length = 0;
- }
- }
+ dwNumChars = TitleRequest->Length / (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
+
+ if (dwNumChars > 0)
+ {
+ memcpy(lpConsoleTitle, TitleRequest->Title, TitleRequest->Length);
+
+ if (bUnicode)
+ ((LPWSTR)lpConsoleTitle)[dwNumChars] = L'\0';
+ else
+ ((LPSTR)lpConsoleTitle)[dwNumChars] = '\0';
+ }
+
CsrFreeCaptureBuffer(CaptureBuffer);
- return TitleRequest->Length / sizeof(WCHAR);
+ return dwNumChars;
}
@@ -1793,21 +1795,16 @@
}
-/*--------------------------------------------------------------
- * SetConsoleTitleW
- *
- * @implemented
- */
-BOOL
-WINAPI
-SetConsoleTitleW(LPCWSTR lpConsoleTitle)
-{
- NTSTATUS Status;
+static BOOL
+IntSetConsoleTitle(CONST VOID *lpConsoleTitle, DWORD dwNumChars, BOOLEAN bUnicode)
+{
CONSOLE_API_MESSAGE ApiMessage;
PCONSOLE_GETSETCONSOLETITLE TitleRequest = &ApiMessage.Data.TitleRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
- TitleRequest->Length = wcslen(lpConsoleTitle) * sizeof(WCHAR);
+ TitleRequest->ConsoleHandle =
NtCurrentPeb()->ProcessParameters->ConsoleHandle;
+ TitleRequest->Length = dwNumChars * (bUnicode ? sizeof(WCHAR) :
sizeof(CHAR));
+ TitleRequest->Unicode = bUnicode;
CaptureBuffer = CsrAllocateCaptureBuffer(1, TitleRequest->Length);
if (CaptureBuffer == NULL)
@@ -1822,20 +1819,32 @@
TitleRequest->Length,
(PVOID*)&TitleRequest->Title);
- Status = CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
- CaptureBuffer,
- CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepSetTitle),
- sizeof(CONSOLE_GETSETCONSOLETITLE));
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
+ CaptureBuffer,
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX, ConsolepSetTitle),
+ sizeof(*TitleRequest));
CsrFreeCaptureBuffer(CaptureBuffer);
- if (!NT_SUCCESS(Status))
- {
- BaseSetLastNTError(Status);
- return FALSE;
- }
-
- return TRUE;
+ if (!NT_SUCCESS(ApiMessage.Status))
+ {
+ BaseSetLastNTError(ApiMessage.Status);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/*--------------------------------------------------------------
+ * SetConsoleTitleW
+ *
+ * @implemented
+ */
+BOOL
+WINAPI
+SetConsoleTitleW(LPCWSTR lpConsoleTitle)
+{
+ return IntSetConsoleTitle(lpConsoleTitle, wcslen(lpConsoleTitle), TRUE);
}
@@ -1848,22 +1857,7 @@
WINAPI
SetConsoleTitleA(LPCSTR lpConsoleTitle)
{
- BOOL Ret;
- ULONG Length = strlen(lpConsoleTitle) + 1;
- LPWSTR WideTitle = HeapAlloc(GetProcessHeap(), 0, Length * sizeof(WCHAR));
-
- if (!WideTitle)
- {
- SetLastError(ERROR_NOT_ENOUGH_MEMORY);
- return FALSE;
- }
-
- MultiByteToWideChar(CP_ACP, 0, lpConsoleTitle, -1, WideTitle, Length);
-
- Ret = SetConsoleTitleW(WideTitle);
-
- HeapFree(GetProcessHeap(), 0, WideTitle);
- return Ret;
+ return IntSetConsoleTitle(lpConsoleTitle, strlen(lpConsoleTitle), FALSE);
}
@@ -2160,6 +2154,7 @@
}
*lpConsoleSelectionInfo = GetSelectionInfoRequest->Info;
+
return TRUE;
}
Modified: trunk/reactos/include/reactos/subsys/win/conmsg.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/win…
==============================================================================
--- trunk/reactos/include/reactos/subsys/win/conmsg.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/subsys/win/conmsg.h [iso-8859-1] Sun Apr 20 11:25:38
2014
@@ -274,8 +274,9 @@
typedef struct
{
- HANDLE OutputHandle;
- COORD Position;
+ HANDLE ConsoleHandle;
+ HANDLE OutputHandle;
+ COORD Position;
} CONSOLE_SETCURSORPOSITION, *PCONSOLE_SETCURSORPOSITION;
typedef struct
@@ -295,20 +296,27 @@
typedef struct
{
+ HANDLE ConsoleHandle;
HANDLE OutputHandle;
CONSOLE_CURSOR_INFO Info;
+/*
+ DWORD Size;
+ BOOLEAN Visible;
+*/
} CONSOLE_GETSETCURSORINFO, *PCONSOLE_GETSETCURSORINFO;
typedef struct
{
- HANDLE OutputHandle;
- WORD Attrib;
+ HANDLE ConsoleHandle;
+ HANDLE OutputHandle;
+ WORD Attributes;
} CONSOLE_SETTEXTATTRIB, *PCONSOLE_SETTEXTATTRIB;
typedef struct
{
- HANDLE ConsoleHandle; /* A valid input or output console handle */
- DWORD ConsoleMode;
+ HANDLE ConsoleHandle;
+ HANDLE Handle;
+ DWORD Mode;
} CONSOLE_GETSETCONSOLEMODE, *PCONSOLE_GETSETCONSOLEMODE;
typedef struct
@@ -358,6 +366,7 @@
typedef struct
{
+ HANDLE ConsoleHandle;
HANDLE OutputHandle; /* Handle to screen buffer to switch to */
} CONSOLE_SETACTIVESCREENBUFFER, *PCONSOLE_SETACTIVESCREENBUFFER;
@@ -378,8 +387,10 @@
typedef struct
{
- DWORD Length;
- PWCHAR Title;
+ HANDLE ConsoleHandle;
+ DWORD Length;
+ PVOID Title;
+ BOOLEAN Unicode;
} CONSOLE_GETSETCONSOLETITLE, *PCONSOLE_GETSETCONSOLETITLE;
typedef struct
@@ -395,6 +406,7 @@
typedef struct
{
+ HANDLE ConsoleHandle;
HANDLE InputHandle;
} CONSOLE_FLUSHINPUTBUFFER, *PCONSOLE_FLUSHINPUTBUFFER;
@@ -527,10 +539,12 @@
typedef struct
{
- HANDLE ConsoleHandle;
- DWORD Access;
- BOOL Inheritable;
- DWORD Options;
+ HANDLE ConsoleHandle;
+ HANDLE SourceHandle;
+ DWORD DesiredAccess;
+ BOOLEAN InheritHandle;
+ DWORD Options;
+ HANDLE TargetHandle;
} CONSOLE_DUPLICATEHANDLE, *PCONSOLE_DUPLICATEHANDLE;
/*
@@ -546,14 +560,16 @@
{
HANDLE ConsoleHandle;
CONSOLE_HANDLE_TYPE HandleType;
- DWORD Access;
- BOOL Inheritable;
- DWORD ShareMode;
+ DWORD DesiredAccess;
+ BOOL InheritHandle;
+ DWORD ShareMode;
+ HANDLE Handle;
} CONSOLE_OPENCONSOLE, *PCONSOLE_OPENCONSOLE;
typedef struct
{
+ HANDLE ConsoleHandle;
HANDLE OutputHandle;
COORD Size;
} CONSOLE_GETLARGESTWINDOWSIZE, *PCONSOLE_GETLARGESTWINDOWSIZE;
@@ -575,6 +591,7 @@
typedef struct
{
+ HANDLE ConsoleHandle;
HANDLE OutputHandle;
BOOL Absolute;
SMALL_RECT WindowRect; // New console window position in the screen-buffer frame
(Absolute == TRUE)
@@ -668,20 +685,23 @@
typedef struct
{
- DWORD Event;
- DWORD ProcessGroup;
+ HANDLE ConsoleHandle;
+ DWORD CtrlEvent;
+ DWORD ProcessGroupId;
} CONSOLE_GENERATECTRLEVENT, *PCONSOLE_GENERATECTRLEVENT;
typedef struct
{
+ HANDLE ConsoleHandle;
HANDLE InputHandle;
- DWORD NumInputEvents;
+ DWORD NumberOfEvents;
} CONSOLE_GETNUMINPUTEVENTS, *PCONSOLE_GETNUMINPUTEVENTS;
typedef struct
{
- HANDLE OutputHandle;
- COORD Size;
+ HANDLE ConsoleHandle;
+ HANDLE OutputHandle;
+ COORD Size;
} CONSOLE_SETSCREENBUFFERSIZE, *PCONSOLE_SETSCREENBUFFERSIZE;
typedef struct
Modified: trunk/reactos/win32ss/user/winsrv/consrv/condrv/coninput.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/condrv/coninput.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/condrv/coninput.c [iso-8859-1] Sun Apr 20
11:25:38 2014
@@ -519,24 +519,24 @@
NTSTATUS NTAPI
ConDrvGetConsoleNumberOfInputEvents(IN PCONSOLE Console,
IN PCONSOLE_INPUT_BUFFER InputBuffer,
- OUT PULONG NumEvents)
+ OUT PULONG NumberOfEvents)
{
PLIST_ENTRY CurrentInput;
- if (Console == NULL || InputBuffer == NULL || NumEvents == NULL)
+ if (Console == NULL || InputBuffer == NULL || NumberOfEvents == NULL)
return STATUS_INVALID_PARAMETER;
/* Validity check */
ASSERT(Console == InputBuffer->Header.Console);
- *NumEvents = 0;
+ *NumberOfEvents = 0;
/* If there are any events ... */
CurrentInput = InputBuffer->InputEvents.Flink;
while (CurrentInput != &InputBuffer->InputEvents)
{
CurrentInput = CurrentInput->Flink;
- (*NumEvents)++;
+ (*NumberOfEvents)++;
}
return STATUS_SUCCESS;
Modified: trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/condrv/console.c [iso-8859-1] Sun Apr 20
11:25:38 2014
@@ -197,7 +197,7 @@
/* PRIVATE FUNCTIONS **********************************************************/
static NTSTATUS
-ConDrvConsoleCtrlEventTimeout(IN ULONG Event,
+ConDrvConsoleCtrlEventTimeout(IN ULONG CtrlEvent,
IN PCONSOLE_PROCESS_DATA ProcessData,
IN ULONG Timeout)
{
@@ -215,7 +215,7 @@
{
Thread = CreateRemoteThread(ProcessData->Process->ProcessHandle,
NULL, 0,
ProcessData->CtrlDispatcher,
- UlongToPtr(Event), 0, NULL);
+ UlongToPtr(CtrlEvent), 0, NULL);
if (NULL == Thread)
{
Status = RtlGetLastNtStatus();
@@ -245,10 +245,10 @@
}
static NTSTATUS
-ConDrvConsoleCtrlEvent(IN ULONG Event,
+ConDrvConsoleCtrlEvent(IN ULONG CtrlEvent,
IN PCONSOLE_PROCESS_DATA ProcessData)
{
- return ConDrvConsoleCtrlEventTimeout(Event, ProcessData, 0);
+ return ConDrvConsoleCtrlEventTimeout(CtrlEvent, ProcessData, 0);
}
VOID FASTCALL
@@ -879,7 +879,8 @@
IN PCONSOLE_IO_OBJECT Object,
IN ULONG ConsoleMode)
{
-#define CONSOLE_VALID_CONTROL_MODES ( ENABLE_EXTENDED_FLAGS | ENABLE_INSERT_MODE |
ENABLE_QUICK_EDIT_MODE )
+#define CONSOLE_VALID_CONTROL_MODES ( ENABLE_EXTENDED_FLAGS | \
+ ENABLE_INSERT_MODE | ENABLE_QUICK_EDIT_MODE )
#define CONSOLE_VALID_INPUT_MODES ( ENABLE_PROCESSED_INPUT | ENABLE_LINE_INPUT | \
ENABLE_ECHO_INPUT | ENABLE_WINDOW_INPUT | \
ENABLE_MOUSE_INPUT )
@@ -956,39 +957,80 @@
NTSTATUS NTAPI
ConDrvGetConsoleTitle(IN PCONSOLE Console,
- IN OUT PWCHAR Title,
+ IN BOOLEAN Unicode,
+ IN OUT PVOID TitleBuffer,
IN OUT PULONG BufLength)
{
ULONG Length;
- if (Console == NULL || Title == NULL || BufLength == NULL)
+ if (Console == NULL || TitleBuffer == NULL || BufLength == NULL)
return STATUS_INVALID_PARAMETER;
/* Copy title of the console to the user title buffer */
- if (*BufLength >= sizeof(WCHAR))
- {
- Length = min(*BufLength - sizeof(WCHAR), Console->Title.Length);
- RtlCopyMemory(Title, Console->Title.Buffer, Length);
- Title[Length / sizeof(WCHAR)] = L'\0';
- }
-
- *BufLength = Console->Title.Length;
+ if (Unicode)
+ {
+ if (*BufLength >= sizeof(WCHAR))
+ {
+ Length = min(*BufLength - sizeof(WCHAR), Console->Title.Length);
+ RtlCopyMemory(TitleBuffer, Console->Title.Buffer, Length);
+ ((PWCHAR)TitleBuffer)[Length / sizeof(WCHAR)] = L'\0';
+ *BufLength = Length;
+ }
+ else
+ {
+ *BufLength = Console->Title.Length;
+ }
+ }
+ else
+ {
+ if (*BufLength >= sizeof(CHAR))
+ {
+ Length = min(*BufLength - sizeof(CHAR), Console->Title.Length /
sizeof(WCHAR));
+ Length = WideCharToMultiByte(Console->CodePage, 0,
+ Console->Title.Buffer, Length,
+ TitleBuffer, Length,
+ NULL, NULL);
+ ((PCHAR)TitleBuffer)[Length] = '\0';
+ *BufLength = Length;
+ }
+ else
+ {
+ *BufLength = Console->Title.Length / sizeof(WCHAR);
+ }
+ }
return STATUS_SUCCESS;
}
NTSTATUS NTAPI
ConDrvSetConsoleTitle(IN PCONSOLE Console,
- IN PWCHAR Title,
+ IN BOOLEAN Unicode,
+ IN PVOID TitleBuffer,
IN ULONG BufLength)
{
PWCHAR Buffer;
-
- if (Console == NULL || Title == NULL)
+ ULONG Length;
+
+ if (Console == NULL || TitleBuffer == NULL)
return STATUS_INVALID_PARAMETER;
+ if (Unicode)
+ {
+ /* Length is in bytes */
+ Length = BufLength;
+ }
+ else
+ {
+ /* Use the console input CP for the conversion */
+ Length = MultiByteToWideChar(Console->CodePage, 0,
+ TitleBuffer, BufLength,
+ NULL, 0);
+ /* The returned Length was in number of wchars, convert it in bytes */
+ Length *= sizeof(WCHAR);
+ }
+
/* Allocate a new buffer to hold the new title (NULL-terminated) */
- Buffer = ConsoleAllocHeap(0, BufLength + sizeof(WCHAR));
+ Buffer = ConsoleAllocHeap(HEAP_ZERO_MEMORY, Length + sizeof(WCHAR));
if (!Buffer) return STATUS_NO_MEMORY;
/* Free the old title */
@@ -996,9 +1038,22 @@
/* Copy title to console */
Console->Title.Buffer = Buffer;
- Console->Title.Length = BufLength;
+ Console->Title.Length = Length;
Console->Title.MaximumLength = Console->Title.Length + sizeof(WCHAR);
- RtlCopyMemory(Console->Title.Buffer, Title, Console->Title.Length);
+
+ if (Unicode)
+ {
+ RtlCopyMemory(Console->Title.Buffer, TitleBuffer, Console->Title.Length);
+ }
+ else
+ {
+ MultiByteToWideChar(Console->CodePage, 0,
+ TitleBuffer, BufLength,
+ Console->Title.Buffer,
+ Console->Title.Length / sizeof(WCHAR));
+ }
+
+ /* NULL-terminate */
Console->Title.Buffer[Console->Title.Length / sizeof(WCHAR)] = L'\0';
// TermChangeTitle(Console);
@@ -1066,7 +1121,7 @@
NTSTATUS NTAPI
ConDrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
IN ULONG ProcessGroupId,
- IN ULONG Event)
+ IN ULONG CtrlEvent)
{
NTSTATUS Status = STATUS_SUCCESS;
PLIST_ENTRY current_entry;
@@ -1094,7 +1149,7 @@
*/
if (ProcessGroupId == 0 || current->Process->ProcessGroupId ==
ProcessGroupId)
{
- Status = ConDrvConsoleCtrlEvent(Event, current);
+ Status = ConDrvConsoleCtrlEvent(CtrlEvent, current);
}
}
Modified: trunk/reactos/win32ss/user/winsrv/consrv/condrv/text.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/condrv/text.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/condrv/text.c [iso-8859-1] Sun Apr 20
11:25:38 2014
@@ -1259,7 +1259,7 @@
NTSTATUS NTAPI
ConDrvSetConsoleTextAttribute(IN PCONSOLE Console,
IN PTEXTMODE_SCREEN_BUFFER Buffer,
- IN WORD Attribute)
+ IN WORD Attributes)
{
if (Console == NULL || Buffer == NULL)
return STATUS_INVALID_PARAMETER;
@@ -1267,7 +1267,7 @@
/* Validity check */
ASSERT(Console == Buffer->Header.Console);
- Buffer->ScreenDefaultAttrib = Attribute;
+ Buffer->ScreenDefaultAttrib = Attributes;
return STATUS_SUCCESS;
}
Modified: trunk/reactos/win32ss/user/winsrv/consrv/coninput.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/coninput.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/coninput.c [iso-8859-1] Sun Apr 20 11:25:38
2014
@@ -444,7 +444,7 @@
NTSTATUS NTAPI
ConDrvGetConsoleNumberOfInputEvents(IN PCONSOLE Console,
IN PCONSOLE_INPUT_BUFFER InputBuffer,
- OUT PULONG NumEvents);
+ OUT PULONG NumberOfEvents);
CSR_API(SrvGetConsoleNumberOfInputEvents)
{
NTSTATUS Status;
@@ -460,7 +460,7 @@
Status = ConDrvGetConsoleNumberOfInputEvents(InputBuffer->Header.Console,
InputBuffer,
-
&GetNumInputEventsRequest->NumInputEvents);
+
&GetNumInputEventsRequest->NumberOfEvents);
ConSrvReleaseInputBuffer(InputBuffer, TRUE);
return Status;
Modified: trunk/reactos/win32ss/user/winsrv/consrv/conoutput.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/conoutput.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/conoutput.c [iso-8859-1] Sun Apr 20 11:25:38
2014
@@ -720,7 +720,7 @@
NTSTATUS NTAPI
ConDrvSetConsoleTextAttribute(IN PCONSOLE Console,
IN PTEXTMODE_SCREEN_BUFFER Buffer,
- IN WORD Attribute);
+ IN WORD Attributes);
CSR_API(SrvSetConsoleTextAttribute)
{
NTSTATUS Status;
@@ -736,7 +736,7 @@
Status = ConDrvSetConsoleTextAttribute(Buffer->Header.Console,
Buffer,
- SetTextAttribRequest->Attrib);
+ SetTextAttribRequest->Attributes);
ConSrvReleaseScreenBuffer(Buffer, TRUE);
return Status;
Modified: trunk/reactos/win32ss/user/winsrv/consrv/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/console.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/console.c [iso-8859-1] Sun Apr 20 11:25:38
2014
@@ -439,12 +439,12 @@
PCONSOLE_IO_OBJECT Object;
Status = ConSrvGetObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- ConsoleModeRequest->ConsoleHandle,
+ ConsoleModeRequest->Handle,
&Object, NULL, GENERIC_READ, TRUE, 0);
if (!NT_SUCCESS(Status)) return Status;
Status = ConDrvGetConsoleMode(Object->Console, Object,
- &ConsoleModeRequest->ConsoleMode);
+ &ConsoleModeRequest->Mode);
ConSrvReleaseObject(Object, TRUE);
return Status;
@@ -461,12 +461,12 @@
PCONSOLE_IO_OBJECT Object;
Status = ConSrvGetObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- ConsoleModeRequest->ConsoleHandle,
+ ConsoleModeRequest->Handle,
&Object, NULL, GENERIC_WRITE, TRUE, 0);
if (!NT_SUCCESS(Status)) return Status;
Status = ConDrvSetConsoleMode(Object->Console, Object,
- ConsoleModeRequest->ConsoleMode);
+ ConsoleModeRequest->Mode);
ConSrvReleaseObject(Object, TRUE);
return Status;
@@ -474,7 +474,8 @@
NTSTATUS NTAPI
ConDrvGetConsoleTitle(IN PCONSOLE Console,
- IN OUT PWCHAR Title,
+ IN BOOLEAN Unicode,
+ IN OUT PVOID TitleBuffer,
IN OUT PULONG BufLength);
CSR_API(SrvGetConsoleTitle)
{
@@ -498,6 +499,7 @@
}
Status = ConDrvGetConsoleTitle(Console,
+ TitleRequest->Unicode,
TitleRequest->Title,
&TitleRequest->Length);
@@ -507,7 +509,8 @@
NTSTATUS NTAPI
ConDrvSetConsoleTitle(IN PCONSOLE Console,
- IN PWCHAR Title,
+ IN BOOLEAN Unicode,
+ IN PVOID TitleBuffer,
IN ULONG BufLength);
CSR_API(SrvSetConsoleTitle)
{
@@ -531,9 +534,9 @@
}
Status = ConDrvSetConsoleTitle(Console,
+ TitleRequest->Unicode,
TitleRequest->Title,
TitleRequest->Length);
-
if (NT_SUCCESS(Status)) TermChangeTitle(Console);
ConSrvReleaseConsole(Console, TRUE);
@@ -629,8 +632,8 @@
if (!NT_SUCCESS(Status)) return Status;
Status = ConDrvConsoleProcessCtrlEvent(Console,
- GenerateCtrlEventRequest->ProcessGroup,
- GenerateCtrlEventRequest->Event);
+ GenerateCtrlEventRequest->ProcessGroupId,
+ GenerateCtrlEventRequest->CtrlEvent);
ConSrvReleaseConsole(Console, TRUE);
return Status;
Modified: trunk/reactos/win32ss/user/winsrv/consrv/handle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/handle.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/handle.c [iso-8859-1] Sun Apr 20 11:25:38
2014
@@ -688,11 +688,11 @@
PCONSOLE_PROCESS_DATA ProcessData =
ConsoleGetPerProcessData(CsrGetClientThread()->Process);
PCONSOLE Console;
- DWORD DesiredAccess = OpenConsoleRequest->Access;
+ DWORD DesiredAccess = OpenConsoleRequest->DesiredAccess;
DWORD ShareMode = OpenConsoleRequest->ShareMode;
PCONSOLE_IO_OBJECT Object;
- OpenConsoleRequest->ConsoleHandle = INVALID_HANDLE_VALUE;
+ OpenConsoleRequest->Handle = INVALID_HANDLE_VALUE;
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
if (!NT_SUCCESS(Status))
@@ -726,10 +726,10 @@
else
{
Status = ConSrvInsertObject(ProcessData,
- &OpenConsoleRequest->ConsoleHandle,
+ &OpenConsoleRequest->Handle,
Object,
DesiredAccess,
- OpenConsoleRequest->Inheritable,
+ OpenConsoleRequest->InheritHandle,
ShareMode);
}
@@ -746,11 +746,13 @@
PCONSOLE_PROCESS_DATA ProcessData =
ConsoleGetPerProcessData(CsrGetClientThread()->Process);
PCONSOLE Console;
- HANDLE ConsoleHandle = DuplicateHandleRequest->ConsoleHandle;
- ULONG Index = HandleToULong(ConsoleHandle) >> 2;
+ HANDLE SourceHandle = DuplicateHandleRequest->SourceHandle;
+ ULONG Index = HandleToULong(SourceHandle) >> 2;
PCONSOLE_IO_HANDLE Entry;
DWORD DesiredAccess;
+ DuplicateHandleRequest->TargetHandle = INVALID_HANDLE_VALUE;
+
Status = ConSrvGetConsole(ProcessData, &Console, TRUE);
if (!NT_SUCCESS(Status))
{
@@ -763,11 +765,11 @@
// ASSERT( (ProcessData->HandleTable == NULL &&
ProcessData->HandleTableSize == 0) ||
// (ProcessData->HandleTable != NULL &&
ProcessData->HandleTableSize != 0) );
- if ( /** !IsConsoleHandle(ConsoleHandle) || **/
+ if ( /** !IsConsoleHandle(SourceHandle) || **/
Index >= ProcessData->HandleTableSize ||
(Entry = &ProcessData->HandleTable[Index])->Object == NULL)
{
- DPRINT1("Couldn't duplicate invalid handle %p\n", ConsoleHandle);
+ DPRINT1("Couldn't duplicate invalid handle 0x%p\n", SourceHandle);
Status = STATUS_INVALID_HANDLE;
goto Quit;
}
@@ -778,12 +780,12 @@
}
else
{
- DesiredAccess = DuplicateHandleRequest->Access;
+ DesiredAccess = DuplicateHandleRequest->DesiredAccess;
/* Make sure the source handle has all the desired flags */
if ((Entry->Access & DesiredAccess) == 0)
{
- DPRINT1("Handle %p only has access %X; requested %X\n",
- ConsoleHandle, Entry->Access, DesiredAccess);
+ DPRINT1("Handle 0x%p only has access %X; requested %X\n",
+ SourceHandle, Entry->Access, DesiredAccess);
Status = STATUS_INVALID_PARAMETER;
goto Quit;
}
@@ -791,10 +793,10 @@
/* Insert the new handle inside the process handles table */
Status = ConSrvInsertObject(ProcessData,
- &DuplicateHandleRequest->ConsoleHandle, // Use the
new handle value!
+ &DuplicateHandleRequest->TargetHandle,
Entry->Object,
DesiredAccess,
- DuplicateHandleRequest->Inheritable,
+ DuplicateHandleRequest->InheritHandle,
Entry->ShareMode);
if (NT_SUCCESS(Status) &&
(DuplicateHandleRequest->Options & DUPLICATE_CLOSE_SOURCE))
Modified: trunk/reactos/win32ss/user/winsrv/consrv/include/conio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/winsrv/consrv…
==============================================================================
--- trunk/reactos/win32ss/user/winsrv/consrv/include/conio.h [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/winsrv/consrv/include/conio.h [iso-8859-1] Sun Apr 20
11:25:38 2014
@@ -344,7 +344,7 @@
NTSTATUS NTAPI
ConDrvConsoleProcessCtrlEvent(IN PCONSOLE Console,
IN ULONG ProcessGroupId,
- IN ULONG Event);
+ IN ULONG CtrlEvent);
/* coninput.c */
VOID NTAPI ConioProcessKey(PCONSOLE Console, MSG* msg);