mirror of
https://github.com/reactos/reactos.git
synced 2024-07-18 10:26:09 +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 =
|
|
||||||
nNumberOfCharsToWrite;
|
|
||||||
|
|
||||||
// DbgPrint("nNumberOfCharsToWrite %d\n", nNumberOfCharsToWrite);
|
|
||||||
// DbgPrint("Buffer %s\n", Request->Data.WriteConsoleRequest.Buffer);
|
|
||||||
|
|
||||||
memcpy(Request->Data.WriteConsoleRequest.Buffer,
|
|
||||||
lpBuffer,
|
|
||||||
nNumberOfCharsToWrite);
|
|
||||||
|
|
||||||
Status = CsrClientCallServer(Request,
|
|
||||||
&Reply,
|
|
||||||
sizeof(CSRSS_API_REQUEST) +
|
|
||||||
nNumberOfCharsToWrite,
|
|
||||||
sizeof(CSRSS_API_REPLY));
|
|
||||||
|
|
||||||
HeapFree(GetProcessHeap(),
|
|
||||||
0,
|
|
||||||
Request);
|
|
||||||
|
|
||||||
if (!NT_SUCCESS(Status))
|
|
||||||
{
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (lpNumberOfCharsWritten != NULL)
|
if (lpNumberOfCharsWritten != NULL)
|
||||||
{
|
*lpNumberOfCharsWritten = nNumberOfCharsToWrite;
|
||||||
*lpNumberOfCharsWritten =
|
while( nNumberOfCharsToWrite )
|
||||||
Reply.Data.WriteConsoleReply.NrCharactersWritten;
|
{
|
||||||
}
|
Size = nNumberOfCharsToWrite > CSRSS_MAX_WRITE_CONSOLE_REQUEST ? CSRSS_MAX_WRITE_CONSOLE_REQUEST : nNumberOfCharsToWrite;
|
||||||
|
|
||||||
|
Request->Data.WriteConsoleRequest.NrCharactersToWrite = Size;
|
||||||
|
|
||||||
|
// DbgPrint("nNumberOfCharsToWrite %d\n", nNumberOfCharsToWrite);
|
||||||
|
// DbgPrint("Buffer %s\n", Request->Data.WriteConsoleRequest.Buffer);
|
||||||
|
|
||||||
|
memcpy( Request->Data.WriteConsoleRequest.Buffer, lpBuffer, Size );
|
||||||
|
|
||||||
return(TRUE);
|
Status = CsrClientCallServer(Request,
|
||||||
|
&Reply,
|
||||||
|
sizeof(CSRSS_WRITE_CONSOLE_REQUEST) +
|
||||||
|
Size,
|
||||||
|
sizeof(CSRSS_API_REPLY));
|
||||||
|
|
||||||
|
if (!NT_SUCCESS(Status) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
|
{
|
||||||
|
HeapFree( GetProcessHeap(), 0, Request );
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
|
return(FALSE);
|
||||||
|
}
|
||||||
|
nNumberOfCharsToWrite -= Size;
|
||||||
|
lpBuffer += Size;
|
||||||
|
}
|
||||||
|
HeapFree( GetProcessHeap(), 0, Request );
|
||||||
|
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 ) )
|
||||||
return FALSE;
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
|
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,25 +269,20 @@ GetConsoleScreenBufferInfo(
|
||||||
PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
|
PCONSOLE_SCREEN_BUFFER_INFO lpConsoleScreenBufferInfo
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
CSRSS_API_REQUEST Request;
|
||||||
|
CSRSS_API_REPLY Reply;
|
||||||
if ( !DeviceIoControl(
|
NTSTATUS Status;
|
||||||
hConsoleOutput,
|
|
||||||
IOCTL_CONSOLE_GET_SCREEN_BUFFER_INFO,
|
Request.Type = CSRSS_SCREEN_BUFFER_INFO;
|
||||||
NULL,
|
Request.Data.ScreenBufferInfoRequest.ConsoleHandle = hConsoleOutput;
|
||||||
0,
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
lpConsoleScreenBufferInfo,
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
sizeof(CONSOLE_SCREEN_BUFFER_INFO),
|
{
|
||||||
& dwBytesReturned,
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
NULL
|
return FALSE;
|
||||||
)
|
}
|
||||||
)
|
*lpConsoleScreenBufferInfo = Reply.Data.ScreenBufferInfoReply.Info;
|
||||||
{
|
return TRUE;
|
||||||
SetLastError(0); /* FIXME: What error code? */
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
SetLastError(ERROR_SUCCESS); /* OK */
|
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -301,29 +296,20 @@ 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;
|
||||||
SetLastError(0); /* FIXME: What error code? */
|
Request.Data.SetCursorRequest.Position = dwCursorPosition;
|
||||||
return FALSE;
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
}
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
ConsoleScreenBufferInfo.dwCursorPosition.X = dwCursorPosition.X;
|
{
|
||||||
ConsoleScreenBufferInfo.dwCursorPosition.Y = dwCursorPosition.Y;
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
|
return FALSE;
|
||||||
if( !DeviceIoControl(
|
}
|
||||||
hConsoleOutput,
|
return TRUE;
|
||||||
IOCTL_CONSOLE_SET_SCREEN_BUFFER_INFO,
|
|
||||||
&ConsoleScreenBufferInfo,
|
|
||||||
sizeof(CONSOLE_SCREEN_BUFFER_INFO),
|
|
||||||
NULL,
|
|
||||||
0,
|
|
||||||
&dwBytesReturned,
|
|
||||||
NULL ))
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
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,
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
sizeof(OUTPUT_CHARACTER),
|
return FALSE;
|
||||||
&dwBytesReturned,
|
}
|
||||||
NULL))
|
*lpNumberOfCharsWritten = nLength;
|
||||||
{
|
return TRUE;
|
||||||
*lpNumberOfCharsWritten = Buffer.dwTransfered;
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*lpNumberOfCharsWritten = 0;
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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;
|
||||||
stat = ReadFile(hConsoleInput,
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
&lpBuffer[i].Event.KeyEvent,
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
sizeof(KEY_EVENT_RECORD),
|
{
|
||||||
&Result,
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
NULL);
|
return FALSE;
|
||||||
if (stat)
|
}
|
||||||
{
|
while( Status == STATUS_PENDING )
|
||||||
lpBuffer[i].EventType = KEY_EVENT;
|
{
|
||||||
i++;
|
Status = NtWaitForSingleObject( Reply.Data.ReadInputReply.Event, FALSE, 0 );
|
||||||
}
|
if( !NT_SUCCESS( Status ) )
|
||||||
}
|
{
|
||||||
if (lpNumberOfEventsRead != NULL)
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
{
|
return FALSE;
|
||||||
*lpNumberOfEventsRead = i;
|
}
|
||||||
}
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
return(stat);
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*lpNumberOfEventsRead = 1;
|
||||||
|
*lpBuffer = Reply.Data.ReadInputReply.Input;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -600,26 +589,8 @@ ReadConsoleOutputCharacterA(
|
||||||
LPDWORD lpNumberOfCharsRead
|
LPDWORD lpNumberOfCharsRead
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
||||||
OUTPUT_CHARACTER Buffer;
|
return FALSE;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -656,27 +627,8 @@ ReadConsoleOutputAttribute(
|
||||||
LPDWORD lpNumberOfAttrsRead
|
LPDWORD lpNumberOfAttrsRead
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
DWORD dwBytesReturned;
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
||||||
OUTPUT_ATTRIBUTE Buffer;
|
return FALSE;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
Request.Data.WriteConsoleOutputCharRequest.Coord = dwWriteCoord;
|
||||||
|
if( lpNumberOfCharsWritten )
|
||||||
|
*lpNumberOfCharsWritten = nLength;
|
||||||
|
while( nLength )
|
||||||
|
{
|
||||||
|
Size = nLength > CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR ? CSRSS_MAX_WRITE_CONSOLE_OUTPUT_CHAR : nLength;
|
||||||
|
Request.Data.WriteConsoleOutputCharRequest.Length = Size;
|
||||||
|
|
||||||
if (DeviceIoControl (hConsoleOutput,
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
IOCTL_CONSOLE_WRITE_OUTPUT_CHARACTER,
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
&Buffer,
|
{
|
||||||
sizeof(OUTPUT_CHARACTER),
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
(LPSTR)lpCharacter,
|
return FALSE;
|
||||||
nLength,
|
}
|
||||||
&dwBytesReturned,
|
nLength -= Size;
|
||||||
NULL))
|
lpCharacter += Size;
|
||||||
{
|
Request.Data.WriteConsoleOutputCharRequest.Coord = Reply.Data.WriteConsoleOutputCharReply.EndCoord;
|
||||||
*lpNumberOfCharsWritten = Buffer.dwTransfered;
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
|
||||||
|
|
||||||
*lpNumberOfCharsWritten = 0;
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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,
|
Size = nLength > CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB ? CSRSS_MAX_WRITE_CONSOLE_OUTPUT_ATTRIB : nLength;
|
||||||
&dwBytesReturned,
|
Request.Data.WriteConsoleOutputAttribRequest.Length = Size;
|
||||||
NULL))
|
for( c = 0; c < Size; c++ )
|
||||||
{
|
Request.Data.WriteConsoleOutputAttribRequest.String[c] = lpAttribute[c];
|
||||||
*lpNumberOfAttrsWritten = Buffer.dwTransfered;
|
Status = CsrClientCallServer( &Request, &Reply, sizeof( CSRSS_API_REQUEST ), sizeof( CSRSS_API_REPLY ) );
|
||||||
return TRUE;
|
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Reply.Status ) )
|
||||||
}
|
{
|
||||||
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
*lpNumberOfAttrsWritten = 0;
|
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,
|
SetLastError( RtlNtStatusToDosError( Status ) );
|
||||||
sizeof(OUTPUT_ATTRIBUTE),
|
return FALSE;
|
||||||
&dwBytesReturned,
|
}
|
||||||
NULL))
|
if( lpNumberOfAttrsWritten )
|
||||||
{
|
*lpNumberOfAttrsWritten = nLength;
|
||||||
*lpNumberOfAttrsWritten = Buffer.dwTransfered;
|
return TRUE;
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
*lpNumberOfAttrsWritten = 0;
|
|
||||||
|
|
||||||
return FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -826,25 +786,8 @@ GetConsoleMode(
|
||||||
LPDWORD lpMode
|
LPDWORD lpMode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CONSOLE_MODE Buffer;
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
||||||
DWORD dwBytesReturned;
|
return FALSE;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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;
|
|
||||||
|
|
||||||
return FALSE;
|
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;
|
||||||
|
}
|
||||||
|
*lpConsoleCursorInfo = Reply.Data.GetCursorInfoReply.Info;
|
||||||
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -936,26 +880,8 @@ SetConsoleMode(
|
||||||
DWORD dwMode
|
DWORD dwMode
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
CONSOLE_MODE Buffer;
|
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
|
||||||
DWORD dwBytesReturned;
|
return FALSE;
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -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;
|
|
||||||
|
|
||||||
return FALSE;
|
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 TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1097,18 +1024,20 @@ 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