mirror of
https://github.com/reactos/reactos.git
synced 2024-08-30 23:28:58 +00:00
big work on the console front
svn path=/trunk/; revision=1163
This commit is contained in:
parent
97f4345422
commit
9f7a5635de
|
@ -112,10 +112,11 @@ WINBOOL STDCALL WriteConsoleA(HANDLE hConsoleOutput,
|
||||||
PCSRSS_API_REQUEST Request;
|
PCSRSS_API_REQUEST Request;
|
||||||
CSRSS_API_REPLY Reply;
|
CSRSS_API_REPLY Reply;
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
|
WORD Size;
|
||||||
|
|
||||||
Request = HeapAlloc(GetProcessHeap(),
|
Request = HeapAlloc(GetProcessHeap(),
|
||||||
HEAP_ZERO_MEMORY,
|
HEAP_ZERO_MEMORY,
|
||||||
sizeof(CSRSS_API_REQUEST) + nNumberOfCharsToWrite);
|
sizeof(CSRSS_API_REQUEST) + CSRSS_MAX_WRITE_CONSOLE_REQUEST);
|
||||||
if (Request == NULL)
|
if (Request == NULL)
|
||||||
{
|
{
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
|
@ -123,38 +124,36 @@ WINBOOL STDCALL WriteConsoleA(HANDLE hConsoleOutput,
|
||||||
|
|
||||||
Request->Type = CSRSS_WRITE_CONSOLE;
|
Request->Type = CSRSS_WRITE_CONSOLE;
|
||||||
Request->Data.WriteConsoleRequest.ConsoleHandle = hConsoleOutput;
|
Request->Data.WriteConsoleRequest.ConsoleHandle = hConsoleOutput;
|
||||||
Request->Data.WriteConsoleRequest.NrCharactersToWrite =
|
if (lpNumberOfCharsWritten != NULL)
|
||||||
nNumberOfCharsToWrite;
|
*lpNumberOfCharsWritten = nNumberOfCharsToWrite;
|
||||||
|
while( nNumberOfCharsToWrite )
|
||||||
|
{
|
||||||
|
Size = nNumberOfCharsToWrite > CSRSS_MAX_WRITE_CONSOLE_REQUEST ? CSRSS_MAX_WRITE_CONSOLE_REQUEST : nNumberOfCharsToWrite;
|
||||||
|
|
||||||
// DbgPrint("nNumberOfCharsToWrite %d\n", nNumberOfCharsToWrite);
|
Request->Data.WriteConsoleRequest.NrCharactersToWrite = Size;
|
||||||
// DbgPrint("Buffer %s\n", Request->Data.WriteConsoleRequest.Buffer);
|
|
||||||
|
|
||||||
memcpy(Request->Data.WriteConsoleRequest.Buffer,
|
// DbgPrint("nNumberOfCharsToWrite %d\n", nNumberOfCharsToWrite);
|
||||||
lpBuffer,
|
// DbgPrint("Buffer %s\n", Request->Data.WriteConsoleRequest.Buffer);
|
||||||
nNumberOfCharsToWrite);
|
|
||||||
|
memcpy( Request->Data.WriteConsoleRequest.Buffer, lpBuffer, Size );
|
||||||
|
|
||||||
Status = CsrClientCallServer(Request,
|
Status = CsrClientCallServer(Request,
|
||||||
&Reply,
|
&Reply,
|
||||||
sizeof(CSRSS_API_REQUEST) +
|
sizeof(CSRSS_WRITE_CONSOLE_REQUEST) +
|
||||||
nNumberOfCharsToWrite,
|
Size,
|
||||||
sizeof(CSRSS_API_REPLY));
|
sizeof(CSRSS_API_REPLY));
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(),
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
0,
|
|
||||||
Request);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
{
|
||||||
|
HeapFree( GetProcessHeap(), 0, Request );
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
|
nNumberOfCharsToWrite -= Size;
|
||||||
if (lpNumberOfCharsWritten != NULL)
|
lpBuffer += Size;
|
||||||
{
|
|
||||||
*lpNumberOfCharsWritten =
|
|
||||||
Reply.Data.WriteConsoleReply.NrCharactersWritten;
|
|
||||||
}
|
}
|
||||||
|
HeapFree( GetProcessHeap(), 0, Request );
|
||||||
return(TRUE);
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,8 +180,7 @@ WINBOOL STDCALL ReadConsoleA(HANDLE hConsoleInput,
|
||||||
|
|
||||||
Request.Type = CSRSS_READ_CONSOLE;
|
Request.Type = CSRSS_READ_CONSOLE;
|
||||||
Request.Data.ReadConsoleRequest.ConsoleHandle = hConsoleInput;
|
Request.Data.ReadConsoleRequest.ConsoleHandle = hConsoleInput;
|
||||||
Request.Data.ReadConsoleRequest.NrCharactersToRead =
|
Request.Data.ReadConsoleRequest.NrCharactersToRead = nNumberOfCharsToRead > CSRSS_MAX_READ_CONSOLE_REQUEST ? CSRSS_MAX_READ_CONSOLE_REQUEST : nNumberOfCharsToRead;
|
||||||
nNumberOfCharsToRead;
|
|
||||||
|
|
||||||
Status = CsrClientCallServer(&Request,
|
Status = CsrClientCallServer(&Request,
|
||||||
Reply,
|
Reply,
|
||||||
|
@ -190,13 +188,14 @@ WINBOOL STDCALL ReadConsoleA(HANDLE hConsoleInput,
|
||||||
sizeof(CSRSS_API_REPLY) +
|
sizeof(CSRSS_API_REPLY) +
|
||||||
nNumberOfCharsToRead);
|
nNumberOfCharsToRead);
|
||||||
// DbgPrint( "Csrss Returned\n" );
|
// DbgPrint( "Csrss Returned\n" );
|
||||||
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Reply->Status))
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS( Status = Reply->Status ))
|
||||||
{
|
{
|
||||||
DbgPrint( "CSR returned error in ReadConsole\n" );
|
DbgPrint( "CSR returned error in ReadConsole\n" );
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
HeapFree( GetProcessHeap(), 0, Reply );
|
HeapFree( GetProcessHeap(), 0, Reply );
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if( Reply->Status == STATUS_PENDING )
|
while( Reply->Status == STATUS_PENDING )
|
||||||
{
|
{
|
||||||
//DbgPrint( "Read pending, waiting on object %x\n", Reply->Data.ReadConsoleReply.EventHandle );
|
//DbgPrint( "Read pending, waiting on object %x\n", Reply->Data.ReadConsoleReply.EventHandle );
|
||||||
Status = NtWaitForSingleObject( Reply->Data.ReadConsoleReply.EventHandle, FALSE, 0 );
|
Status = NtWaitForSingleObject( Reply->Data.ReadConsoleReply.EventHandle, FALSE, 0 );
|
||||||
|
@ -207,18 +206,15 @@ WINBOOL STDCALL ReadConsoleA(HANDLE hConsoleInput,
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
Status = CsrClientCallServer( &Request, Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) + nNumberOfCharsToRead );
|
Status = CsrClientCallServer( &Request, Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) + nNumberOfCharsToRead );
|
||||||
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Reply->Status ) )
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply->Status ) )
|
||||||
{
|
{
|
||||||
SetLastError( RtlNtStatusToDosError( Reply->Status ) );
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
HeapFree( GetProcessHeap(), 0, Reply );
|
HeapFree( GetProcessHeap(), 0, Reply );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lpNumberOfCharsRead != NULL)
|
if (lpNumberOfCharsRead != NULL)
|
||||||
{
|
*lpNumberOfCharsRead = Reply->Data.ReadConsoleReply.NrCharactersRead;
|
||||||
*lpNumberOfCharsRead =
|
|
||||||
Reply->Data.ReadConsoleReply.NrCharactersRead;
|
|
||||||
}
|
|
||||||
memcpy(lpBuffer,
|
memcpy(lpBuffer,
|
||||||
Reply->Data.ReadConsoleReply.Buffer,
|
Reply->Data.ReadConsoleReply.Buffer,
|
||||||
Reply->Data.ReadConsoleReply.NrCharactersRead);
|
Reply->Data.ReadConsoleReply.NrCharactersRead);
|
||||||
|
@ -241,8 +237,11 @@ WINBOOL STDCALL AllocConsole(VOID)
|
||||||
|
|
||||||
Request.Type = CSRSS_ALLOC_CONSOLE;
|
Request.Type = CSRSS_ALLOC_CONSOLE;
|
||||||
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Reply.Status ) )
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
SetStdHandle( STD_INPUT_HANDLE, Reply.Data.AllocConsoleReply.ConsoleHandle );
|
SetStdHandle( STD_INPUT_HANDLE, Reply.Data.AllocConsoleReply.ConsoleHandle );
|
||||||
SetStdHandle( STD_OUTPUT_HANDLE, Reply.Data.AllocConsoleReply.ConsoleHandle );
|
SetStdHandle( STD_OUTPUT_HANDLE, Reply.Data.AllocConsoleReply.ConsoleHandle );
|
||||||
SetStdHandle( STD_ERROR_HANDLE, Reply.Data.AllocConsoleReply.ConsoleHandle );
|
SetStdHandle( STD_ERROR_HANDLE, Reply.Data.AllocConsoleReply.ConsoleHandle );
|
||||||
|
@ -256,6 +255,7 @@ WINBOOL STDCALL AllocConsole(VOID)
|
||||||
WINBOOL STDCALL FreeConsole(VOID)
|
WINBOOL STDCALL FreeConsole(VOID)
|
||||||
{
|
{
|
||||||
DbgPrint("FreeConsole() is unimplemented");
|
DbgPrint("FreeConsole() is unimplemented");
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -269,24 +269,19 @@ GetConsoleScreenBufferInfo(
|
||||||
PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
|
PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
CSRSS_API_REQUEST Request;
|
||||||
|
CSRSS_API_REPLY Reply;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
if ( !DeviceIoControl(
|
Request.Type = CSRSS_SCREEN_BUFFER_INFO;
|
||||||
hConsoleOutput,
|
Request.Data.ScreenBufferInfoRequest.ConsoleHandle = hConsoleOutput;
|
||||||
IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO,
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
NULL,
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
0,
|
|
||||||
lpConsoleScreenBufferInfo,
|
|
||||||
sizeof(CONSOLE_SCREEN_BUFFER_INFO),
|
|
||||||
& dwBytesReturned,
|
|
||||||
NULL
|
|
||||||
)
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
SetLastError(0); /* FIXME: What error code? */
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
SetLastError(ERROR_SUCCESS); /* OK */
|
*lpConsoleScreenBufferInfo = Reply.Data.ScreenBufferInfoReply.Info;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,28 +296,19 @@ SetConsoleCursorPosition(
|
||||||
COORD dwCursorPosition
|
COORD dwCursorPosition
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
CSRSS_API_REQUEST Request;
|
||||||
CONSOLE_SCREEN_BUFFER_INFO ConsoleScreenBufferInfo;
|
CSRSS_API_REPLY Reply;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
if( !GetConsoleScreenBufferInfo(hConsoleOutput,&ConsoleScreenBufferInfo) )
|
Request.Type = CSRSS_SET_CURSOR;
|
||||||
|
Request.Data.SetCursorRequest.ConsoleHandle = hConsoleOutput;
|
||||||
|
Request.Data.SetCursorRequest.Position = dwCursorPosition;
|
||||||
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
{
|
{
|
||||||
SetLastError(0); /* FIXME: What error code? */
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
ConsoleScreenBufferInfo.dwCursorPosition.X = dwCursorPosition.X;
|
|
||||||
ConsoleScreenBufferInfo.dwCursorPosition.Y = dwCursorPosition.Y;
|
|
||||||
|
|
||||||
if( !DeviceIoControl(
|
|
||||||
hConsoleOutput,
|
|
||||||
IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO,
|
|
||||||
&ConsoleScreenBufferInfo,
|
|
||||||
sizeof(CONSOLE_SCREEN_BUFFER_INFO),
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL ))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -340,28 +326,23 @@ FillConsoleOutputCharacterA(
|
||||||
LPDWORD lpNumberOfCharsWritten
|
LPDWORD lpNumberOfCharsWritten
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
CSRSS_API_REQUEST Request;
|
||||||
OUTPUT_CHARACTER Buffer;
|
CSRSS_API_REPLY Reply;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
Buffer.cCharacter = cCharacter;
|
Request.Type = CSRSS_FILL_OUTPUT;
|
||||||
Buffer.nLength = nLength;
|
Request.Data.FillOutputRequest.ConsoleHandle = hConsoleOutput;
|
||||||
Buffer.dwCoord = dwWriteCoord;
|
Request.Data.FillOutputRequest.Char = cCharacter;
|
||||||
|
Request.Data.FillOutputRequest.Position = dwWriteCoord;
|
||||||
if (DeviceIoControl (hConsoleOutput,
|
Request.Data.FillOutputRequest.Length = nLength;
|
||||||
IOCTL_CONSOLE_FILL_OUTPUT_CHARACTER,
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
&Buffer,
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
sizeof(OUTPUT_CHARACTER),
|
|
||||||
&Buffer,
|
|
||||||
sizeof(OUTPUT_CHARACTER),
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL))
|
|
||||||
{
|
{
|
||||||
*lpNumberOfCharsWritten = Buffer.dwTransfered;
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*lpNumberOfCharsWritten = 0;
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
*lpNumberOfCharsWritten = nLength;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -432,28 +413,36 @@ ReadConsoleInputA(
|
||||||
LPDWORD lpNumberOfEventsRead
|
LPDWORD lpNumberOfEventsRead
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
BOOL stat = TRUE;
|
CSRSS_API_REQUEST Request;
|
||||||
DWORD Result;
|
CSRSS_API_REPLY Reply;
|
||||||
int i;
|
NTSTATUS Status;
|
||||||
|
|
||||||
for (i=0; (stat && i < nLength);)
|
Request.Type = CSRSS_READ_INPUT;
|
||||||
|
Request.Data.ReadInputRequest.ConsoleHandle = hConsoleInput;
|
||||||
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
{
|
{
|
||||||
stat = ReadFile(hConsoleInput,
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
&lpBuffer[i].Event.KeyEvent,
|
return FALSE;
|
||||||
sizeof(KEY_EVENT_RECORD),
|
}
|
||||||
&Result,
|
while( Status == STATUS_PENDING )
|
||||||
NULL);
|
|
||||||
if (stat)
|
|
||||||
{
|
{
|
||||||
lpBuffer[i].EventType = KEY_EVENT;
|
Status = NtWaitForSingleObject( Reply.Data.ReadInputReply.Event, FALSE, 0 );
|
||||||
i++;
|
if( !NT_SUCCESS( Status ) )
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (lpNumberOfEventsRead != NULL)
|
*lpNumberOfEventsRead = 1;
|
||||||
{
|
*lpBuffer = Reply.Data.ReadInputReply.Input;
|
||||||
*lpNumberOfEventsRead = i;
|
return TRUE;
|
||||||
}
|
|
||||||
return(stat);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -600,25 +589,7 @@ ReadConsoleOutputCharacterA(
|
||||||
LPDWORD lpNumberOfCharsRead
|
LPDWORD lpNumberOfCharsRead
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
||||||
OUTPUT_CHARACTER Buffer;
|
|
||||||
|
|
||||||
Buffer.dwCoord = dwReadCoord;
|
|
||||||
|
|
||||||
if (DeviceIoControl (hConsoleOutput,
|
|
||||||
IOCTL_CONSOLE_READ_OUTPUT_CHARACTER,
|
|
||||||
&Buffer,
|
|
||||||
sizeof(OUTPUT_CHARACTER),
|
|
||||||
lpCharacter,
|
|
||||||
nLength,
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL))
|
|
||||||
{
|
|
||||||
*lpNumberOfCharsRead = Buffer.dwTransfered;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*lpNumberOfCharsRead = 0;
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -656,26 +627,7 @@ ReadConsoleOutputAttribute(
|
||||||
LPDWORD lpNumberOfAttrsRead
|
LPDWORD lpNumberOfAttrsRead
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
||||||
OUTPUT_ATTRIBUTE Buffer;
|
|
||||||
|
|
||||||
Buffer.dwCoord = dwReadCoord;
|
|
||||||
|
|
||||||
if (DeviceIoControl (hConsoleOutput,
|
|
||||||
IOCTL_CONSOLE_READ_OUTPUT_ATTRIBUTE,
|
|
||||||
&Buffer,
|
|
||||||
sizeof(OUTPUT_ATTRIBUTE),
|
|
||||||
(PVOID)lpAttribute,
|
|
||||||
nLength,
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL))
|
|
||||||
{
|
|
||||||
*lpNumberOfAttrsRead = Buffer.dwTransfered;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*lpNumberOfAttrsRead = 0;
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -694,26 +646,32 @@ WriteConsoleOutputCharacterA(
|
||||||
LPDWORD lpNumberOfCharsWritten
|
LPDWORD lpNumberOfCharsWritten
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
CSRSS_API_REQUEST Request;
|
||||||
OUTPUT_CHARACTER Buffer;
|
CSRSS_API_REPLY Reply;
|
||||||
|
NTSTATUS Status;
|
||||||
|
WORD Size;
|
||||||
|
|
||||||
Buffer.dwCoord = dwWriteCoord;
|
Request.Type = CSRSS_WRITE_CONSOLE_OUTPUT_CHAR;
|
||||||
|
Request.Data.WriteConsoleOutputCharRequest.ConsoleHandle = hConsoleOutput;
|
||||||
if (DeviceIoControl (hConsoleOutput,
|
Request.Data.WriteConsoleOutputCharRequest.Coord = dwWriteCoord;
|
||||||
IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER,
|
if( lpNumberOfCharsWritten )
|
||||||
&Buffer,
|
*lpNumberOfCharsWritten = nLength;
|
||||||
sizeof(OUTPUT_CHARACTER),
|
while( nLength )
|
||||||
(LPSTR)lpCharacter,
|
|
||||||
nLength,
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL))
|
|
||||||
{
|
{
|
||||||
*lpNumberOfCharsWritten = Buffer.dwTransfered;
|
Size = nLength > CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR ? CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR : nLength;
|
||||||
return TRUE;
|
Request.Data.WriteConsoleOutputCharRequest.Length = Size;
|
||||||
}
|
|
||||||
|
|
||||||
*lpNumberOfCharsWritten = 0;
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
nLength -= Size;
|
||||||
|
lpCharacter += Size;
|
||||||
|
Request.Data.WriteConsoleOutputCharRequest.Coord = Reply.Data.WriteConsoleOutputCharReply.EndCoord;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -751,27 +709,34 @@ WriteConsoleOutputAttribute(
|
||||||
LPDWORD lpNumberOfAttrsWritten
|
LPDWORD lpNumberOfAttrsWritten
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
CSRSS_API_REQUEST Request;
|
||||||
OUTPUT_ATTRIBUTE Buffer;
|
CSRSS_API_REPLY Reply;
|
||||||
|
NTSTATUS Status;
|
||||||
|
WORD Size;
|
||||||
|
int c;
|
||||||
|
|
||||||
Buffer.dwCoord = dwWriteCoord;
|
Request.Type = CSRSS_WRITE_CONSOLE_OUTPUT_ATTRIB;
|
||||||
|
Request.Data.WriteConsoleOutputAttribRequest.ConsoleHandle = hConsoleOutput;
|
||||||
if (DeviceIoControl (hConsoleOutput,
|
Request.Data.WriteConsoleOutputAttribRequest.Coord = dwWriteCoord;
|
||||||
IOCTL_CONSOLE_WRITE_OUTPUT_ATTRIBUTE,
|
if( lpNumberOfAttrsWritten )
|
||||||
&Buffer,
|
*lpNumberOfAttrsWritten = nLength;
|
||||||
sizeof(OUTPUT_ATTRIBUTE),
|
while( nLength )
|
||||||
(PVOID)lpAttribute,
|
|
||||||
nLength,
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL))
|
|
||||||
{
|
{
|
||||||
*lpNumberOfAttrsWritten = Buffer.dwTransfered;
|
Size = nLength > CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB ? CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB : nLength;
|
||||||
return TRUE;
|
Request.Data.WriteConsoleOutputAttribRequest.Length = Size;
|
||||||
}
|
for( c = 0; c < Size; c++ )
|
||||||
|
Request.Data.WriteConsoleOutputAttribRequest.String[c] = lpAttribute[c];
|
||||||
*lpNumberOfAttrsWritten = 0;
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
nLength -= Size;
|
||||||
|
lpAttribute += Size;
|
||||||
|
Request.Data.WriteConsoleOutputAttribRequest.Coord = Reply.Data.WriteConsoleOutputAttribReply.EndCoord;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -789,29 +754,24 @@ FillConsoleOutputAttribute(
|
||||||
LPDWORD lpNumberOfAttrsWritten
|
LPDWORD lpNumberOfAttrsWritten
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
CSRSS_API_REQUEST Request;
|
||||||
OUTPUT_ATTRIBUTE Buffer;
|
CSRSS_API_REPLY Reply;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
Buffer.wAttribute = wAttribute;
|
Request.Type = CSRSS_FILL_OUTPUT_ATTRIB;
|
||||||
Buffer.nLength = nLength;
|
Request.Data.FillOutputAttribRequest.ConsoleHandle = hConsoleOutput;
|
||||||
Buffer.dwCoord = dwWriteCoord;
|
Request.Data.FillOutputAttribRequest.Attribute = wAttribute;
|
||||||
|
Request.Data.FillOutputAttribRequest.Coord = dwWriteCoord;
|
||||||
if (DeviceIoControl (hConsoleOutput,
|
Request.Data.FillOutputAttribRequest.Length = nLength;
|
||||||
IOCTL_CONSOLE_FILL_OUTPUT_ATTRIBUTE,
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
&Buffer,
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
sizeof(OUTPUT_ATTRIBUTE),
|
|
||||||
&Buffer,
|
|
||||||
sizeof(OUTPUT_ATTRIBUTE),
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL))
|
|
||||||
{
|
{
|
||||||
*lpNumberOfAttrsWritten = Buffer.dwTransfered;
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*lpNumberOfAttrsWritten = 0;
|
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
if( lpNumberOfAttrsWritten )
|
||||||
|
*lpNumberOfAttrsWritten = nLength;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -826,24 +786,7 @@ GetConsoleMode(
|
||||||
LPDWORD lpMode
|
LPDWORD lpMode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CONSOLE_MODE Buffer;
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
||||||
DWORD dwBytesReturned;
|
|
||||||
|
|
||||||
if (DeviceIoControl (hConsoleHandle,
|
|
||||||
IOCTL_CONSOLE_GET_MODE,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&Buffer,
|
|
||||||
sizeof(CONSOLE_MODE),
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL))
|
|
||||||
{
|
|
||||||
*lpMode = Buffer.dwMode;
|
|
||||||
SetLastError (ERROR_SUCCESS);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetLastError(0); /* FIXME: What error code? */
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -894,19 +837,20 @@ GetConsoleCursorInfo(
|
||||||
PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
|
PCONSOLE_CURSOR_INFO lpConsoleCursorInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
CSRSS_API_REQUEST Request;
|
||||||
|
CSRSS_API_REPLY Reply;
|
||||||
if (DeviceIoControl (hConsoleOutput,
|
NTSTATUS Status;
|
||||||
IOCTL_CONSOLE_GET_CURSOR_INFO,
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
lpConsoleCursorInfo,
|
|
||||||
sizeof(CONSOLE_CURSOR_INFO),
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
|
Request.Type = CSRSS_GET_CURSOR_INFO;
|
||||||
|
Request.Data.GetCursorInfoRequest.ConsoleHandle = hConsoleOutput;
|
||||||
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
*lpConsoleCursorInfo = Reply.Data.GetCursorInfoReply.Info;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -936,25 +880,7 @@ SetConsoleMode(
|
||||||
DWORD dwMode
|
DWORD dwMode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CONSOLE_MODE Buffer;
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
||||||
DWORD dwBytesReturned;
|
|
||||||
|
|
||||||
Buffer.dwMode = dwMode;
|
|
||||||
|
|
||||||
if (DeviceIoControl (hConsoleHandle,
|
|
||||||
IOCTL_CONSOLE_SET_MODE,
|
|
||||||
&Buffer,
|
|
||||||
sizeof(CONSOLE_MODE),
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL))
|
|
||||||
{
|
|
||||||
SetLastError (ERROR_SUCCESS);
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
SetLastError(0); /* FIXME: What error code? */
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1015,19 +941,20 @@ SetConsoleCursorInfo(
|
||||||
CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo
|
CONST CONSOLE_CURSOR_INFO *lpConsoleCursorInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
CSRSS_API_REQUEST Request;
|
||||||
|
CSRSS_API_REPLY Reply;
|
||||||
if (DeviceIoControl (hConsoleOutput,
|
NTSTATUS Status;
|
||||||
IOCTL_CONSOLE_SET_CURSOR_INFO,
|
|
||||||
(PCONSOLE_CURSOR_INFO)lpConsoleCursorInfo,
|
|
||||||
sizeof(CONSOLE_CURSOR_INFO),
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL))
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
|
Request.Type = CSRSS_SET_CURSOR_INFO;
|
||||||
|
Request.Data.SetCursorInfoRequest.ConsoleHandle = hConsoleOutput;
|
||||||
|
Request.Data.SetCursorInfoRequest.Info = *lpConsoleCursorInfo;
|
||||||
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1097,17 +1024,19 @@ SetConsoleTextAttribute(
|
||||||
WORD wAttributes
|
WORD wAttributes
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
CSRSS_API_REQUEST Request;
|
||||||
|
CSRSS_API_REPLY Reply;
|
||||||
|
NTSTATUS Status;
|
||||||
|
|
||||||
if (!DeviceIoControl (hConsoleOutput,
|
Request.Type = CSRSS_SET_ATTRIB;
|
||||||
IOCTL_CONSOLE_SET_TEXT_ATTRIBUTE,
|
Request.Data.SetAttribRequest.ConsoleHandle = hConsoleOutput;
|
||||||
&wAttributes,
|
Request.Data.SetAttribRequest.Attrib = wAttributes;
|
||||||
sizeof(WORD),
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
NULL,
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
0,
|
{
|
||||||
&dwBytesReturned,
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
NULL))
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1421,4 +1350,3 @@ SetConsoleOutputCP(
|
||||||
|
|
||||||
|
|
||||||
/* EOF */
|
/* EOF */
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue