-Implemented GetNumberOfConsoleInputEvents and ReadConsoleOutputAttribute

-Added definition of CONSOLE_SELECTION_INFO struct
-Added stubs for GetConsoleSelectionInfo, GetConsoleProcessList, and AttachConsole
-Fixed prototypes for AddConsoleAlias[AW]

svn path=/trunk/; revision=3639
This commit is contained in:
Marty Dill 2002-10-20 00:34:40 +00:00
parent 0f48860c6c
commit 4add2cf6f0
6 changed files with 271 additions and 20 deletions

View file

@ -259,6 +259,28 @@ typedef struct
CHAR String[1];
}CSRSS_READ_CONSOLE_OUTPUT_CHAR_REPLY, *PCSRSS_READ_CONSOLE_OUTPUT_CHAR_REPLY;
typedef struct
{
HANDLE ConsoleHandle;
DWORD NumAttrsToRead;
COORD ReadCoord;
}CSRSS_READ_CONSOLE_OUTPUT_ATTRIB_REQUEST, *PCSRSS_READ_CONSOLE_OUTPUT_ATTRIB_REQUEST;
typedef struct
{
COORD EndCoord;
CHAR String[1];
}CSRSS_READ_CONSOLE_OUTPUT_ATTRIB_REPLY, *PCSRSS_READ_CONSOLE_OUTPUT_ATTRIB_REPLY;
typedef struct
{
HANDLE ConsoleHandle;
}CSRSS_GET_NUM_INPUT_EVENTS_REQUEST, *PCSRSS_GET_NUM_INPUT_EVENTS_REQUEST;
typedef struct
{
DWORD NumInputEvents;
}CSRSS_GET_NUM_INPUT_EVENTS_REPLY, *PCSRSS_GET_NUM_INPUT_EVENTS_REPLY;
#define CSRSS_MAX_WRITE_CONSOLE_REQUEST \
(MAX_MESSAGE_DATA - sizeof(ULONG) - sizeof(CSRSS_WRITE_CONSOLE_REQUEST))
@ -273,6 +295,8 @@ typedef struct
#define CSRSS_MAX_READ_CONSOLE_OUTPUT_CHAR (MAX_MESSAGE_DATA - sizeof(ULONG) - sizeof(HANDLE) - sizeof(DWORD) - sizeof(CSRSS_READ_CONSOLE_OUTPUT_CHAR_REQUEST))
#define CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB (MAX_MESSAGE_DATA - sizeof(ULONG) - sizeof(HANDLE) - sizeof(DWORD) - sizeof(CSRSS_READ_CONSOLE_OUTPUT_ATTRIB_REQUEST))
// FIXME: it should be 80. Is this a limit due to LPC msg size?
#define CSRSS_MAX_TITLE_LENGTH 50
@ -303,6 +327,8 @@ typedef struct
#define CSRSS_FLUSH_INPUT_BUFFER (0x18)
#define CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER (0x19)
#define CSRSS_READ_CONSOLE_OUTPUT_CHAR (0x1A)
#define CSRSS_READ_CONSOLE_OUTPUT_ATTRIB (0x1B)
#define CSRSS_GET_NUM_INPUT_EVENTS (0x1C)
/* Keep in sync with definition below. */
@ -339,6 +365,8 @@ typedef struct
CSRSS_SCROLL_CONSOLE_SCREEN_BUFFER_REQUEST
ScrollConsoleScreenBufferRequest;
CSRSS_READ_CONSOLE_OUTPUT_CHAR_REQUEST ReadConsoleOutputCharRequest;
CSRSS_READ_CONSOLE_OUTPUT_ATTRIB_REQUEST ReadConsoleOutputAttribRequest;
CSRSS_GET_NUM_INPUT_EVENTS_REQUEST GetNumInputEventsRequest;
} Data;
} CSRSS_API_REQUEST, *PCSRSS_API_REQUEST;
@ -363,6 +391,8 @@ typedef struct
CSRSS_GET_TITLE_REPLY GetTitleReply;
CSRSS_WRITE_CONSOLE_OUTPUT_REPLY WriteConsoleOutputReply;
CSRSS_READ_CONSOLE_OUTPUT_CHAR_REPLY ReadConsoleOutputCharReply;
CSRSS_READ_CONSOLE_OUTPUT_ATTRIB_REPLY ReadConsoleOutputAttribReply;
CSRSS_GET_NUM_INPUT_EVENTS_REPLY GetNumInputEventsReply;
} Data;
} CSRSS_API_REPLY, *PCSRSS_API_REPLY;

View file

@ -42,6 +42,12 @@ typedef struct _CONSOLE_FONT_INFO {
COORD dwFontSize;
} CONSOLE_FONT_INFO, *PCONSOLE_FONT_INFO;
typedef struct _CONSOLE_SELECTION_INFO {
DWORD dwFlags;
COORD dwSelectionAnchor;
SMALL_RECT srSelection;
} CONSOLE_SELECTION_INFO, *PCONSOLE_SELECTION_INFO;
#endif /* __INCLUDE_CONSOLE_H */

View file

@ -1,4 +1,4 @@
/* $Id: console.c,v 1.43 2002/09/08 10:22:43 chorns Exp $
/* $Id: console.c,v 1.44 2002/10/20 00:34:39 mdill Exp $
*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
@ -35,24 +35,18 @@ static PHANDLER_ROUTINE* CtrlHandlers = NULL;
/* FUNCTIONS *****************************************************************/
BOOL STDCALL
AddConsoleAliasA (DWORD a0,
DWORD a1,
DWORD a2)
/*
* Undocumented
*/
AddConsoleAliasA (LPSTR Source,
LPSTR Target,
LPSTR ExeName)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
BOOL STDCALL
AddConsoleAliasW (DWORD a0,
DWORD a1,
DWORD a2)
/*
* Undocumented
*/
AddConsoleAliasW (LPWSTR Source,
LPWSTR Target,
LPWSTR ExeName)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
@ -1244,7 +1238,7 @@ ReadConsoleOutputCharacterA(
}
if (lpNumberOfCharsRead != NULL)
*lpNumberOfCharsRead = Size;
*lpNumberOfCharsRead = nLength;
Request.Type = CSRSS_READ_CONSOLE_OUTPUT_CHAR;
Request.Data.ReadConsoleOutputCharRequest.ConsoleHandle = hConsoleOutput;
@ -1315,8 +1309,58 @@ ReadConsoleOutputAttribute(
LPDWORD lpNumberOfAttrsRead
)
{
SetLastError( ERROR_CALL_NOT_IMPLEMENTED );
return FALSE;
CSRSS_API_REQUEST Request;
PCSRSS_API_REPLY Reply;
NTSTATUS Status;
DWORD Size, i;
Reply = RtlAllocateHeap(GetProcessHeap(),
HEAP_ZERO_MEMORY,
sizeof(CSRSS_API_REPLY) + CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB);
if (Reply == NULL)
{
SetLastError(ERROR_OUTOFMEMORY);
return(FALSE);
}
if (lpNumberOfAttrsRead != NULL)
*lpNumberOfAttrsRead = nLength;
Request.Type = CSRSS_READ_CONSOLE_OUTPUT_ATTRIB;
Request.Data.ReadConsoleOutputAttribRequest.ConsoleHandle = hConsoleOutput;
Request.Data.ReadConsoleOutputAttribRequest.ReadCoord = dwReadCoord;
while (nLength != 0)
{
if (nLength > CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB)
Size = CSRSS_MAX_READ_CONSOLE_OUTPUT_ATTRIB;
else
Size = nLength;
Request.Data.ReadConsoleOutputAttribRequest.NumAttrsToRead = Size;
Status = CsrClientCallServer(&Request,
Reply,
sizeof(CSRSS_API_REQUEST),
sizeof(CSRSS_API_REPLY) + Size);
if (!NT_SUCCESS(Status) || !NT_SUCCESS(Reply->Status))
{
RtlFreeHeap(GetProcessHeap(), 0, Reply);
SetLastErrorByStatus(Status);
return(FALSE);
}
// Convert CHARs to WORDs
for(i = 0; i < Size; ++i)
*lpAttribute++ = Reply->Data.ReadConsoleOutputAttribReply.String[i];
nLength -= Size;
Request.Data.ReadConsoleOutputAttribRequest.ReadCoord = Reply->Data.ReadConsoleOutputAttribReply.EndCoord;
}
RtlFreeHeap(GetProcessHeap(), 0, Reply);
return(TRUE);
}
@ -1518,8 +1562,28 @@ GetNumberOfConsoleInputEvents(
LPDWORD lpNumberOfEvents
)
{
/* TO DO */
return FALSE;
CSRSS_API_REQUEST Request;
CSRSS_API_REPLY Reply;
NTSTATUS Status;
if(lpNumberOfEvents == NULL)
{
SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
}
Request.Type = CSRSS_GET_NUM_INPUT_EVENTS;
Request.Data.GetNumInputEventsRequest.ConsoleHandle = hConsoleInput;
Status = CsrClientCallServer(&Request, &Reply, sizeof(CSRSS_API_REQUEST), sizeof(CSRSS_API_REPLY));
if(!NT_SUCCESS(Status) || !NT_SUCCESS(Reply.Status))
{
SetLastErrorByStatus(Reply.Status);
return FALSE;
}
*lpNumberOfEvents = Reply.Data.GetNumInputEventsReply.NumInputEvents;
return TRUE;
}
@ -2291,4 +2355,39 @@ SetConsoleOutputCP(
}
/*--------------------------------------------------------------
* GetConsoleProcessList
*/
DWORD STDCALL
GetConsoleProcessList(LPDWORD lpdwProcessList,
DWORD dwProcessCount)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return 0;
}
/*--------------------------------------------------------------
* GetConsoleSelectionInfo
*/
BOOL STDCALL
GetConsoleSelectionInfo(PCONSOLE_SELECTION_INFO lpConsoleSelectionInfo)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/*--------------------------------------------------------------
* AttachConsole
*/
BOOL STDCALL
AttachConsole(DWORD dwProcessId)
{
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
return FALSE;
}
/* EOF */

View file

@ -120,6 +120,8 @@ CSR_API(CsrWriteConsoleOutput);
CSR_API(CsrFlushInputBuffer);
CSR_API(CsrScrollConsoleScreenBuffer);
CSR_API(CsrReadConsoleOutputChar);
CSR_API(CsrReadConsoleOutputAttrib);
CSR_API(CsrGetNumberOfConsoleInputEvents);
/* print.c */
VOID STDCALL DisplayString(LPCWSTR lpwString);

View file

@ -1,4 +1,4 @@
/* $Id: conio.c,v 1.34 2002/09/08 10:23:45 chorns Exp $
/* $Id: conio.c,v 1.35 2002/10/20 00:34:40 mdill Exp $
*
* reactos/subsys/csrss/api/conio.c
*
@ -1964,4 +1964,116 @@ CSR_API(CsrReadConsoleOutputChar)
return(Reply->Status);
}
CSR_API(CsrReadConsoleOutputAttrib)
{
NTSTATUS Status;
PCSRSS_SCREEN_BUFFER ScreenBuffer;
DWORD Xpos, Ypos;
CHAR* ReadBuffer;
DWORD i;
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
Reply->Header.DataSize = Reply->Header.MessageSize - sizeof(LPC_MESSAGE_HEADER);
ReadBuffer = Reply->Data.ReadConsoleOutputAttribReply.String;
LOCK;
Status = CsrGetObject(ProcessData, Request->Data.ReadConsoleOutputAttribRequest.ConsoleHandle, (Object_t**)&ScreenBuffer);
if (!NT_SUCCESS(Status))
{
Reply->Status = Status;
UNLOCK;
return(Reply->Status);
}
if (ScreenBuffer->Header.Type != CSRSS_SCREEN_BUFFER_MAGIC)
{
Reply->Status = STATUS_INVALID_HANDLE;
UNLOCK;
return(Reply->Status);
}
Xpos = Request->Data.ReadConsoleOutputAttribRequest.ReadCoord.X + ScreenBuffer->ShowX;
Ypos = Request->Data.ReadConsoleOutputAttribRequest.ReadCoord.Y + ScreenBuffer->ShowY;
for (i = 0; i < Request->Data.ReadConsoleOutputAttribRequest.NumAttrsToRead; ++i)
{
*ReadBuffer = ScreenBuffer->Buffer[(Xpos * 2) + (Ypos * 2 * ScreenBuffer->MaxX) + 1];
ReadBuffer++;
Xpos++;
if (Xpos == ScreenBuffer->MaxX)
{
Xpos = 0;
Ypos++;
if (Ypos == ScreenBuffer->MaxY)
Ypos = 0;
}
}
*ReadBuffer = 0;
Reply->Status = STATUS_SUCCESS;
Reply->Data.ReadConsoleOutputAttribReply.EndCoord.X = Xpos - ScreenBuffer->ShowX;
Reply->Data.ReadConsoleOutputAttribReply.EndCoord.Y = Ypos - ScreenBuffer->ShowY;
Reply->Header.MessageSize += Request->Data.ReadConsoleOutputAttribRequest.NumAttrsToRead;
Reply->Header.DataSize += Request->Data.ReadConsoleOutputAttribRequest.NumAttrsToRead;
UNLOCK;
return(Reply->Status);
}
CSR_API(CsrGetNumberOfConsoleInputEvents)
{
NTSTATUS Status;
PCSRSS_CONSOLE Console;
PLIST_ENTRY CurrentItem;
DWORD NumEvents;
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
Reply->Header.DataSize = Reply->Header.MessageSize - sizeof(LPC_MESSAGE_HEADER);
LOCK;
Status = CsrGetObject(ProcessData, Request->Data.GetNumInputEventsRequest.ConsoleHandle, (Object_t**)&Console);
if (!NT_SUCCESS(Status))
{
Reply->Status = Status;
UNLOCK;
return(Reply->Status);
}
if (Console->Header.Type != CSRSS_CONSOLE_MAGIC)
{
Reply->Status = STATUS_INVALID_HANDLE;
UNLOCK;
return(Reply->Status);
}
CurrentItem = &Console->InputEvents;
NumEvents = 0;
// If there are any events ...
if(CurrentItem->Flink != CurrentItem)
{
do
{
CurrentItem = CurrentItem->Flink;
++NumEvents;
}while(CurrentItem != &Console->InputEvents);
}
UNLOCK;
Reply->Status = STATUS_SUCCESS;
Reply->Data.GetNumInputEventsReply.NumInputEvents = NumEvents;
return Reply->Status;
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: wapi.c,v 1.19 2002/09/08 10:23:45 chorns Exp $
/* $Id: wapi.c,v 1.20 2002/10/20 00:34:40 mdill Exp $
*
* reactos/subsys/csrss/api/wapi.c
*
@ -54,6 +54,8 @@ static const CsrFunc CsrFuncs[] = {
CsrFlushInputBuffer,
CsrScrollConsoleScreenBuffer,
CsrReadConsoleOutputChar,
CsrReadConsoleOutputAttrib,
CsrGetNumberOfConsoleInputEvents,
0 };
static void Thread_Api2(HANDLE ServerPort)