DPRINT("ConioConsoleCtrlEvent Parent ProcessId = %x\n", ProcessData->Process->ClientId.UniqueProcess);
- /* Notify all the waits only if we see Ctrl-C or Ctrl-Break */
- if (Event == CTRL_C_EVENT || Event == CTRL_BREAK_EVENT)
- {
- DWORD Flag = (1 << Event); // Transform an integer value to a power of 2.
- NTSTATUS Status;
- PCSRSS_CONSOLE Console;
- // LIST_ENTRY WaitQueue;
-
- DPRINT1("ConioConsoleCtrlEvent - Ctrl-C captured\n");
- Status = ConioConsoleFromProcessData(ProcessData, &Console);
- if (NT_SUCCESS(Status))
- {
- DPRINT1("ConioConsoleCtrlEvent - console captured, try to dereference waits...\n");
- /*
- * Wake-up all of the writing waiters, dereference them
- * and purge them all from the list.
- */
- if (CsrNotifyWait(&Console->ReadWaitQueue,
- WaitAll,
- (PVOID)Flag,
- NULL))
- {
- DPRINT1("ConioConsoleCtrlEvent - waits dereferenced...\n");
- // InitializeListHead(&WaitQueue);
-
- // CsrMoveSatisfiedWait(&WaitQueue, &Console->ReadWaitQueue);
- if (!IsListEmpty(&Console->ReadWaitQueue /* &WaitQueue */))
- {
- CsrDereferenceWait(&Console->ReadWaitQueue /* &WaitQueue */);
- }
- }
- ConioUnlockConsole(Console); // NOTE_WAITS: <-- Here we have the possibility to free the console waits also.
- }
- }
-
- /* Notify the process of the control event */
if (ProcessData->CtrlDispatcher)
{
Thread = CreateRemoteThread(ProcessData->Process->ProcessHandle, NULL, 0,
InitializeListHead(&Console->ProcessList);
InitializeListHead(&Console->BufferList);
Console->ActiveBuffer = NULL;
- // Console->SatisfiedWaits = NULL;
InitializeListHead(&Console->ReadWaitQueue);
InitializeListHead(&Console->WriteWaitQueue);
InitializeListHead(&Console->InputEvents);
DPRINT("ConioDeleteConsole\n");
- /* TODO: Dereference all the waits in Console->ReadWaitQueue */
- /* TODO: Dereference all the waits in Console->WriteWaitQueue */
-
/* Drain input event queue */
while (Console->InputEvents.Flink != &Console->InputEvents)
{
VOID FASTCALL
ConioUnpause(PCSRSS_CONSOLE Console, UINT Flags)
{
- // LIST_ENTRY WaitQueue;
-
Console->PauseFlags &= ~Flags;
// if ((Console->PauseFlags & (PAUSED_FROM_KEYBOARD | PAUSED_FROM_SCROLLBAR | PAUSED_FROM_SELECTION)) == 0)
CloseHandle(Console->UnpauseEvent);
Console->UnpauseEvent = NULL;
- /*
- * Wake-up all of the writing waiters, dereference them
- * and purge them all from the list.
- */
- if (CsrNotifyWait(&Console->WriteWaitQueue,
- WaitAll,
- NULL,
- NULL))
- {
- // InitializeListHead(&WaitQueue);
-
- // CsrMoveSatisfiedWait(&WaitQueue, &Console->WriteWaitQueue);
- if (!IsListEmpty(&Console->WriteWaitQueue /* &WaitQueue */))
- {
- CsrDereferenceWait(&Console->WriteWaitQueue /* &WaitQueue */);
- }
- }
+ CsrNotifyWait(&Console->WriteWaitQueue,
+ WaitAll,
+ NULL,
+ NULL);
}
}