mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 10:04:49 +00:00
Implement GUI consoles
svn path=/trunk/; revision=6389
This commit is contained in:
parent
f0f8de0966
commit
2515e0e291
20 changed files with 1880 additions and 595 deletions
|
@ -108,6 +108,7 @@ copy /Y services\eventlog\eventlog.exe %BOOTCD_DIR%\disk\reactos
|
||||||
copy /Y services\rpcss\rpcss.exe %BOOTCD_DIR%\disk\reactos
|
copy /Y services\rpcss\rpcss.exe %BOOTCD_DIR%\disk\reactos
|
||||||
|
|
||||||
copy /Y subsys\csrss\csrss.exe %BOOTCD_DIR%\disk\reactos
|
copy /Y subsys\csrss\csrss.exe %BOOTCD_DIR%\disk\reactos
|
||||||
|
copy /Y subsys\csrss\usercsr\usercsr.dll %BOOTCD_DIR%\disk\reactos
|
||||||
copy /Y subsys\ntvdm\ntvdm.exe %BOOTCD_DIR%\disk\reactos
|
copy /Y subsys\ntvdm\ntvdm.exe %BOOTCD_DIR%\disk\reactos
|
||||||
copy /Y subsys\smss\smss.exe %BOOTCD_DIR%\disk\reactos
|
copy /Y subsys\smss\smss.exe %BOOTCD_DIR%\disk\reactos
|
||||||
copy /Y subsys\system\autochk\autochk.exe %BOOTCD_DIR%\disk\reactos
|
copy /Y subsys\system\autochk\autochk.exe %BOOTCD_DIR%\disk\reactos
|
||||||
|
|
|
@ -68,6 +68,7 @@ lib\ws2help\ws2help.dll 1
|
||||||
lib\wshirda\wshirda.dll 1
|
lib\wshirda\wshirda.dll 1
|
||||||
lib\wsock32\wsock32.dll 1
|
lib\wsock32\wsock32.dll 1
|
||||||
subsys\csrss\csrss.exe 1
|
subsys\csrss\csrss.exe 1
|
||||||
|
subsys\csrss\usercsr\usercsr.dll 1
|
||||||
subsys\ntvdm\ntvdm.exe 1
|
subsys\ntvdm\ntvdm.exe 1
|
||||||
subsys\smss\smss.exe 1
|
subsys\smss\smss.exe 1
|
||||||
subsys\win32k\win32k.sys 1
|
subsys\win32k\win32k.sys 1
|
||||||
|
|
|
@ -98,6 +98,7 @@ cp lib/wsock32/wsock32.dll $ROS_INSTALL/system32
|
||||||
cp lib/kbdus/kbdus.dll $ROS_INSTALL/system32
|
cp lib/kbdus/kbdus.dll $ROS_INSTALL/system32
|
||||||
cp subsys/smss/smss.exe $ROS_INSTALL/system32
|
cp subsys/smss/smss.exe $ROS_INSTALL/system32
|
||||||
cp subsys/csrss/csrss.exe $ROS_INSTALL/system32
|
cp subsys/csrss/csrss.exe $ROS_INSTALL/system32
|
||||||
|
cp subsys/csrss/usercsr/usercsr.dll $ROS_INSTALL/system32
|
||||||
cp subsys/ntvdm/ntvdm.exe $ROS_INSTALL/system32
|
cp subsys/ntvdm/ntvdm.exe $ROS_INSTALL/system32
|
||||||
cp subsys/win32k/win32k.sys $ROS_INSTALL/system32
|
cp subsys/win32k/win32k.sys $ROS_INSTALL/system32
|
||||||
cp subsys/system/usetup/usetup.exe $ROS_INSTALL/system32
|
cp subsys/system/usetup/usetup.exe $ROS_INSTALL/system32
|
||||||
|
|
|
@ -104,6 +104,7 @@ copy services\eventlog\eventlog.exe %ROS_INSTALL%\system32
|
||||||
copy services\rpcss\rpcss.exe %ROS_INSTALL%\system32
|
copy services\rpcss\rpcss.exe %ROS_INSTALL%\system32
|
||||||
copy subsys\smss\smss.exe %ROS_INSTALL%\system32
|
copy subsys\smss\smss.exe %ROS_INSTALL%\system32
|
||||||
copy subsys\csrss\csrss.exe %ROS_INSTALL%\system32
|
copy subsys\csrss\csrss.exe %ROS_INSTALL%\system32
|
||||||
|
copy subsys\csrss\usercsr\usercsr.dll %ROS_INSTALL%\system32
|
||||||
copy subsys\ntvdm\ntvdm.exe %ROS_INSTALL%\system32
|
copy subsys\ntvdm\ntvdm.exe %ROS_INSTALL%\system32
|
||||||
copy subsys\win32k\win32k.sys %ROS_INSTALL%\system32
|
copy subsys\win32k\win32k.sys %ROS_INSTALL%\system32
|
||||||
copy subsys\system\usetup\usetup.exe %ROS_INSTALL%\system32
|
copy subsys\system\usetup\usetup.exe %ROS_INSTALL%\system32
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: process.c,v 1.28 2003/08/18 10:58:49 hbirr Exp $
|
/* $Id: process.c,v 1.29 2003/10/20 18:02:04 gvg Exp $
|
||||||
*
|
*
|
||||||
* reactos/subsys/csrss/api/process.c
|
* reactos/subsys/csrss/api/process.c
|
||||||
*
|
*
|
||||||
|
@ -39,7 +39,6 @@ VOID STDCALL CsrInitProcessData(VOID)
|
||||||
|
|
||||||
PCSRSS_PROCESS_DATA STDCALL CsrGetProcessData(ULONG ProcessId)
|
PCSRSS_PROCESS_DATA STDCALL CsrGetProcessData(ULONG ProcessId)
|
||||||
{
|
{
|
||||||
ULONG i;
|
|
||||||
ULONG hash;
|
ULONG hash;
|
||||||
PCSRSS_PROCESS_DATA pProcessData;
|
PCSRSS_PROCESS_DATA pProcessData;
|
||||||
|
|
||||||
|
@ -59,7 +58,6 @@ PCSRSS_PROCESS_DATA STDCALL CsrGetProcessData(ULONG ProcessId)
|
||||||
|
|
||||||
PCSRSS_PROCESS_DATA STDCALL CsrCreateProcessData(ULONG ProcessId)
|
PCSRSS_PROCESS_DATA STDCALL CsrCreateProcessData(ULONG ProcessId)
|
||||||
{
|
{
|
||||||
ULONG i;
|
|
||||||
ULONG hash;
|
ULONG hash;
|
||||||
PCSRSS_PROCESS_DATA pProcessData;
|
PCSRSS_PROCESS_DATA pProcessData;
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@ typedef struct ConsoleInput_t
|
||||||
BOOLEAN Fake; // synthesized, not a real event
|
BOOLEAN Fake; // synthesized, not a real event
|
||||||
} ConsoleInput;
|
} ConsoleInput;
|
||||||
|
|
||||||
|
typedef struct CSRSS_CONSOLE_t *PCSRSS_CONSOLE;
|
||||||
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* Screen buffer structure represents the win32 screen buffer object. *
|
* Screen buffer structure represents the win32 screen buffer object. *
|
||||||
|
@ -53,6 +54,8 @@ typedef struct CSRSS_SCREEN_BUFFER_t
|
||||||
USHORT VirtualX; /* top row of buffer being displayed, reported to callers */
|
USHORT VirtualX; /* top row of buffer being displayed, reported to callers */
|
||||||
CONSOLE_CURSOR_INFO CursorInfo;
|
CONSOLE_CURSOR_INFO CursorInfo;
|
||||||
USHORT Mode;
|
USHORT Mode;
|
||||||
|
PCSRSS_CONSOLE Console; /* Console this buffer is currently attached to */
|
||||||
|
CRITICAL_SECTION Lock;
|
||||||
} CSRSS_SCREEN_BUFFER, *PCSRSS_SCREEN_BUFFER;
|
} CSRSS_SCREEN_BUFFER, *PCSRSS_SCREEN_BUFFER;
|
||||||
|
|
||||||
typedef struct CSRSS_CONSOLE_t
|
typedef struct CSRSS_CONSOLE_t
|
||||||
|
@ -74,8 +77,10 @@ typedef struct CSRSS_CONSOLE_t
|
||||||
BOOL EarlyReturn; /* wake client and return data, even if we are in line buffered mode, and we don't have a complete line */
|
BOOL EarlyReturn; /* wake client and return data, even if we are in line buffered mode, and we don't have a complete line */
|
||||||
DWORD HardwareState; /* _GDI_MANAGED, _DIRECT */
|
DWORD HardwareState; /* _GDI_MANAGED, _DIRECT */
|
||||||
HWND hWindow;
|
HWND hWindow;
|
||||||
|
COORD Size;
|
||||||
|
PVOID GuiConsoleData;
|
||||||
LIST_ENTRY ProcessList;
|
LIST_ENTRY ProcessList;
|
||||||
} CSRSS_CONSOLE, *PCSRSS_CONSOLE;
|
} CSRSS_CONSOLE;
|
||||||
|
|
||||||
typedef struct _CSRSS_PROCESS_DATA
|
typedef struct _CSRSS_PROCESS_DATA
|
||||||
{
|
{
|
||||||
|
@ -160,7 +165,10 @@ extern HANDLE CsrssApiHeap;
|
||||||
NTSTATUS STDCALL CsrInitConsole(PCSRSS_CONSOLE Console);
|
NTSTATUS STDCALL CsrInitConsole(PCSRSS_CONSOLE Console);
|
||||||
VOID STDCALL CsrDeleteConsole( PCSRSS_CONSOLE Console );
|
VOID STDCALL CsrDeleteConsole( PCSRSS_CONSOLE Console );
|
||||||
VOID STDCALL CsrDeleteScreenBuffer( PCSRSS_SCREEN_BUFFER Buffer );
|
VOID STDCALL CsrDeleteScreenBuffer( PCSRSS_SCREEN_BUFFER Buffer );
|
||||||
NTSTATUS STDCALL CsrInitConsoleScreenBuffer( PCSRSS_SCREEN_BUFFER Console );
|
NTSTATUS STDCALL CsrInitConsoleScreenBuffer(PCSRSS_SCREEN_BUFFER Buffer,
|
||||||
|
PCSRSS_CONSOLE Console,
|
||||||
|
unsigned Width,
|
||||||
|
unsigned Height);
|
||||||
VOID STDCALL CsrInitConsoleSupport(VOID);
|
VOID STDCALL CsrInitConsoleSupport(VOID);
|
||||||
|
|
||||||
/* api/process.c */
|
/* api/process.c */
|
||||||
|
@ -174,7 +182,7 @@ NTSTATUS STDCALL CsrGetObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, O
|
||||||
BOOL STDCALL CsrServerInitialization (ULONG ArgumentCount, PWSTR *ArgumentArray);
|
BOOL STDCALL CsrServerInitialization (ULONG ArgumentCount, PWSTR *ArgumentArray);
|
||||||
NTSTATUS STDCALL CsrReleaseObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
|
NTSTATUS STDCALL CsrReleaseObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
|
||||||
NTSTATUS STDCALL CsrVerifyObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
|
NTSTATUS STDCALL CsrVerifyObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
|
||||||
VOID STDCALL CsrDrawConsole( PCSRSS_SCREEN_BUFFER Console );
|
VOID STDCALL CsrDrawConsole(PCSRSS_CONSOLE Console);
|
||||||
NTSTATUS STDCALL CsrpWriteConsole( PCSRSS_SCREEN_BUFFER Buff, CHAR *Buffer, DWORD Length, BOOL Attrib );
|
NTSTATUS STDCALL CsrpWriteConsole( PCSRSS_SCREEN_BUFFER Buff, CHAR *Buffer, DWORD Length, BOOL Attrib );
|
||||||
|
|
||||||
#endif /* ndef _CSRSS_API_H */
|
#endif /* ndef _CSRSS_API_H */
|
34
reactos/subsys/csrss/include/usercsr.h
Normal file
34
reactos/subsys/csrss/include/usercsr.h
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
/* $Id: usercsr.h,v 1.1 2003/10/20 18:02:04 gvg Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: subsys/csrss/usercsr/usercsr.h
|
||||||
|
* PURPOSE: Interface to usercsr.dll
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
|
||||||
|
typedef BOOL STDCALL (*USERCSRINITCONSOLEPROC)(PCSRSS_CONSOLE Console);
|
||||||
|
typedef VOID STDCALL (*USERCSRDRAWREGIONPROC)(PCSRSS_CONSOLE Console, SMALL_RECT Region);
|
||||||
|
typedef VOID STDCALL (*USERCSRCOPYREGIONPROC)(PCSRSS_CONSOLE Console,
|
||||||
|
RECT *Source,
|
||||||
|
RECT *Dest);
|
||||||
|
typedef VOID STDCALL (*USERCSRCHANGETITLEPROC)(PCSRSS_CONSOLE Console);
|
||||||
|
typedef VOID STDCALL (*USERCSRDELETECONSOLEPROC)(PCSRSS_CONSOLE Console);
|
||||||
|
typedef VOID STDCALL (*USERCSRPROCESSKEYCALLBACK)(MSG *msg, PCSRSS_CONSOLE Console);
|
||||||
|
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
USERCSRINITCONSOLEPROC InitConsole;
|
||||||
|
USERCSRDRAWREGIONPROC DrawRegion;
|
||||||
|
USERCSRCOPYREGIONPROC CopyRegion;
|
||||||
|
USERCSRCHANGETITLEPROC ChangeTitle;
|
||||||
|
USERCSRDELETECONSOLEPROC DeleteConsole;
|
||||||
|
} USERCSRFUNCS, *PUSERCSRFUNCS;
|
||||||
|
|
||||||
|
typedef BOOL STDCALL (*USERCSRINITIALIZEPROC)(PUSERCSRFUNCS Funcs,
|
||||||
|
HANDLE CsrssApiHeap,
|
||||||
|
USERCSRPROCESSKEYCALLBACK ProcessKey);
|
||||||
|
|
||||||
|
extern HANDLE UserCsrApiHeap;
|
||||||
|
extern USERCSRPROCESSKEYCALLBACK UserCsrProcessKey;
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: init.c,v 1.21 2003/08/19 11:48:49 weiden Exp $
|
/* $Id: init.c,v 1.22 2003/10/20 18:02:04 gvg Exp $
|
||||||
*
|
*
|
||||||
* reactos/subsys/csrss/init.c
|
* reactos/subsys/csrss/init.c
|
||||||
*
|
*
|
||||||
|
@ -50,9 +50,7 @@ CsrParseCommandLine (
|
||||||
{
|
{
|
||||||
NTSTATUS Status;
|
NTSTATUS Status;
|
||||||
OBJECT_ATTRIBUTES Attributes;
|
OBJECT_ATTRIBUTES Attributes;
|
||||||
ANSI_STRING AnsiString;
|
|
||||||
|
|
||||||
ULONG i;
|
|
||||||
|
|
||||||
/* DbgPrint ("Arguments: %ld\n", ArgumentCount);
|
/* DbgPrint ("Arguments: %ld\n", ArgumentCount);
|
||||||
for (i = 0; i < ArgumentCount; i++)
|
for (i = 0; i < ArgumentCount; i++)
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
# $Id: makefile,v 1.22 2003/08/07 04:03:24 royce Exp $
|
# $Id: makefile,v 1.23 2003/10/20 18:02:04 gvg Exp $
|
||||||
|
|
||||||
PATH_TO_TOP = ../..
|
PATH_TO_TOP = ../..
|
||||||
|
|
||||||
|
@ -9,13 +9,19 @@ TARGET_APPTYPE = native
|
||||||
|
|
||||||
TARGET_NAME = csrss
|
TARGET_NAME = csrss
|
||||||
|
|
||||||
|
#TARGET_SDKLIBS = kernel32.a gdi32.a user32.a ntdll.a
|
||||||
|
|
||||||
TARGET_INSTALLDIR = system32
|
TARGET_INSTALLDIR = system32
|
||||||
|
|
||||||
TARGET_CFLAGS = -D__NTAPP__
|
TARGET_CFLAGS = -D__NTAPP__ -Wall -Werror -Iinclude
|
||||||
|
|
||||||
|
TARGET_LFLAGS = -nostdlib
|
||||||
|
|
||||||
# require os code to explicitly request A/W version of structs/functions
|
# require os code to explicitly request A/W version of structs/functions
|
||||||
TARGET_CFLAGS += -D_DISABLE_TIDENTS
|
TARGET_CFLAGS += -D_DISABLE_TIDENTS
|
||||||
|
|
||||||
|
SUBDIRS = usercsr
|
||||||
|
|
||||||
OBJECTS_API = \
|
OBJECTS_API = \
|
||||||
api/process.o \
|
api/process.o \
|
||||||
api/wapi.o \
|
api/wapi.o \
|
||||||
|
@ -34,8 +40,27 @@ TARGET_OBJECTS = \
|
||||||
$(OBJECTS_API) \
|
$(OBJECTS_API) \
|
||||||
$(OBJECTS_MISC)
|
$(OBJECTS_MISC)
|
||||||
|
|
||||||
|
DEP_OBJECTS = $(TARGET_OBJECTS)
|
||||||
|
|
||||||
include $(PATH_TO_TOP)/rules.mak
|
include $(PATH_TO_TOP)/rules.mak
|
||||||
|
|
||||||
include $(TOOLS_PATH)/helper.mk
|
include $(TOOLS_PATH)/helper.mk
|
||||||
|
|
||||||
|
include $(TOOLS_PATH)/depend.mk
|
||||||
|
|
||||||
|
#all::
|
||||||
|
# $(MAKE) -C usercsr all
|
||||||
|
#
|
||||||
|
#clean::
|
||||||
|
# $(MAKE) -C usercsr clean
|
||||||
|
#
|
||||||
|
#install::
|
||||||
|
# $(MAKE) -C usercsr install
|
||||||
|
#
|
||||||
|
#dist::
|
||||||
|
# $(MAKE) -C usercsr dist
|
||||||
|
#
|
||||||
|
#bootcd::
|
||||||
|
# $(MAKE) -C usercsr bootcd
|
||||||
|
|
||||||
# EOF
|
# EOF
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: print.c,v 1.5 2002/09/08 10:23:44 chorns Exp $
|
/* $Id: print.c,v 1.6 2003/10/20 18:02:04 gvg Exp $
|
||||||
*
|
*
|
||||||
* smss.c - Session Manager
|
* smss.c - Session Manager
|
||||||
*
|
*
|
||||||
|
@ -46,7 +46,6 @@ VOID STDCALL PrintString (char* fmt, ...)
|
||||||
va_list ap;
|
va_list ap;
|
||||||
UNICODE_STRING UnicodeString;
|
UNICODE_STRING UnicodeString;
|
||||||
ANSI_STRING AnsiString;
|
ANSI_STRING AnsiString;
|
||||||
ULONG i;
|
|
||||||
|
|
||||||
va_start(ap, fmt);
|
va_start(ap, fmt);
|
||||||
vsprintf(buffer, fmt, ap);
|
vsprintf(buffer, fmt, ap);
|
||||||
|
|
7
reactos/subsys/csrss/usercsr/.cvsignore
Normal file
7
reactos/subsys/csrss/usercsr/.cvsignore
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
usercsr.coff
|
||||||
|
usercsr.dll
|
||||||
|
usercsr.nostrip.dll
|
||||||
|
*.d
|
||||||
|
*.o
|
||||||
|
*.sym
|
||||||
|
*.map
|
49
reactos/subsys/csrss/usercsr/dllmain.c
Normal file
49
reactos/subsys/csrss/usercsr/dllmain.c
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
/* $Id: dllmain.c,v 1.1 2003/10/20 18:02:04 gvg Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: subsys/csrss/usercsr/dllmain.c
|
||||||
|
* PURPOSE: Initialization
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include "guiconsole.h"
|
||||||
|
#include "usercsr.h"
|
||||||
|
|
||||||
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
HANDLE UserCsrApiHeap;
|
||||||
|
USERCSRPROCESSKEYCALLBACK UserCsrProcessKey;
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
BOOL STDCALL
|
||||||
|
DllMain(HANDLE hDll,
|
||||||
|
DWORD dwReason,
|
||||||
|
LPVOID lpReserved)
|
||||||
|
{
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL STDCALL
|
||||||
|
UserCsrInitialization(PUSERCSRFUNCS Funcs,
|
||||||
|
HANDLE CsrssApiHeap,
|
||||||
|
USERCSRPROCESSKEYCALLBACK ProcessKey)
|
||||||
|
{
|
||||||
|
UserCsrApiHeap = CsrssApiHeap;
|
||||||
|
UserCsrProcessKey = ProcessKey;
|
||||||
|
|
||||||
|
GuiConsoleInitConsoleSupport();
|
||||||
|
|
||||||
|
Funcs->InitConsole = GuiConsoleInitConsole;
|
||||||
|
Funcs->DrawRegion = GuiConsoleDrawRegion;
|
||||||
|
Funcs->CopyRegion = GuiConsoleCopyRegion;
|
||||||
|
Funcs->ChangeTitle = GuiConsoleChangeTitle;
|
||||||
|
Funcs->DeleteConsole = GuiConsoleDeleteConsole;
|
||||||
|
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
694
reactos/subsys/csrss/usercsr/guiconsole.c
Normal file
694
reactos/subsys/csrss/usercsr/guiconsole.c
Normal file
|
@ -0,0 +1,694 @@
|
||||||
|
/* $Id: guiconsole.c,v 1.1 2003/10/20 18:02:04 gvg Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: subsys/csrss/usercsr/dllmain.c
|
||||||
|
* PURPOSE: Initialization
|
||||||
|
*/
|
||||||
|
|
||||||
|
/* INCLUDES ******************************************************************/
|
||||||
|
|
||||||
|
#include <windows.h>
|
||||||
|
#include "guiconsole.h"
|
||||||
|
#include "usercsr.h"
|
||||||
|
|
||||||
|
/* GLOBALS *******************************************************************/
|
||||||
|
|
||||||
|
typedef struct GUI_CONSOLE_DATA_TAG
|
||||||
|
{
|
||||||
|
HFONT Font;
|
||||||
|
unsigned CharWidth;
|
||||||
|
unsigned CharHeight;
|
||||||
|
PWCHAR LineBuffer;
|
||||||
|
BOOL CursorBlinkOn;
|
||||||
|
BOOL ForceCursorOff;
|
||||||
|
} GUI_CONSOLE_DATA, *PGUI_CONSOLE_DATA;
|
||||||
|
|
||||||
|
#ifndef WM_APP
|
||||||
|
#define WM_APP 0x8000
|
||||||
|
#endif
|
||||||
|
#define PM_CREATE_CONSOLE (WM_APP + 1)
|
||||||
|
#define PM_DESTROY_CONSOLE (WM_APP + 2)
|
||||||
|
|
||||||
|
#define PM_COPY_REGION (WM_APP + 100)
|
||||||
|
|
||||||
|
#define CURSOR_BLINK_TIME 500
|
||||||
|
|
||||||
|
static HWND NotifyWnd;
|
||||||
|
|
||||||
|
/* FUNCTIONS *****************************************************************/
|
||||||
|
|
||||||
|
static VOID FASTCALL
|
||||||
|
GuiConsoleGetDataPointers(HWND hWnd, PCSRSS_CONSOLE *Console, PGUI_CONSOLE_DATA *GuiData)
|
||||||
|
{
|
||||||
|
*Console = (PCSRSS_CONSOLE) GetWindowLongW(hWnd, GWL_USERDATA);
|
||||||
|
*GuiData = (NULL == *Console ? NULL : (*Console)->GuiConsoleData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static BOOL FASTCALL
|
||||||
|
GuiConsoleHandleNcCreate(HWND hWnd, CREATESTRUCTW *Create)
|
||||||
|
{
|
||||||
|
RECT Rect;
|
||||||
|
PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) Create->lpCreateParams;
|
||||||
|
PGUI_CONSOLE_DATA GuiData;
|
||||||
|
HDC Dc;
|
||||||
|
HFONT OldFont;
|
||||||
|
TEXTMETRICW Metrics;
|
||||||
|
|
||||||
|
GuiData = HeapAlloc(UserCsrApiHeap, 0,
|
||||||
|
sizeof(GUI_CONSOLE_DATA) +
|
||||||
|
(Console->Size.X + 1) * sizeof(WCHAR));
|
||||||
|
if (NULL == GuiData)
|
||||||
|
{
|
||||||
|
DbgPrint("GuiConsoleNcCreate: HeapAlloc failed\n");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
GuiData->LineBuffer = (PWCHAR)(GuiData + 1);
|
||||||
|
|
||||||
|
GuiData->Font = CreateFontW(12, 0, 0, TA_BASELINE, FW_NORMAL,
|
||||||
|
FALSE, FALSE, FALSE, ANSI_CHARSET,
|
||||||
|
OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS,
|
||||||
|
DEFAULT_QUALITY, FIXED_PITCH | FF_DONTCARE,
|
||||||
|
L"Bitstream Vera Sans Mono");
|
||||||
|
if (NULL == GuiData->Font)
|
||||||
|
{
|
||||||
|
DbgPrint("GuiConsoleNcCreate: CreateFont failed\n");
|
||||||
|
HeapFree(UserCsrApiHeap, 0, GuiData);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
Dc = GetDC(hWnd);
|
||||||
|
if (NULL == Dc)
|
||||||
|
{
|
||||||
|
DbgPrint("GuiConsoleNcCreate: GetDC failed\n");
|
||||||
|
HeapFree(UserCsrApiHeap, 0, GuiData);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
OldFont = SelectObject(Dc, GuiData->Font);
|
||||||
|
if (NULL == OldFont)
|
||||||
|
{
|
||||||
|
DbgPrint("GuiConsoleNcCreate: SelectObject failed\n");
|
||||||
|
ReleaseDC(hWnd, Dc);
|
||||||
|
HeapFree(UserCsrApiHeap, 0, GuiData);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (! GetTextMetricsW(Dc, &Metrics))
|
||||||
|
{
|
||||||
|
DbgPrint("GuiConsoleNcCreate: GetTextMetrics failed\n");
|
||||||
|
SelectObject(Dc, OldFont);
|
||||||
|
ReleaseDC(hWnd, Dc);
|
||||||
|
HeapFree(UserCsrApiHeap, 0, GuiData);
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
GuiData->CharWidth = Metrics.tmMaxCharWidth;
|
||||||
|
GuiData->CharHeight = Metrics.tmHeight + Metrics.tmExternalLeading;
|
||||||
|
SelectObject(Dc, OldFont);
|
||||||
|
ReleaseDC(hWnd, Dc);
|
||||||
|
GuiData->CursorBlinkOn = TRUE;
|
||||||
|
GuiData->ForceCursorOff = FALSE;
|
||||||
|
|
||||||
|
Console->GuiConsoleData = GuiData;
|
||||||
|
SetWindowLongW(hWnd, GWL_USERDATA, (LONG) Console);
|
||||||
|
|
||||||
|
GetWindowRect(hWnd, &Rect);
|
||||||
|
Rect.right = Rect.left + Console->Size.X * GuiData->CharWidth +
|
||||||
|
2 * GetSystemMetrics(SM_CXFIXEDFRAME);
|
||||||
|
Rect.bottom = Rect.top + Console->Size.Y * GuiData->CharHeight +
|
||||||
|
2 * GetSystemMetrics(SM_CYFIXEDFRAME) + GetSystemMetrics(SM_CYCAPTION);
|
||||||
|
MoveWindow(hWnd, Rect.left, Rect.top, Rect.right - Rect.left,
|
||||||
|
Rect.bottom - Rect.top, FALSE);
|
||||||
|
|
||||||
|
SetTimer(hWnd, 1, CURSOR_BLINK_TIME, NULL);
|
||||||
|
|
||||||
|
return (BOOL) DefWindowProcW(hWnd, WM_NCCREATE, 0, (LPARAM) Create);
|
||||||
|
}
|
||||||
|
|
||||||
|
static COLORREF FASTCALL
|
||||||
|
GuiConsoleRGBFromAttribute(BYTE Attribute)
|
||||||
|
{
|
||||||
|
int Red = (Attribute & 0x04 ? (Attribute & 0x08 ? 0xff : 0x80) : 0x00);
|
||||||
|
int Green = (Attribute & 0x02 ? (Attribute & 0x08 ? 0xff : 0x80) : 0x00);
|
||||||
|
int Blue = (Attribute & 0x01 ? (Attribute & 0x08 ? 0xff : 0x80) : 0x00);
|
||||||
|
|
||||||
|
return RGB(Red, Green, Blue);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID FASTCALL
|
||||||
|
GuiConsoleSetTextColors(HDC Dc, BYTE Attribute)
|
||||||
|
{
|
||||||
|
SetTextColor(Dc, GuiConsoleRGBFromAttribute(Attribute & 0x0f));
|
||||||
|
SetBkColor(Dc, GuiConsoleRGBFromAttribute((Attribute & 0xf0) >> 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID FASTCALL
|
||||||
|
GuiConsoleGetLogicalCursorPos(PCSRSS_SCREEN_BUFFER Buff, ULONG *CursorX, ULONG *CursorY)
|
||||||
|
{
|
||||||
|
*CursorX = Buff->CurrentX;
|
||||||
|
if (Buff->CurrentY < Buff->ShowY)
|
||||||
|
{
|
||||||
|
*CursorY = Buff->MaxY - Buff->ShowY + Buff->CurrentY;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
*CursorY = Buff->CurrentY - Buff->ShowY;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID FASTCALL
|
||||||
|
GuiConsoleHandlePaint(HWND hWnd)
|
||||||
|
{
|
||||||
|
PAINTSTRUCT Ps;
|
||||||
|
HDC Dc;
|
||||||
|
PCSRSS_CONSOLE Console;
|
||||||
|
PGUI_CONSOLE_DATA GuiData;
|
||||||
|
PCSRSS_SCREEN_BUFFER Buff;
|
||||||
|
unsigned TopLine, BottomLine, LeftChar, RightChar;
|
||||||
|
unsigned Line, Char, Start;
|
||||||
|
HFONT OldFont;
|
||||||
|
PCHAR From;
|
||||||
|
PWCHAR To;
|
||||||
|
BYTE LastAttribute, Attribute;
|
||||||
|
ULONG CursorX, CursorY, CursorHeight;
|
||||||
|
HBRUSH CursorBrush, OldBrush;
|
||||||
|
|
||||||
|
GuiConsoleGetDataPointers(hWnd, &Console, &GuiData);
|
||||||
|
if (NULL != Console && NULL != GuiData && NULL != Console->ActiveBuffer)
|
||||||
|
{
|
||||||
|
Buff = Console->ActiveBuffer;
|
||||||
|
EnterCriticalSection(&(Buff->Lock));
|
||||||
|
|
||||||
|
Dc = BeginPaint(hWnd, &Ps);
|
||||||
|
if (Ps.rcPaint.right <= Ps.rcPaint.left || Ps.rcPaint.bottom <= Ps.rcPaint.top)
|
||||||
|
{
|
||||||
|
EndPaint(hWnd, &Ps);
|
||||||
|
LeaveCriticalSection(&(Buff->Lock));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
OldFont = SelectObject(Dc, GuiData->Font);
|
||||||
|
|
||||||
|
TopLine = Ps.rcPaint.top / GuiData->CharHeight;
|
||||||
|
BottomLine = (Ps.rcPaint.bottom + (GuiData->CharHeight - 1)) / GuiData->CharHeight - 1;
|
||||||
|
LeftChar = Ps.rcPaint.left / GuiData->CharWidth;
|
||||||
|
RightChar = (Ps.rcPaint.right + (GuiData->CharWidth - 1)) / GuiData->CharWidth - 1;
|
||||||
|
LastAttribute = Buff->Buffer[(TopLine * Buff->MaxX + LeftChar) * 2 + 1];
|
||||||
|
GuiConsoleSetTextColors(Dc, LastAttribute);
|
||||||
|
for (Line = TopLine; Line <= BottomLine; Line++)
|
||||||
|
{
|
||||||
|
if (Line + Buff->ShowY < Buff->MaxY)
|
||||||
|
{
|
||||||
|
From = Buff->Buffer + ((Line + Buff->ShowY) * Buff->MaxX + LeftChar) * 2;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
From = Buff->Buffer +
|
||||||
|
((Line - (Buff->MaxY - Buff->ShowY)) * Buff->MaxX + LeftChar) * 2;
|
||||||
|
}
|
||||||
|
Attribute = *(From + 1);
|
||||||
|
Start = LeftChar;
|
||||||
|
To = GuiData->LineBuffer;
|
||||||
|
for (Char = LeftChar; Char <= RightChar; Char++)
|
||||||
|
{
|
||||||
|
if (*(From + 1) != Attribute)
|
||||||
|
{
|
||||||
|
TextOutW(Dc, Start * GuiData->CharWidth, Line * GuiData->CharHeight,
|
||||||
|
GuiData->LineBuffer, Char - Start);
|
||||||
|
Start = Char;
|
||||||
|
Attribute = *(From + 1);
|
||||||
|
if (Attribute != LastAttribute)
|
||||||
|
{
|
||||||
|
GuiConsoleSetTextColors(Dc, LastAttribute);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*((PBYTE) To) = *From;
|
||||||
|
*(((PBYTE) To) + 1) = '\0';
|
||||||
|
To++;
|
||||||
|
From += 2;
|
||||||
|
}
|
||||||
|
TextOutW(Dc, Start * GuiData->CharWidth, Line * GuiData->CharHeight,
|
||||||
|
GuiData->LineBuffer, RightChar - Start + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
SelectObject(Dc, OldFont);
|
||||||
|
|
||||||
|
if (Buff->CursorInfo.bVisible && GuiData->CursorBlinkOn
|
||||||
|
&&! GuiData->ForceCursorOff)
|
||||||
|
{
|
||||||
|
GuiConsoleGetLogicalCursorPos(Buff, &CursorX, &CursorY);
|
||||||
|
if (LeftChar <= CursorX && CursorX <= RightChar &&
|
||||||
|
TopLine <= CursorY && CursorY <= BottomLine)
|
||||||
|
{
|
||||||
|
CursorHeight = (GuiData->CharHeight * Buff->CursorInfo.dwSize) / 100;
|
||||||
|
if (CursorHeight < 1)
|
||||||
|
{
|
||||||
|
CursorHeight = 1;
|
||||||
|
}
|
||||||
|
From = Buff->Buffer + (Buff->CurrentY * Buff->MaxX + Buff->CurrentX) * 2 + 1;
|
||||||
|
CursorBrush = CreateSolidBrush(GuiConsoleRGBFromAttribute(*From));
|
||||||
|
OldBrush = SelectObject(Dc, CursorBrush);
|
||||||
|
PatBlt(Dc, CursorX * GuiData->CharWidth,
|
||||||
|
CursorY * GuiData->CharHeight + (GuiData->CharHeight - CursorHeight),
|
||||||
|
GuiData->CharWidth, CursorHeight, PATCOPY);
|
||||||
|
SelectObject(Dc, OldBrush);
|
||||||
|
DeleteObject(CursorBrush);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EndPaint(hWnd, &Ps);
|
||||||
|
|
||||||
|
LeaveCriticalSection(&(Buff->Lock));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Dc = BeginPaint(hWnd, &Ps);
|
||||||
|
EndPaint(hWnd, &Ps);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID FASTCALL
|
||||||
|
GuiConsoleHandleKey(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
PCSRSS_CONSOLE Console;
|
||||||
|
PGUI_CONSOLE_DATA GuiData;
|
||||||
|
MSG Message;
|
||||||
|
|
||||||
|
GuiConsoleGetDataPointers(hWnd, &Console, &GuiData);
|
||||||
|
Message.hwnd = hWnd;
|
||||||
|
Message.message = msg;
|
||||||
|
Message.wParam = wParam;
|
||||||
|
Message.lParam = lParam;
|
||||||
|
|
||||||
|
(*UserCsrProcessKey)(&Message, Console);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID FASTCALL
|
||||||
|
GuiConsoleHandleCopyRegion(HWND hWnd, PRECT Source, PRECT Dest)
|
||||||
|
{
|
||||||
|
HDC Dc;
|
||||||
|
int XDest, YDest, Width, Height, XSrc, YSrc;
|
||||||
|
PCSRSS_CONSOLE Console;
|
||||||
|
PGUI_CONSOLE_DATA GuiData;
|
||||||
|
RECT CursorRect, UpdateRect;
|
||||||
|
DWORD CursorX, CursorY;
|
||||||
|
PCSRSS_SCREEN_BUFFER Buff;
|
||||||
|
|
||||||
|
GuiConsoleGetDataPointers(hWnd, &Console, &GuiData);
|
||||||
|
Buff = Console->ActiveBuffer;
|
||||||
|
|
||||||
|
/* Check if the cursor is in the source rectangle and if it is,
|
||||||
|
* make sure it's invisible */
|
||||||
|
GuiConsoleGetLogicalCursorPos(Buff, &CursorX, &CursorY);
|
||||||
|
if (Source->left <= CursorX && CursorX <= Source->right &&
|
||||||
|
Source->top <= CursorY && CursorY <= Source->bottom)
|
||||||
|
{
|
||||||
|
GuiData->ForceCursorOff = TRUE;
|
||||||
|
|
||||||
|
CursorRect.left = CursorX * GuiData->CharWidth;
|
||||||
|
CursorRect.top = CursorY * GuiData->CharHeight;
|
||||||
|
CursorRect.right = (CursorX + 1) * GuiData->CharWidth;
|
||||||
|
CursorRect.bottom = (CursorY + 1) * GuiData->CharHeight;
|
||||||
|
|
||||||
|
InvalidateRect(hWnd, &CursorRect, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* This is a bit tricky. We want to copy a source rectangle to
|
||||||
|
* a destination rectangle, but there is no guarantee that the
|
||||||
|
* contents of the source rectangle is valid. First let's try
|
||||||
|
* to make it as valid as possible by painting all outstanding
|
||||||
|
* updates. To do that we have to release the lock, otherwise
|
||||||
|
* the paint code can't acquire it */
|
||||||
|
|
||||||
|
UpdateWindow(hWnd);
|
||||||
|
|
||||||
|
Dc = GetDC(hWnd);
|
||||||
|
if (NULL == Dc)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
XSrc = Source->left * GuiData->CharWidth;
|
||||||
|
YSrc = Source->top * GuiData->CharHeight;
|
||||||
|
XDest = Dest->left * GuiData->CharWidth;
|
||||||
|
YDest = Dest->top * GuiData->CharHeight;
|
||||||
|
Width = (Dest->right - Dest->left + 1) * GuiData->CharWidth;
|
||||||
|
Height = (Dest->bottom - Dest->top + 1) * GuiData->CharHeight;
|
||||||
|
|
||||||
|
BitBlt(Dc, XDest, YDest, Width, Height, Dc, XSrc, YSrc, SRCCOPY);
|
||||||
|
|
||||||
|
ReleaseDC(hWnd, Dc);
|
||||||
|
|
||||||
|
/* Although we tried to make sure that the source rectangle was
|
||||||
|
* up-to-date, this is not guaranteed. For example, the user could
|
||||||
|
* have moved a window between the UpdateWindow() and the BitBlt()
|
||||||
|
* above, invalidating part of the window. So, we're going to
|
||||||
|
* check if the current update rect of the window overlaps with the
|
||||||
|
* source rectangle. If it does, we invalidate the corresponding
|
||||||
|
* part of the destination rectangle so it will eventually be
|
||||||
|
* repainted. Note that this is probably doesn't happen all that
|
||||||
|
* often and GetUpdateRect() below will usually return FALSE,
|
||||||
|
* indicating that the whole window is valid */
|
||||||
|
|
||||||
|
if (GetUpdateRect(hWnd, &UpdateRect, FALSE))
|
||||||
|
{
|
||||||
|
UpdateRect.left = max(UpdateRect.left, XSrc);
|
||||||
|
UpdateRect.top = max(UpdateRect.top, YSrc);
|
||||||
|
UpdateRect.right = min(UpdateRect.right, XSrc + Width);
|
||||||
|
UpdateRect.bottom = min(UpdateRect.bottom, YSrc + Height);
|
||||||
|
if (UpdateRect.left < UpdateRect.right && UpdateRect.top < UpdateRect.bottom)
|
||||||
|
{
|
||||||
|
UpdateRect.left += XDest - XSrc;
|
||||||
|
UpdateRect.top += YDest - YSrc;
|
||||||
|
UpdateRect.right += XDest - XSrc;
|
||||||
|
UpdateRect.bottom += YDest - YSrc;
|
||||||
|
|
||||||
|
InvalidateRect(Console->hWindow, &UpdateRect, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Show cursor again if we made it invisible */
|
||||||
|
if (GuiData->ForceCursorOff)
|
||||||
|
{
|
||||||
|
GuiData->ForceCursorOff = FALSE;
|
||||||
|
|
||||||
|
InvalidateRect(hWnd, &CursorRect, FALSE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID FASTCALL
|
||||||
|
GuiConsoleHandleTimer(HWND hWnd)
|
||||||
|
{
|
||||||
|
PCSRSS_CONSOLE Console;
|
||||||
|
PGUI_CONSOLE_DATA GuiData;
|
||||||
|
SMALL_RECT CursorRect;
|
||||||
|
ULONG CursorX, CursorY;
|
||||||
|
|
||||||
|
GuiConsoleGetDataPointers(hWnd, &Console, &GuiData);
|
||||||
|
GuiData->CursorBlinkOn = ! GuiData->CursorBlinkOn;
|
||||||
|
|
||||||
|
GuiConsoleGetLogicalCursorPos(Console->ActiveBuffer, &CursorX, &CursorY);
|
||||||
|
CursorRect.Left = CursorX;
|
||||||
|
CursorRect.Top = CursorY;
|
||||||
|
CursorRect.Right = CursorX;
|
||||||
|
CursorRect.Bottom = CursorY;
|
||||||
|
GuiConsoleDrawRegion(Console, CursorRect);
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID FASTCALL
|
||||||
|
GuiConsoleHandleClose(HWND hWnd)
|
||||||
|
{
|
||||||
|
/* FIXME for now, just ignore close requests */
|
||||||
|
}
|
||||||
|
|
||||||
|
static VOID FASTCALL
|
||||||
|
GuiConsoleHandleNcDestroy(HWND hWnd)
|
||||||
|
{
|
||||||
|
PCSRSS_CONSOLE Console;
|
||||||
|
PGUI_CONSOLE_DATA GuiData;
|
||||||
|
|
||||||
|
GuiConsoleGetDataPointers(hWnd, &Console, &GuiData);
|
||||||
|
KillTimer(hWnd, 1);
|
||||||
|
Console->GuiConsoleData = NULL;
|
||||||
|
HeapFree(UserCsrApiHeap, 0, GuiData);
|
||||||
|
}
|
||||||
|
|
||||||
|
static LRESULT CALLBACK
|
||||||
|
GuiConsoleWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
LRESULT Result;
|
||||||
|
|
||||||
|
switch(msg)
|
||||||
|
{
|
||||||
|
case WM_NCCREATE:
|
||||||
|
Result = (LRESULT) GuiConsoleHandleNcCreate(hWnd, (CREATESTRUCTW *) lParam);
|
||||||
|
break;
|
||||||
|
case WM_PAINT:
|
||||||
|
GuiConsoleHandlePaint(hWnd);
|
||||||
|
Result = 0;
|
||||||
|
break;
|
||||||
|
case WM_KEYDOWN:
|
||||||
|
case WM_KEYUP:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
case WM_SYSKEYUP:
|
||||||
|
GuiConsoleHandleKey(hWnd, msg, wParam, lParam);
|
||||||
|
Result = 0;
|
||||||
|
break;
|
||||||
|
case WM_TIMER:
|
||||||
|
GuiConsoleHandleTimer(hWnd);
|
||||||
|
Result = 0;
|
||||||
|
break;
|
||||||
|
case PM_COPY_REGION:
|
||||||
|
GuiConsoleHandleCopyRegion(hWnd, (PRECT) wParam, (PRECT) lParam);
|
||||||
|
break;
|
||||||
|
case WM_CLOSE:
|
||||||
|
GuiConsoleHandleClose(hWnd);
|
||||||
|
Result = 0;
|
||||||
|
break;
|
||||||
|
case WM_NCDESTROY:
|
||||||
|
GuiConsoleHandleNcDestroy(hWnd);
|
||||||
|
Result = 0;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Result = DefWindowProcW(hWnd, msg, wParam, lParam);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
static LRESULT CALLBACK
|
||||||
|
GuiConsoleNotifyWndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
|
{
|
||||||
|
HWND NewWindow;
|
||||||
|
LONG WindowCount;
|
||||||
|
PCSRSS_CONSOLE Console = (PCSRSS_CONSOLE) lParam;
|
||||||
|
|
||||||
|
switch(msg)
|
||||||
|
{
|
||||||
|
case WM_CREATE:
|
||||||
|
SetWindowLongW(hWnd, GWL_USERDATA, 0);
|
||||||
|
return 0;
|
||||||
|
case PM_CREATE_CONSOLE:
|
||||||
|
NewWindow = CreateWindowW(L"UserCsrConsole",
|
||||||
|
Console->Title.Buffer,
|
||||||
|
WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(HINSTANCE) GetModuleHandleW(NULL),
|
||||||
|
(PVOID) Console);
|
||||||
|
if (NULL != NewWindow)
|
||||||
|
{
|
||||||
|
SetWindowLongW(hWnd, GWL_USERDATA, GetWindowLongW(hWnd, GWL_USERDATA) + 1);
|
||||||
|
ShowWindow(NewWindow, SW_SHOW);
|
||||||
|
}
|
||||||
|
return (LRESULT) NewWindow;
|
||||||
|
case PM_DESTROY_CONSOLE:
|
||||||
|
DestroyWindow(Console->hWindow);
|
||||||
|
Console->hWindow = NULL;
|
||||||
|
WindowCount = GetWindowLongW(hWnd, GWL_USERDATA);
|
||||||
|
WindowCount--;
|
||||||
|
SetWindowLongW(hWnd, GWL_USERDATA, WindowCount);
|
||||||
|
if (0 == WindowCount)
|
||||||
|
{
|
||||||
|
DestroyWindow(hWnd);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
default:
|
||||||
|
return DefWindowProcW(hWnd, msg, wParam, lParam);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static DWORD STDCALL
|
||||||
|
GuiConsoleGuiThread(PVOID Data)
|
||||||
|
{
|
||||||
|
WNDCLASSW wc;
|
||||||
|
MSG msg;
|
||||||
|
PHANDLE GraphicsStartupEvent = (PHANDLE) Data;
|
||||||
|
|
||||||
|
wc.lpszClassName = L"UserCsrCreateNotify";
|
||||||
|
wc.lpfnWndProc = GuiConsoleNotifyWndProc;
|
||||||
|
wc.style = 0;
|
||||||
|
wc.hInstance = (HINSTANCE) GetModuleHandleW(NULL);
|
||||||
|
wc.hIcon = NULL;
|
||||||
|
wc.hCursor = NULL;
|
||||||
|
wc.hbrBackground = NULL;
|
||||||
|
wc.lpszMenuName = NULL;
|
||||||
|
wc.cbClsExtra = 0;
|
||||||
|
wc.cbWndExtra = 0;
|
||||||
|
if (RegisterClassW(&wc) == 0)
|
||||||
|
{
|
||||||
|
NtSetEvent(*GraphicsStartupEvent, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
wc.lpszClassName = L"UserCsrConsole";
|
||||||
|
wc.lpfnWndProc = GuiConsoleWndProc;
|
||||||
|
wc.style = 0;
|
||||||
|
wc.hInstance = (HINSTANCE) GetModuleHandleW(NULL);
|
||||||
|
wc.hIcon = LoadIconW(NULL, (LPCWSTR) IDI_APPLICATION);
|
||||||
|
wc.hCursor = LoadCursorW(NULL, (LPCWSTR) IDC_ARROW);
|
||||||
|
wc.hbrBackground = NULL;
|
||||||
|
wc.lpszMenuName = NULL;
|
||||||
|
wc.cbClsExtra = 0;
|
||||||
|
wc.cbWndExtra = 0;
|
||||||
|
if (RegisterClassW(&wc) == 0)
|
||||||
|
{
|
||||||
|
NtSetEvent(*GraphicsStartupEvent, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NotifyWnd = CreateWindowW(L"UserCsrCreateNotify",
|
||||||
|
L"",
|
||||||
|
WS_OVERLAPPEDWINDOW,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
CW_USEDEFAULT,
|
||||||
|
NULL,
|
||||||
|
NULL,
|
||||||
|
(HINSTANCE) GetModuleHandleW(NULL),
|
||||||
|
NULL);
|
||||||
|
if (NULL == NotifyWnd)
|
||||||
|
{
|
||||||
|
NtSetEvent(*GraphicsStartupEvent, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
NtSetEvent(*GraphicsStartupEvent, 0);
|
||||||
|
|
||||||
|
while(GetMessageW(&msg, NULL, 0, 0))
|
||||||
|
{
|
||||||
|
TranslateMessage(&msg);
|
||||||
|
DispatchMessageW(&msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID FASTCALL
|
||||||
|
GuiConsoleInitConsoleSupport(VOID)
|
||||||
|
{
|
||||||
|
NTSTATUS Status;
|
||||||
|
OBJECT_ATTRIBUTES ObjectAttributes;
|
||||||
|
HANDLE GraphicsStartupEvent;
|
||||||
|
HWINSTA WindowStation;
|
||||||
|
HDESK Desktop;
|
||||||
|
HANDLE ThreadHandle;
|
||||||
|
|
||||||
|
WindowStation = OpenWindowStationW(L"WinSta0", FALSE, GENERIC_ALL);
|
||||||
|
if (NULL == WindowStation)
|
||||||
|
{
|
||||||
|
DbgPrint("UserCsr: failed to open window station\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (! SetProcessWindowStation(WindowStation))
|
||||||
|
{
|
||||||
|
DbgPrint("UserCsr: failed to set process window station\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Desktop = OpenDesktopW(L"Default", 0, FALSE, GENERIC_ALL);
|
||||||
|
if (NULL == Desktop)
|
||||||
|
{
|
||||||
|
DbgPrint("UserCsr: failed to open desktop\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Status = NtSetInformationProcess(NtCurrentProcess(),
|
||||||
|
ProcessDesktop,
|
||||||
|
&Desktop,
|
||||||
|
sizeof(Desktop));
|
||||||
|
if (!NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
DbgPrint("UserCsr: cannot set default desktop.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (! SetThreadDesktop(Desktop))
|
||||||
|
{
|
||||||
|
DbgPrint("UserCsr: failed to set thread desktop\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
InitializeObjectAttributes(&ObjectAttributes, NULL, OBJ_INHERIT, NULL, NULL);
|
||||||
|
|
||||||
|
Status = NtCreateEvent(&GraphicsStartupEvent, STANDARD_RIGHTS_ALL, &ObjectAttributes, FALSE, FALSE);
|
||||||
|
if( !NT_SUCCESS(Status))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ThreadHandle = CreateThread(NULL,
|
||||||
|
0,
|
||||||
|
GuiConsoleGuiThread,
|
||||||
|
(PVOID) &GraphicsStartupEvent,
|
||||||
|
0,
|
||||||
|
NULL);
|
||||||
|
if (NULL == ThreadHandle)
|
||||||
|
{
|
||||||
|
NtClose(GraphicsStartupEvent);
|
||||||
|
DbgPrint("UserCsr: Failed to create graphics console thread. Expect problems\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
CloseHandle(ThreadHandle);
|
||||||
|
|
||||||
|
NtWaitForSingleObject(GraphicsStartupEvent, FALSE, NULL);
|
||||||
|
NtClose(GraphicsStartupEvent);
|
||||||
|
|
||||||
|
if (NULL == NotifyWnd)
|
||||||
|
{
|
||||||
|
DbgPrint("UserCsr: Failed to create notification window.\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL STDCALL
|
||||||
|
GuiConsoleInitConsole(PCSRSS_CONSOLE Console)
|
||||||
|
{
|
||||||
|
Console->Size.X = 80;
|
||||||
|
Console->Size.Y = 25;
|
||||||
|
Console->hWindow = (HWND) SendMessageW(NotifyWnd, PM_CREATE_CONSOLE, 0, (LPARAM) Console);
|
||||||
|
|
||||||
|
return NULL != Console->hWindow;
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
GuiConsoleDrawRegion(PCSRSS_CONSOLE Console, SMALL_RECT Region)
|
||||||
|
{
|
||||||
|
PGUI_CONSOLE_DATA GuiData = (PGUI_CONSOLE_DATA) Console->GuiConsoleData;
|
||||||
|
RECT RegionRect;
|
||||||
|
|
||||||
|
if (NULL == Console->hWindow || NULL == GuiData)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RegionRect.left = Region.Left * GuiData->CharWidth;
|
||||||
|
RegionRect.top = Region.Top * GuiData->CharHeight;
|
||||||
|
RegionRect.right = (Region.Right + 1) * GuiData->CharWidth;
|
||||||
|
RegionRect.bottom = (Region.Bottom + 1) * GuiData->CharHeight;
|
||||||
|
|
||||||
|
InvalidateRect(Console->hWindow, &RegionRect, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
GuiConsoleCopyRegion(PCSRSS_CONSOLE Console,
|
||||||
|
RECT *Source,
|
||||||
|
RECT *Dest)
|
||||||
|
{
|
||||||
|
LeaveCriticalSection(&(Console->ActiveBuffer->Lock));
|
||||||
|
SendMessageW(Console->hWindow, PM_COPY_REGION, (WPARAM) Source, (LPARAM) Dest);
|
||||||
|
EnterCriticalSection(&(Console->ActiveBuffer->Lock));
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
GuiConsoleChangeTitle(PCSRSS_CONSOLE Console)
|
||||||
|
{
|
||||||
|
SendMessageW(Console->hWindow, WM_SETTEXT, 0, (LPARAM) Console->Title.Buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
VOID STDCALL
|
||||||
|
GuiConsoleDeleteConsole(PCSRSS_CONSOLE Console)
|
||||||
|
{
|
||||||
|
SendMessageW(NotifyWnd, PM_DESTROY_CONSOLE, 0, (LPARAM) Console);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* EOF */
|
21
reactos/subsys/csrss/usercsr/guiconsole.h
Normal file
21
reactos/subsys/csrss/usercsr/guiconsole.h
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
/* $Id: guiconsole.h,v 1.1 2003/10/20 18:02:04 gvg Exp $
|
||||||
|
*
|
||||||
|
* COPYRIGHT: See COPYING in the top level directory
|
||||||
|
* PROJECT: ReactOS system libraries
|
||||||
|
* FILE: subsys/csrss/usercsr/usercsr.h
|
||||||
|
* PURPOSE: Interface to usercsr.dll
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "api.h"
|
||||||
|
|
||||||
|
extern BOOL STDCALL GuiConsoleInitConsole(PCSRSS_CONSOLE Console);
|
||||||
|
extern VOID STDCALL GuiConsoleDrawRegion(PCSRSS_CONSOLE Console, SMALL_RECT Region);
|
||||||
|
extern VOID STDCALL GuiConsoleCopyRegion(PCSRSS_CONSOLE Console,
|
||||||
|
RECT *Source,
|
||||||
|
RECT *Dest);
|
||||||
|
extern VOID STDCALL GuiConsoleChangeTitle(PCSRSS_CONSOLE Console);
|
||||||
|
extern VOID STDCALL GuiConsoleDeleteConsole(PCSRSS_CONSOLE Console);
|
||||||
|
|
||||||
|
extern VOID FASTCALL GuiConsoleInitConsoleSupport(VOID);
|
||||||
|
|
||||||
|
/*EOF*/
|
28
reactos/subsys/csrss/usercsr/makefile
Normal file
28
reactos/subsys/csrss/usercsr/makefile
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
# $Id: makefile,v 1.1 2003/10/20 18:02:04 gvg Exp $
|
||||||
|
|
||||||
|
PATH_TO_TOP = ../../..
|
||||||
|
|
||||||
|
TARGET_TYPE = dynlink
|
||||||
|
|
||||||
|
TARGET_NAME = usercsr
|
||||||
|
|
||||||
|
TARGET_BASE = 0x5ffb0000
|
||||||
|
|
||||||
|
# require os code to explicitly request A/W version of structs/functions
|
||||||
|
TARGET_CFLAGS += -D_DISABLE_TIDENTS -Wall -Werror -I../include
|
||||||
|
|
||||||
|
TARGET_LFLAGS = -nostartfiles -nostdlib
|
||||||
|
|
||||||
|
TARGET_SDKLIBS = ntdll.a kernel32.a user32.a gdi32.a
|
||||||
|
|
||||||
|
TARGET_OBJECTS = dllmain.o guiconsole.o
|
||||||
|
|
||||||
|
TARGET_ENTRY = _DllMain@12
|
||||||
|
|
||||||
|
DEP_OBJECTS = $(TARGET_OBJECTS)
|
||||||
|
|
||||||
|
include $(PATH_TO_TOP)/rules.mak
|
||||||
|
|
||||||
|
include $(TOOLS_PATH)/helper.mk
|
||||||
|
|
||||||
|
include $(TOOLS_PATH)/depend.mk
|
8
reactos/subsys/csrss/usercsr/usercsr.def
Normal file
8
reactos/subsys/csrss/usercsr/usercsr.def
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
; $Id: usercsr.def,v 1.1 2003/10/20 18:02:04 gvg Exp $
|
||||||
|
;
|
||||||
|
|
||||||
|
LIBRARY usercsr.exe
|
||||||
|
|
||||||
|
EXPORTS
|
||||||
|
|
||||||
|
UserCsrInitialization
|
9
reactos/subsys/csrss/usercsr/usercsr.edf
Normal file
9
reactos/subsys/csrss/usercsr/usercsr.edf
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
; $Id: usercsr.edf,v 1.1 2003/10/20 18:02:04 gvg Exp $
|
||||||
|
;
|
||||||
|
;
|
||||||
|
|
||||||
|
LIBRARY usercsr.dll
|
||||||
|
|
||||||
|
EXPORTS
|
||||||
|
|
||||||
|
UserCsrInitialization=UserCsrInitialization@12
|
38
reactos/subsys/csrss/usercsr/usercsr.rc
Normal file
38
reactos/subsys/csrss/usercsr/usercsr.rc
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
#include <defines.h>
|
||||||
|
#include <reactos/resource.h>
|
||||||
|
|
||||||
|
|
||||||
|
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||||
|
|
||||||
|
VS_VERSION_INFO VERSIONINFO
|
||||||
|
FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
|
||||||
|
PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
|
||||||
|
FILEFLAGSMASK 0x3fL
|
||||||
|
#ifdef _DEBUG
|
||||||
|
FILEFLAGS 0x1L
|
||||||
|
#else
|
||||||
|
FILEFLAGS 0x0L
|
||||||
|
#endif
|
||||||
|
FILEOS 0x40004L
|
||||||
|
FILETYPE 0x2L
|
||||||
|
FILESUBTYPE 0x0L
|
||||||
|
BEGIN
|
||||||
|
BLOCK "StringFileInfo"
|
||||||
|
BEGIN
|
||||||
|
BLOCK "040904b0"
|
||||||
|
BEGIN
|
||||||
|
VALUE "CompanyName", RES_STR_COMPANY_NAME
|
||||||
|
VALUE "FileDescription", "CSRSS subsystem usermode code\0"
|
||||||
|
VALUE "FileVersion", RES_STR_FILE_VERSION
|
||||||
|
VALUE "InternalName", "usercsr\0"
|
||||||
|
VALUE "LegalCopyright", RES_STR_LEGAL_COPYRIGHT
|
||||||
|
VALUE "OriginalFilename", "usercsr.dll\0"
|
||||||
|
VALUE "ProductName", RES_STR_PRODUCT_NAME
|
||||||
|
VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
|
||||||
|
END
|
||||||
|
END
|
||||||
|
BLOCK "VarFileInfo"
|
||||||
|
BEGIN
|
||||||
|
VALUE "Translation", 0x409, 1200
|
||||||
|
END
|
||||||
|
END
|
|
@ -1,4 +1,4 @@
|
||||||
/* $Id: video.c,v 1.6 2002/09/08 10:23:44 chorns Exp $
|
/* $Id: video.c,v 1.7 2003/10/20 18:02:04 gvg Exp $
|
||||||
*
|
*
|
||||||
* ReactOS Project
|
* ReactOS Project
|
||||||
*/
|
*/
|
||||||
|
@ -14,7 +14,6 @@ InitializeVideoAddressSpace(VOID)
|
||||||
PVOID BaseAddress;
|
PVOID BaseAddress;
|
||||||
LARGE_INTEGER Offset;
|
LARGE_INTEGER Offset;
|
||||||
ULONG ViewSize;
|
ULONG ViewSize;
|
||||||
PUCHAR TextMap;
|
|
||||||
CHAR IVT[1024];
|
CHAR IVT[1024];
|
||||||
CHAR BDA[256];
|
CHAR BDA[256];
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue