From d9289eb23003465e05b69ac07823961dda813abf Mon Sep 17 00:00:00 2001 From: Alex Ionescu Date: Fri, 30 Aug 2013 17:14:41 +0000 Subject: [PATCH] [CONSRV]: Reorganize/rename/add some fields to CONSRV_API_CONNECTINFO, partially based on an MSDN page, and a little bit of RE, which makes it closer to the Windows structure. No behavioral change should have happened as a result of these changes. svn path=/trunk/; revision=59904 --- .../dll/win32/kernel32/client/console/init.c | 30 +++---- reactos/include/reactos/subsys/win/conmsg.h | 80 +++++++++++++++---- reactos/win32ss/user/winsrv/consrv/console.c | 8 +- .../winsrv/consrv/frontends/gui/guiterm.c | 7 +- reactos/win32ss/user/winsrv/consrv/init.c | 6 +- 5 files changed, 88 insertions(+), 43 deletions(-) diff --git a/reactos/dll/win32/kernel32/client/console/init.c b/reactos/dll/win32/kernel32/client/console/init.c index 4c8f7c511e7..80a7dffb79b 100644 --- a/reactos/dll/win32/kernel32/client/console/init.c +++ b/reactos/dll/win32/kernel32/client/console/init.c @@ -121,26 +121,26 @@ InitConsoleInfo(IN OUT PCONSOLE_START_INFO ConsoleStartInfo, ConsoleStartInfo->dwStartupFlags = si.dwFlags; if (si.dwFlags & STARTF_USEFILLATTRIBUTE) { - ConsoleStartInfo->FillAttribute = si.dwFillAttribute; + ConsoleStartInfo->wFillAttribute = si.dwFillAttribute; } if (si.dwFlags & STARTF_USECOUNTCHARS) { - ConsoleStartInfo->ScreenBufferSize.X = (SHORT)(si.dwXCountChars); - ConsoleStartInfo->ScreenBufferSize.Y = (SHORT)(si.dwYCountChars); + ConsoleStartInfo->dwScreenBufferSize.X = (SHORT)(si.dwXCountChars); + ConsoleStartInfo->dwScreenBufferSize.Y = (SHORT)(si.dwYCountChars); } if (si.dwFlags & STARTF_USESHOWWINDOW) { - ConsoleStartInfo->ShowWindow = si.wShowWindow; + ConsoleStartInfo->wShowWindow = si.wShowWindow; } if (si.dwFlags & STARTF_USEPOSITION) { - ConsoleStartInfo->ConsoleWindowOrigin.x = (LONG)(si.dwX); - ConsoleStartInfo->ConsoleWindowOrigin.y = (LONG)(si.dwY); + ConsoleStartInfo->dwWindowOrigin.X = (LONG)(si.dwX); + ConsoleStartInfo->dwWindowOrigin.Y = (LONG)(si.dwY); } if (si.dwFlags & STARTF_USESIZE) { - ConsoleStartInfo->ConsoleWindowSize.cx = (LONG)(si.dwXSize); - ConsoleStartInfo->ConsoleWindowSize.cy = (LONG)(si.dwYSize); + ConsoleStartInfo->dwWindowSize.X = (LONG)(si.dwXSize); + ConsoleStartInfo->dwWindowSize.Y = (LONG) (si.dwYSize); } /* Set up the title for the console */ @@ -194,7 +194,7 @@ BasepInitConsole(VOID) { DPRINT("Image is not a console application\n"); Parameters->ConsoleHandle = NULL; - ConnectInfo.ConsoleNeeded = FALSE; // ConsoleNeeded is used for knowing whether or not this is a CUI app. + ConnectInfo.ConsoleStartInfo.ConsoleNeeded = FALSE; // ConsoleNeeded is used for knowing whether or not this is a CUI app. ConnectInfo.ConsoleStartInfo.ConsoleTitle[0] = L'\0'; ConnectInfo.ConsoleStartInfo.AppPath[0] = L'\0'; @@ -211,7 +211,7 @@ BasepInitConsole(VOID) if (ExeName) SetConsoleInputExeNameW(ExeName + 1); /* Assume one is needed */ - ConnectInfo.ConsoleNeeded = TRUE; + ConnectInfo.ConsoleStartInfo.ConsoleNeeded = TRUE; /* Handle the special flags given to us by BasePushProcessParameters */ if (Parameters->ConsoleHandle == HANDLE_DETACHED_PROCESS) @@ -219,7 +219,7 @@ BasepInitConsole(VOID) /* No console to create */ DPRINT("No console to create\n"); Parameters->ConsoleHandle = NULL; - ConnectInfo.ConsoleNeeded = FALSE; + ConnectInfo.ConsoleStartInfo.ConsoleNeeded = FALSE; } else if (Parameters->ConsoleHandle == HANDLE_CREATE_NEW_CONSOLE) { @@ -232,7 +232,7 @@ BasepInitConsole(VOID) /* We'll get the real one soon */ DPRINT("Creating new invisible console\n"); Parameters->ConsoleHandle = NULL; - ConnectInfo.ConsoleStartInfo.ShowWindow = SW_HIDE; + ConnectInfo.ConsoleStartInfo.wShowWindow = SW_HIDE; } else { @@ -249,10 +249,10 @@ BasepInitConsole(VOID) /* Initialize the Console Ctrl Handler */ InitConsoleCtrlHandling(); - ConnectInfo.CtrlDispatcher = ConsoleControlDispatcher; + ConnectInfo.ConsoleStartInfo.CtrlDispatcher = ConsoleControlDispatcher; /* Initialize the Property Dialog Handler */ - ConnectInfo.PropDispatcher = PropDialogHandler; + ConnectInfo.ConsoleStartInfo.PropDispatcher = PropDialogHandler; /* Setup the right Object Directory path */ if (!SessionId) @@ -287,7 +287,7 @@ BasepInitConsole(VOID) if (InServer) return TRUE; /* Nothing to do if not a console app */ - if (!ConnectInfo.ConsoleNeeded) return TRUE; + if (!ConnectInfo.ConsoleStartInfo.ConsoleNeeded) return TRUE; /* We got the handles, let's set them */ if ((Parameters->ConsoleHandle = ConnectInfo.ConsoleHandle)) diff --git a/reactos/include/reactos/subsys/win/conmsg.h b/reactos/include/reactos/subsys/win/conmsg.h index bebd8ec1fe2..d817b52ac47 100644 --- a/reactos/include/reactos/subsys/win/conmsg.h +++ b/reactos/include/reactos/subsys/win/conmsg.h @@ -110,38 +110,84 @@ typedef enum _CONSRV_API_NUMBER ConsolepMaxApiNumber } CONSRV_API_NUMBER, *PCONSRV_API_NUMBER; - +// +// See http://msdn.microsoft.com/en-us/library/windows/desktop/bb773359(v=vs.85).aspx +// +typedef struct _CONSOLE_PROPERTIES +{ + WORD wFillAttribute; + WORD wPopupFillAttribute; + + // + // Not on MSDN, but show up in binary + // + WORD wShowWindow; + WORD wUnknown; + + COORD dwScreenBufferSize; + COORD dwWindowSize; + COORD dwWindowOrigin; + DWORD nFont; + DWORD nInputBufferSize; + COORD dwFontSize; + UINT uFontFamily; + UINT uFontWeight; + WCHAR FaceName[LF_FACESIZE]; + UINT uCursorSize; + BOOL bFullScreen; + BOOL bQuickEdit; + BOOL bInsertMode; + BOOL bAutoPosition; + UINT uHistoryBufferSize; + UINT uNumberOfHistoryBuffers; + BOOL bHistoryNoDup; + COLORREF ColorTable[16]; + + //NT_FE_CONSOLE_PROPS + UINT uCodePage; +} CONSOLE_PROPERTIES; + +// +// To minimize code changes, some fields were put here even though they really only belong in +// CONSRV_API_CONNECTINFO. Do not change the ordering however, as it's required for Windows +// compatibility. +// typedef struct _CONSOLE_START_INFO { + INT IconIndex; + HICON IconHandle1; + HICON IconHandle2; + DWORD dwHotKey; DWORD dwStartupFlags; - DWORD FillAttribute; - COORD ScreenBufferSize; - WORD ShowWindow; - POINT ConsoleWindowOrigin; - SIZE ConsoleWindowSize; - // UNICODE_STRING ConsoleTitle; + CONSOLE_PROPERTIES; + BOOL ConsoleNeeded; // Used for GUI apps only. + LPTHREAD_START_ROUTINE CtrlDispatcher; + LPTHREAD_START_ROUTINE ImeDispatcher; + LPTHREAD_START_ROUTINE PropDispatcher; + ULONG TitleLength; WCHAR ConsoleTitle[MAX_PATH + 1]; // Console title or full path to the startup shortcut - WCHAR AppPath[MAX_PATH + 1]; // Full path of the launched app + ULONG DesktopLength; + PWCHAR DesktopPath; + ULONG AppNameLength; + WCHAR AppPath[128]; // Full path of the launched app + ULONG IconPathLength; WCHAR IconPath[MAX_PATH + 1]; // Path to the file containing the icon - INT IconIndex; // Index of the icon } CONSOLE_START_INFO, *PCONSOLE_START_INFO; typedef struct _CONSRV_API_CONNECTINFO { - BOOL ConsoleNeeded; // Used for GUI apps only. - - /* Adapted from CONSOLE_ALLOCCONSOLE */ - CONSOLE_START_INFO ConsoleStartInfo; - HANDLE ConsoleHandle; + HANDLE InputWaitHandle; HANDLE InputHandle; HANDLE OutputHandle; HANDLE ErrorHandle; - HANDLE InputWaitHandle; - LPTHREAD_START_ROUTINE CtrlDispatcher; - LPTHREAD_START_ROUTINE PropDispatcher; + HANDLE Event1; + HANDLE Event2; + /* Adapted from CONSOLE_ALLOCCONSOLE */ + CONSOLE_START_INFO ConsoleStartInfo; } CONSRV_API_CONNECTINFO, *PCONSRV_API_CONNECTINFO; +//C_ASSERT(sizeof(CONSRV_API_CONNECTINFO) == 0x638); typedef struct { diff --git a/reactos/win32ss/user/winsrv/consrv/console.c b/reactos/win32ss/user/winsrv/consrv/console.c index 932d623ff21..d904d1a17dc 100644 --- a/reactos/win32ss/user/winsrv/consrv/console.c +++ b/reactos/win32ss/user/winsrv/consrv/console.c @@ -249,17 +249,15 @@ ConSrvInitConsole(OUT PHANDLE NewConsoleHandle, */ if (ConsoleStartInfo->dwStartupFlags & STARTF_USEFILLATTRIBUTE) { - ConsoleInfo.ScreenAttrib = (USHORT)ConsoleStartInfo->FillAttribute; + ConsoleInfo.ScreenAttrib = (USHORT)ConsoleStartInfo->wFillAttribute; } if (ConsoleStartInfo->dwStartupFlags & STARTF_USECOUNTCHARS) { - ConsoleInfo.ScreenBufferSize = ConsoleStartInfo->ScreenBufferSize; + ConsoleInfo.ScreenBufferSize = ConsoleStartInfo->dwScreenBufferSize; } if (ConsoleStartInfo->dwStartupFlags & STARTF_USESIZE) { - // ConsoleInfo.ConsoleSize = ConsoleStartInfo->ConsoleWindowSize; - ConsoleInfo.ConsoleSize.X = (SHORT)ConsoleStartInfo->ConsoleWindowSize.cx; - ConsoleInfo.ConsoleSize.Y = (SHORT)ConsoleStartInfo->ConsoleWindowSize.cy; + ConsoleInfo.ConsoleSize = ConsoleStartInfo->dwWindowSize; } } diff --git a/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c b/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c index 34fe68fdc0b..33727ebc1f5 100644 --- a/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c +++ b/reactos/win32ss/user/winsrv/consrv/frontends/gui/guiterm.c @@ -2279,12 +2279,13 @@ GuiInitFrontEnd(IN OUT PFRONTEND This, */ if (ConsoleStartInfo->dwStartupFlags & STARTF_USESHOWWINDOW) { - TermInfo.ShowWindow = ConsoleStartInfo->ShowWindow; + TermInfo.ShowWindow = ConsoleStartInfo->wShowWindow; } if (ConsoleStartInfo->dwStartupFlags & STARTF_USEPOSITION) { TermInfo.AutoPosition = FALSE; - TermInfo.WindowOrigin = ConsoleStartInfo->ConsoleWindowOrigin; + TermInfo.WindowOrigin.x = ConsoleStartInfo->dwWindowOrigin.X; + TermInfo.WindowOrigin.y = ConsoleStartInfo->dwWindowOrigin.Y; } if (ConsoleStartInfo->dwStartupFlags & STARTF_RUNFULLSCREEN) { @@ -2868,7 +2869,7 @@ LoadShellLinkConsoleInfo(IN OUT PCONSOLE_START_INFO ConsoleStartInfo, /* Get the window showing command */ hRes = IShellLinkW_GetShowCmd(pshl, &ShowCmd); - if (SUCCEEDED(hRes)) ConsoleStartInfo->ShowWindow = (WORD)ShowCmd; + if (SUCCEEDED(hRes)) ConsoleStartInfo->wShowWindow = (WORD)ShowCmd; /* Get the hotkey */ // hRes = pshl->GetHotkey(&ShowCmd); diff --git a/reactos/win32ss/user/winsrv/consrv/init.c b/reactos/win32ss/user/winsrv/consrv/init.c index e33a0aaadab..09b268597d8 100644 --- a/reactos/win32ss/user/winsrv/consrv/init.c +++ b/reactos/win32ss/user/winsrv/consrv/init.c @@ -413,7 +413,7 @@ ConSrvConnect(IN PCSR_PROCESS CsrProcess, } /* If we don't need a console, then get out of here */ - if (!ConnectInfo->ConsoleNeeded || !ProcessData->ConsoleApp) // In fact, it is for GUI apps. + if (!ConnectInfo->ConsoleStartInfo.ConsoleNeeded || !ProcessData->ConsoleApp) // In fact, it is for GUI apps. { return STATUS_SUCCESS; } @@ -470,8 +470,8 @@ ConSrvConnect(IN PCSR_PROCESS CsrProcess, ConnectInfo->InputWaitHandle = ProcessData->ConsoleEvent; /* Set the Property-Dialog and Control-Dispatcher handlers */ - ProcessData->PropDispatcher = ConnectInfo->PropDispatcher; - ProcessData->CtrlDispatcher = ConnectInfo->CtrlDispatcher; + ProcessData->PropDispatcher = ConnectInfo->ConsoleStartInfo.PropDispatcher; + ProcessData->CtrlDispatcher = ConnectInfo->ConsoleStartInfo.CtrlDispatcher; return STATUS_SUCCESS; } -- 2.17.1