Author: hbelusca
Date: Sun Nov 18 13:54:32 2012
New Revision: 57729
URL:
http://svn.reactos.org/svn/reactos?rev=57729&view=rev
Log:
[KERNEL32]
Use new structures and api indices namings.
[CONSRV]
Use CsrValidateMessageBuffer instead of Win32CsrValidateBuffer.
Modified:
branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c
branches/ros-csrss/win32ss/user/consrv/coninput.c
branches/ros-csrss/win32ss/user/consrv/conoutput.c
Modified: branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/dll/win32/kernel32/cl…
==============================================================================
--- branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1]
(original)
+++ branches/ros-csrss/dll/win32/kernel32/client/console/readwrite.c [iso-8859-1] Sun Nov
18 13:54:32 2012
@@ -503,7 +503,8 @@
LPDWORD lpNumberOfEventsWritten,
BOOL bUnicode)
{
- CSR_API_MESSAGE Request;
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCSRSS_WRITE_CONSOLE_INPUT WriteConsoleInputRequest =
&ApiMessage.Data.WriteConsoleInputRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
DWORD Size;
@@ -515,8 +516,9 @@
Size = nLength * sizeof(INPUT_RECORD);
+ DPRINT("IntWriteConsoleInput: %lx %p\n", Size, lpNumberOfEventsWritten);
+
/* Allocate a Capture Buffer */
- DPRINT("IntWriteConsoleInput: %lx %p\n", Size, lpNumberOfEventsWritten);
CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
if (CaptureBuffer == NULL)
{
@@ -525,43 +527,47 @@
return FALSE;
}
- /* Allocate space in the Buffer */
+ /* Capture the user buffer */
CsrCaptureMessageBuffer(CaptureBuffer,
lpBuffer,
Size,
-
(PVOID*)&Request.Data.WriteConsoleInputRequest.InputRecord);
+ (PVOID*)&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;
+ WriteConsoleInputRequest->ConsoleHandle = hConsoleInput;
+ WriteConsoleInputRequest->Unicode = bUnicode;
+ WriteConsoleInputRequest->Length = nLength;
/* Call the server */
- CsrClientCallServer(&Request,
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
CaptureBuffer,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE_INPUT),
- sizeof(CSR_API_MESSAGE));
- DPRINT("Server returned: %x\n", Request.Status);
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepWriteConsoleInput),
+ sizeof(CSRSS_WRITE_CONSOLE_INPUT));
+ DPRINT("Server returned: %x\n", ApiMessage.Status);
/* Check for success*/
- if (NT_SUCCESS(Request.Status))
+ if (NT_SUCCESS(ApiMessage.Status))
{
/* Return the number of events read */
- DPRINT("Events read: %lx\n",
Request.Data.WriteConsoleInputRequest.Length);
- *lpNumberOfEventsWritten = Request.Data.WriteConsoleInputRequest.Length;
+ DPRINT("Events read: %lx\n", WriteConsoleInputRequest->Length);
+
+ if (lpNumberOfEventsWritten != NULL)
+ *lpNumberOfEventsWritten = WriteConsoleInputRequest->Length;
}
else
{
+ if (lpNumberOfEventsWritten != NULL)
+ *lpNumberOfEventsWritten = 0;
+
/* Error out */
- *lpNumberOfEventsWritten = 0;
- BaseSetLastNTError(Request.Status);
+ BaseSetLastNTError(ApiMessage.Status);
}
/* Release the capture buffer */
CsrFreeCaptureBuffer(CaptureBuffer);
/* Return TRUE or FALSE */
- return NT_SUCCESS(Request.Status);
+ return NT_SUCCESS(ApiMessage.Status);
}
@@ -574,14 +580,22 @@
PSMALL_RECT lpWriteRegion,
BOOL bUnicode)
{
- CSR_API_MESSAGE Request;
+ CONSOLE_API_MESSAGE ApiMessage;
+ PCSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest =
&ApiMessage.Data.WriteConsoleOutputRequest;
PCSR_CAPTURE_BUFFER CaptureBuffer;
ULONG Size;
+ if ((lpBuffer == NULL) || (lpWriteRegion == NULL))
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
Size = dwBufferSize.Y * dwBufferSize.X * sizeof(CHAR_INFO);
+ DPRINT("IntWriteConsoleOutput: %lx %p\n", Size, lpWriteRegion);
+
/* Allocate a Capture Buffer */
- DPRINT("IntWriteConsoleOutput: %lx %p\n", Size, lpWriteRegion);
CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
if (CaptureBuffer == NULL)
{
@@ -590,45 +604,42 @@
return FALSE;
}
- /* Allocate space in the Buffer */
+ /* Capture the user buffer */
CsrCaptureMessageBuffer(CaptureBuffer,
- NULL,
+ (PVOID)lpBuffer,
Size,
-
(PVOID*)&Request.Data.WriteConsoleOutputRequest.CharInfo);
-
- /* Copy from the buffer */
- RtlCopyMemory(Request.Data.WriteConsoleOutputRequest.CharInfo, lpBuffer, Size);
+ (PVOID*)&WriteConsoleOutputRequest->CharInfo);
/* 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;
+ WriteConsoleOutputRequest->ConsoleHandle = hConsoleOutput;
+ WriteConsoleOutputRequest->Unicode = bUnicode;
+ WriteConsoleOutputRequest->BufferSize = dwBufferSize;
+ WriteConsoleOutputRequest->BufferCoord = dwBufferCoord;
+ WriteConsoleOutputRequest->WriteRegion = *lpWriteRegion;
/* Call the server */
- CsrClientCallServer(&Request,
+ CsrClientCallServer((PCSR_API_MESSAGE)&ApiMessage,
CaptureBuffer,
- CSR_CREATE_API_NUMBER(CSR_CONSOLE, WRITE_CONSOLE_OUTPUT),
- sizeof(CSR_API_MESSAGE));
- DPRINT("Server returned: %x\n", Request.Status);
+ CSR_CREATE_API_NUMBER(CONSRV_SERVERDLL_INDEX,
ConsolepWriteConsoleOutput),
+ sizeof(CSRSS_WRITE_CONSOLE_OUTPUT));
+ DPRINT("Server returned: %x\n", ApiMessage.Status);
/* Check for success*/
- if (!NT_SUCCESS(Request.Status))
+ if (!NT_SUCCESS(ApiMessage.Status))
{
/* Error out */
- BaseSetLastNTError(Request.Status);
+ BaseSetLastNTError(ApiMessage.Status);
}
/* Return the read region */
- DPRINT("read region: %lx\n",
Request.Data.WriteConsoleOutputRequest.WriteRegion);
- *lpWriteRegion = Request.Data.WriteConsoleOutputRequest.WriteRegion;
+ DPRINT("read region: %lx\n", WriteConsoleOutputRequest->WriteRegion);
+ *lpWriteRegion = WriteConsoleOutputRequest->WriteRegion;
/* Release the capture buffer */
CsrFreeCaptureBuffer(CaptureBuffer);
/* Return TRUE or FALSE */
- return NT_SUCCESS(Request.Status);
+ return NT_SUCCESS(ApiMessage.Status);
}
Modified: branches/ros-csrss/win32ss/user/consrv/coninput.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] Sun Nov 18 13:54:32
2012
@@ -457,20 +457,27 @@
DPRINT("SrvWriteConsoleInput\n");
+ if (!CsrValidateMessageBuffer(ApiMessage,
+ (PVOID*)&WriteConsoleInputRequest->InputRecord,
+ WriteConsoleInputRequest->Length,
+ sizeof(INPUT_RECORD)))
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
Status = ConioLockConsole(ProcessData, WriteConsoleInputRequest->ConsoleHandle,
&Console, GENERIC_WRITE);
- if (! NT_SUCCESS(Status))
- {
- return Status;
- }
+ if (!NT_SUCCESS(Status)) return Status;
InputRecord = WriteConsoleInputRequest->InputRecord;
Length = WriteConsoleInputRequest->Length;
+/*
if (!Win32CsrValidateBuffer(ProcessData->Process, InputRecord, Length,
sizeof(INPUT_RECORD)))
{
ConioUnlockConsole(Console);
return STATUS_ACCESS_VIOLATION;
}
+*/
for (i = 0; i < Length && NT_SUCCESS(Status); i++)
{
@@ -482,6 +489,7 @@
&InputRecord->Event.KeyEvent.uChar.UnicodeChar,
&AsciiChar);
}
+
Status = ConioProcessChar(Console, InputRecord++);
}
Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Sun Nov 18 13:54:32
2012
@@ -453,18 +453,22 @@
DPRINT("SrvReadConsoleOutput\n");
+ if (!CsrValidateMessageBuffer(ApiMessage,
+ (PVOID*)&ReadConsoleOutputRequest->CharInfo,
+ BufferSize.X * BufferSize.Y,
+ sizeof(CHAR_INFO)))
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
+ Status = ConioLockScreenBuffer(ProcessData,
ReadConsoleOutputRequest->ConsoleHandle, &Buff, GENERIC_READ);
+ if (!NT_SUCCESS(Status)) return Status;
+
CharInfo = ReadConsoleOutputRequest->CharInfo;
ReadRegion = ReadConsoleOutputRequest->ReadRegion;
BufferSize = ReadConsoleOutputRequest->BufferSize;
BufferCoord = ReadConsoleOutputRequest->BufferCoord;
- if (!CsrValidateMessageBuffer(ApiMessage,
- (PVOID*)&ReadConsoleOutputRequest->CharInfo,
- BufferSize.X * BufferSize.Y,
- sizeof(CHAR_INFO)))
- {
- return STATUS_INVALID_PARAMETER;
- }
/*
if (!Win32CsrValidateBuffer(ProcessData->Process, CharInfo,
BufferSize.X * BufferSize.Y, sizeof(CHAR_INFO)))
@@ -473,9 +477,6 @@
return STATUS_ACCESS_VIOLATION;
}
*/
-
- Status = ConioLockScreenBuffer(ProcessData,
ReadConsoleOutputRequest->ConsoleHandle, &Buff, GENERIC_READ);
- if (!NT_SUCCESS(Status)) return Status;
/* FIXME: Is this correct? */
CodePage = ProcessData->Console->OutputCodePage;
@@ -613,8 +614,8 @@
CSR_API(SrvWriteConsoleOutput)
{
PCSRSS_WRITE_CONSOLE_OUTPUT WriteConsoleOutputRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteConsoleOutputRequest;
+ PCONSOLE_PROCESS_DATA ProcessData =
ConsoleGetPerProcessData(CsrGetClientThread()->Process);
SHORT i, X, Y, SizeX, SizeY;
- PCSR_PROCESS ProcessData = CsrGetClientThread()->Process;
PCSRSS_CONSOLE Console;
PCSRSS_SCREEN_BUFFER Buff;
SMALL_RECT ScreenBuffer;
@@ -628,25 +629,35 @@
DPRINT("SrvWriteConsoleOutput\n");
+ if (!CsrValidateMessageBuffer(ApiMessage,
+ (PVOID*)&WriteConsoleOutputRequest->CharInfo,
+ BufferSize.X * BufferSize.Y,
+ sizeof(CHAR_INFO)))
+ {
+ return STATUS_INVALID_PARAMETER;
+ }
+
Status = ConioLockScreenBuffer(ProcessData,
WriteConsoleOutputRequest->ConsoleHandle,
&Buff,
GENERIC_WRITE);
- if (! NT_SUCCESS(Status))
- {
- return Status;
- }
+ if (!NT_SUCCESS(Status)) return Status;
+
Console = Buff->Header.Console;
BufferSize = WriteConsoleOutputRequest->BufferSize;
BufferCoord = WriteConsoleOutputRequest->BufferCoord;
CharInfo = WriteConsoleOutputRequest->CharInfo;
- if (!Win32CsrValidateBuffer(ProcessData, CharInfo,
+
+/*
+ if (!Win32CsrValidateBuffer(ProcessData->Process, CharInfo,
BufferSize.X * BufferSize.Y, sizeof(CHAR_INFO)))
{
ConioUnlockScreenBuffer(Buff);
return STATUS_ACCESS_VIOLATION;
}
+*/
+
WriteRegion = WriteConsoleOutputRequest->WriteRegion;
SizeY = min(BufferSize.Y - BufferCoord.Y, ConioRectHeight(&WriteRegion));
@@ -656,7 +667,7 @@
/* Make sure WriteRegion is inside the screen buffer */
ConioInitRect(&ScreenBuffer, 0, 0, Buff->MaxY - 1, Buff->MaxX - 1);
- if (! ConioGetIntersection(&WriteRegion, &ScreenBuffer, &WriteRegion))
+ if (!ConioGetIntersection(&WriteRegion, &ScreenBuffer, &WriteRegion))
{
ConioUnlockScreenBuffer(Buff);