mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Allocated a converting buffer for WideCharToMultiByte. This does fix bug #702.
svn path=/trunk/; revision=17146
This commit is contained in:
parent
9a5a82cd3c
commit
a48242f711
1 changed files with 113 additions and 78 deletions
|
@ -37,8 +37,6 @@ extern VOID STDCALL PrivateCsrssAcquireOrReleaseInputOwnership(BOOL Release);
|
|||
#define ConsoleAnsiCharToUnicodeChar(Console, sWChar, dChar) \
|
||||
MultiByteToWideChar((Console)->CodePage, 0, (dChar), 1, (sWChar), 1)
|
||||
|
||||
#define ConsoleUnicodeToAnsiN(Console, dChar, sWChar, nChars) \
|
||||
WideCharToMultiByte((Console)->CodePage, 0, (sWChar), (nChars), (dChar), (nChars) * sizeof(WCHAR), NULL, NULL)
|
||||
|
||||
/* FUNCTIONS *****************************************************************/
|
||||
|
||||
|
@ -903,18 +901,22 @@ ConioInputEventToAnsi(PCSRSS_CONSOLE Console, PINPUT_RECORD InputEvent)
|
|||
{
|
||||
if (InputEvent->EventType == KEY_EVENT)
|
||||
{
|
||||
WCHAR UnicodeChar = InputEvent->Event.KeyEvent.uChar.UnicodeChar;
|
||||
InputEvent->Event.KeyEvent.uChar.UnicodeChar = 0;
|
||||
ConsoleUnicodeCharToAnsiChar(Console,
|
||||
&InputEvent->Event.KeyEvent.uChar.AsciiChar,
|
||||
&InputEvent->Event.KeyEvent.uChar.UnicodeChar);
|
||||
&UnicodeChar);
|
||||
}
|
||||
}
|
||||
|
||||
CSR_API(CsrWriteConsole)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PCHAR Buffer = (PCHAR)Request->Data.WriteConsoleRequest.Buffer;
|
||||
PCHAR Buffer;
|
||||
PCSRSS_SCREEN_BUFFER Buff;
|
||||
PCSRSS_CONSOLE Console;
|
||||
DWORD Written = 0;
|
||||
ULONG Length;
|
||||
ULONG CharSize = (Request->Data.WriteConsoleRequest.Unicode ? sizeof(WCHAR) : sizeof(CHAR));
|
||||
|
||||
DPRINT("CsrWriteConsole\n");
|
||||
|
@ -940,37 +942,54 @@ CSR_API(CsrWriteConsole)
|
|||
|
||||
if(Request->Data.WriteConsoleRequest.Unicode)
|
||||
{
|
||||
ConsoleUnicodeToAnsiN(Console, Buffer, (PWCHAR)Buffer, Request->Data.WriteConsoleRequest.NrCharactersToWrite);
|
||||
}
|
||||
|
||||
Status = ConioLockScreenBuffer(ProcessData, Request->Data.WriteConsoleRequest.ConsoleHandle, &Buff);
|
||||
if (! NT_SUCCESS(Status))
|
||||
Length = WideCharToMultiByte(Console->CodePage, 0,
|
||||
(PWCHAR)Request->Data.WriteConsoleRequest.Buffer,
|
||||
Request->Data.WriteConsoleRequest.NrCharactersToWrite,
|
||||
NULL, 0, NULL, NULL);
|
||||
Buffer = RtlAllocateHeap(GetProcessHeap(), 0, Length);
|
||||
if (Buffer)
|
||||
{
|
||||
if (NULL != Console)
|
||||
{
|
||||
ConioUnlockConsole(Console);
|
||||
}
|
||||
return Request->Status = Status;
|
||||
}
|
||||
|
||||
Request->Status = ConioWriteConsole(Console, Buff, Buffer,
|
||||
Request->Data.WriteConsoleRequest.NrCharactersToWrite, TRUE);
|
||||
ConioUnlockScreenBuffer(Buff);
|
||||
if (NULL != Console)
|
||||
{
|
||||
ConioUnlockConsole(Console);
|
||||
}
|
||||
|
||||
if(NT_SUCCESS(Request->Status))
|
||||
{
|
||||
Request->Data.WriteConsoleRequest.NrCharactersWritten = Request->Data.WriteConsoleRequest.NrCharactersToWrite;
|
||||
WideCharToMultiByte(Console->CodePage, 0,
|
||||
(PWCHAR)Request->Data.WriteConsoleRequest.Buffer,
|
||||
Request->Data.WriteConsoleRequest.NrCharactersToWrite,
|
||||
Buffer, Length, NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
Request->Data.WriteConsoleRequest.NrCharactersWritten = 0; /* FIXME - return the actual number of characters written! */
|
||||
Status = STATUS_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Buffer = (PCHAR)Request->Data.WriteConsoleRequest.Buffer;
|
||||
}
|
||||
|
||||
return Request->Status = STATUS_SUCCESS;
|
||||
if (Buffer)
|
||||
{
|
||||
Status = ConioLockScreenBuffer(ProcessData, Request->Data.WriteConsoleRequest.ConsoleHandle, &Buff);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Request->Status = ConioWriteConsole(Console, Buff, Buffer,
|
||||
Request->Data.WriteConsoleRequest.NrCharactersToWrite, TRUE);
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
Written = Request->Data.WriteConsoleRequest.NrCharactersToWrite;
|
||||
}
|
||||
ConioUnlockScreenBuffer(Buff);
|
||||
}
|
||||
if (Request->Data.WriteConsoleRequest.Unicode)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, Buffer);
|
||||
}
|
||||
}
|
||||
if (NULL != Console)
|
||||
{
|
||||
ConioUnlockConsole(Console);
|
||||
}
|
||||
|
||||
Request->Data.WriteConsoleRequest.NrCharactersWritten = Written;
|
||||
|
||||
return Request->Status = Status;
|
||||
}
|
||||
|
||||
VOID STDCALL
|
||||
|
@ -1526,7 +1545,7 @@ ConioComputeUpdateRect(PCSRSS_SCREEN_BUFFER Buff, RECT *UpdateRect, COORD *Start
|
|||
CSR_API(CsrWriteConsoleOutputChar)
|
||||
{
|
||||
NTSTATUS Status;
|
||||
PCHAR String = (PCHAR)Request->Data.WriteConsoleOutputCharRequest.String;
|
||||
PCHAR tmpString, String;
|
||||
PBYTE Buffer;
|
||||
PCSRSS_CONSOLE Console;
|
||||
PCSRSS_SCREEN_BUFFER Buff;
|
||||
|
@ -1550,28 +1569,39 @@ CSR_API(CsrWriteConsoleOutputChar)
|
|||
Status = ConioConsoleFromProcessData(ProcessData, &Console);
|
||||
Request->Header.MessageSize = sizeof(CSR_API_MESSAGE);
|
||||
Request->Header.DataSize = sizeof(CSR_API_MESSAGE) - LPC_MESSAGE_BASE_SIZE;
|
||||
if (! NT_SUCCESS(Status))
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
return Request->Status = Status;
|
||||
}
|
||||
|
||||
if(Request->Data.WriteConsoleOutputCharRequest.Unicode)
|
||||
{
|
||||
ConsoleUnicodeToAnsiN(Console, String, (PWCHAR)String, Request->Data.WriteConsoleOutputCharRequest.Length);
|
||||
Length = WideCharToMultiByte(Console->CodePage, 0,
|
||||
(PWCHAR)Request->Data.WriteConsoleOutputCharRequest.String,
|
||||
Request->Data.WriteConsoleOutputCharRequest.Length,
|
||||
NULL, 0, NULL, NULL);
|
||||
tmpString = String = RtlAllocateHeap(GetProcessHeap(), 0, Length);
|
||||
if (String)
|
||||
{
|
||||
WideCharToMultiByte(Console->CodePage, 0,
|
||||
(PWCHAR)Request->Data.WriteConsoleOutputCharRequest.String,
|
||||
Request->Data.WriteConsoleOutputCharRequest.Length,
|
||||
String, Length, NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
Status = STATUS_NO_MEMORY;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String = (PCHAR)Request->Data.WriteConsoleOutputCharRequest.String;
|
||||
}
|
||||
|
||||
if (String)
|
||||
{
|
||||
Status = ConioLockScreenBuffer(ProcessData,
|
||||
Request->Data.WriteConsoleOutputCharRequest.ConsoleHandle,
|
||||
&Buff);
|
||||
if (! NT_SUCCESS(Status))
|
||||
if (NT_SUCCESS(Status))
|
||||
{
|
||||
if (NULL != Console)
|
||||
{
|
||||
ConioUnlockConsole(Console);
|
||||
}
|
||||
return Request->Status = Status;
|
||||
}
|
||||
|
||||
X = Request->Data.WriteConsoleOutputCharRequest.Coord.X + Buff->ShowX;
|
||||
Y = (Request->Data.WriteConsoleOutputCharRequest.Coord.Y + Buff->ShowY) % Buff->MaxY;
|
||||
Length = Request->Data.WriteConsoleOutputCharRequest.Length;
|
||||
|
@ -1591,7 +1621,6 @@ CSR_API(CsrWriteConsoleOutputChar)
|
|||
X = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL != Console && Buff == Console->ActiveBuffer)
|
||||
{
|
||||
ConioComputeUpdateRect(Buff, &UpdateRect, &Request->Data.WriteConsoleOutputCharRequest.Coord,
|
||||
|
@ -1603,13 +1632,19 @@ CSR_API(CsrWriteConsoleOutputChar)
|
|||
Request->Data.WriteConsoleOutputCharRequest.EndCoord.Y = (Y + Buff->MaxY - Buff->ShowY) % Buff->MaxY;
|
||||
|
||||
ConioUnlockScreenBuffer(Buff);
|
||||
}
|
||||
if (Request->Data.WriteConsoleRequest.Unicode)
|
||||
{
|
||||
RtlFreeHeap(GetProcessHeap(), 0, tmpString);
|
||||
}
|
||||
}
|
||||
if (NULL != Console)
|
||||
{
|
||||
ConioUnlockConsole(Console);
|
||||
}
|
||||
|
||||
}
|
||||
Request->Data.WriteConsoleOutputCharRequest.NrCharactersWritten = Written;
|
||||
return Request->Status = STATUS_SUCCESS;
|
||||
return Request->Status = Status;
|
||||
}
|
||||
|
||||
CSR_API(CsrFillOutputChar)
|
||||
|
|
Loading…
Reference in a new issue