Author: hbelusca
Date: Fri Jan 18 22:31:16 2013
New Revision: 58191
URL:
http://svn.reactos.org/svn/reactos?rev=58191&view=rev
Log:
[CONSRV]
- Isolate the members of the CONSOLE structure which are used as input buffer data, in a
new structure called ... CONSOLE_INPUT_BUFFER !
- Rename some helper functions to better match what they are doing.
Modified:
branches/ros-csrss/win32ss/user/consrv/alias.c
branches/ros-csrss/win32ss/user/consrv/coninput.c
branches/ros-csrss/win32ss/user/consrv/conio.h
branches/ros-csrss/win32ss/user/consrv/conoutput.c
branches/ros-csrss/win32ss/user/consrv/console.c
branches/ros-csrss/win32ss/user/consrv/consrv.h
branches/ros-csrss/win32ss/user/consrv/handle.c
branches/ros-csrss/win32ss/user/consrv/init.c
branches/ros-csrss/win32ss/user/consrv/lineinput.c
Modified: branches/ros-csrss/win32ss/user/consrv/alias.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/a…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/alias.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/alias.c [iso-8859-1] Fri Jan 18 22:31:16 2013
@@ -324,7 +324,7 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@@ -411,7 +411,7 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@@ -468,7 +468,7 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@@ -516,7 +516,7 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@@ -552,7 +552,7 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@@ -587,7 +587,7 @@
PCONSOLE Console;
DPRINT("SrvGetConsoleAliasExesLength entered\n");
- ApiMessage->Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (NT_SUCCESS(ApiMessage->Status))
{
GetAliasesExesLengthRequest->Length =
IntGetConsoleAliasesExesLength(Console->Aliases);
Modified: branches/ros-csrss/win32ss/user/consrv/coninput.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/coninput.c [iso-8859-1] Fri Jan 18 22:31:16
2013
@@ -60,7 +60,7 @@
if (!(Console->PauseFlags & PAUSED_FROM_KEYBOARD))
{
DWORD cks = InputEvent->Event.KeyEvent.dwControlKeyState;
- if (Console->Mode & ENABLE_LINE_INPUT &&
+ if (Console->InputBuffer.Mode & ENABLE_LINE_INPUT &&
(vk == VK_PAUSE || (vk == 'S' &&
(cks & (LEFT_CTRL_PRESSED | RIGHT_CTRL_PRESSED))
&&
!(cks & (LEFT_ALT_PRESSED |
RIGHT_ALT_PRESSED)))))
@@ -85,10 +85,10 @@
if (ConInRec == NULL)
return STATUS_INSUFFICIENT_RESOURCES;
ConInRec->InputEvent = *InputEvent;
- InsertTailList(&Console->InputEvents, &ConInRec->ListEntry);
-
- SetEvent(Console->ActiveEvent);
- CsrNotifyWait(&Console->ReadWaitQueue,
+ InsertTailList(&Console->InputBuffer.InputEvents,
&ConInRec->ListEntry);
+
+ SetEvent(Console->InputBuffer.ActiveEvent);
+ CsrNotifyWait(&Console->InputBuffer.ReadWaitQueue,
WaitAny,
NULL,
NULL);
@@ -239,7 +239,7 @@
return;
/* process Ctrl-C and Ctrl-Break */
- if (Console->Mode & ENABLE_PROCESSED_INPUT &&
+ if (Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT &&
er.Event.KeyEvent.bKeyDown &&
((er.Event.KeyEvent.wVirtualKeyCode == VK_PAUSE) ||
(er.Event.KeyEvent.wVirtualKeyCode == 'C')) &&
@@ -317,7 +317,7 @@
memmove(CapturedInputInfo, InputInfo, sizeof(GET_INPUT_INFO));
- if (!CsrCreateWait(&InputInfo->Console->ReadWaitQueue,
+ if (!CsrCreateWait(&InputInfo->Console->InputBuffer.ReadWaitQueue,
WaitFunction,
CsrGetClientThread(),
ApiMessage,
@@ -373,7 +373,7 @@
IN PCSR_API_MESSAGE ApiMessage,
IN BOOL CreateWaitBlock OPTIONAL)
{
- if (IsListEmpty(&InputInfo->Console->InputEvents))
+ if (IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents))
{
if (Wait)
{
@@ -397,9 +397,9 @@
PINPUT_RECORD InputRecord = GetInputRequest->InputRecord;
/* Only get input if there is any */
- CurrentInput = InputInfo->Console->InputEvents.Flink;
-
- while ( CurrentInput != &InputInfo->Console->InputEvents &&
+ CurrentInput = InputInfo->Console->InputBuffer.InputEvents.Flink;
+
+ while ( CurrentInput != &InputInfo->Console->InputBuffer.InputEvents
&&
GetInputRequest->InputsRead < Length )
{
Input = CONTAINING_RECORD(CurrentInput, ConsoleInput, ListEntry);
@@ -422,9 +422,9 @@
}
}
- if (IsListEmpty(&InputInfo->Console->InputEvents))
- {
- ResetEvent(InputInfo->Console->ActiveEvent);
+ if (IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents))
+ {
+ ResetEvent(InputInfo->Console->InputBuffer.ActiveEvent);
}
/* We read all the inputs available, we return success */
@@ -479,7 +479,7 @@
/* We haven't read anything (yet) */
- if (InputInfo->Console->Mode & ENABLE_LINE_INPUT)
+ if (InputInfo->Console->InputBuffer.Mode & ENABLE_LINE_INPUT)
{
if (InputInfo->Console->LineBuffer == NULL)
{
@@ -511,13 +511,13 @@
/* If we don't have a complete line yet, process the pending input */
while ( !InputInfo->Console->LineComplete &&
- !IsListEmpty(&InputInfo->Console->InputEvents) )
+ !IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents) )
{
/* Remove input event from queue */
- CurrentEntry = RemoveHeadList(&InputInfo->Console->InputEvents);
- if (IsListEmpty(&InputInfo->Console->InputEvents))
- {
- ResetEvent(InputInfo->Console->ActiveEvent);
+ CurrentEntry =
RemoveHeadList(&InputInfo->Console->InputBuffer.InputEvents);
+ if (IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents))
+ {
+ ResetEvent(InputInfo->Console->InputBuffer.ActiveEvent);
}
Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
@@ -567,13 +567,13 @@
{
/* Character input */
while ( ReadConsoleRequest->NrCharactersRead < nNumberOfCharsToRead
&&
- !IsListEmpty(&InputInfo->Console->InputEvents) )
+ !IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents) )
{
/* Remove input event from queue */
- CurrentEntry = RemoveHeadList(&InputInfo->Console->InputEvents);
- if (IsListEmpty(&InputInfo->Console->InputEvents))
- {
- ResetEvent(InputInfo->Console->ActiveEvent);
+ CurrentEntry =
RemoveHeadList(&InputInfo->Console->InputBuffer.InputEvents);
+ if (IsListEmpty(&InputInfo->Console->InputBuffer.InputEvents))
+ {
+ ResetEvent(InputInfo->Console->InputBuffer.ActiveEvent);
}
Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
@@ -626,7 +626,7 @@
NTSTATUS Status;
PCONSOLE_GETINPUT GetInputRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetInputRequest;
PCONSOLE_PROCESS_DATA ProcessData =
ConsoleGetPerProcessData(CsrGetClientThread()->Process);
- PCONSOLE Console;
+ PCONSOLE_INPUT_BUFFER InputBuffer;
GET_INPUT_INFO InputInfo;
DPRINT("SrvGetConsoleInput\n");
@@ -639,20 +639,20 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockConsole(ProcessData, GetInputRequest->InputHandle, &Console,
GENERIC_READ);
+ Status = ConioLockInputBuffer(ProcessData, GetInputRequest->InputHandle,
&InputBuffer, GENERIC_READ);
if(!NT_SUCCESS(Status)) return Status;
GetInputRequest->InputsRead = 0;
InputInfo.ProcessData = ProcessData; //
ConsoleGetPerProcessData(CsrGetClientThread()->Process);
- InputInfo.Console = Console;
+ InputInfo.Console = InputBuffer->Header.Console;
Status = ReadInputBuffer(&InputInfo,
GetInputRequest->bRead,
ApiMessage,
TRUE);
- ConioUnlockConsole(Console);
+ ConioUnlockInputBuffer(InputBuffer);
if (Status == STATUS_PENDING)
*ReplyCode = CsrReplyPending;
@@ -666,6 +666,7 @@
PCONSOLE_WRITEINPUT WriteInputRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.WriteInputRequest;
PINPUT_RECORD InputRecord;
PCONSOLE_PROCESS_DATA ProcessData =
ConsoleGetPerProcessData(CsrGetClientThread()->Process);
+ PCONSOLE_INPUT_BUFFER InputBuffer;
PCONSOLE Console;
DWORD Length;
DWORD i;
@@ -680,9 +681,10 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockConsole(ProcessData, WriteInputRequest->InputHandle,
&Console, GENERIC_WRITE);
+ Status = ConioLockInputBuffer(ProcessData, WriteInputRequest->InputHandle,
&InputBuffer, GENERIC_WRITE);
if (!NT_SUCCESS(Status)) return Status;
+ Console = InputBuffer->Header.Console;
InputRecord = WriteInputRequest->InputRecord;
Length = WriteInputRequest->Length;
@@ -700,7 +702,7 @@
Status = ConioProcessChar(Console, InputRecord++);
}
- ConioUnlockConsole(Console);
+ ConioUnlockInputBuffer(InputBuffer);
WriteInputRequest->Length = i;
@@ -712,7 +714,7 @@
NTSTATUS Status;
PCONSOLE_READCONSOLE ReadConsoleRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ReadConsoleRequest;
PCONSOLE_PROCESS_DATA ProcessData =
ConsoleGetPerProcessData(CsrGetClientThread()->Process);
- PCONSOLE Console;
+ PCONSOLE_INPUT_BUFFER InputBuffer;
GET_INPUT_INFO InputInfo;
DPRINT("SrvReadConsole\n");
@@ -731,19 +733,19 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockConsole(ProcessData, ReadConsoleRequest->InputHandle,
&Console, GENERIC_READ);
+ Status = ConioLockInputBuffer(ProcessData, ReadConsoleRequest->InputHandle,
&InputBuffer, GENERIC_READ);
if (!NT_SUCCESS(Status)) return Status;
ReadConsoleRequest->NrCharactersRead = 0;
InputInfo.ProcessData = ProcessData; //
ConsoleGetPerProcessData(CsrGetClientThread()->Process);
- InputInfo.Console = Console;
+ InputInfo.Console = InputBuffer->Header.Console;
Status = ReadChars(&InputInfo,
ApiMessage,
TRUE);
- ConioUnlockConsole(Console);
+ ConioUnlockInputBuffer(InputBuffer);
if (Status == STATUS_PENDING)
*ReplyCode = CsrReplyPending;
@@ -756,28 +758,28 @@
NTSTATUS Status;
PCONSOLE_FLUSHINPUTBUFFER FlushInputBufferRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.FlushInputBufferRequest;
PLIST_ENTRY CurrentEntry;
- PCONSOLE Console;
+ PCONSOLE_INPUT_BUFFER InputBuffer;
ConsoleInput* Input;
DPRINT("SrvFlushConsoleInputBuffer\n");
- Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ Status =
ConioLockInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
FlushInputBufferRequest->InputHandle,
- &Console,
+ &InputBuffer,
GENERIC_WRITE);
if(!NT_SUCCESS(Status)) return Status;
/* Discard all entries in the input event queue */
- while (!IsListEmpty(&Console->InputEvents))
- {
- CurrentEntry = RemoveHeadList(&Console->InputEvents);
+ while (!IsListEmpty(&InputBuffer->InputEvents))
+ {
+ CurrentEntry = RemoveHeadList(&InputBuffer->InputEvents);
Input = CONTAINING_RECORD(CurrentEntry, ConsoleInput, ListEntry);
/* Destroy the event */
RtlFreeHeap(ConSrvHeap, 0, Input);
}
- ResetEvent(Console->ActiveEvent);
-
- ConioUnlockConsole(Console);
+ ResetEvent(InputBuffer->ActiveEvent);
+
+ ConioUnlockInputBuffer(InputBuffer);
return STATUS_SUCCESS;
}
@@ -786,26 +788,26 @@
{
NTSTATUS Status;
PCONSOLE_GETNUMINPUTEVENTS GetNumInputEventsRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetNumInputEventsRequest;
- PCONSOLE Console;
+ PCONSOLE_INPUT_BUFFER InputBuffer;
PLIST_ENTRY CurrentInput;
DWORD NumEvents;
DPRINT("SrvGetConsoleNumberOfInputEvents\n");
- Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
GetNumInputEventsRequest->InputHandle, &Console, GENERIC_READ);
+ Status =
ConioLockInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
GetNumInputEventsRequest->InputHandle, &InputBuffer, GENERIC_READ);
if (!NT_SUCCESS(Status)) return Status;
- CurrentInput = Console->InputEvents.Flink;
+ CurrentInput = InputBuffer->InputEvents.Flink;
NumEvents = 0;
/* If there are any events ... */
- while (CurrentInput != &Console->InputEvents)
+ while (CurrentInput != &InputBuffer->InputEvents)
{
CurrentInput = CurrentInput->Flink;
NumEvents++;
}
- ConioUnlockConsole(Console);
+ ConioUnlockInputBuffer(InputBuffer);
GetNumInputEventsRequest->NumInputEvents = NumEvents;
Modified: branches/ros-csrss/win32ss/user/consrv/conio.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/conio.h [iso-8859-1] Fri Jan 18 22:31:16 2013
@@ -28,46 +28,58 @@
typedef struct _CONSOLE_SCREEN_BUFFER
{
- Object_t Header; /* Object header */
- LIST_ENTRY ListEntry; /* Entry in console's list of buffers */
-
- BYTE *Buffer; /* Pointer to screen buffer */
- USHORT MaxX, MaxY; /* Size of the entire scrollback buffer */
- USHORT ShowX, ShowY; /* Beginning offset for the actual display area */
- ULONG CurrentX; /* Current X cursor position */
- ULONG CurrentY; /* Current Y cursor position */
- WORD DefaultAttrib; /* Default char attribute */
- USHORT VirtualY; /* Top row of buffer being displayed, reported to
callers */
+ Object_t Header; /* Object header */
+ LIST_ENTRY ListEntry; /* Entry in console's list of buffers */
+
+ BYTE *Buffer; /* Pointer to screen buffer */
+ USHORT MaxX, MaxY; /* Size of the entire scrollback buffer */
+ USHORT ShowX, ShowY; /* Beginning offset for the actual display area */
+ ULONG CurrentX; /* Current X cursor position */
+ ULONG CurrentY; /* Current Y cursor position */
+ WORD DefaultAttrib; /* Default char attribute */
+ USHORT VirtualY; /* Top row of buffer being displayed, reported to
callers */
CONSOLE_CURSOR_INFO CursorInfo;
USHORT Mode;
} CONSOLE_SCREEN_BUFFER, *PCONSOLE_SCREEN_BUFFER;
+typedef struct _CONSOLE_INPUT_BUFFER
+{
+ Object_t Header; /* Object header */
+
+ LIST_ENTRY InputEvents; /* List head for input event queue */
+ HANDLE ActiveEvent; /* Event set when an input event is added in its
queue */
+ LIST_ENTRY ReadWaitQueue; /* List head for the queue of read wait blocks */
+ WORD Mode; /* Console Input Buffer mode flags */
+} CONSOLE_INPUT_BUFFER, *PCONSOLE_INPUT_BUFFER;
+
+typedef struct ConsoleInput_t
+{
+ LIST_ENTRY ListEntry;
+ INPUT_RECORD InputEvent;
+} ConsoleInput;
+
typedef struct _CONSOLE
{
- Object_t Header; /* Object header */
- LONG ReferenceCount; /* Is incremented each time a handle to a
screen-buffer or the input buffer of this console gets referenced, or the console gets
locked */
+ LONG ReferenceCount; /* Is incremented each time a handle to a
screen-buffer or the input buffer of this console gets referenced, or the console gets
locked */
CRITICAL_SECTION Lock;
- struct _CONSOLE *Prev, *Next; /* Next and Prev consoles in console wheel */
- struct _CONSOLE_VTBL *Vtbl; /* Using CUI or GUI consoles */
-
- CLIENT_ID ConsoleLeaderCID; /* Contains the Console Leader Process CID for
this console. TODO: Is it possible to compute it via the contents of the ProcessList list
?? */
+ struct _CONSOLE *Prev, *Next; /* Next and Prev consoles in console wheel
*/
+ struct _CONSOLE_VTBL *Vtbl; /* Using CUI or GUI consoles */
+
+ CLIENT_ID ConsoleLeaderCID; /* Contains the Console Leader Process CID
for this console. TODO: Is it possible to compute it via the contents of the ProcessList
list ?? */
LIST_ENTRY ProcessList;
/**************************** Input buffer and data ***************************/
- LIST_ENTRY InputEvents; /* List head for input event queue */
- HANDLE ActiveEvent; /* Event set when an input event is added in
its queue */
- LIST_ENTRY ReadWaitQueue; /* List head for the queue of read wait blocks
*/
- WORD Mode; /* Console Input Buffer mode flags */
-
- PWCHAR LineBuffer; /* current line being input, in line buffered
mode */
- WORD LineMaxSize; /* maximum size of line in characters
(including CR+LF) */
- WORD LineSize; /* current size of line */
- WORD LinePos; /* current position within line */
- BOOLEAN LineComplete; /* user pressed enter, ready to send back to
client */
+ CONSOLE_INPUT_BUFFER InputBuffer; /* Input buffer of the console */
+
+ PWCHAR LineBuffer; /* Current line being input, in line buffered
mode */
+ WORD LineMaxSize; /* Maximum size of line in characters
(including CR+LF) */
+ WORD LineSize; /* Current size of line */
+ WORD LinePos; /* Current position within line */
+ BOOLEAN LineComplete; /* User pressed enter, ready to send back to
client */
BOOLEAN LineUpPressed;
- BOOLEAN LineInsertToggle; /* replace character over cursor instead of
inserting */
- ULONG LineWakeupMask; /* bitmap of which control characters will end
line input */
+ BOOLEAN LineInsertToggle; /* Replace character over cursor instead of
inserting */
+ ULONG LineWakeupMask; /* Bitmap of which control characters will
end line input */
UINT CodePage;
UINT OutputCodePage;
@@ -77,21 +89,21 @@
/**************************** Aliases and Histories ***************************/
struct _ALIAS_HEADER *Aliases;
LIST_ENTRY HistoryBuffers;
- UINT HistoryBufferSize; /* size for newly created history buffers */
- UINT NumberOfHistoryBuffers; /* maximum number of history buffers allowed
*/
- BOOLEAN HistoryNoDup; /* remove old duplicate history entries */
+ UINT HistoryBufferSize; /* Size for newly created history buffers */
+ UINT NumberOfHistoryBuffers; /* Maximum number of history buffers allowed
*/
+ BOOLEAN HistoryNoDup; /* Remove old duplicate history entries */
/******************************* Screen buffers *******************************/
- LIST_ENTRY BufferList; /* List of all screen buffers for this console
*/
- PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer
*/
+ LIST_ENTRY BufferList; /* List of all screen buffers for this
console */
+ PCONSOLE_SCREEN_BUFFER ActiveBuffer; /* Pointer to currently active screen buffer
*/
BYTE PauseFlags;
HANDLE UnpauseEvent;
- LIST_ENTRY WriteWaitQueue; /* List head for the queue of write wait blocks
*/
-
- DWORD HardwareState; /* _GDI_MANAGED, _DIRECT */
+ LIST_ENTRY WriteWaitQueue; /* List head for the queue of write wait
blocks */
+
+ DWORD HardwareState; /* _GDI_MANAGED, _DIRECT */
/****************************** GUI-related data ******************************/
- UNICODE_STRING Title; /* Title of console */
+ UNICODE_STRING Title; /* Title of console */
HWND hWindow;
COORD Size;
PVOID PrivateData;
@@ -126,12 +138,6 @@
BOOL (WINAPI *ChangeIcon)(PCONSOLE Console, HICON hWindowIcon);
NTSTATUS (WINAPI *ResizeBuffer)(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER
ScreenBuffer, COORD Size);
} CONSOLE_VTBL, *PCONSOLE_VTBL;
-
-typedef struct ConsoleInput_t
-{
- LIST_ENTRY ListEntry;
- INPUT_RECORD InputEvent;
-} ConsoleInput;
/* CONSOLE_SELECTION_INFO dwFlags values */
#define CONSOLE_NO_SELECTION 0x0
@@ -163,8 +169,10 @@
#define ConioResizeBuffer(Console, Buff, Size)
(Console)->Vtbl->ResizeBuffer(Console, Buff, Size)
/* console.c */
-NTSTATUS FASTCALL ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
- PCONSOLE *Console);
+#define ConioLockConsole(ProcessData, Console) \
+ ConioConsoleFromProcessData((ProcessData), (Console))
+#define ConioUnlockConsole(Console) \
+ Win32CsrUnlockConsole(Console)
VOID WINAPI ConioDeleteConsole(PCONSOLE Console);
VOID WINAPI CsrInitConsoleSupport(VOID);
NTSTATUS WINAPI CsrInitConsole(PCONSOLE* NewConsole, int ShowCmd, PCSR_PROCESS
ConsoleLeaderProcess);
@@ -176,10 +184,10 @@
DWORD Timeout);
/* coninput.c */
-#define ConioLockConsole(ProcessData, Handle, Ptr, Access) \
- Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access,
CONIO_CONSOLE_MAGIC)
-#define ConioUnlockConsole(Console) \
- Win32CsrUnlockObject((Object_t *) Console)
+#define ConioLockInputBuffer(ProcessData, Handle, Ptr, Access) \
+ Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), (Access),
CONIO_INPUT_BUFFER_MAGIC)
+#define ConioUnlockInputBuffer(Buff) \
+ Win32CsrUnlockObject(&(Buff)->Header)
void WINAPI ConioProcessKey(MSG *msg, PCONSOLE Console, BOOL TextMode);
/* conoutput.c */
@@ -188,9 +196,9 @@
#define ConioRectWidth(Rect) \
(((Rect)->Left) > ((Rect)->Right) ? 0 : ((Rect)->Right) -
((Rect)->Left) + 1)
#define ConioLockScreenBuffer(ProcessData, Handle, Ptr, Access) \
- Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), Access,
CONIO_SCREEN_BUFFER_MAGIC)
+ Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), (Access),
CONIO_SCREEN_BUFFER_MAGIC)
#define ConioUnlockScreenBuffer(Buff) \
- Win32CsrUnlockObject((Object_t *) Buff)
+ Win32CsrUnlockObject(&(Buff)->Header)
PBYTE FASTCALL ConioCoordToPointer(PCONSOLE_SCREEN_BUFFER Buf, ULONG X, ULONG Y);
VOID FASTCALL ConioDrawConsole(PCONSOLE Console);
NTSTATUS FASTCALL ConioWriteConsole(PCONSOLE Console, PCONSOLE_SCREEN_BUFFER Buff,
Modified: branches/ros-csrss/win32ss/user/consrv/conoutput.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/conoutput.c [iso-8859-1] Fri Jan 18 22:31:16
2013
@@ -1228,7 +1228,7 @@
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
- Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ Status = ConioLockConsole(ProcessData, &Console);
if (!NT_SUCCESS(Status))
{
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
Modified: branches/ros-csrss/win32ss/user/consrv/console.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/console.c [iso-8859-1] Fri Jan 18 22:31:16
2013
@@ -31,30 +31,6 @@
return VisibleDesktopWindow != NULL;
}
-NTSTATUS FASTCALL
-ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
- PCONSOLE *Console)
-{
- PCONSOLE ProcessConsole;
-
- RtlEnterCriticalSection(&ProcessData->HandleTableLock);
- ProcessConsole = ProcessData->Console;
-
- if (!ProcessConsole)
- {
- *Console = NULL;
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- return STATUS_INVALID_HANDLE;
- }
-
- InterlockedIncrement(&ProcessConsole->ReferenceCount);
- RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- EnterCriticalSection(&(ProcessConsole->Lock));
- *Console = ProcessConsole;
-
- return STATUS_SUCCESS;
-}
-
VOID FASTCALL
ConioConsoleCtrlEventTimeout(DWORD Event,
PCONSOLE_PROCESS_DATA ProcessData,
@@ -124,16 +100,19 @@
Console->ReferenceCount = 0;
Console->LineBuffer = NULL;
- Console->Header.Type = CONIO_CONSOLE_MAGIC;
- Console->Header.Console = Console;
- Console->Mode = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT | ENABLE_PROCESSED_INPUT |
ENABLE_MOUSE_INPUT;
Console->ConsoleLeaderCID = ConsoleLeaderProcess->ClientId;
InitializeListHead(&Console->ProcessList);
InitializeListHead(&Console->BufferList);
Console->ActiveBuffer = NULL;
- InitializeListHead(&Console->ReadWaitQueue);
+
+ /* Initialize the input buffer */
+ Console->InputBuffer.Header.Type = CONIO_INPUT_BUFFER_MAGIC;
+ Console->InputBuffer.Header.Console = Console;
+ Console->InputBuffer.Mode = ENABLE_LINE_INPUT | ENABLE_ECHO_INPUT |
ENABLE_PROCESSED_INPUT | ENABLE_MOUSE_INPUT;
+ InitializeListHead(&Console->InputBuffer.ReadWaitQueue);
+ InitializeListHead(&Console->InputBuffer.InputEvents);
+
InitializeListHead(&Console->WriteWaitQueue);
- InitializeListHead(&Console->InputEvents);
InitializeListHead(&Console->HistoryBuffers);
Console->CodePage = GetOEMCP();
Console->OutputCodePage = GetOEMCP();
@@ -142,8 +121,8 @@
SecurityAttributes.lpSecurityDescriptor = NULL;
SecurityAttributes.bInheritHandle = TRUE;
- Console->ActiveEvent = CreateEventW(&SecurityAttributes, TRUE, FALSE, NULL);
- if (NULL == Console->ActiveEvent)
+ Console->InputBuffer.ActiveEvent = CreateEventW(&SecurityAttributes, TRUE,
FALSE, NULL);
+ if (NULL == Console->InputBuffer.ActiveEvent)
{
RtlFreeUnicodeString(&Console->Title);
RtlFreeHeap(ConSrvHeap, 0, Console);
@@ -160,7 +139,7 @@
{
RtlFreeUnicodeString(&Console->Title);
DeleteCriticalSection(&Console->Lock);
- CloseHandle(Console->ActiveEvent);
+ CloseHandle(Console->InputBuffer.ActiveEvent);
RtlFreeHeap(ConSrvHeap, 0, Console);
return STATUS_INSUFFICIENT_RESOURCES;
}
@@ -168,7 +147,7 @@
NewBuffer->CursorInfo.bVisible = TRUE;
NewBuffer->CursorInfo.dwSize = CSR_DEFAULT_CURSOR_SIZE;
/* make console active, and insert into console list */
- Console->ActiveBuffer = (PCONSOLE_SCREEN_BUFFER) NewBuffer;
+ Console->ActiveBuffer = (PCONSOLE_SCREEN_BUFFER)NewBuffer;
/*
* If we are not in GUI-mode, start the text-mode console. If we fail,
@@ -203,7 +182,7 @@
RtlFreeHeap(ConSrvHeap,0, NewBuffer);
RtlFreeUnicodeString(&Console->Title);
DeleteCriticalSection(&Console->Lock);
- CloseHandle(Console->ActiveEvent);
+ CloseHandle(Console->InputBuffer.ActiveEvent);
DPRINT1("GuiInitConsole: failed, Status = 0x%08lx\n", Status);
RtlFreeHeap(ConSrvHeap, 0, Console);
return Status;
@@ -216,7 +195,7 @@
ConioCleanupConsole(Console);
RtlFreeUnicodeString(&Console->Title);
DeleteCriticalSection(&Console->Lock);
- CloseHandle(Console->ActiveEvent);
+ CloseHandle(Console->InputBuffer.ActiveEvent);
RtlFreeHeap(ConSrvHeap, 0, NewBuffer);
DPRINT1("CsrInitConsoleScreenBuffer: failed\n");
RtlFreeHeap(ConSrvHeap, 0, Console);
@@ -259,9 +238,13 @@
DPRINT1("SrvOpenConsole - Checkpoint 3\n");
if (OpenConsoleRequest->HandleType == HANDLE_OUTPUT)
+ {
Object = &Console->ActiveBuffer->Header;
+ }
else // HANDLE_INPUT
- Object = &Console->Header;
+ {
+ Object = &Console->InputBuffer.Header;
+ }
if (((DesiredAccess & GENERIC_READ) && Object->ExclusiveRead !=
0) ||
((DesiredAccess & GENERIC_WRITE) && Object->ExclusiveWrite !=
0) ||
@@ -342,7 +325,7 @@
/* Duplicate the Event */
Status = NtDuplicateObject(NtCurrentProcess(),
- ProcessData->Console->ActiveEvent,
+ ProcessData->Console->InputBuffer.ActiveEvent,
ProcessData->Process->ProcessHandle,
&ProcessData->ConsoleEvent,
EVENT_ALL_ACCESS, 0, 0);
@@ -476,7 +459,7 @@
/* Duplicate the Event */
Status = NtDuplicateObject(NtCurrentProcess(),
- TargetProcessData->Console->ActiveEvent,
+
TargetProcessData->Console->InputBuffer.ActiveEvent,
TargetProcessData->Process->ProcessHandle,
&TargetProcessData->ConsoleEvent,
EVENT_ALL_ACCESS, 0, 0);
@@ -524,11 +507,11 @@
DPRINT("ConioDeleteConsole\n");
/* Drain input event queue */
- while (Console->InputEvents.Flink != &Console->InputEvents)
- {
- Event = (ConsoleInput *) Console->InputEvents.Flink;
- Console->InputEvents.Flink = Console->InputEvents.Flink->Flink;
- Console->InputEvents.Flink->Flink->Blink =
&Console->InputEvents;
+ while (Console->InputBuffer.InputEvents.Flink !=
&Console->InputBuffer.InputEvents)
+ {
+ Event = (ConsoleInput *) Console->InputBuffer.InputEvents.Flink;
+ Console->InputBuffer.InputEvents.Flink =
Console->InputBuffer.InputEvents.Flink->Flink;
+ Console->InputBuffer.InputEvents.Flink->Flink->Blink =
&Console->InputBuffer.InputEvents;
RtlFreeHeap(ConSrvHeap, 0, Event);
}
@@ -544,7 +527,7 @@
DPRINT1("BUG: screen buffer list not empty\n");
}
- CloseHandle(Console->ActiveEvent);
+ CloseHandle(Console->InputBuffer.ActiveEvent);
if (Console->UnpauseEvent) CloseHandle(Console->UnpauseEvent);
DeleteCriticalSection(&Console->Lock);
RtlFreeUnicodeString(&Console->Title);
@@ -591,24 +574,25 @@
{
NTSTATUS Status;
PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
- PCONSOLE Console;
- PCONSOLE_SCREEN_BUFFER Buff;
+ Object_t* Object = NULL;
DPRINT("SrvSetConsoleMode\n");
Status =
Win32CsrLockObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
ConsoleModeRequest->ConsoleHandle,
- (Object_t **) &Console, GENERIC_WRITE, 0);
+ &Object, GENERIC_WRITE, 0);
if (!NT_SUCCESS(Status)) return Status;
- Buff = (PCONSOLE_SCREEN_BUFFER)Console;
-
- if (CONIO_CONSOLE_MAGIC == Console->Header.Type)
- {
- Console->Mode = ConsoleModeRequest->ConsoleMode &
CONSOLE_INPUT_MODE_VALID;
- }
- else if (CONIO_SCREEN_BUFFER_MAGIC == Console->Header.Type)
- {
+ Status = STATUS_SUCCESS;
+
+ if (CONIO_INPUT_BUFFER_MAGIC == Object->Type)
+ {
+ PCONSOLE Console = (PCONSOLE)Object;
+ Console->InputBuffer.Mode = ConsoleModeRequest->ConsoleMode &
CONSOLE_INPUT_MODE_VALID;
+ }
+ else if (CONIO_SCREEN_BUFFER_MAGIC == Object->Type)
+ {
+ PCONSOLE_SCREEN_BUFFER Buff = (PCONSOLE_SCREEN_BUFFER)Object;
Buff->Mode = ConsoleModeRequest->ConsoleMode &
CONSOLE_OUTPUT_MODE_VALID;
}
else
@@ -616,7 +600,7 @@
Status = STATUS_INVALID_HANDLE;
}
- Win32CsrUnlockObject((Object_t *)Console);
+ Win32CsrUnlockObject(Object);
return Status;
}
@@ -625,25 +609,25 @@
{
NTSTATUS Status;
PCONSOLE_GETSETCONSOLEMODE ConsoleModeRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.ConsoleModeRequest;
- PCONSOLE Console;
- PCONSOLE_SCREEN_BUFFER Buff;
+ Object_t* Object = NULL;
DPRINT("SrvGetConsoleMode\n");
Status =
Win32CsrLockObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
ConsoleModeRequest->ConsoleHandle,
- (Object_t **) &Console, GENERIC_READ, 0);
+ &Object, GENERIC_READ, 0);
if (!NT_SUCCESS(Status)) return Status;
Status = STATUS_SUCCESS;
- Buff = (PCONSOLE_SCREEN_BUFFER) Console;
-
- if (CONIO_CONSOLE_MAGIC == Console->Header.Type)
- {
- ConsoleModeRequest->ConsoleMode = Console->Mode;
- }
- else if (CONIO_SCREEN_BUFFER_MAGIC == Buff->Header.Type)
- {
+
+ if (CONIO_INPUT_BUFFER_MAGIC == Object->Type)
+ {
+ PCONSOLE Console = (PCONSOLE)Object;
+ ConsoleModeRequest->ConsoleMode = Console->InputBuffer.Mode;
+ }
+ else if (CONIO_SCREEN_BUFFER_MAGIC == Object->Type)
+ {
+ PCONSOLE_SCREEN_BUFFER Buff = (PCONSOLE_SCREEN_BUFFER)Object;
ConsoleModeRequest->ConsoleMode = Buff->Mode;
}
else
@@ -651,7 +635,8 @@
Status = STATUS_INVALID_HANDLE;
}
- Win32CsrUnlockObject((Object_t *)Console);
+ Win32CsrUnlockObject(Object);
+
return Status;
}
@@ -673,7 +658,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if(NT_SUCCESS(Status))
{
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, TitleRequest->Length);
@@ -723,7 +708,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(Status))
{
DPRINT1("Can't get console\n");
@@ -783,13 +768,14 @@
{
NTSTATUS Status;
PCONSOLE_GETSETHWSTATE HardwareStateRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HardwareStateRequest;
+ PCONSOLE_SCREEN_BUFFER Buff;
PCONSOLE Console;
DPRINT("SrvGetConsoleHardwareState\n");
- Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
HardwareStateRequest->OutputHandle,
- &Console,
+ &Buff,
GENERIC_READ);
if (!NT_SUCCESS(Status))
{
@@ -797,9 +783,10 @@
return Status;
}
+ Console = Buff->Header.Console;
HardwareStateRequest->State = Console->HardwareState;
- ConioUnlockConsole(Console);
+ ConioUnlockScreenBuffer(Buff);
return Status;
}
@@ -808,13 +795,14 @@
{
NTSTATUS Status;
PCONSOLE_GETSETHWSTATE HardwareStateRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HardwareStateRequest;
+ PCONSOLE_SCREEN_BUFFER Buff;
PCONSOLE Console;
DPRINT("SrvSetConsoleHardwareState\n");
- Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
HardwareStateRequest->OutputHandle,
- &Console,
+ &Buff,
GENERIC_READ);
if (!NT_SUCCESS(Status))
{
@@ -823,9 +811,10 @@
}
DPRINT("Setting console hardware state.\n");
+ Console = Buff->Header.Console;
Status = SetConsoleHardwareState(Console, HardwareStateRequest->State);
- ConioUnlockConsole(Console);
+ ConioUnlockScreenBuffer(Buff);
return Status;
}
@@ -838,7 +827,7 @@
DPRINT("SrvGetConsoleWindow\n");
- Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(Status)) return Status;
GetWindowRequest->WindowHandle = Console->hWindow;
@@ -855,7 +844,7 @@
DPRINT("SrvSetConsoleIcon\n");
- Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(Status)) return Status;
Status = (ConioChangeIcon(Console, SetIconRequest->WindowIcon)
@@ -876,7 +865,7 @@
DPRINT("SrvGetConsoleCP, getting %s Code Page\n",
ConsoleCPRequest->InputCP ? "Input" : "Output");
- Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(Status)) return Status;
ConsoleCPRequest->CodePage = (ConsoleCPRequest->InputCP ? Console->CodePage
@@ -894,7 +883,7 @@
DPRINT("SrvSetConsoleCP, setting %s Code Page\n",
ConsoleCPRequest->InputCP ? "Input" : "Output");
- Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(Status)) return Status;
if (IsValidCodePage(ConsoleCPRequest->CodePage))
@@ -935,7 +924,7 @@
Buffer = GetProcessListRequest->pProcessIds;
- Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(Status)) return Status;
for (current_entry = Console->ProcessList.Flink;
@@ -964,7 +953,7 @@
PLIST_ENTRY current_entry;
DWORD Group;
- Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (!NT_SUCCESS(Status)) return Status;
Group = GenerateCtrlEventRequest->ProcessGroup;
@@ -992,7 +981,7 @@
PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetSelectionInfoRequest;
PCONSOLE Console;
- Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (NT_SUCCESS(Status))
{
memset(&GetSelectionInfoRequest->Info, 0,
sizeof(CONSOLE_SELECTION_INFO));
Modified: branches/ros-csrss/win32ss/user/consrv/consrv.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/c…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/consrv.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/consrv.h [iso-8859-1] Fri Jan 18 22:31:16 2013
@@ -39,13 +39,13 @@
// extern PBASE_STATIC_SERVER_DATA BaseStaticServerData;
/* Object type magic numbers */
-#define CONIO_CONSOLE_MAGIC 0x00000001 // --> Input-type handles
+#define CONIO_INPUT_BUFFER_MAGIC 0x00000001 // --> Input-type handles
#define CONIO_SCREEN_BUFFER_MAGIC 0x00000002 // --> Output-type handles
/* Common things to input/output/console objects */
typedef struct Object_tt
{
- LONG Type;
+ ULONG Type;
struct _CONSOLE *Console;
LONG AccessRead, AccessWrite;
LONG ExclusiveRead, ExclusiveWrite;
@@ -157,8 +157,9 @@
HANDLE Handle,
Object_t **Object,
DWORD Access,
- LONG Type);
+ ULONG Type);
VOID FASTCALL Win32CsrUnlockObject(Object_t *Object);
+VOID FASTCALL Win32CsrUnlockConsole(struct _CONSOLE* Console);
NTSTATUS FASTCALL Win32CsrReleaseObject(PCONSOLE_PROCESS_DATA ProcessData,
HANDLE Handle);
@@ -169,6 +170,8 @@
int ShowCmd,
PCSR_PROCESS CsrProcess);
VOID FASTCALL Win32CsrReleaseConsole(PCONSOLE_PROCESS_DATA ProcessData);
+NTSTATUS FASTCALL ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
+ struct _CONSOLE** Console);
NTSTATUS NTAPI ConsoleNewProcess(PCSR_PROCESS SourceProcess,
PCSR_PROCESS TargetProcess);
Modified: branches/ros-csrss/win32ss/user/consrv/handle.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/h…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/handle.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/handle.c [iso-8859-1] Fri Jan 18 22:31:16 2013
@@ -2,7 +2,7 @@
* LICENSE: GPL - See COPYING in the top level directory
* PROJECT: ReactOS Console Server DLL
* FILE: win32ss/user/consrv/handle.c
- * PURPOSE: Console IO Handle functions
+ * PURPOSE: Console I/O Handles functions
* PROGRAMMERS:
*/
@@ -64,10 +64,9 @@
if (Buffer->ListEntry.Flink != Buffer->ListEntry.Blink)
ConioDeleteScreenBuffer(Buffer);
}
- else if (Object->Type == CONIO_CONSOLE_MAGIC)
+ else if (Object->Type == CONIO_INPUT_BUFFER_MAGIC)
{
- /* TODO: FIXME: Destroy here the console ?? */
- // ConioDeleteConsole(Console);
+ DPRINT1("Closing the input buffer\n");
}
}
@@ -104,7 +103,7 @@
/* Insert the Input handle */
Status = Win32CsrInsertObject(ProcessData,
&InputHandle,
- &ProcessData->Console->Header,
+ &ProcessData->Console->InputBuffer.Header,
GENERIC_READ | GENERIC_WRITE,
TRUE,
FILE_SHARE_READ | FILE_SHARE_WRITE);
@@ -243,6 +242,8 @@
BOOL Inheritable,
DWORD ShareMode)
{
+#define IO_HANDLES_INCREMENT 2*3
+
ULONG i;
PCONSOLE_IO_HANDLE Block;
@@ -259,7 +260,8 @@
{
Block = RtlAllocateHeap(ConSrvHeap,
HEAP_ZERO_MEMORY,
- (ProcessData->HandleTableSize + 64) *
sizeof(CONSOLE_IO_HANDLE));
+ (ProcessData->HandleTableSize +
+ IO_HANDLES_INCREMENT) * sizeof(CONSOLE_IO_HANDLE));
if (Block == NULL)
{
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
@@ -270,8 +272,9 @@
ProcessData->HandleTableSize * sizeof(CONSOLE_IO_HANDLE));
RtlFreeHeap(ConSrvHeap, 0, ProcessData->HandleTable);
ProcessData->HandleTable = Block;
- ProcessData->HandleTableSize += 64;
- }
+ ProcessData->HandleTableSize += IO_HANDLES_INCREMENT;
+ }
+
ProcessData->HandleTable[i].Object = Object;
ProcessData->HandleTable[i].Access = Access;
ProcessData->HandleTable[i].Inheritable = Inheritable;
@@ -280,6 +283,7 @@
*Handle = ULongToHandle((i << 2) | 0x3);
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
+
return STATUS_SUCCESS;
}
@@ -314,12 +318,12 @@
HANDLE Handle,
Object_t **Object,
DWORD Access,
- LONG Type)
+ ULONG Type)
{
ULONG_PTR h = (ULONG_PTR)Handle >> 2;
- DPRINT("Win32CsrLockObject, Object: %x, %x, %x\n",
- Object, Handle, ProcessData ? ProcessData->HandleTableSize : 0);
+ // DPRINT("Win32CsrLockObject, Object: %x, %x, %x\n",
+ // Object, Handle, ProcessData ? ProcessData->HandleTableSize : 0);
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
@@ -329,7 +333,7 @@
~ProcessData->HandleTable[h].Access & Access ||
(Type != 0 && (*Object)->Type != Type) )
{
- DPRINT1("CsrGetObject returning invalid handle (%x)\n", Handle);
+ DPRINT1("CsrGetObject returning invalid handle (%x) of type %lu with access
%lu\n", Handle, Type, Access);
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
return STATUS_INVALID_HANDLE;
}
@@ -337,7 +341,7 @@
_InterlockedIncrement(&(*Object)->Console->ReferenceCount);
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- EnterCriticalSection(&((*Object)->Console->Lock));
+ EnterCriticalSection(&(*Object)->Console->Lock);
return STATUS_SUCCESS;
}
@@ -419,6 +423,31 @@
//CloseHandle(ProcessData->ConsoleEvent);
//ProcessData->ConsoleEvent = NULL;
}
+}
+
+NTSTATUS
+FASTCALL
+ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
+ PCONSOLE* Console)
+{
+ PCONSOLE ProcessConsole;
+
+ RtlEnterCriticalSection(&ProcessData->HandleTableLock);
+ ProcessConsole = ProcessData->Console;
+
+ if (!ProcessConsole)
+ {
+ *Console = NULL;
+ RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
+ return STATUS_INVALID_HANDLE;
+ }
+
+ InterlockedIncrement(&ProcessConsole->ReferenceCount);
+ RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
+ EnterCriticalSection(&(ProcessConsole->Lock));
+ *Console = ProcessConsole;
+
+ return STATUS_SUCCESS;
}
@@ -581,7 +610,7 @@
/// TODO: Move this up ?
/* Duplicate the Event */
Status = NtDuplicateObject(NtCurrentProcess(),
- ProcessData->Console->ActiveEvent,
+ ProcessData->Console->InputBuffer.ActiveEvent,
ProcessData->Process->ProcessHandle,
&ProcessData->ConsoleEvent,
EVENT_ALL_ACCESS, 0, 0);
Modified: branches/ros-csrss/win32ss/user/consrv/init.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/i…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/init.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/init.c [iso-8859-1] Fri Jan 18 22:31:16 2013
@@ -448,6 +448,15 @@
/* Initialize memory */
ConSrvHeap = RtlGetProcessHeap(); // Initialize our own heap.
+/*
+ ConSrvHeap = RtlCreateHeap( HEAP_GROWABLE | HEAP_CLASS_5, // Flags
+ NULL, // HeapBase
+ 64 * 1024, // ReserveSize
+ 4096, // CommitSize
+ NULL, // Lock to use for serialization
+ NULL // GrowthThreshold
+ );
+*/
// BaseSrvSharedHeap = LoadedServerDll->SharedSection; // Get the CSR shared
heap.
// LoadedServerDll->SharedSection = BaseStaticServerData;
Modified: branches/ros-csrss/win32ss/user/consrv/lineinput.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/l…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/lineinput.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/lineinput.c [iso-8859-1] Fri Jan 18 22:31:16
2013
@@ -167,7 +167,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ Status = ConioLockConsole(ProcessData, &Console);
if (NT_SUCCESS(Status))
{
Hist = HistoryFindBuffer(Console,
&GetCommandHistoryLengthRequest->ExeName);
@@ -205,7 +205,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ Status = ConioLockConsole(ProcessData, &Console);
if (NT_SUCCESS(Status))
{
Hist = HistoryFindBuffer(Console, &GetCommandHistoryRequest->ExeName);
@@ -246,7 +246,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ Status = ConioLockConsole(ProcessData, &Console);
if (NT_SUCCESS(Status))
{
Hist = HistoryFindBuffer(Console,
&ExpungeCommandHistoryRequest->ExeName);
@@ -274,7 +274,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ Status = ConioLockConsole(ProcessData, &Console);
if (NT_SUCCESS(Status))
{
Hist = HistoryFindBuffer(Console,
&SetHistoryNumberCommandsRequest->ExeName);
@@ -311,7 +311,7 @@
{
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
PCONSOLE Console;
- NTSTATUS Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ NTSTATUS Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (NT_SUCCESS(Status))
{
HistoryInfoRequest->HistoryBufferSize = Console->HistoryBufferSize;
@@ -326,7 +326,7 @@
{
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
PCONSOLE Console;
- NTSTATUS Status =
ConioConsoleFromProcessData(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ NTSTATUS Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
if (NT_SUCCESS(Status))
{
Console->HistoryBufferSize = HistoryInfoRequest->HistoryBufferSize;
@@ -340,7 +340,7 @@
static VOID
LineInputSetPos(PCONSOLE Console, UINT Pos)
{
- if (Pos != Console->LinePos && Console->Mode & ENABLE_ECHO_INPUT)
+ if (Pos != Console->LinePos && Console->InputBuffer.Mode &
ENABLE_ECHO_INPUT)
{
PCONSOLE_SCREEN_BUFFER Buffer = Console->ActiveBuffer;
UINT OldCursorX = Buffer->CurrentX;
@@ -377,7 +377,7 @@
(Console->LineSize - (Pos + NumToDelete)) * sizeof(WCHAR));
memcpy(&Console->LineBuffer[Pos], Insertion, NumToInsert * sizeof(WCHAR));
- if (Console->Mode & ENABLE_ECHO_INPUT)
+ if (Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
{
for (i = Pos; i < NewSize; i++)
{
@@ -559,7 +559,7 @@
return;
}
- if (KeyEvent->uChar.UnicodeChar == L'\b' && Console->Mode &
ENABLE_PROCESSED_INPUT)
+ if (KeyEvent->uChar.UnicodeChar == L'\b' &&
Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT)
{
/* backspace handling - if processed input enabled then we handle it here
* otherwise we treat it like a normal char. */
@@ -577,17 +577,17 @@
LineInputSetPos(Console, Console->LineSize);
Console->LineBuffer[Console->LineSize++] = L'\r';
- if (Console->Mode & ENABLE_ECHO_INPUT)
+ if (Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
ConioWriteConsole(Console, Console->ActiveBuffer, "\r", 1,
TRUE);
/* Add \n if processed input. There should usually be room for it,
* but an exception to the rule exists: the buffer could have been
* pre-filled with LineMaxSize - 1 characters. */
- if (Console->Mode & ENABLE_PROCESSED_INPUT &&
+ if (Console->InputBuffer.Mode & ENABLE_PROCESSED_INPUT &&
Console->LineSize < Console->LineMaxSize)
{
Console->LineBuffer[Console->LineSize++] = L'\n';
- if (Console->Mode & ENABLE_ECHO_INPUT)
+ if (Console->InputBuffer.Mode & ENABLE_ECHO_INPUT)
ConioWriteConsole(Console, Console->ActiveBuffer, "\n", 1,
TRUE);
}
Console->LineComplete = TRUE;