mirror of
https://github.com/reactos/reactos.git
synced 2025-06-04 00:40:31 +00:00
[KERNEL32]
Use new structures and api indices namings. [CONSRV] Use CsrValidateMessageBuffer instead of Win32CsrValidateBuffer. svn path=/branches/ros-csrss/; revision=57729
This commit is contained in:
parent
feb045c64b
commit
4b04f7d488
3 changed files with 87 additions and 57 deletions
|
@ -503,7 +503,8 @@ IntWriteConsoleInput(HANDLE hConsoleInput,
|
|||
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 @@ IntWriteConsoleInput(HANDLE hConsoleInput,
|
|||
|
||||
Size = nLength * sizeof(INPUT_RECORD);
|
||||
|
||||
/* Allocate a Capture Buffer */
|
||||
DPRINT("IntWriteConsoleInput: %lx %p\n", Size, lpNumberOfEventsWritten);
|
||||
|
||||
/* Allocate a Capture Buffer */
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
|
||||
if (CaptureBuffer == NULL)
|
||||
{
|
||||
|
@ -525,43 +527,47 @@ IntWriteConsoleInput(HANDLE hConsoleInput,
|
|||
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 @@ IntWriteConsoleOutput(HANDLE hConsoleOutput,
|
|||
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);
|
||||
|
||||
/* Allocate a Capture Buffer */
|
||||
DPRINT("IntWriteConsoleOutput: %lx %p\n", Size, lpWriteRegion);
|
||||
|
||||
/* Allocate a Capture Buffer */
|
||||
CaptureBuffer = CsrAllocateCaptureBuffer(1, Size);
|
||||
if (CaptureBuffer == NULL)
|
||||
{
|
||||
|
@ -590,45 +604,42 @@ IntWriteConsoleOutput(HANDLE hConsoleOutput,
|
|||
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);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -457,20 +457,27 @@ CSR_API(SrvWriteConsoleInput)
|
|||
|
||||
DPRINT("SrvWriteConsoleInput\n");
|
||||
|
||||
Status = ConioLockConsole(ProcessData, WriteConsoleInputRequest->ConsoleHandle, &Console, GENERIC_WRITE);
|
||||
if (! NT_SUCCESS(Status))
|
||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&WriteConsoleInputRequest->InputRecord,
|
||||
WriteConsoleInputRequest->Length,
|
||||
sizeof(INPUT_RECORD)))
|
||||
{
|
||||
return Status;
|
||||
return STATUS_INVALID_PARAMETER;
|
||||
}
|
||||
|
||||
Status = ConioLockConsole(ProcessData, WriteConsoleInputRequest->ConsoleHandle, &Console, GENERIC_WRITE);
|
||||
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 @@ CSR_API(SrvWriteConsoleInput)
|
|||
&InputRecord->Event.KeyEvent.uChar.UnicodeChar,
|
||||
&AsciiChar);
|
||||
}
|
||||
|
||||
Status = ConioProcessChar(Console, InputRecord++);
|
||||
}
|
||||
|
||||
|
|
|
@ -453,11 +453,6 @@ CSR_API(SrvReadConsoleOutput)
|
|||
|
||||
DPRINT("SrvReadConsoleOutput\n");
|
||||
|
||||
CharInfo = ReadConsoleOutputRequest->CharInfo;
|
||||
ReadRegion = ReadConsoleOutputRequest->ReadRegion;
|
||||
BufferSize = ReadConsoleOutputRequest->BufferSize;
|
||||
BufferCoord = ReadConsoleOutputRequest->BufferCoord;
|
||||
|
||||
if (!CsrValidateMessageBuffer(ApiMessage,
|
||||
(PVOID*)&ReadConsoleOutputRequest->CharInfo,
|
||||
BufferSize.X * BufferSize.Y,
|
||||
|
@ -465,6 +460,15 @@ CSR_API(SrvReadConsoleOutput)
|
|||
{
|
||||
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 (!Win32CsrValidateBuffer(ProcessData->Process, CharInfo,
|
||||
BufferSize.X * BufferSize.Y, sizeof(CHAR_INFO)))
|
||||
|
@ -474,9 +478,6 @@ CSR_API(SrvReadConsoleOutput)
|
|||
}
|
||||
*/
|
||||
|
||||
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(SrvWriteConsole)
|
|||
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 @@ CSR_API(SrvWriteConsoleOutput)
|
|||
|
||||
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 @@ CSR_API(SrvWriteConsoleOutput)
|
|||
|
||||
/* 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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue