CSR.GetTitle implemented.

Some cleanup in the csrss.exe code.

svn path=/trunk/; revision=2170
This commit is contained in:
Emanuele Aliberti 2001-08-14 12:57:16 +00:00
parent 1f36dc8a8a
commit 52a23385a1
10 changed files with 289 additions and 200 deletions

View file

@ -203,6 +203,17 @@ typedef struct
WCHAR Title[1]; WCHAR Title[1];
} CSRSS_SET_TITLE_REQUEST, *PCSRSS_SET_TITLE_REQUEST; } CSRSS_SET_TITLE_REQUEST, *PCSRSS_SET_TITLE_REQUEST;
typedef struct
{
HANDLE ConsoleHandle;
} CSRSS_GET_TITLE_REQUEST, *PCSRSS_GET_TITLE_REQUEST;
typedef struct
{
HANDLE ConsoleHandle;
DWORD Length;
WCHAR Title[1];
} CSRSS_GET_TITLE_REPLY, *PCSRSS_GET_TITLE_REPLY;
#define CSRSS_MAX_WRITE_CONSOLE_REQUEST (MAX_MESSAGE_DATA - sizeof( ULONG ) - sizeof( CSRSS_WRITE_CONSOLE_REQUEST)) #define CSRSS_MAX_WRITE_CONSOLE_REQUEST (MAX_MESSAGE_DATA - sizeof( ULONG ) - sizeof( CSRSS_WRITE_CONSOLE_REQUEST))
@ -214,6 +225,7 @@ typedef struct
#define CSRSS_MAX_READ_CONSOLE_REQUEST (MAX_MESSAGE_DATA - sizeof( ULONG ) - sizeof( CSRSS_READ_CONSOLE_REQUEST )) #define CSRSS_MAX_READ_CONSOLE_REQUEST (MAX_MESSAGE_DATA - sizeof( ULONG ) - sizeof( CSRSS_READ_CONSOLE_REQUEST ))
// FIXME: it should be 80. Is this a limit due to LPC msg size?
#define CSRSS_MAX_TITLE_LENGTH 50 #define CSRSS_MAX_TITLE_LENGTH 50
#define CSRSS_CREATE_PROCESS (0x0) #define CSRSS_CREATE_PROCESS (0x0)
@ -238,6 +250,7 @@ typedef struct
#define CSRSS_CREATE_SCREEN_BUFFER (0x13) #define CSRSS_CREATE_SCREEN_BUFFER (0x13)
#define CSRSS_SET_SCREEN_BUFFER (0x14) #define CSRSS_SET_SCREEN_BUFFER (0x14)
#define CSRSS_SET_TITLE (0x15) #define CSRSS_SET_TITLE (0x15)
#define CSRSS_GET_TITLE (0x16)
typedef struct typedef struct
{ {
@ -264,6 +277,7 @@ typedef struct
CSRSS_CREATE_SCREEN_BUFFER_REQUEST CreateScreenBufferRequest; CSRSS_CREATE_SCREEN_BUFFER_REQUEST CreateScreenBufferRequest;
CSRSS_SET_ACTIVE_SCREEN_BUFFER_REQUEST SetActiveScreenBufferRequest; CSRSS_SET_ACTIVE_SCREEN_BUFFER_REQUEST SetActiveScreenBufferRequest;
CSRSS_SET_TITLE_REQUEST SetTitleRequest; CSRSS_SET_TITLE_REQUEST SetTitleRequest;
CSRSS_GET_TITLE_REQUEST GetTitleRequest;
} Data; } Data;
} CSRSS_API_REQUEST, *PCSRSS_API_REQUEST; } CSRSS_API_REQUEST, *PCSRSS_API_REQUEST;
@ -285,6 +299,7 @@ typedef struct
CSRSS_GET_CURSOR_INFO_REPLY GetCursorInfoReply; CSRSS_GET_CURSOR_INFO_REPLY GetCursorInfoReply;
CSRSS_GET_CONSOLE_MODE_REPLY GetConsoleModeReply; CSRSS_GET_CONSOLE_MODE_REPLY GetConsoleModeReply;
CSRSS_CREATE_SCREEN_BUFFER_REPLY CreateScreenBufferReply; CSRSS_CREATE_SCREEN_BUFFER_REPLY CreateScreenBufferReply;
CSRSS_GET_TITLE_REPLY GetTitleReply;
} Data; } Data;
} CSRSS_API_REPLY, *PCSRSS_API_REPLY; } CSRSS_API_REPLY, *PCSRSS_API_REPLY;

View file

@ -1,4 +1,4 @@
/* $Id: console.c,v 1.33 2001/06/22 02:11:43 phreak Exp $ /* $Id: console.c,v 1.34 2001/08/14 12:57:15 ea Exp $
* *
* COPYRIGHT: See COPYING in the top level directory * COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries * PROJECT: ReactOS system libraries
@ -1759,8 +1759,60 @@ GetConsoleTitleW(
DWORD nSize DWORD nSize
) )
{ {
/* TO DO */ union {
return 0; CSRSS_API_REQUEST quest;
CSRSS_API_REPLY ply;
} Re;
NTSTATUS Status;
/* Marshall data */
Re.quest.Type = CSRSS_GET_TITLE;
Re.quest.Data.GetTitleRequest.ConsoleHandle =
GetStdHandle (STD_INPUT_HANDLE);
/* Call CSRSS */
Status = CsrClientCallServer (
& Re.quest,
& Re.ply,
(sizeof (CSRSS_GET_TITLE_REQUEST) +
sizeof (LPC_MESSAGE_HEADER) +
sizeof (ULONG)),
sizeof (CSRSS_API_REPLY)
);
if ( !NT_SUCCESS(Status)
|| !NT_SUCCESS (Status = Re.ply.Status)
)
{
SetLastErrorByStatus (Status);
return (0);
}
/* Convert size in characters to size in bytes */
nSize = sizeof (WCHAR) * nSize;
/* Unmarshall data */
if (nSize < Re.ply.Data.GetTitleReply.Length)
{
DbgPrint ("%s: ret=%d\n", __FUNCTION__, Re.ply.Data.GetTitleReply.Length);
nSize /= sizeof (WCHAR);
if (nSize > 1)
{
wcsncpy (
lpConsoleTitle,
Re.ply.Data.GetTitleReply.Title,
(nSize - 1)
);
/* Add null */
lpConsoleTitle [nSize --] = L'\0';
}
}
else
{
nSize = Re.ply.Data.GetTitleReply.Length / sizeof (WCHAR);
wcscpy (lpConsoleTitle, Re.ply.Data.GetTitleReply.Title);
}
return nSize;
} }

View file

