[kernel32]

- Fix IntReadConsoleOutputCharacter to copy the correct count of characters. Its 3rd parameter is a character count and not buffer size. 
- Should fix infinite loop when kernel32:console test runs

svn path=/trunk/; revision=55081
This commit is contained in:
Giannis Adamopoulos 2012-01-22 22:27:08 +00:00
parent 51772abf74
commit 51a64982dd

View file

@ -2634,18 +2634,17 @@ IntReadConsoleOutputCharacter(HANDLE hConsoleOutput,
PCSR_API_MESSAGE Request; PCSR_API_MESSAGE Request;
ULONG CsrRequest; ULONG CsrRequest;
NTSTATUS Status; NTSTATUS Status;
ULONG nChars, SizeBytes, CharSize; ULONG SizeBytes, CharSize;
DWORD CharsRead = 0; DWORD CharsRead = 0;
CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR)); CharSize = (bUnicode ? sizeof(WCHAR) : sizeof(CHAR));
nChars = min(nLength, CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR) / CharSize; nLength = min(nLength, CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR / CharSize);
SizeBytes = nChars * CharSize; SizeBytes = nLength * CharSize;
Request = RtlAllocateHeap(RtlGetProcessHeap(), 0, Request = RtlAllocateHeap(RtlGetProcessHeap(), 0,
max(sizeof(CSR_API_MESSAGE), max(sizeof(CSR_API_MESSAGE),
CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR) CSR_API_MESSAGE_HEADER_SIZE(CSRSS_READ_CONSOLE_OUTPUT_CHAR) + SizeBytes));
+ min (nChars, CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR / CharSize) * CharSize));
if (Request == NULL) if (Request == NULL)
{ {
SetLastError(ERROR_NOT_ENOUGH_MEMORY); SetLastError(ERROR_NOT_ENOUGH_MEMORY);
@ -2661,7 +2660,7 @@ IntReadConsoleOutputCharacter(HANDLE hConsoleOutput,
Request->Data.ReadConsoleOutputCharRequest.ConsoleHandle = hConsoleOutput; Request->Data.ReadConsoleOutputCharRequest.ConsoleHandle = hConsoleOutput;
Request->Data.ReadConsoleOutputCharRequest.Unicode = bUnicode; Request->Data.ReadConsoleOutputCharRequest.Unicode = bUnicode;
Request->Data.ReadConsoleOutputCharRequest.NumCharsToRead = min(nLength, nChars); Request->Data.ReadConsoleOutputCharRequest.NumCharsToRead = nLength;
SizeBytes = Request->Data.ReadConsoleOutputCharRequest.NumCharsToRead * CharSize; SizeBytes = Request->Data.ReadConsoleOutputCharRequest.NumCharsToRead * CharSize;
Status = CsrClientCallServer(Request, Status = CsrClientCallServer(Request,