Author: hbelusca
Date: Tue Jan 22 23:28:51 2013
New Revision: 58205
URL:
http://svn.reactos.org/svn/reactos?rev=58205&view=rev
Log:
[CONSRV]
- Start to uniformize some helpers' names :
ConioLockConsole --> ConioGetConsole and ConioUnlockConsole -->
ConioReleaseConsole
ConioLockInputBuffer --> ConioGetInputBuffer and ConioUnlockInputBuffer -->
ConioReleaseInputBuffer
ConioLockScreenBuffer --> ConioGetScreenBuffer and ConioUnlockScreenBuffer -->
ConioReleaseScreenBuffer
but the overall naming must be revamped.
- Add them a boolean parameter to determine whether or not we should lock the console. It
is useful to not lock an already locked console when input / output waiting threads are
called,
because these are called from functions which lock the console.
- In the GUI console window message loop, after retrieving a pointer to the corresponding
console, lock it before calling funtions in the message dispatcher (and unlock the console
at the end).
- Use PostMessage instead of SendMessage for "sending" GUI messages to console
windows, to avoid possible deadlocks (because of console locking).
- Add temporary /// LOCK /// comments to easily localize where I deactivated extra console
(un)locking code (this remains to be analyzed further).
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/guiconsole.c
branches/ros-csrss/win32ss/user/consrv/handle.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] Tue Jan 22 23:28:51 2013
@@ -324,7 +324,7 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@@ -336,7 +336,7 @@
Header = IntCreateAliasHeader(lpExeName);
if (!Header)
{
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_INSUFFICIENT_RESOURCES;
}
IntInsertAliasHeader(&Console->Aliases, Header);
@@ -354,7 +354,7 @@
{
ApiMessage->Status = STATUS_INVALID_PARAMETER;
}
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return ApiMessage->Status;
}
@@ -362,12 +362,12 @@
if (!Entry)
{
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_INSUFFICIENT_RESOURCES;
}
IntInsertAliasEntry(Header, Entry);
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
}
@@ -411,7 +411,7 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@@ -420,27 +420,27 @@
Header = IntFindAliasHeader(Console->Aliases, lpExeName);
if (!Header)
{
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_INVALID_PARAMETER;
}
Entry = IntGetAliasEntry(Header, lpSource);
if (!Entry)
{
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_INVALID_PARAMETER;
}
Length = (wcslen(Entry->lpTarget) + 1) * sizeof(WCHAR);
if (Length > ConsoleAliasRequest->TargetLength)
{
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_BUFFER_TOO_SMALL;
}
wcscpy(lpTarget, Entry->lpTarget);
ConsoleAliasRequest->TargetLength = Length;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
}
@@ -468,7 +468,7 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@@ -477,13 +477,13 @@
Header = IntFindAliasHeader(Console->Aliases, GetAllAliasesRequest->ExeName);
if (!Header)
{
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_INVALID_PARAMETER;
}
if (IntGetAllConsoleAliasesLength(Header) >
GetAllAliasesRequest->AliasesBufferLength)
{
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_BUFFER_OVERFLOW;
}
@@ -492,7 +492,7 @@
GetAllAliasesRequest->AliasesBufferLength);
GetAllAliasesRequest->AliasesBufferLength = BytesWritten;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
}
@@ -516,7 +516,7 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@@ -525,13 +525,13 @@
Header = IntFindAliasHeader(Console->Aliases,
GetAllAliasesLengthRequest->ExeName);
if (!Header)
{
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_INVALID_PARAMETER;
}
Length = IntGetAllConsoleAliasesLength(Header);
GetAllAliasesLengthRequest->Length = Length;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
}
@@ -552,7 +552,7 @@
return STATUS_INVALID_PARAMETER;
}
- ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
if (!NT_SUCCESS(ApiMessage->Status))
{
return ApiMessage->Status;
@@ -562,13 +562,13 @@
if (ExesLength > GetAliasesExesRequest->Length)
{
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_BUFFER_OVERFLOW;
}
if (GetAliasesExesRequest->ExeNames == NULL)
{
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_INVALID_PARAMETER;
}
@@ -577,7 +577,7 @@
GetAliasesExesRequest->Length);
GetAliasesExesRequest->Length = BytesWritten;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
}
@@ -587,11 +587,11 @@
PCONSOLE Console;
DPRINT("SrvGetConsoleAliasExesLength entered\n");
- ApiMessage->Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ ApiMessage->Status =
ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
if (NT_SUCCESS(ApiMessage->Status))
{
GetAliasesExesLengthRequest->Length =
IntGetConsoleAliasesExesLength(Console->Aliases);
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
}
return ApiMessage->Status;
}
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] Tue Jan 22 23:28:51
2013
@@ -639,12 +639,12 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockInputBuffer(ProcessData, GetInputRequest->InputHandle,
&InputBuffer, GENERIC_READ);
+ GetInputRequest->InputsRead = 0;
+
+ Status = ConioGetInputBuffer(ProcessData, GetInputRequest->InputHandle,
&InputBuffer, GENERIC_READ, TRUE);
if(!NT_SUCCESS(Status)) return Status;
- GetInputRequest->InputsRead = 0;
-
- InputInfo.ProcessData = ProcessData; //
ConsoleGetPerProcessData(CsrGetClientThread()->Process);
+ InputInfo.ProcessData = ProcessData;
InputInfo.Console = InputBuffer->Header.Console;
Status = ReadInputBuffer(&InputInfo,
@@ -652,7 +652,7 @@
ApiMessage,
TRUE);
- ConioUnlockInputBuffer(InputBuffer);
+ ConioReleaseInputBuffer(InputBuffer, TRUE);
if (Status == STATUS_PENDING)
*ReplyCode = CsrReplyPending;
@@ -681,7 +681,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockInputBuffer(ProcessData, WriteInputRequest->InputHandle,
&InputBuffer, GENERIC_WRITE);
+ Status = ConioGetInputBuffer(ProcessData, WriteInputRequest->InputHandle,
&InputBuffer, GENERIC_WRITE, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = InputBuffer->Header.Console;
@@ -702,7 +702,7 @@
Status = ConioProcessChar(Console, InputRecord++);
}
- ConioUnlockInputBuffer(InputBuffer);
+ ConioReleaseInputBuffer(InputBuffer, TRUE);
WriteInputRequest->Length = i;
@@ -733,7 +733,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockInputBuffer(ProcessData, ReadConsoleRequest->InputHandle,
&InputBuffer, GENERIC_READ);
+ Status = ConioGetInputBuffer(ProcessData, ReadConsoleRequest->InputHandle,
&InputBuffer, GENERIC_READ, TRUE);
if (!NT_SUCCESS(Status)) return Status;
ReadConsoleRequest->NrCharactersRead = 0;
@@ -745,7 +745,7 @@
ApiMessage,
TRUE);
- ConioUnlockInputBuffer(InputBuffer);
+ ConioReleaseInputBuffer(InputBuffer, TRUE);
if (Status == STATUS_PENDING)
*ReplyCode = CsrReplyPending;
@@ -763,10 +763,11 @@
DPRINT("SrvFlushConsoleInputBuffer\n");
- Status =
ConioLockInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- FlushInputBufferRequest->InputHandle,
- &InputBuffer,
- GENERIC_WRITE);
+ Status =
ConioGetInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ FlushInputBufferRequest->InputHandle,
+ &InputBuffer,
+ GENERIC_WRITE,
+ TRUE);
if(!NT_SUCCESS(Status)) return Status;
/* Discard all entries in the input event queue */
@@ -779,7 +780,7 @@
}
ResetEvent(InputBuffer->ActiveEvent);
- ConioUnlockInputBuffer(InputBuffer);
+ ConioReleaseInputBuffer(InputBuffer, TRUE);
return STATUS_SUCCESS;
}
@@ -794,7 +795,7 @@
DPRINT("SrvGetConsoleNumberOfInputEvents\n");
- Status =
ConioLockInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
GetNumInputEventsRequest->InputHandle, &InputBuffer, GENERIC_READ);
+ Status =
ConioGetInputBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
GetNumInputEventsRequest->InputHandle, &InputBuffer, GENERIC_READ, TRUE);
if (!NT_SUCCESS(Status)) return Status;
CurrentInput = InputBuffer->InputEvents.Flink;
@@ -807,7 +808,7 @@
NumEvents++;
}
- ConioUnlockInputBuffer(InputBuffer);
+ ConioReleaseInputBuffer(InputBuffer, TRUE);
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] Tue Jan 22 23:28:51 2013
@@ -169,10 +169,10 @@
#define ConioResizeBuffer(Console, Buff, Size)
(Console)->Vtbl->ResizeBuffer((Console), (Buff), (Size))
/* console.c */
-#define ConioLockConsole(ProcessData, Console) \
- ConioConsoleFromProcessData((ProcessData), (Console))
-#define ConioUnlockConsole(Console) \
- Win32CsrUnlockConsole(Console)
+#define ConioGetConsole(ProcessData, Console, LockConsole) \
+ ConioConsoleFromProcessData((ProcessData), (Console), (LockConsole))
+#define ConioReleaseConsole(Console, ConsoleLocked) \
+ Win32CsrUnlockConsole((Console), (ConsoleLocked))
VOID WINAPI ConioDeleteConsole(PCONSOLE Console);
VOID WINAPI CsrInitConsoleSupport(VOID);
NTSTATUS WINAPI CsrInitConsole(PCONSOLE* NewConsole, int ShowCmd, PCSR_PROCESS
ConsoleLeaderProcess);
@@ -184,10 +184,10 @@
DWORD Timeout);
/* coninput.c */
-#define ConioLockInputBuffer(ProcessData, Handle, Ptr, Access) \
- Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), (Access),
CONIO_INPUT_BUFFER_MAGIC)
-#define ConioUnlockInputBuffer(Buff) \
- Win32CsrUnlockObject(&(Buff)->Header)
+#define ConioGetInputBuffer(ProcessData, Handle, Ptr, Access, LockConsole) \
+ Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), (Access),
(LockConsole), CONIO_INPUT_BUFFER_MAGIC)
+#define ConioReleaseInputBuffer(Buff, IsConsoleLocked) \
+ Win32CsrUnlockObject(&(Buff)->Header, (IsConsoleLocked))
void WINAPI ConioProcessKey(MSG *msg, PCONSOLE Console, BOOL TextMode);
/* conoutput.c */
@@ -195,10 +195,10 @@
(((Rect)->Top) > ((Rect)->Bottom) ? 0 : ((Rect)->Bottom) -
((Rect)->Top) + 1)
#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)
-#define ConioUnlockScreenBuffer(Buff) \
- Win32CsrUnlockObject(&(Buff)->Header)
+#define ConioGetScreenBuffer(ProcessData, Handle, Ptr, Access, LockConsole) \
+ Win32CsrLockObject((ProcessData), (Handle), (Object_t **)(Ptr), (Access),
(LockConsole), CONIO_SCREEN_BUFFER_MAGIC)
+#define ConioReleaseScreenBuffer(Buff, IsConsoleLocked) \
+ Win32CsrUnlockObject(&(Buff)->Header, (IsConsoleLocked))
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] Tue Jan 22 23:28:51
2013
@@ -472,7 +472,7 @@
DWORD Written = 0;
ULONG Length;
- Status = ConioLockScreenBuffer(ConsoleGetPerProcessData(ClientThread->Process),
WriteConsoleRequest->OutputHandle, &Buff, GENERIC_WRITE);
+ Status = ConioGetScreenBuffer(ConsoleGetPerProcessData(ClientThread->Process),
WriteConsoleRequest->OutputHandle, &Buff, GENERIC_WRITE, FALSE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
@@ -490,7 +490,7 @@
NULL))
{
/* Fail */
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, FALSE);
return STATUS_NO_MEMORY;
}
}
@@ -500,7 +500,7 @@
}
else
{
- if(WriteConsoleRequest->Unicode)
+ if (WriteConsoleRequest->Unicode)
{
Length = WideCharToMultiByte(Console->OutputCodePage, 0,
(PWCHAR)WriteConsoleRequest->Buffer,
@@ -544,7 +544,7 @@
WriteConsoleRequest->NrCharactersWritten = Written;
}
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, FALSE);
return Status;
}
@@ -584,7 +584,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockScreenBuffer(ProcessData, ReadOutputRequest->OutputHandle,
&Buff, GENERIC_READ);
+ Status = ConioGetScreenBuffer(ProcessData, ReadOutputRequest->OutputHandle,
&Buff, GENERIC_READ, TRUE);
if (!NT_SUCCESS(Status)) return Status;
/* FIXME: Is this correct? */
@@ -598,7 +598,7 @@
ConioInitRect(&ScreenRect, 0, 0, Buff->MaxY, Buff->MaxX);
if (!ConioGetIntersection(&ReadRegion, &ScreenRect, &ReadRegion))
{
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
@@ -625,7 +625,7 @@
}
}
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
ReadOutputRequest->ReadRegion.Right = ReadRegion.Left + SizeX - 1;
ReadOutputRequest->ReadRegion.Bottom = ReadRegion.Top + SizeY - 1;
@@ -690,10 +690,11 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockScreenBuffer(ProcessData,
- WriteOutputRequest->OutputHandle,
- &Buff,
- GENERIC_WRITE);
+ Status = ConioGetScreenBuffer(ProcessData,
+ WriteOutputRequest->OutputHandle,
+ &Buff,
+ GENERIC_WRITE,
+ TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
@@ -709,7 +710,7 @@
ConioInitRect(&ScreenBuffer, 0, 0, Buff->MaxY - 1, Buff->MaxX - 1);
if (!ConioGetIntersection(&WriteRegion, &ScreenBuffer, &WriteRegion))
{
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
/* It is okay to have a WriteRegion completely outside the screen buffer.
No data is written then. */
@@ -739,7 +740,7 @@
ConioDrawRegion(Console, &WriteRegion);
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
WriteOutputRequest->WriteRegion.Right = WriteRegion.Left + SizeX - 1;
WriteOutputRequest->WriteRegion.Bottom = WriteRegion.Top + SizeY - 1;
@@ -791,7 +792,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
ReadOutputCodeRequest->OutputHandle, &Buff, GENERIC_READ);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
ReadOutputCodeRequest->OutputHandle, &Buff, GENERIC_READ, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
@@ -865,7 +866,7 @@
ReadOutputCodeRequest->EndCoord.X = Xpos;
ReadOutputCodeRequest->EndCoord.Y = (Ypos - Buff->VirtualY + Buff->MaxY) %
Buff->MaxY;
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
ReadOutputCodeRequest->CodesRead = (DWORD)((ULONG_PTR)ReadBuffer -
(ULONG_PTR)ReadOutputCodeRequest->pCode.pCode) / CodeSize;
// <= ReadOutputCodeRequest->NumCodesToRead
@@ -915,10 +916,11 @@
return STATUS_INVALID_PARAMETER;
}
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- WriteOutputCodeRequest->OutputHandle,
- &Buff,
- GENERIC_WRITE);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ WriteOutputCodeRequest->OutputHandle,
+ &Buff,
+ GENERIC_WRITE,
+ TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
@@ -999,7 +1001,7 @@
RtlFreeHeap(RtlGetProcessHeap(), 0, tmpString);
}
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
// WriteOutputCodeRequest->NrCharactersWritten = Written;
return Status;
@@ -1019,7 +1021,7 @@
DPRINT("SrvFillConsoleOutput\n");
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
FillOutputRequest->OutputHandle, &Buff, GENERIC_WRITE);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
FillOutputRequest->OutputHandle, &Buff, GENERIC_WRITE, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
@@ -1046,7 +1048,7 @@
break;
default:
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_INVALID_PARAMETER;
}
@@ -1073,7 +1075,7 @@
ConioDrawRegion(Console, &UpdateRect);
}
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
/*
Length = FillOutputRequest->Length;
FillOutputRequest->NrCharactersWritten = Length;
@@ -1089,12 +1091,12 @@
DPRINT("SrvGetConsoleCursorInfo\n");
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
CursorInfoRequest->OutputHandle, &Buff, GENERIC_READ);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
CursorInfoRequest->OutputHandle, &Buff, GENERIC_READ, TRUE);
if (!NT_SUCCESS(Status)) return Status;
CursorInfoRequest->Info.bVisible = Buff->CursorInfo.bVisible;
CursorInfoRequest->Info.dwSize = Buff->CursorInfo.dwSize;
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
@@ -1110,7 +1112,7 @@
DPRINT("SrvSetConsoleCursorInfo\n");
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
CursorInfoRequest->OutputHandle, &Buff, GENERIC_WRITE);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
CursorInfoRequest->OutputHandle, &Buff, GENERIC_WRITE, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
@@ -1135,12 +1137,12 @@
if (!ConioSetCursorInfo(Console, Buff))
{
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_UNSUCCESSFUL;
}
}
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
@@ -1156,7 +1158,7 @@
DPRINT("SrvSetConsoleCursorPosition\n");
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetCursorPositionRequest->OutputHandle, &Buff, GENERIC_WRITE);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetCursorPositionRequest->OutputHandle, &Buff, GENERIC_WRITE, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
@@ -1166,7 +1168,7 @@
if ( NewCursorX < 0 || NewCursorX >= Buff->MaxX ||
NewCursorY < 0 || NewCursorY >= Buff->MaxY )
{
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_INVALID_PARAMETER;
}
OldCursorX = Buff->CurrentX;
@@ -1175,14 +1177,14 @@
Buff->CurrentY = NewCursorY;
if (Buff == Console->ActiveBuffer)
{
- if (! ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY))
- {
- ConioUnlockScreenBuffer(Buff);
+ if (!ConioSetScreenInfo(Console, Buff, OldCursorX, OldCursorY))
+ {
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_UNSUCCESSFUL;
}
}
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
@@ -1196,7 +1198,7 @@
DPRINT("SrvSetConsoleTextAttribute\n");
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetTextAttribRequest->OutputHandle, &Buff, GENERIC_WRITE);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetTextAttribRequest->OutputHandle, &Buff, GENERIC_WRITE, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
@@ -1206,12 +1208,12 @@
{
if (!ConioUpdateScreenInfo(Console, Buff))
{
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_UNSUCCESSFUL;
}
}
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
@@ -1228,7 +1230,7 @@
RtlEnterCriticalSection(&ProcessData->HandleTableLock);
- Status = ConioLockConsole(ProcessData, &Console);
+ Status = ConioGetConsole(ProcessData, &Console, TRUE);
if (!NT_SUCCESS(Status))
{
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
@@ -1277,7 +1279,7 @@
Status = STATUS_INSUFFICIENT_RESOURCES;
}
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
@@ -1294,7 +1296,7 @@
DPRINT("SrvGetConsoleScreenBufferInfo\n");
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
ScreenBufferInfoRequest->OutputHandle, &Buff, GENERIC_READ);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
ScreenBufferInfoRequest->OutputHandle, &Buff, GENERIC_READ, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
@@ -1311,7 +1313,7 @@
pInfo->dwMaximumWindowSize.X = Buff->MaxX;
pInfo->dwMaximumWindowSize.Y = Buff->MaxY;
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
@@ -1325,14 +1327,14 @@
DPRINT("SrvSetConsoleActiveScreenBuffer\n");
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetScreenBufferRequest->OutputHandle, &Buff, GENERIC_WRITE);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetScreenBufferRequest->OutputHandle, &Buff, GENERIC_WRITE, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
if (Buff == Console->ActiveBuffer)
{
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
@@ -1348,7 +1350,7 @@
/* Redraw the console */
ConioDrawConsole(Console);
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
@@ -1378,7 +1380,7 @@
DestinationOrigin = ScrollScreenBufferRequest->DestinationOrigin;
Fill = ScrollScreenBufferRequest->Fill;
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
OutputHandle, &Buff, GENERIC_WRITE);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
OutputHandle, &Buff, GENERIC_WRITE, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Console = Buff->Header.Console;
@@ -1387,9 +1389,9 @@
/* Make sure source rectangle is inside the screen buffer */
ConioInitRect(&ScreenBuffer, 0, 0, Buff->MaxY - 1, Buff->MaxX - 1);
- if (! ConioGetIntersection(&SrcRegion, &ScreenBuffer, &ScrollRectangle))
- {
- ConioUnlockScreenBuffer(Buff);
+ if (!ConioGetIntersection(&SrcRegion, &ScreenBuffer, &ScrollRectangle))
+ {
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
@@ -1408,7 +1410,7 @@
ClipRectangle = ScrollScreenBufferRequest->ClipRectangle;
if (!ConioGetIntersection(&ClipRectangle, &ClipRectangle,
&ScreenBuffer))
{
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
}
@@ -1440,7 +1442,7 @@
}
}
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return STATUS_SUCCESS;
}
@@ -1451,11 +1453,11 @@
PCONSOLE_SETSCREENBUFFERSIZE SetScreenBufferSizeRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.SetScreenBufferSizeRequest;
PCONSOLE_SCREEN_BUFFER Buff;
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetScreenBufferSizeRequest->OutputHandle, &Buff, GENERIC_WRITE);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
SetScreenBufferSizeRequest->OutputHandle, &Buff, GENERIC_WRITE, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Status = ConioResizeBuffer(Buff->Header.Console, Buff,
SetScreenBufferSizeRequest->Size);
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return Status;
}
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] Tue Jan 22 23:28:51
2013
@@ -581,7 +581,7 @@
Status =
Win32CsrLockObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
ConsoleModeRequest->ConsoleHandle,
- &Object, GENERIC_WRITE, 0);
+ &Object, GENERIC_WRITE, TRUE, 0);
if (!NT_SUCCESS(Status)) return Status;
Status = STATUS_SUCCESS;
@@ -601,7 +601,7 @@
Status = STATUS_INVALID_HANDLE;
}
- Win32CsrUnlockObject(Object);
+ Win32CsrUnlockObject(Object, TRUE);
return Status;
}
@@ -616,7 +616,7 @@
Status =
Win32CsrLockObject(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
ConsoleModeRequest->ConsoleHandle,
- &Object, GENERIC_READ, 0);
+ &Object, GENERIC_READ, TRUE, 0);
if (!NT_SUCCESS(Status)) return Status;
Status = STATUS_SUCCESS;
@@ -636,7 +636,7 @@
Status = STATUS_INVALID_HANDLE;
}
- Win32CsrUnlockObject(Object);
+ Win32CsrUnlockObject(Object, TRUE);
return Status;
}
@@ -659,7 +659,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if(NT_SUCCESS(Status))
{
Buffer = RtlAllocateHeap(RtlGetProcessHeap(), 0, TitleRequest->Length);
@@ -685,7 +685,7 @@
Status = STATUS_NO_MEMORY;
}
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
}
return Status;
@@ -709,7 +709,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT1("Can't get console\n");
@@ -726,7 +726,7 @@
TitleRequest->Length = Console->Title.Length;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
}
@@ -774,10 +774,11 @@
DPRINT("SrvGetConsoleHardwareState\n");
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- HardwareStateRequest->OutputHandle,
- &Buff,
- GENERIC_READ);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ HardwareStateRequest->OutputHandle,
+ &Buff,
+ GENERIC_READ,
+ TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to get console handle in
SrvGetConsoleHardwareState\n");
@@ -787,7 +788,7 @@
Console = Buff->Header.Console;
HardwareStateRequest->State = Console->HardwareState;
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return Status;
}
@@ -801,10 +802,11 @@
DPRINT("SrvSetConsoleHardwareState\n");
- Status =
ConioLockScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
- HardwareStateRequest->OutputHandle,
- &Buff,
- GENERIC_READ);
+ Status =
ConioGetScreenBuffer(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
+ HardwareStateRequest->OutputHandle,
+ &Buff,
+ GENERIC_READ,
+ TRUE);
if (!NT_SUCCESS(Status))
{
DPRINT1("Failed to get console handle in
SrvSetConsoleHardwareState\n");
@@ -815,7 +817,7 @@
Console = Buff->Header.Console;
Status = SetConsoleHardwareState(Console, HardwareStateRequest->State);
- ConioUnlockScreenBuffer(Buff);
+ ConioReleaseScreenBuffer(Buff, TRUE);
return Status;
}
@@ -828,11 +830,11 @@
DPRINT("SrvGetConsoleWindow\n");
- Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
GetWindowRequest->WindowHandle = Console->hWindow;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
}
@@ -845,14 +847,14 @@
DPRINT("SrvSetConsoleIcon\n");
- Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Status = (ConioChangeIcon(Console, SetIconRequest->WindowIcon)
? STATUS_SUCCESS
: STATUS_UNSUCCESSFUL);
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return Status;
}
@@ -866,12 +868,12 @@
DPRINT("SrvGetConsoleCP, getting %s Code Page\n",
ConsoleCPRequest->InputCP ? "Input" : "Output");
- Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
ConsoleCPRequest->CodePage = (ConsoleCPRequest->InputCP ? Console->CodePage
:
Console->OutputCodePage);
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
}
@@ -884,7 +886,7 @@
DPRINT("SrvSetConsoleCP, setting %s Code Page\n",
ConsoleCPRequest->InputCP ? "Input" : "Output");
- Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
if (IsValidCodePage(ConsoleCPRequest->CodePage))
@@ -894,11 +896,11 @@
else
Console->OutputCodePage = ConsoleCPRequest->CodePage;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_SUCCESS;
}
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return STATUS_INVALID_PARAMETER;
}
@@ -925,7 +927,7 @@
Buffer = GetProcessListRequest->pProcessIds;
- Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
for (current_entry = Console->ProcessList.Flink;
@@ -939,7 +941,7 @@
}
}
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
GetProcessListRequest->nProcessIdsTotal = nItems;
return STATUS_SUCCESS;
@@ -954,7 +956,7 @@
PLIST_ENTRY current_entry;
DWORD Group;
- Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (!NT_SUCCESS(Status)) return Status;
Group = GenerateCtrlEventRequest->ProcessGroup;
@@ -971,7 +973,7 @@
}
}
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
return Status;
}
@@ -982,13 +984,13 @@
PCONSOLE_GETSELECTIONINFO GetSelectionInfoRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.GetSelectionInfoRequest;
PCONSOLE Console;
- Status = ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ Status = ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console, TRUE);
if (NT_SUCCESS(Status))
{
memset(&GetSelectionInfoRequest->Info, 0,
sizeof(CONSOLE_SELECTION_INFO));
if (Console->Selection.dwFlags != 0)
GetSelectionInfoRequest->Info = Console->Selection;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
}
return Status;
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] Tue Jan 22 23:28:51 2013
@@ -157,9 +157,12 @@
HANDLE Handle,
Object_t **Object,
DWORD Access,
+ BOOL LockConsole,
ULONG Type);
-VOID FASTCALL Win32CsrUnlockObject(Object_t *Object);
-VOID FASTCALL Win32CsrUnlockConsole(struct _CONSOLE* Console);
+VOID FASTCALL Win32CsrUnlockObject(Object_t *Object,
+ BOOL IsConsoleLocked);
+VOID FASTCALL Win32CsrUnlockConsole(struct _CONSOLE* Console,
+ BOOL IsConsoleLocked);
NTSTATUS FASTCALL Win32CsrReleaseObject(PCONSOLE_PROCESS_DATA ProcessData,
HANDLE Handle);
@@ -171,7 +174,8 @@
PCSR_PROCESS CsrProcess);
VOID FASTCALL Win32CsrReleaseConsole(PCONSOLE_PROCESS_DATA ProcessData);
NTSTATUS FASTCALL ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
- struct _CONSOLE** Console);
+ struct _CONSOLE** Console,
+ BOOL LockConsole);
NTSTATUS NTAPI ConsoleNewProcess(PCSR_PROCESS SourceProcess,
PCSR_PROCESS TargetProcess);
Modified: branches/ros-csrss/win32ss/user/consrv/guiconsole.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/consrv/g…
==============================================================================
--- branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/consrv/guiconsole.c [iso-8859-1] Tue Jan 22 23:28:51
2013
@@ -900,7 +900,7 @@
Buff = Console->ActiveBuffer;
- EnterCriticalSection(&Buff->Header.Console->Lock);
+ /// LOCK /// EnterCriticalSection(&Buff->Header.Console->Lock);
TopLine = rc->top / GuiData->CharHeight + Buff->ShowY;
BottomLine = (rc->bottom + (GuiData->CharHeight - 1)) / GuiData->CharHeight
- 1 + Buff->ShowY;
@@ -995,7 +995,7 @@
}
}
- LeaveCriticalSection(&Buff->Header.Console->Lock);
+ /// LOCK /// LeaveCriticalSection(&Buff->Header.Console->Lock);
SelectObject(hDC,
OldFont);
@@ -1274,7 +1274,7 @@
PLIST_ENTRY current_entry;
PCONSOLE_PROCESS_DATA current;
- EnterCriticalSection(&Console->Lock);
+ /// LOCK /// EnterCriticalSection(&Console->Lock);
current_entry = Console->ProcessList.Flink;
while (current_entry != &Console->ProcessList)
@@ -1288,7 +1288,7 @@
ConioConsoleCtrlEvent(CTRL_CLOSE_EVENT, current);
}
- LeaveCriticalSection(&Console->Lock);
+ /// LOCK /// LeaveCriticalSection(&Console->Lock);
}
static VOID
@@ -1792,7 +1792,7 @@
#endif
}
- (void)InterlockedExchangePointer((PVOID volatile *)&ScreenBuffer->Buffer,
Buffer);
+ (void)InterlockedExchangePointer((PVOID volatile*)&ScreenBuffer->Buffer,
Buffer);
RtlFreeHeap(ConSrvHeap, 0, OldBuffer);
ScreenBuffer->MaxX = Size.X;
ScreenBuffer->MaxY = Size.Y;
@@ -1809,7 +1809,7 @@
ScreenBuffer->ShowY = Size.Y - Console->Size.Y;
/* TODO: Should update scrollbar, but can't use anything that
- * calls SendMessage or it could cause deadlock */
+ * calls SendMessage or it could cause deadlock --> Use PostMessage */
return STATUS_SUCCESS;
}
@@ -1824,7 +1824,7 @@
COORD BufSize;
BOOL SizeChanged = FALSE;
- EnterCriticalSection(&Console->Lock);
+ /// LOCK /// EnterCriticalSection(&Console->Lock);
/* apply text / background color */
GuiData->ScreenText = pConInfo->ScreenText;
@@ -1859,7 +1859,7 @@
GuiData->WindowSizeLock = FALSE;
}
- LeaveCriticalSection(&Console->Lock);
+ /// LOCK /// LeaveCriticalSection(&Console->Lock);
InvalidateRect(pConInfo->hConsoleWindow, NULL, TRUE);
}
@@ -1994,9 +1994,20 @@
Console = GuiGetWindowConsole(hWnd);
if (Console == NULL) return 0;
+ /* Lock the console */
+ EnterCriticalSection(&Console->Lock);
+
/* We have a console, start message dispatching. */
switch (msg)
{
+ case WM_CLOSE:
+ GuiConsoleHandleClose(Console, hWnd);
+ break;
+
+ case WM_NCDESTROY:
+ GuiConsoleHandleNcDestroy(Console, hWnd);
+ break;
+
case WM_PAINT:
GuiConsoleHandlePaint(Console, hWnd, (HDC)wParam);
break;
@@ -2013,14 +2024,6 @@
GuiConsoleHandleTimer(Console, hWnd);
break;
- case WM_CLOSE:
- GuiConsoleHandleClose(Console, hWnd);
- break;
-
- case WM_NCDESTROY:
- GuiConsoleHandleNcDestroy(Console, hWnd);
- break;
-
case WM_LBUTTONDOWN:
GuiConsoleLeftMouseDown(Console, hWnd, lParam);
break;
@@ -2066,6 +2069,9 @@
Result = DefWindowProcW(hWnd, msg, wParam, lParam);
break;
}
+
+ /* Unlock the console */
+ LeaveCriticalSection(&Console->Lock);
return Result;
}
@@ -2264,7 +2270,7 @@
Title = L"";
}
- SendMessageW(Console->hWindow, WM_SETTEXT, 0, (LPARAM)Title);
+ PostMessageW(Console->hWindow, WM_SETTEXT, 0, (LPARAM)Title);
if (NULL != Buffer)
{
@@ -2277,8 +2283,8 @@
static BOOL WINAPI
GuiChangeIcon(PCONSOLE Console, HICON hWindowIcon)
{
- SendMessageW(Console->hWindow, WM_SETICON, ICON_BIG, (LPARAM)hWindowIcon);
- SendMessageW(Console->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)hWindowIcon);
+ PostMessageW(Console->hWindow, WM_SETICON, ICON_BIG, (LPARAM)hWindowIcon);
+ PostMessageW(Console->hWindow, WM_SETICON, ICON_SMALL, (LPARAM)hWindowIcon);
return TRUE;
}
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] Tue Jan 22 23:28:51 2013
@@ -37,10 +37,10 @@
static VOID
Win32CsrCreateHandleEntry(PCONSOLE_IO_HANDLE Entry)
{
- Object_t *Object = Entry->Object;
- EnterCriticalSection(&Object->Console->Lock);
+ /// LOCK /// Object_t *Object = Entry->Object;
+ /// LOCK /// EnterCriticalSection(&Object->Console->Lock);
AdjustHandleCounts(Entry, +1);
- LeaveCriticalSection(&Object->Console->Lock);
+ /// LOCK /// LeaveCriticalSection(&Object->Console->Lock);
}
static VOID
@@ -49,8 +49,10 @@
Object_t *Object = Entry->Object;
if (Object != NULL)
{
- PCONSOLE Console = Object->Console;
- EnterCriticalSection(&Console->Lock);
+ /// LOCK /// PCONSOLE Console = Object->Console;
+ /// LOCK /// EnterCriticalSection(&Console->Lock);
+
+ /// TODO: HERE, trigger input waiting threads.
/* If the last handle to a screen buffer is closed, delete it... */
if (AdjustHandleCounts(Entry, -1) == 0)
@@ -70,7 +72,7 @@
}
}
- LeaveCriticalSection(&Console->Lock);
+ /// LOCK /// LeaveCriticalSection(&Console->Lock);
Entry->Object = NULL;
}
}
@@ -318,6 +320,7 @@
HANDLE Handle,
Object_t **Object,
DWORD Access,
+ BOOL LockConsole,
ULONG Type)
{
ULONG_PTR h = (ULONG_PTR)Handle >> 2;
@@ -330,7 +333,7 @@
if ( !IsConsoleHandle(Handle) ||
h >= ProcessData->HandleTableSize ||
(*Object = ProcessData->HandleTable[h].Object) == NULL ||
- ~ProcessData->HandleTable[h].Access & Access ||
+ (ProcessData->HandleTable[h].Access & Access) == 0 ||
(Type != 0 && (*Object)->Type != Type) )
{
DPRINT1("CsrGetObject returning invalid handle (%x) of type %lu with access
%lu\n", Handle, Type, Access);
@@ -341,14 +344,16 @@
_InterlockedIncrement(&(*Object)->Console->ReferenceCount);
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- EnterCriticalSection(&(*Object)->Console->Lock);
+ if (LockConsole) EnterCriticalSection(&(*Object)->Console->Lock);
+
return STATUS_SUCCESS;
}
VOID FASTCALL
-Win32CsrUnlockConsole(PCONSOLE Console)
-{
- LeaveCriticalSection(&Console->Lock);
+Win32CsrUnlockConsole(PCONSOLE Console,
+ BOOL IsConsoleLocked)
+{
+ if (IsConsoleLocked) LeaveCriticalSection(&Console->Lock);
/* Decrement reference count */
if (_InterlockedDecrement(&Console->ReferenceCount) == 0)
@@ -357,9 +362,10 @@
VOID
FASTCALL
-Win32CsrUnlockObject(Object_t *Object)
-{
- Win32CsrUnlockConsole(Object->Console);
+Win32CsrUnlockObject(Object_t *Object,
+ BOOL IsConsoleLocked)
+{
+ Win32CsrUnlockConsole(Object->Console, IsConsoleLocked);
}
NTSTATUS
@@ -418,8 +424,9 @@
DPRINT1("Win32CsrReleaseConsole - Console->ReferenceCount = %lu - We are
going to decrement it !\n", Console->ReferenceCount);
ProcessData->Console = NULL;
EnterCriticalSection(&Console->Lock);
+ DPRINT1("Win32CsrReleaseConsole - Locking OK\n");
RemoveEntryList(&ProcessData->ConsoleLink);
- Win32CsrUnlockConsole(Console);
+ Win32CsrUnlockConsole(Console, TRUE);
//CloseHandle(ProcessData->ConsoleEvent);
//ProcessData->ConsoleEvent = NULL;
}
@@ -428,7 +435,8 @@
NTSTATUS
FASTCALL
ConioConsoleFromProcessData(PCONSOLE_PROCESS_DATA ProcessData,
- PCONSOLE* Console)
+ PCONSOLE* Console,
+ BOOL LockConsole)
{
PCONSOLE ProcessConsole;
@@ -444,7 +452,9 @@
InterlockedIncrement(&ProcessConsole->ReferenceCount);
RtlLeaveCriticalSection(&ProcessData->HandleTableLock);
- EnterCriticalSection(&(ProcessConsole->Lock));
+
+ if (LockConsole) EnterCriticalSection(&ProcessConsole->Lock);
+
*Console = ProcessConsole;
return STATUS_SUCCESS;
@@ -716,7 +726,7 @@
{
DesiredAccess = DuplicateHandleRequest->Access;
/* Make sure the source handle has all the desired flags */
- if (~Entry->Access & DesiredAccess)
+ if ((Entry->Access & DesiredAccess) == 0)
{
DPRINT1("Handle %p only has access %X; requested %X\n",
ConsoleHandle, Entry->Access, DesiredAccess);
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] Tue Jan 22 23:28:51
2013
@@ -167,7 +167,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockConsole(ProcessData, &Console);
+ Status = ConioGetConsole(ProcessData, &Console, TRUE);
if (NT_SUCCESS(Status))
{
Hist = HistoryFindBuffer(Console,
&GetCommandHistoryLengthRequest->ExeName);
@@ -177,7 +177,7 @@
Length += Hist->Entries[i].Length + sizeof(WCHAR);
}
GetCommandHistoryLengthRequest->Length = Length;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
}
return Status;
}
@@ -205,7 +205,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockConsole(ProcessData, &Console);
+ Status = ConioGetConsole(ProcessData, &Console, TRUE);
if (NT_SUCCESS(Status))
{
Hist = HistoryFindBuffer(Console, &GetCommandHistoryRequest->ExeName);
@@ -225,7 +225,7 @@
}
}
GetCommandHistoryRequest->Length = Buffer -
(PBYTE)GetCommandHistoryRequest->History;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
}
return Status;
}
@@ -246,12 +246,12 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockConsole(ProcessData, &Console);
+ Status = ConioGetConsole(ProcessData, &Console, TRUE);
if (NT_SUCCESS(Status))
{
Hist = HistoryFindBuffer(Console,
&ExpungeCommandHistoryRequest->ExeName);
HistoryDeleteBuffer(Hist);
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
}
return Status;
}
@@ -274,7 +274,7 @@
return STATUS_INVALID_PARAMETER;
}
- Status = ConioLockConsole(ProcessData, &Console);
+ Status = ConioGetConsole(ProcessData, &Console, TRUE);
if (NT_SUCCESS(Status))
{
Hist = HistoryFindBuffer(Console,
&SetHistoryNumberCommandsRequest->ExeName);
@@ -302,7 +302,7 @@
RtlFreeHeap(ConSrvHeap, 0, OldEntryList);
}
}
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
}
return Status;
}
@@ -311,13 +311,13 @@
{
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
PCONSOLE Console;
- NTSTATUS Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ NTSTATUS Status =
ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
if (NT_SUCCESS(Status))
{
HistoryInfoRequest->HistoryBufferSize = Console->HistoryBufferSize;
HistoryInfoRequest->NumberOfHistoryBuffers =
Console->NumberOfHistoryBuffers;
HistoryInfoRequest->dwFlags = Console->HistoryNoDup;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
}
return Status;
}
@@ -326,13 +326,13 @@
{
PCONSOLE_GETSETHISTORYINFO HistoryInfoRequest =
&((PCONSOLE_API_MESSAGE)ApiMessage)->Data.HistoryInfoRequest;
PCONSOLE Console;
- NTSTATUS Status =
ConioLockConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process),
&Console);
+ NTSTATUS Status =
ConioGetConsole(ConsoleGetPerProcessData(CsrGetClientThread()->Process), &Console,
TRUE);
if (NT_SUCCESS(Status))
{
Console->HistoryBufferSize = HistoryInfoRequest->HistoryBufferSize;
Console->NumberOfHistoryBuffers =
HistoryInfoRequest->NumberOfHistoryBuffers;
Console->HistoryNoDup = HistoryInfoRequest->dwFlags &
HISTORY_NO_DUP_FLAG;
- ConioUnlockConsole(Console);
+ ConioReleaseConsole(Console, TRUE);
}
return Status;
}