@ -1,3 +1,6 @@
#ifndef _CSRSS_API_H
#define _CSRSS_API_H
#include <ntos.h> #include <ntos.h>
#include <csrss/csrss.h> #include <csrss/csrss.h>
@ -63,6 +66,10 @@ typedef struct CSRSS_CONSOLE_t
WORD Mode; /* Console mode flags */ WORD Mode; /* Console mode flags */
WORD EchoCount; /* count of chars to echo, in line buffered mode */ WORD EchoCount; /* count of chars to echo, in line buffered mode */
UNICODE_STRING Title; /* Title of console */ UNICODE_STRING Title; /* Title of console */
struct { /* active code pages */
UINT Input;
UINT Output;
} CodePageId;
} CSRSS_CONSOLE, *PCSRSS_CONSOLE; } CSRSS_CONSOLE, *PCSRSS_CONSOLE;
typedef struct typedef struct
@ -75,69 +82,42 @@ typedef struct
} CSRSS_PROCESS_DATA, *PCSRSS_PROCESS_DATA; } CSRSS_PROCESS_DATA, *PCSRSS_PROCESS_DATA;
VOID CsrInitProcessData(VOID); #define CSR_API(n) NTSTATUS n (\
PCSRSS_PROCESS_DATA ProcessData,\
PCSRSS_API_REQUEST Request,\
PCSRSS_API_REPLY Reply)
NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData, /* api/process.c */
PCSRSS_API_REQUEST Request, CSR_API(CsrConnectProcess);
PCSRSS_API_REPLY Reply); CSR_API(CsrCreateProcess);
CSR_API(CsrTerminateProcess);
NTSTATUS CsrTerminateProcess(PCSRSS_PROCESS_DATA ProcessData, /* api/conio.c */
PCSRSS_API_REQUEST LpcMessage, CSR_API(CsrWriteConsole);
PCSRSS_API_REPLY Reply); CSR_API(CsrAllocConsole);
CSR_API(CsrFreeConsole);
NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrReadConsole);
PCSRSS_API_REQUEST LpcMessage, CSR_API(CsrConnectProcess);
PCSRSS_API_REPLY Reply); CSR_API(CsrGetScreenBufferInfo);
CSR_API(CsrSetCursor);
NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrFillOutputChar);
PCSRSS_API_REQUEST LpcMessage, CSR_API(CsrReadInputEvent);
PCSRSS_API_REPLY Reply); CSR_API(CsrWriteConsoleOutputChar);
CSR_API(CsrWriteConsoleOutputAttrib);
NTSTATUS CsrFreeConsole(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrFillOutputAttrib);
PCSRSS_API_REQUEST LpcMessage, CSR_API(CsrGetCursorInfo);
PCSRSS_API_REPLY Reply); CSR_API(CsrSetCursorInfo);
CSR_API(CsrSetTextAttrib);
NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrSetConsoleMode);
PCSRSS_API_REQUEST LpcMessage, CSR_API(CsrGetConsoleMode);
PCSRSS_API_REPLY Reply); CSR_API(CsrCreateScreenBuffer);
CSR_API(CsrSetScreenBuffer);
NTSTATUS CsrConnectProcess(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrSetTitle);
PCSRSS_API_REQUEST Request, CSR_API(CsrGetTitle);
PCSRSS_API_REPLY Reply);
NTSTATUS CsrGetScreenBufferInfo( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrSetCursor( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrFillOutputChar( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrReadInputEvent( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrWriteConsoleOutputChar( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrWriteConsoleOutputAttrib( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrFillOutputAttrib( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrGetCursorInfo( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrSetCursorInfo( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrSetTextAttrib( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrSetConsoleMode( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrGetConsoleMode( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrCreateScreenBuffer( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrSetScreenBuffer( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
NTSTATUS CsrSetTitle( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply );
/* print.c */ /* print.c */
VOID DisplayString(LPCWSTR lpwString); VOID STDCALL DisplayString(LPCWSTR lpwString);
VOID PrintString (char* fmt, ...); VOID STDCALL PrintString (char* fmt, ...);
/* api/wapi.c */ /* api/wapi.c */
VOID Thread_Api(PVOID PortHandle); VOID Thread_Api(PVOID PortHandle);
@ -146,21 +126,23 @@ VOID Console_Api( DWORD Ignored );
extern HANDLE CsrssApiHeap; extern HANDLE CsrssApiHeap;
/* api/conio.c */ /* api/conio.c */
NTSTATUS CsrInitConsole(PCSRSS_CONSOLE Console); NTSTATUS STDCALL CsrInitConsole(PCSRSS_CONSOLE Console);
VOID CsrDeleteConsole( PCSRSS_CONSOLE Console ); VOID STDCALL CsrDeleteConsole( PCSRSS_CONSOLE Console );
VOID CsrDeleteScreenBuffer( PCSRSS_SCREEN_BUFFER Buffer ); VOID STDCALL CsrDeleteScreenBuffer( PCSRSS_SCREEN_BUFFER Buffer );
NTSTATUS CsrInitConsoleScreenBuffer( PCSRSS_SCREEN_BUFFER Console ); NTSTATUS STDCALL CsrInitConsoleScreenBuffer( PCSRSS_SCREEN_BUFFER Console );
VOID CsrInitConsoleSupport(VOID); VOID STDCALL CsrInitConsoleSupport(VOID);
/* api/process.c */ /* api/process.c */
PCSRSS_PROCESS_DATA CsrGetProcessData(ULONG ProcessId); VOID STDCALL CsrInitProcessData(VOID);
NTSTATUS CsrFreeProcessData( ULONG Pid ); PCSRSS_PROCESS_DATA STDCALL CsrGetProcessData(ULONG ProcessId);
/* api/handle.c */ NTSTATUS STDCALL CsrFreeProcessData( ULONG Pid );
NTSTATUS CsrInsertObject( PCSRSS_PROCESS_DATA ProcessData, PHANDLE Handle, Object_t *Object );
NTSTATUS CsrGetObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, Object_t **Object );
BOOL STDCALL CsrServerInitialization (ULONG ArgumentCount, /* api/handle.c */
PWSTR *ArgumentArray); NTSTATUS STDCALL CsrInsertObject( PCSRSS_PROCESS_DATA ProcessData, PHANDLE Handle, Object_t *Object );
NTSTATUS CsrReleaseObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object ); NTSTATUS STDCALL CsrGetObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, Object_t **Object );
VOID CsrDrawConsole( PCSRSS_SCREEN_BUFFER Console ); BOOL STDCALL CsrServerInitialization (ULONG ArgumentCount, PWSTR *ArgumentArray);
NTSTATUS CsrpWriteConsole( PCSRSS_SCREEN_BUFFER Buff, CHAR *Buffer, DWORD Length, BOOL Attrib ); NTSTATUS STDCALL CsrReleaseObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
VOID STDCALL CsrDrawConsole( PCSRSS_SCREEN_BUFFER Console );
NTSTATUS STDCALL CsrpWriteConsole( PCSRSS_SCREEN_BUFFER Buff, CHAR *Buffer, DWORD Length, BOOL Attrib );
#endif /* ndef _CSRSS_API_H */

View file

@ -1,4 +1,4 @@
/* $Id: conio.c,v 1.22 2001/07/31 20:47:44 ea Exp $ /* $Id: conio.c,v 1.23 2001/08/14 12:57:16 ea Exp $
* *
* reactos/subsys/csrss/api/conio.c * reactos/subsys/csrss/api/conio.c
* *
@ -20,6 +20,7 @@
#define LOCK RtlEnterCriticalSection(&ActiveConsoleLock) #define LOCK RtlEnterCriticalSection(&ActiveConsoleLock)
#define UNLOCK RtlLeaveCriticalSection(&ActiveConsoleLock) #define UNLOCK RtlLeaveCriticalSection(&ActiveConsoleLock)
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
static HANDLE ConsoleDeviceHandle; static HANDLE ConsoleDeviceHandle;
@ -30,53 +31,51 @@ static COORD PhysicalConsoleSize;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrAllocConsole)
PCSRSS_API_REQUEST LpcMessage,
PCSRSS_API_REPLY LpcReply)
{ {
PCSRSS_CONSOLE Console; PCSRSS_CONSOLE Console;
HANDLE Process; HANDLE Process;
NTSTATUS Status; NTSTATUS Status;
CLIENT_ID ClientId; CLIENT_ID ClientId;
LpcReply->Header.MessageSize = sizeof(CSRSS_API_REPLY); Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
LpcReply->Header.DataSize = sizeof(CSRSS_API_REPLY) - Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) -
sizeof(LPC_MESSAGE_HEADER); sizeof(LPC_MESSAGE_HEADER);
if( ProcessData->Console ) if( ProcessData->Console )
{ {
LpcReply->Status = STATUS_INVALID_PARAMETER; Reply->Status = STATUS_INVALID_PARAMETER;
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
LpcReply->Status = STATUS_SUCCESS; Reply->Status = STATUS_SUCCESS;
Console = RtlAllocateHeap( CsrssApiHeap, 0, sizeof( CSRSS_CONSOLE ) ); Console = RtlAllocateHeap( CsrssApiHeap, 0, sizeof( CSRSS_CONSOLE ) );
if( Console == 0 ) if( Console == 0 )
{ {
LpcReply->Status = STATUS_INSUFFICIENT_RESOURCES; Reply->Status = STATUS_INSUFFICIENT_RESOURCES;
return STATUS_INSUFFICIENT_RESOURCES; return STATUS_INSUFFICIENT_RESOURCES;
} }
LpcReply->Status = CsrInitConsole( Console ); Reply->Status = CsrInitConsole( Console );
if( !NT_SUCCESS( LpcReply->Status ) ) if( !NT_SUCCESS( Reply->Status ) )
{ {
RtlFreeHeap( CsrssApiHeap, 0, Console ); RtlFreeHeap( CsrssApiHeap, 0, Console );
return LpcReply->Status; return Reply->Status;
} }
ProcessData->Console = Console; ProcessData->Console = Console;
/* add a reference count because the process is tied to the console */ /* add a reference count because the process is tied to the console */
Console->Header.ReferenceCount++; Console->Header.ReferenceCount++;
Status = CsrInsertObject( ProcessData, &LpcReply->Data.AllocConsoleReply.InputHandle, &Console->Header ); Status = CsrInsertObject( ProcessData, &Reply->Data.AllocConsoleReply.InputHandle, &Console->Header );
if( !NT_SUCCESS( Status ) ) if( !NT_SUCCESS( Status ) )
{ {
CsrDeleteConsole( Console ); CsrDeleteConsole( Console );
ProcessData->Console = 0; ProcessData->Console = 0;
return LpcReply->Status = Status; return Reply->Status = Status;
} }
Status = CsrInsertObject( ProcessData, &LpcReply->Data.AllocConsoleReply.OutputHandle, &Console->ActiveBuffer->Header ); Status = CsrInsertObject( ProcessData, &Reply->Data.AllocConsoleReply.OutputHandle, &Console->ActiveBuffer->Header );
if( !NT_SUCCESS( Status ) ) if( !NT_SUCCESS( Status ) )
{ {
Console->Header.ReferenceCount--; Console->Header.ReferenceCount--;
CsrReleaseObject( ProcessData, LpcReply->Data.AllocConsoleReply.InputHandle ); CsrReleaseObject( ProcessData, Reply->Data.AllocConsoleReply.InputHandle );
ProcessData->Console = 0; ProcessData->Console = 0;
return LpcReply->Status = Status; return Reply->Status = Status;
} }
ClientId.UniqueProcess = (HANDLE)ProcessData->ProcessId; ClientId.UniqueProcess = (HANDLE)ProcessData->ProcessId;
Status = NtOpenProcess( &Process, PROCESS_DUP_HANDLE, 0, &ClientId ); Status = NtOpenProcess( &Process, PROCESS_DUP_HANDLE, 0, &ClientId );
@ -85,9 +84,9 @@ NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData,
DbgPrint( "CSR: NtOpenProcess() failed for handle duplication\n" ); DbgPrint( "CSR: NtOpenProcess() failed for handle duplication\n" );
Console->Header.ReferenceCount--; Console->Header.ReferenceCount--;
ProcessData->Console = 0; ProcessData->Console = 0;
CsrReleaseObject( ProcessData, LpcReply->Data.AllocConsoleReply.OutputHandle ); CsrReleaseObject( ProcessData, Reply->Data.AllocConsoleReply.OutputHandle );
CsrReleaseObject( ProcessData, LpcReply->Data.AllocConsoleReply.InputHandle ); CsrReleaseObject( ProcessData, Reply->Data.AllocConsoleReply.InputHandle );
LpcReply->Status = Status; Reply->Status = Status;
return Status; return Status;
} }
Status = NtDuplicateObject( NtCurrentProcess(), &ProcessData->Console->ActiveEvent, Process, &ProcessData->ConsoleEvent, SYNCHRONIZE, FALSE, 0 ); Status = NtDuplicateObject( NtCurrentProcess(), &ProcessData->Console->ActiveEvent, Process, &ProcessData->ConsoleEvent, SYNCHRONIZE, FALSE, 0 );
@ -96,32 +95,28 @@ NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData,
DbgPrint( "CSR: NtDuplicateObject() failed: %x\n", Status ); DbgPrint( "CSR: NtDuplicateObject() failed: %x\n", Status );
NtClose( Process ); NtClose( Process );
Console->Header.ReferenceCount--; Console->Header.ReferenceCount--;
CsrReleaseObject( ProcessData, LpcReply->Data.AllocConsoleReply.OutputHandle ); CsrReleaseObject( ProcessData, Reply->Data.AllocConsoleReply.OutputHandle );
CsrReleaseObject( ProcessData, LpcReply->Data.AllocConsoleReply.InputHandle ); CsrReleaseObject( ProcessData, Reply->Data.AllocConsoleReply.InputHandle );
ProcessData->Console = 0; ProcessData->Console = 0;
LpcReply->Status = Status; Reply->Status = Status;
return Status; return Status;
} }
NtClose( Process ); NtClose( Process );
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NTSTATUS CsrFreeConsole(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrFreeConsole)
PCSRSS_API_REQUEST LpcMessage,
PCSRSS_API_REPLY LpcReply)
{ {
LpcReply->Header.MessageSize = sizeof(CSRSS_API_REPLY); Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
LpcReply->Header.DataSize = sizeof(CSRSS_API_REPLY) - Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) -
sizeof(LPC_MESSAGE_HEADER); sizeof(LPC_MESSAGE_HEADER);
LpcReply->Status = STATUS_NOT_IMPLEMENTED; Reply->Status = STATUS_NOT_IMPLEMENTED;
return(STATUS_NOT_IMPLEMENTED); return(STATUS_NOT_IMPLEMENTED);
} }
NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrReadConsole)
PCSRSS_API_REQUEST LpcMessage,
PCSRSS_API_REPLY LpcReply)
{ {
ConsoleInput *Input; ConsoleInput *Input;
PCHAR Buffer; PCHAR Buffer;
@ -131,23 +126,23 @@ NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
NTSTATUS Status; NTSTATUS Status;
/* truncate length to CSRSS_MAX_READ_CONSOLE_REQUEST */ /* truncate length to CSRSS_MAX_READ_CONSOLE_REQUEST */
nNumberOfCharsToRead = LpcMessage->Data.ReadConsoleRequest.NrCharactersToRead > CSRSS_MAX_READ_CONSOLE_REQUEST ? CSRSS_MAX_READ_CONSOLE_REQUEST : LpcMessage->Data.ReadConsoleRequest.NrCharactersToRead; nNumberOfCharsToRead = Request->Data.ReadConsoleRequest.NrCharactersToRead > CSRSS_MAX_READ_CONSOLE_REQUEST ? CSRSS_MAX_READ_CONSOLE_REQUEST : Request->Data.ReadConsoleRequest.NrCharactersToRead;
LpcReply->Header.MessageSize = sizeof(CSRSS_API_REPLY); Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
LpcReply->Header.DataSize = LpcReply->Header.MessageSize - Reply->Header.DataSize = Reply->Header.MessageSize -
sizeof(LPC_MESSAGE_HEADER); sizeof(LPC_MESSAGE_HEADER);
Buffer = LpcReply->Data.ReadConsoleReply.Buffer; Buffer = Reply->Data.ReadConsoleReply.Buffer;
LpcReply->Data.ReadConsoleReply.EventHandle = ProcessData->ConsoleEvent; Reply->Data.ReadConsoleReply.EventHandle = ProcessData->ConsoleEvent;
LOCK; LOCK;
Status = CsrGetObject( ProcessData, LpcMessage->Data.ReadConsoleRequest.ConsoleHandle, (Object_t **)&Console ); Status = CsrGetObject( ProcessData, Request->Data.ReadConsoleRequest.ConsoleHandle, (Object_t **)&Console );
if( !NT_SUCCESS( Status ) ) if( !NT_SUCCESS( Status ) )
{ {
LpcReply->Status = Status; Reply->Status = Status;
UNLOCK; UNLOCK;
return Status; return Status;
} }
if( Console->Header.Type != CSRSS_CONSOLE_MAGIC ) if( Console->Header.Type != CSRSS_CONSOLE_MAGIC )
{ {
LpcReply->Status = STATUS_INVALID_HANDLE; Reply->Status = STATUS_INVALID_HANDLE;
UNLOCK; UNLOCK;
return STATUS_INVALID_HANDLE; return STATUS_INVALID_HANDLE;
} }
@ -167,20 +162,20 @@ NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
if( Input->InputEvent.Event.KeyEvent.uChar.AsciiChar == '\b' ) if( Input->InputEvent.Event.KeyEvent.uChar.AsciiChar == '\b' )
{ {
// echo if it has not already been done, and either we or the client has chars to be deleted // echo if it has not already been done, and either we or the client has chars to be deleted
if( !Input->Echoed && ( i || LpcMessage->Data.ReadConsoleRequest.nCharsCanBeDeleted ) ) if( !Input->Echoed && ( i || Request->Data.ReadConsoleRequest.nCharsCanBeDeleted ) )
CsrpWriteConsole( Console->ActiveBuffer, &Input->InputEvent.Event.KeyEvent.uChar.AsciiChar, 1, TRUE ); CsrpWriteConsole( Console->ActiveBuffer, &Input->InputEvent.Event.KeyEvent.uChar.AsciiChar, 1, TRUE );
if( i ) if( i )
i-=2; // if we already have something to return, just back it up by 2 i-=2; // if we already have something to return, just back it up by 2
else else
{ // otherwise, return STATUS_NOTIFY_CLEANUP to tell client to back up its buffer { // otherwise, return STATUS_NOTIFY_CLEANUP to tell client to back up its buffer
LpcReply->Data.ReadConsoleReply.NrCharactersRead = 0; Reply->Data.ReadConsoleReply.NrCharactersRead = 0;
LpcReply->Status = STATUS_NOTIFY_CLEANUP; Reply->Status = STATUS_NOTIFY_CLEANUP;
Console->WaitingChars--; Console->WaitingChars--;
RtlFreeHeap( CsrssApiHeap, 0, Input ); RtlFreeHeap( CsrssApiHeap, 0, Input );
UNLOCK; UNLOCK;
return STATUS_NOTIFY_CLEANUP; return STATUS_NOTIFY_CLEANUP;
} }
LpcMessage->Data.ReadConsoleRequest.nCharsCanBeDeleted--; Request->Data.ReadConsoleRequest.nCharsCanBeDeleted--;
Input->Echoed = TRUE; // mark as echoed so we don't echo it below Input->Echoed = TRUE; // mark as echoed so we don't echo it below
} }
// do not copy backspace to buffer // do not copy backspace to buffer
@ -195,29 +190,29 @@ NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData,
Console->WaitingChars--; Console->WaitingChars--;
RtlFreeHeap( CsrssApiHeap, 0, Input ); RtlFreeHeap( CsrssApiHeap, 0, Input );
} }
LpcReply->Data.ReadConsoleReply.NrCharactersRead = i; Reply->Data.ReadConsoleReply.NrCharactersRead = i;
if( !i ) if( !i )
LpcReply->Status = STATUS_PENDING; // we didn't read anything Reply->Status = STATUS_PENDING; // we didn't read anything
else if( Console->Mode & ENABLE_LINE_INPUT ) else if( Console->Mode & ENABLE_LINE_INPUT )
if( !Console->WaitingLines || Buffer[i-1] != '\n' ) if( !Console->WaitingLines || Buffer[i-1] != '\n' )
{ {
LpcReply->Status = STATUS_PENDING; // line buffered, didn't get a complete line Reply->Status = STATUS_PENDING; // line buffered, didn't get a complete line
} }
else { else {
Console->WaitingLines--; Console->WaitingLines--;
LpcReply->Status = STATUS_SUCCESS; // line buffered, did get a complete line Reply->Status = STATUS_SUCCESS; // line buffered, did get a complete line
} }
else LpcReply->Status = STATUS_SUCCESS; // not line buffered, did read something else Reply->Status = STATUS_SUCCESS; // not line buffered, did read something
if( LpcReply->Status == STATUS_PENDING ) if( Reply->Status == STATUS_PENDING )
{ {
Console->EchoCount = nNumberOfCharsToRead - i; Console->EchoCount = nNumberOfCharsToRead - i;
} }
else { else {
Console->EchoCount = 0; // if the client is no longer waiting on input, do not echo Console->EchoCount = 0; // if the client is no longer waiting on input, do not echo
} }
LpcReply->Header.MessageSize += i; Reply->Header.MessageSize += i;
UNLOCK; UNLOCK;
return LpcReply->Status; return Reply->Status;
} }
#define SET_CELL_BUFFER(b,o,c,a)\ #define SET_CELL_BUFFER(b,o,c,a)\
@ -239,7 +234,7 @@ ClearLineBuffer (
} }
} }
NTSTATUS CsrpWriteConsole( PCSRSS_SCREEN_BUFFER Buff, CHAR *Buffer, DWORD Length, BOOL Attrib ) NTSTATUS STDCALL CsrpWriteConsole( PCSRSS_SCREEN_BUFFER Buff, CHAR *Buffer, DWORD Length, BOOL Attrib )
{ {
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
NTSTATUS Status; NTSTATUS Status;
@ -293,7 +288,7 @@ NTSTATUS CsrpWriteConsole( PCSRSS_SCREEN_BUFFER Buff, CHAR *Buffer, DWORD Length
break; break;
/* --- TAB --- */ /* --- TAB --- */
case '\t': case '\t':
CsrpWriteConsole(Buff, " ", (8 - (Buff->CurrentX % 8)), Attrib); CsrpWriteConsole(Buff, " ", (8 - (Buff->CurrentX % 8)), FALSE);
break; break;
/* --- */ /* --- */
default: default:
@ -310,13 +305,9 @@ NTSTATUS CsrpWriteConsole( PCSRSS_SCREEN_BUFFER Buff, CHAR *Buffer, DWORD Length
{ {
/* if end of buffer, wrap back to beginning */ /* if end of buffer, wrap back to beginning */
Buff->CurrentY = 0; Buff->CurrentY = 0;
/* clear new line */
ClearLineBuffer (Buff, 0);
} }
else { /* clear new line */
/* clear new line */ ClearLineBuffer (Buff, 0);
ClearLineBuffer (Buff, 0);
}
/* slide the viewable screen */ /* slide the viewable screen */
if( (Buff->CurrentY - Buff->ShowY) == PhysicalConsoleSize.Y ) if( (Buff->CurrentY - Buff->ShowY) == PhysicalConsoleSize.Y )
if( ++Buff->ShowY == Buff->MaxY ) if( ++Buff->ShowY == Buff->MaxY )
@ -336,11 +327,9 @@ NTSTATUS CsrpWriteConsole( PCSRSS_SCREEN_BUFFER Buff, CHAR *Buffer, DWORD Length
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrWriteConsole)
PCSRSS_API_REQUEST LpcMessage,
PCSRSS_API_REPLY Reply)
{ {
BYTE *Buffer = LpcMessage->Data.WriteConsoleRequest.Buffer; BYTE *Buffer = Request->Data.WriteConsoleRequest.Buffer;
PCSRSS_SCREEN_BUFFER Buff; PCSRSS_SCREEN_BUFFER Buff;
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY); Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
@ -348,18 +337,18 @@ NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData,
sizeof(LPC_MESSAGE_HEADER); sizeof(LPC_MESSAGE_HEADER);
LOCK; LOCK;
if( !NT_SUCCESS( CsrGetObject( ProcessData, LpcMessage->Data.WriteConsoleRequest.ConsoleHandle, (Object_t **)&Buff ) ) || Buff->Header.Type != CSRSS_SCREEN_BUFFER_MAGIC ) if( !NT_SUCCESS( CsrGetObject( ProcessData, Request->Data.WriteConsoleRequest.ConsoleHandle, (Object_t **)&Buff ) ) || Buff->Header.Type != CSRSS_SCREEN_BUFFER_MAGIC )
{ {
UNLOCK; UNLOCK;
return Reply->Status = STATUS_INVALID_HANDLE; return Reply->Status = STATUS_INVALID_HANDLE;
} }
CsrpWriteConsole( Buff, Buffer, LpcMessage->Data.WriteConsoleRequest.NrCharactersToWrite, TRUE ); CsrpWriteConsole( Buff, Buffer, Request->Data.WriteConsoleRequest.NrCharactersToWrite, TRUE );
UNLOCK; UNLOCK;
return Reply->Status = STATUS_SUCCESS; return Reply->Status = STATUS_SUCCESS;
} }
NTSTATUS CsrInitConsoleScreenBuffer( PCSRSS_SCREEN_BUFFER Console ) NTSTATUS STDCALL CsrInitConsoleScreenBuffer( PCSRSS_SCREEN_BUFFER Console )
{ {
Console->Header.Type = CSRSS_SCREEN_BUFFER_MAGIC; Console->Header.Type = CSRSS_SCREEN_BUFFER_MAGIC;
Console->Header.ReferenceCount = 0; Console->Header.ReferenceCount = 0;
@ -386,13 +375,13 @@ NTSTATUS CsrInitConsoleScreenBuffer( PCSRSS_SCREEN_BUFFER Console )
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
VOID CsrDeleteScreenBuffer( PCSRSS_SCREEN_BUFFER Buffer ) VOID STDCALL CsrDeleteScreenBuffer( PCSRSS_SCREEN_BUFFER Buffer )
{ {
RtlFreeHeap( CsrssApiHeap, 0, Buffer->Buffer ); RtlFreeHeap( CsrssApiHeap, 0, Buffer->Buffer );
RtlFreeHeap( CsrssApiHeap, 0, Buffer ); RtlFreeHeap( CsrssApiHeap, 0, Buffer );
} }
NTSTATUS CsrInitConsole(PCSRSS_CONSOLE Console) NTSTATUS STDCALL CsrInitConsole(PCSRSS_CONSOLE Console)
{ {
NTSTATUS Status; NTSTATUS Status;
@ -452,7 +441,7 @@ NTSTATUS CsrInitConsole(PCSRSS_CONSOLE Console)
* CsrDrawConsole blasts the console buffer onto the screen * * CsrDrawConsole blasts the console buffer onto the screen *
* must be called while holding the active console lock * * must be called while holding the active console lock *
**************************************************************/ **************************************************************/
VOID CsrDrawConsole( PCSRSS_SCREEN_BUFFER Buff ) VOID STDCALL CsrDrawConsole( PCSRSS_SCREEN_BUFFER Buff )
{ {
IO_STATUS_BLOCK Iosb; IO_STATUS_BLOCK Iosb;
NTSTATUS Status; NTSTATUS Status;
@ -514,7 +503,7 @@ VOID CsrDrawConsole( PCSRSS_SCREEN_BUFFER Buff )
} }
VOID CsrDeleteConsole( PCSRSS_CONSOLE Console ) VOID STDCALL CsrDeleteConsole( PCSRSS_CONSOLE Console )
{ {
ConsoleInput *Event; ConsoleInput *Event;
DPRINT1( "CsrDeleteConsole\n" ); DPRINT1( "CsrDeleteConsole\n" );
@ -548,7 +537,7 @@ VOID CsrDeleteConsole( PCSRSS_CONSOLE Console )
RtlFreeHeap( CsrssApiHeap, 0, Console ); RtlFreeHeap( CsrssApiHeap, 0, Console );
} }
VOID CsrInitConsoleSupport(VOID) VOID STDCALL CsrInitConsoleSupport(VOID)
{ {
OBJECT_ATTRIBUTES ObjectAttributes; OBJECT_ATTRIBUTES ObjectAttributes;
UNICODE_STRING DeviceName; UNICODE_STRING DeviceName;
@ -875,7 +864,7 @@ VOID Console_Api( DWORD RefreshEvent )
} }
} }
NTSTATUS CsrGetScreenBufferInfo( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrGetScreenBufferInfo)
{ {
NTSTATUS Status; NTSTATUS Status;
PCSRSS_SCREEN_BUFFER Buff; PCSRSS_SCREEN_BUFFER Buff;
@ -916,7 +905,7 @@ NTSTATUS CsrGetScreenBufferInfo( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQ
return Reply->Status; return Reply->Status;
} }
NTSTATUS CsrSetCursor( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrSetCursor)
{ {
NTSTATUS Status; NTSTATUS Status;
PCSRSS_SCREEN_BUFFER Buff; PCSRSS_SCREEN_BUFFER Buff;
@ -947,7 +936,7 @@ NTSTATUS CsrSetCursor( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Reque
return Reply->Status = Status; return Reply->Status = Status;
} }
NTSTATUS CsrWriteConsoleOutputChar( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrWriteConsoleOutputChar)
{ {
BYTE *Buffer = Request->Data.WriteConsoleOutputCharRequest.String; BYTE *Buffer = Request->Data.WriteConsoleOutputCharRequest.String;
PCSRSS_SCREEN_BUFFER Buff; PCSRSS_SCREEN_BUFFER Buff;
@ -993,7 +982,7 @@ NTSTATUS CsrWriteConsoleOutputChar( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_
return Reply->Status = STATUS_SUCCESS; return Reply->Status = STATUS_SUCCESS;
} }
NTSTATUS CsrFillOutputChar( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrFillOutputChar)
{ {
PCSRSS_SCREEN_BUFFER Buff; PCSRSS_SCREEN_BUFFER Buff;
DWORD X, Y, i; DWORD X, Y, i;
@ -1027,7 +1016,7 @@ NTSTATUS CsrFillOutputChar( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST
return Reply->Status; return Reply->Status;
} }
NTSTATUS CsrReadInputEvent( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrReadInputEvent)
{ {
PCSRSS_CONSOLE Console; PCSRSS_CONSOLE Console;
NTSTATUS Status; NTSTATUS Status;
@ -1068,7 +1057,7 @@ NTSTATUS CsrReadInputEvent( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST
return Reply->Status = Status; return Reply->Status = Status;
} }
NTSTATUS CsrWriteConsoleOutputAttrib( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrWriteConsoleOutputAttrib)
{ {
int c; int c;
PCSRSS_SCREEN_BUFFER Buff; PCSRSS_SCREEN_BUFFER Buff;
@ -1125,7 +1114,7 @@ NTSTATUS CsrWriteConsoleOutputAttrib( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_AP
return Reply->Status = STATUS_SUCCESS; return Reply->Status = STATUS_SUCCESS;
} }
NTSTATUS CsrFillOutputAttrib( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrFillOutputAttrib)
{ {
int c; int c;
PCSRSS_SCREEN_BUFFER Buff; PCSRSS_SCREEN_BUFFER Buff;
@ -1184,7 +1173,7 @@ NTSTATUS CsrFillOutputAttrib( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUES
} }
NTSTATUS CsrGetCursorInfo( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrGetCursorInfo)
{ {
PCSRSS_SCREEN_BUFFER Buff; PCSRSS_SCREEN_BUFFER Buff;
NTSTATUS Status; NTSTATUS Status;
@ -1205,7 +1194,7 @@ NTSTATUS CsrGetCursorInfo( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST R
return Reply->Status = STATUS_SUCCESS; return Reply->Status = STATUS_SUCCESS;
} }
NTSTATUS CsrSetCursorInfo( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrSetCursorInfo)
{ {
PCSRSS_SCREEN_BUFFER Buff; PCSRSS_SCREEN_BUFFER Buff;
NTSTATUS Status; NTSTATUS Status;
@ -1236,7 +1225,7 @@ NTSTATUS CsrSetCursorInfo( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST R
return Reply->Status = STATUS_SUCCESS; return Reply->Status = STATUS_SUCCESS;
} }
NTSTATUS CsrSetTextAttrib( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrSetTextAttrib)
{ {
NTSTATUS Status; NTSTATUS Status;
CONSOLE_SCREEN_BUFFER_INFO ScrInfo; CONSOLE_SCREEN_BUFFER_INFO ScrInfo;
@ -1272,7 +1261,7 @@ NTSTATUS CsrSetTextAttrib( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST R
return Reply->Status = STATUS_SUCCESS; return Reply->Status = STATUS_SUCCESS;
} }
NTSTATUS CsrSetConsoleMode( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrSetConsoleMode)
{ {
NTSTATUS Status; NTSTATUS Status;
PCSRSS_CONSOLE Console; PCSRSS_CONSOLE Console;
@ -1303,7 +1292,7 @@ NTSTATUS CsrSetConsoleMode( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST
return Reply->Status; return Reply->Status;
} }
NTSTATUS CsrGetConsoleMode( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrGetConsoleMode)
{ {
NTSTATUS Status; NTSTATUS Status;
PCSRSS_CONSOLE Console; PCSRSS_CONSOLE Console;
@ -1330,7 +1319,7 @@ NTSTATUS CsrGetConsoleMode( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST
return Reply->Status; return Reply->Status;
} }
NTSTATUS CsrCreateScreenBuffer( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrCreateScreenBuffer)
{ {
PCSRSS_SCREEN_BUFFER Buff = RtlAllocateHeap( CsrssApiHeap, 0, sizeof( CSRSS_SCREEN_BUFFER ) ); PCSRSS_SCREEN_BUFFER Buff = RtlAllocateHeap( CsrssApiHeap, 0, sizeof( CSRSS_SCREEN_BUFFER ) );
NTSTATUS Status; NTSTATUS Status;
@ -1353,7 +1342,7 @@ NTSTATUS CsrCreateScreenBuffer( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQU
return Reply->Status; return Reply->Status;
} }
NTSTATUS CsrSetScreenBuffer( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrSetScreenBuffer)
{ {
NTSTATUS Status; NTSTATUS Status;
PCSRSS_SCREEN_BUFFER Buff; PCSRSS_SCREEN_BUFFER Buff;
@ -1381,7 +1370,7 @@ NTSTATUS CsrSetScreenBuffer( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST
return Reply->Status; return Reply->Status;
} }
NTSTATUS CsrSetTitle( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request, PCSRSS_API_REPLY Reply ) CSR_API(CsrSetTitle)
{ {
NTSTATUS Status; NTSTATUS Status;
PCSRSS_CONSOLE Console; PCSRSS_CONSOLE Console;
@ -1402,3 +1391,40 @@ NTSTATUS CsrSetTitle( PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Reques
return Reply->Status; return Reply->Status;
} }
CSR_API(CsrGetTitle)
{
NTSTATUS Status;
PCSRSS_CONSOLE Console;
Reply->Header.MessageSize = sizeof (CSRSS_API_REPLY);
Reply->Header.DataSize =
sizeof (CSRSS_API_REPLY)
- sizeof(LPC_MESSAGE_HEADER);
LOCK;
Status = CsrGetObject (
ProcessData,
Request->Data.GetTitleRequest.ConsoleHandle,
(Object_t **) & Console
);
if ( !NT_SUCCESS( Status ) )
{
Reply->Status = Status;
}
else
{
/* Copy title of the console to the user title buffer */
RtlZeroMemory (
& Reply->Data.GetTitleReply,
sizeof (CSRSS_GET_TITLE_REPLY)
);
Reply->Data.GetTitleReply.ConsoleHandle =
Request->Data.GetTitleRequest.ConsoleHandle;
Reply->Data.GetTitleReply.Length = Console->Title.Length;
wcscpy (Reply->Data.GetTitleReply.Title, Console->Title.Buffer);
Reply->Status = STATUS_SUCCESS;
}
UNLOCK;
return Reply->Status;
}
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: handle.c,v 1.8 2001/01/21 00:11:54 phreak Exp $ /* $Id: handle.c,v 1.9 2001/08/14 12:57:16 ea Exp $
* *
* reactos/subsys/csrss/api/handle.c * reactos/subsys/csrss/api/handle.c
* *
@ -17,7 +17,7 @@
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
NTSTATUS CsrGetObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, Object_t **Object ) NTSTATUS STDCALL CsrGetObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, Object_t **Object )
{ {
// DbgPrint( "CsrGetObject, Object: %x, %x, %x\n", Object, Handle, ProcessData->HandleTableSize ); // DbgPrint( "CsrGetObject, Object: %x, %x, %x\n", Object, Handle, ProcessData->HandleTableSize );
if( (((ULONG)Handle) >> 2) - 1 > ProcessData->HandleTableSize ) if( (((ULONG)Handle) >> 2) - 1 > ProcessData->HandleTableSize )
@ -31,7 +31,7 @@ NTSTATUS CsrGetObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, Object_t
} }
NTSTATUS CsrReleaseObject(PCSRSS_PROCESS_DATA ProcessData, NTSTATUS STDCALL CsrReleaseObject(PCSRSS_PROCESS_DATA ProcessData,
HANDLE Handle) HANDLE Handle)
{ {
Object_t *Object; Object_t *Object;
@ -52,7 +52,7 @@ NTSTATUS CsrReleaseObject(PCSRSS_PROCESS_DATA ProcessData,
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
NTSTATUS CsrInsertObject( PCSRSS_PROCESS_DATA ProcessData, PHANDLE Handle, Object_t *Object ) NTSTATUS STDCALL CsrInsertObject( PCSRSS_PROCESS_DATA ProcessData, PHANDLE Handle, Object_t *Object )
{ {
ULONG i; ULONG i;
PVOID* NewBlock; PVOID* NewBlock;
@ -88,4 +88,4 @@ NTSTATUS CsrInsertObject( PCSRSS_PROCESS_DATA ProcessData, PHANDLE Handle, Objec
} }
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: process.c,v 1.12 2001/03/20 16:09:44 dwelch Exp $ /* $Id: process.c,v 1.13 2001/08/14 12:57:16 ea Exp $
* *
* reactos/subsys/csrss/api/process.c * reactos/subsys/csrss/api/process.c
* *
@ -15,6 +15,9 @@
#include <ntdll/rtl.h> #include <ntdll/rtl.h>
#include "api.h" #include "api.h"
#define LOCK RtlEnterCriticalSection(&ProcessDataLock)
#define UNLOCK RtlLeaveCriticalSection(&ProcessDataLock)
/* GLOBALS *******************************************************************/ /* GLOBALS *******************************************************************/
static ULONG NrProcess; static ULONG NrProcess;
@ -24,29 +27,31 @@ CRITICAL_SECTION ProcessDataLock;
/* FUNCTIONS *****************************************************************/ /* FUNCTIONS *****************************************************************/
VOID CsrInitProcessData(VOID) VOID STDCALL CsrInitProcessData(VOID)
{ {
ULONG i; /* ULONG i;
for (i=0; i<256; i++) for (i=0; i<256; i++)
{ {
ProcessData[i] = NULL; ProcessData[i] = NULL;
} }
NrProcess = 256; */
RtlZeroMemory (ProcessData, sizeof ProcessData);
NrProcess = sizeof ProcessData / sizeof ProcessData[0];
RtlInitializeCriticalSection( &ProcessDataLock ); RtlInitializeCriticalSection( &ProcessDataLock );
} }
PCSRSS_PROCESS_DATA CsrGetProcessData(ULONG ProcessId) PCSRSS_PROCESS_DATA STDCALL CsrGetProcessData(ULONG ProcessId)
{ {
ULONG i; ULONG i;
RtlEnterCriticalSection( &ProcessDataLock ); LOCK;
for (i=0; i<NrProcess; i++) for (i=0; i<NrProcess; i++)
{ {
if (ProcessData[i] && if (ProcessData[i] &&
ProcessData[i]->ProcessId == ProcessId) ProcessData[i]->ProcessId == ProcessId)
{ {
RtlLeaveCriticalSection( &ProcessDataLock ); UNLOCK;
return(ProcessData[i]); return(ProcessData[i]);
} }
} }
@ -59,23 +64,23 @@ PCSRSS_PROCESS_DATA CsrGetProcessData(ULONG ProcessId)
sizeof(CSRSS_PROCESS_DATA)); sizeof(CSRSS_PROCESS_DATA));
if (ProcessData[i] == NULL) if (ProcessData[i] == NULL)
{ {
RtlLeaveCriticalSection( &ProcessDataLock ); UNLOCK;
return(NULL); return(NULL);
} }
ProcessData[i]->ProcessId = ProcessId; ProcessData[i]->ProcessId = ProcessId;
RtlLeaveCriticalSection( &ProcessDataLock ); UNLOCK;
return(ProcessData[i]); return(ProcessData[i]);
} }
} }
// DbgPrint("CSR: CsrGetProcessData() failed\n"); // DbgPrint("CSR: CsrGetProcessData() failed\n");
RtlLeaveCriticalSection(&ProcessDataLock); UNLOCK;
return(NULL); return(NULL);
} }
NTSTATUS CsrFreeProcessData(ULONG Pid) NTSTATUS STDCALL CsrFreeProcessData(ULONG Pid)
{ {
int i; int i;
RtlEnterCriticalSection( &ProcessDataLock ); LOCK;
for( i = 0; i < NrProcess; i++ ) for( i = 0; i < NrProcess; i++ )
{ {
if( ProcessData[i] && ProcessData[i]->ProcessId == Pid ) if( ProcessData[i] && ProcessData[i]->ProcessId == Pid )
@ -95,18 +100,20 @@ NTSTATUS CsrFreeProcessData(ULONG Pid)
} }
RtlFreeHeap( CsrssApiHeap, 0, ProcessData[i] ); RtlFreeHeap( CsrssApiHeap, 0, ProcessData[i] );
ProcessData[i] = 0; ProcessData[i] = 0;
RtlLeaveCriticalSection( &ProcessDataLock ); UNLOCK;
return STATUS_SUCCESS; return STATUS_SUCCESS;
} }
} }
RtlLeaveCriticalSection( &ProcessDataLock ); UNLOCK;
return STATUS_INVALID_PARAMETER; return STATUS_INVALID_PARAMETER;
} }
NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData, /**********************************************************************
PCSRSS_API_REQUEST Request, * CSRSS API
PCSRSS_API_REPLY Reply) *********************************************************************/
CSR_API(CsrCreateProcess)
{ {
PCSRSS_PROCESS_DATA NewProcessData; PCSRSS_PROCESS_DATA NewProcessData;
NTSTATUS Status; NTSTATUS Status;
@ -186,22 +193,20 @@ NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData,
return(STATUS_SUCCESS); return(STATUS_SUCCESS);
} }
NTSTATUS CsrTerminateProcess(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrTerminateProcess)
PCSRSS_API_REQUEST LpcMessage,
PCSRSS_API_REPLY Reply)
{ {
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY) Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY)
- sizeof(LPC_MESSAGE_HEADER); - sizeof(LPC_MESSAGE_HEADER);
Reply->Header.DataSize = sizeof(CSRSS_API_REPLY); Reply->Header.DataSize = sizeof(CSRSS_API_REPLY);
DbgPrint("CSR: %s not implemented.\n", __FUNCTION__);
Reply->Status = STATUS_NOT_IMPLEMENTED; Reply->Status = STATUS_NOT_IMPLEMENTED;
return(STATUS_NOT_IMPLEMENTED); return(STATUS_NOT_IMPLEMENTED);
} }
NTSTATUS CsrConnectProcess(PCSRSS_PROCESS_DATA ProcessData, CSR_API(CsrConnectProcess)
PCSRSS_API_REQUEST Request,
PCSRSS_API_REPLY Reply)
{ {
Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY); Reply->Header.MessageSize = sizeof(CSRSS_API_REPLY);
Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) - Reply->Header.DataSize = sizeof(CSRSS_API_REPLY) -

View file

@ -1,4 +1,4 @@
/* $Id: wapi.c,v 1.13 2001/06/29 19:33:39 ekohl Exp $ /* $Id: wapi.c,v 1.14 2001/08/14 12:57:16 ea Exp $
* *
* reactos/subsys/csrss/api/wapi.c * reactos/subsys/csrss/api/wapi.c
* *
@ -48,6 +48,7 @@ static const CsrFunc CsrFuncs[] = {
CsrCreateScreenBuffer, CsrCreateScreenBuffer,
CsrSetScreenBuffer, CsrSetScreenBuffer,
CsrSetTitle, CsrSetTitle,
CsrGetTitle,
0 }; 0 };
static void Thread_Api2(HANDLE ServerPort) static void Thread_Api2(HANDLE ServerPort)
@ -159,3 +160,4 @@ void Thread_Api(PVOID PortHandle)
} }
} }
/* EOF */

View file

@ -1,4 +1,4 @@
/* $Id: csrss.c,v 1.8 2000/05/26 05:40:20 phreak Exp $ /* $Id: csrss.c,v 1.9 2001/08/14 12:57:16 ea Exp $
* *
* csrss.c - Client/Server Runtime subsystem * csrss.c - Client/Server Runtime subsystem
* *
@ -37,8 +37,6 @@
#include "api.h" #include "api.h"
VOID PrintString (char* fmt, ...);
/* Native process' entry point */ /* Native process' entry point */
VOID NtProcessStartup(PPEB Peb) VOID NtProcessStartup(PPEB Peb)

View file

@ -1,4 +1,4 @@
/* $Id: print.c,v 1.2 1999/12/30 01:51:41 dwelch Exp $ /* $Id: print.c,v 1.3 2001/08/14 12:57:16 ea Exp $
* *
* smss.c - Session Manager * smss.c - Session Manager
* *
@ -32,7 +32,7 @@
#include <csrss/csrss.h> #include <csrss/csrss.h>
VOID DisplayString(LPCWSTR lpwString) VOID STDCALL DisplayString(LPCWSTR lpwString)
{ {
UNICODE_STRING us; UNICODE_STRING us;
@ -40,7 +40,7 @@ VOID DisplayString(LPCWSTR lpwString)
NtDisplayString (&us); NtDisplayString (&us);
} }
VOID PrintString (char* fmt, ...) VOID STDCALL PrintString (char* fmt, ...)
{ {
char buffer[512]; char buffer[512];
va_list ap; va_list ap;
@ -59,3 +59,5 @@ VOID PrintString (char* fmt, ...)
NtDisplayString(&UnicodeString); NtDisplayString(&UnicodeString);
RtlFreeUnicodeString (&UnicodeString); RtlFreeUnicodeString (&UnicodeString);
} }
/* EOF */

View file

@ -1,3 +1,7 @@
/* $Id: video.c,v 1.3 2001/08/14 12:57:16 ea Exp $
*
* ReactOS Project
*/
#include <ddk/ntddk.h> #include <ddk/ntddk.h>
ULONG ULONG
@ -117,3 +121,6 @@ InitializeVideoAddressSpace(VOID)
return(1); return(1);
} }
/* EOF */