Author: jmorlan
Date: Sat Aug 2 12:01:22 2008
New Revision: 35041
URL:
http://svn.reactos.org/svn/reactos?rev=35041&view=rev
Log:
- Implement GenerateConsoleCtrlEvent.
- Remove IgnoreCtrlEvents variable (which ConsoleControlDispatcher did not actually use);
set ProcessParameters->ConsoleFlags instead. Despite the name "ConsoleFlags",
SetConsoleCtrlHandler treats it like a boolean.
- Preserve all 16 bits of the attribute set by SetConsoleTextAttribute. Even though the
upper byte does not affect text colors, it should be retrievable with
GetConsoleScreenBufferInfo.
- Update OpenConsoleW prototype in kernel32.h to match the change made in r34694.
Modified:
trunk/reactos/dll/win32/kernel32/include/kernel32.h
trunk/reactos/dll/win32/kernel32/misc/console.c
trunk/reactos/include/reactos/subsys/csrss/csrss.h
trunk/reactos/subsystems/win32/csrss/api/process.c
trunk/reactos/subsystems/win32/csrss/include/api.h
trunk/reactos/subsystems/win32/csrss/include/conio.h
trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
Modified: trunk/reactos/dll/win32/kernel32/include/kernel32.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/include…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/include/kernel32.h [iso-8859-1] Sat Aug 2 12:01:22
2008
@@ -69,7 +69,7 @@
HANDLE STDCALL OpenConsoleW (LPCWSTR wsName,
DWORD dwDesiredAccess,
BOOL bInheritHandle,
- DWORD dwCreationDistribution);
+ DWORD dwShareMode);
PTEB GetTeb(VOID);
Modified: trunk/reactos/dll/win32/kernel32/misc/console.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/kernel32/misc/co…
==============================================================================
--- trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/kernel32/misc/console.c [iso-8859-1] Sat Aug 2 12:01:22 2008
@@ -26,8 +26,6 @@
extern BOOL WINAPI IsDebuggerPresent(VOID);
/* GLOBALS *******************************************************************/
-
-static BOOL IgnoreCtrlEvents = FALSE;
static PHANDLER_ROUTINE* CtrlHandlers = NULL;
static ULONG NrCtrlHandlers = 0;
@@ -3141,7 +3139,7 @@
CsrRequest = MAKE_CSR_API(SET_ATTRIB, CSR_CONSOLE);
Request.Data.SetAttribRequest.ConsoleHandle = hConsoleOutput;
- Request.Data.SetAttribRequest.Attrib = (CHAR)wAttributes;
+ Request.Data.SetAttribRequest.Attrib = wAttributes;
Status = CsrClientCallServer( &Request, NULL, CsrRequest, sizeof( CSR_API_MESSAGE
) );
if( !NT_SUCCESS( Status ) || !NT_SUCCESS( Status = Request.Status ) )
{
@@ -3157,7 +3155,7 @@
{
if (HandlerRoutine == NULL)
{
- IgnoreCtrlEvents = TRUE;
+ NtCurrentPeb()->ProcessParameters->ConsoleFlags = TRUE;
return(TRUE);
}
else
@@ -3193,7 +3191,7 @@
if (HandlerRoutine == NULL)
{
- IgnoreCtrlEvents = FALSE;
+ NtCurrentPeb()->ProcessParameters->ConsoleFlags = FALSE;
return(TRUE);
}
else
@@ -3245,7 +3243,7 @@
/*--------------------------------------------------------------
* GenerateConsoleCtrlEvent
*
- * @unimplemented
+ * @implemented
*/
BOOL WINAPI
GenerateConsoleCtrlEvent(
@@ -3253,9 +3251,30 @@
DWORD dwProcessGroupId
)
{
- DPRINT1("GenerateConsoleCtrlEvent(0x%x, 0x%x) UNIMPLEMENTED!\n", dwCtrlEvent,
dwProcessGroupId);
- SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
- return FALSE;
+ CSR_API_MESSAGE Request;
+ ULONG CsrRequest;
+ NTSTATUS Status;
+
+ if (dwCtrlEvent != CTRL_C_EVENT && dwCtrlEvent != CTRL_BREAK_EVENT)
+ {
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return FALSE;
+ }
+
+ CsrRequest = MAKE_CSR_API(GENERATE_CTRL_EVENT, CSR_CONSOLE);
+ Request.Data.GenerateCtrlEvent.Event = dwCtrlEvent;
+ Request.Data.GenerateCtrlEvent.ProcessGroup = dwProcessGroupId;
+ Status = CsrClientCallServer(&Request,
+ NULL,
+ CsrRequest,
+ sizeof(CSR_API_MESSAGE));
+ if(!NT_SUCCESS(Status) || !(NT_SUCCESS(Status = Request.Status)))
+ {
+ SetLastErrorByStatus(Status);
+ return FALSE;
+ }
+
+ return TRUE;
}
Modified: trunk/reactos/include/reactos/subsys/csrss/csrss.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/include/reactos/subsys/csr…
==============================================================================
--- trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] (original)
+++ trunk/reactos/include/reactos/subsys/csrss/csrss.h [iso-8859-1] Sat Aug 2 12:01:22
2008
@@ -163,7 +163,7 @@
typedef struct
{
HANDLE ConsoleHandle;
- CHAR Attrib;
+ WORD Attrib;
} CSRSS_SET_ATTRIB, *PCSRSS_SET_ATTRIB;
typedef struct
@@ -459,6 +459,12 @@
{
DWORD Length;
} CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH, *PCSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH;
+
+typedef struct
+{
+ DWORD Event;
+ DWORD ProcessGroup;
+} CSRSS_GENERATE_CTRL_EVENT, *PCSRSS_GENERATE_CTRL_EVENT;
@@ -537,6 +543,7 @@
#define GET_ALL_CONSOLE_ALIASES_LENGTH (0x3B)
#define GET_CONSOLE_ALIASES_EXES (0x3C)
#define GET_CONSOLE_ALIASES_EXES_LENGTH (0x3D)
+#define GENERATE_CTRL_EVENT (0x3E)
/* Keep in sync with definition below. */
#define CSRSS_HEADER_SIZE (sizeof(PORT_MESSAGE) + sizeof(ULONG) + sizeof(NTSTATUS))
@@ -608,6 +615,7 @@
CSRSS_GET_ALL_CONSOLE_ALIASES_LENGTH GetAllConsoleAliasesLength;
CSRSS_GET_CONSOLE_ALIASES_EXES GetConsoleAliasesExes;
CSRSS_GET_CONSOLE_ALIASES_EXES_LENGTH GetConsoleAliasesExesLength;
+ CSRSS_GENERATE_CTRL_EVENT GenerateCtrlEvent;
} Data;
} CSR_API_MESSAGE, *PCSR_API_MESSAGE;
Modified: trunk/reactos/subsystems/win32/csrss/api/process.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/api…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/api/process.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/api/process.c [iso-8859-1] Sat Aug 2 12:01:22
2008
@@ -242,6 +242,15 @@
}
}
+ if (Request->Data.CreateProcessRequest.Flags & CREATE_NEW_PROCESS_GROUP)
+ {
+ NewProcessData->ProcessGroup = (DWORD)NewProcessData->ProcessId;
+ }
+ else
+ {
+ NewProcessData->ProcessGroup = ProcessData->ProcessGroup;
+ }
+
/* Set default shutdown parameters */
NewProcessData->ShutdownLevel = 0x280;
NewProcessData->ShutdownFlags = 0;
Modified: trunk/reactos/subsystems/win32/csrss/include/api.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] Sat Aug 2 12:01:22
2008
@@ -48,6 +48,7 @@
ULONG HandleTableSize;
PCSRSS_HANDLE HandleTable;
HANDLE ProcessId;
+ DWORD ProcessGroup;
HANDLE Process;
ULONG ShutdownLevel;
ULONG ShutdownFlags;
Modified: trunk/reactos/subsystems/win32/csrss/include/conio.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/conio.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/conio.h [iso-8859-1] Sat Aug 2 12:01:22
2008
@@ -41,7 +41,7 @@
USHORT ShowX, ShowY; /* beginning offset for the actual display area */
ULONG CurrentX; /* Current X cursor position */
ULONG CurrentY; /* Current Y cursor position */
- BYTE DefaultAttrib; /* default char attribute */
+ WORD DefaultAttrib; /* default char attribute */
USHORT VirtualY; /* top row of buffer being displayed, reported to
callers */
CONSOLE_CURSOR_INFO CursorInfo;
USHORT Mode;
@@ -135,6 +135,7 @@
CSR_API(CsrGetConsoleOutputCodePage);
CSR_API(CsrSetConsoleOutputCodePage);
CSR_API(CsrGetProcessList);
+CSR_API(CsrGenerateCtrlEvent);
#define ConioInitScreenBuffer(Console, Buff)
(Console)->Vtbl->InitScreenBuffer((Console), (Buff))
#define ConioDrawRegion(Console, Region) (Console)->Vtbl->DrawRegion((Console),
(Region))
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/conio.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/conio.c [iso-8859-1] Sat Aug 2 12:01:22
2008
@@ -3129,4 +3129,40 @@
return Request->Status = STATUS_SUCCESS;
}
+CSR_API(CsrGenerateCtrlEvent)
+{
+ PCSRSS_CONSOLE Console;
+ PCSRSS_PROCESS_DATA current;
+ PLIST_ENTRY current_entry;
+ DWORD Group;
+ NTSTATUS Status;
+
+ Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
+ Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
+
+ Status = ConioConsoleFromProcessData(ProcessData, &Console);
+ if (! NT_SUCCESS(Status))
+ {
+ return Request->Status = Status;
+ }
+
+ Group = Request->Data.GenerateCtrlEvent.ProcessGroup;
+ Status = STATUS_INVALID_PARAMETER;
+ for (current_entry = Console->ProcessList.Flink;
+ current_entry != &Console->ProcessList;
+ current_entry = current_entry->Flink)
+ {
+ current = CONTAINING_RECORD(current_entry, CSRSS_PROCESS_DATA, ProcessEntry);
+ if (Group == 0 || current->ProcessGroup == Group)
+ {
+ ConioConsoleCtrlEvent(Request->Data.GenerateCtrlEvent.Event, current);
+ Status = STATUS_SUCCESS;
+ }
+ }
+
+ ConioUnlockConsole(Console);
+
+ return Request->Status = Status;
+}
+
/* EOF */
Modified: trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/win…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/win32csr/dllmain.c [iso-8859-1] Sat Aug 2
12:01:22 2008
@@ -74,6 +74,7 @@
CSRSS_DEFINE_API(GET_ALL_CONSOLE_ALIASES_LENGTH, CsrGetAllConsoleAliasesLength),
CSRSS_DEFINE_API(GET_CONSOLE_ALIASES_EXES, CsrGetConsoleAliasesExes),
CSRSS_DEFINE_API(GET_CONSOLE_ALIASES_EXES_LENGTH, CsrGetConsoleAliasesExesLength),
+ CSRSS_DEFINE_API(GENERATE_CTRL_EVENT, CsrGenerateCtrlEvent),
{ 0, 0, NULL }
};