2007-12-22 17:18:32 +00:00
|
|
|
/*
|
2003-12-02 11:38:47 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS system libraries
|
|
|
|
* FILE: subsys/csrss/win32csr/dllmain.c
|
2005-05-08 04:07:56 +00:00
|
|
|
* PURPOSE: Initialization
|
2007-12-22 17:18:32 +00:00
|
|
|
* PROGRAMMERS: Dmitry Philippov (shedon@mail.ru)
|
2003-12-02 11:38:47 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
#define NDEBUG
|
2009-01-28 16:30:19 +00:00
|
|
|
#include "w32csr.h"
|
2003-12-02 11:38:47 +00:00
|
|
|
#include <debug.h>
|
|
|
|
|
2003-12-07 23:02:57 +00:00
|
|
|
/* Not defined in any header file */
|
2008-11-29 22:48:58 +00:00
|
|
|
extern VOID WINAPI PrivateCsrssManualGuiCheck(LONG Check);
|
|
|
|
extern VOID WINAPI InitializeAppSwitchHook();
|
2003-12-07 23:02:57 +00:00
|
|
|
|
2003-12-02 11:38:47 +00:00
|
|
|
/* GLOBALS *******************************************************************/
|
|
|
|
|
|
|
|
HANDLE Win32CsrApiHeap;
|
2006-07-04 13:36:57 +00:00
|
|
|
HINSTANCE Win32CsrDllHandle = NULL;
|
2003-12-02 11:38:47 +00:00
|
|
|
static CSRSS_EXPORTED_FUNCS CsrExports;
|
|
|
|
|
|
|
|
static CSRSS_API_DEFINITION Win32CsrApiDefinitions[] =
|
2010-05-30 20:00:17 +00:00
|
|
|
{
|
2010-05-23 09:10:02 +00:00
|
|
|
CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetHandle),
|
|
|
|
CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetHandle),
|
2010-05-22 23:47:54 +00:00
|
|
|
CSRSS_DEFINE_API(CLOSE_HANDLE, CsrCloseHandle),
|
|
|
|
CSRSS_DEFINE_API(VERIFY_HANDLE, CsrVerifyHandle),
|
|
|
|
CSRSS_DEFINE_API(DUPLICATE_HANDLE, CsrDuplicateHandle),
|
|
|
|
CSRSS_DEFINE_API(GET_INPUT_WAIT_HANDLE, CsrGetInputWaitHandle),
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
CSRSS_DEFINE_API(WRITE_CONSOLE, CsrWriteConsole),
|
|
|
|
CSRSS_DEFINE_API(READ_CONSOLE, CsrReadConsole),
|
|
|
|
CSRSS_DEFINE_API(ALLOC_CONSOLE, CsrAllocConsole),
|
|
|
|
CSRSS_DEFINE_API(FREE_CONSOLE, CsrFreeConsole),
|
|
|
|
CSRSS_DEFINE_API(SCREEN_BUFFER_INFO, CsrGetScreenBufferInfo),
|
|
|
|
CSRSS_DEFINE_API(SET_CURSOR, CsrSetCursor),
|
|
|
|
CSRSS_DEFINE_API(FILL_OUTPUT, CsrFillOutputChar),
|
|
|
|
CSRSS_DEFINE_API(READ_INPUT, CsrReadInputEvent),
|
|
|
|
CSRSS_DEFINE_API(WRITE_CONSOLE_OUTPUT_CHAR, CsrWriteConsoleOutputChar),
|
|
|
|
CSRSS_DEFINE_API(WRITE_CONSOLE_OUTPUT_ATTRIB, CsrWriteConsoleOutputAttrib),
|
|
|
|
CSRSS_DEFINE_API(FILL_OUTPUT_ATTRIB, CsrFillOutputAttrib),
|
|
|
|
CSRSS_DEFINE_API(GET_CURSOR_INFO, CsrGetCursorInfo),
|
|
|
|
CSRSS_DEFINE_API(SET_CURSOR_INFO, CsrSetCursorInfo),
|
|
|
|
CSRSS_DEFINE_API(SET_ATTRIB, CsrSetTextAttrib),
|
|
|
|
CSRSS_DEFINE_API(GET_CONSOLE_MODE, CsrGetConsoleMode),
|
|
|
|
CSRSS_DEFINE_API(SET_CONSOLE_MODE, CsrSetConsoleMode),
|
|
|
|
CSRSS_DEFINE_API(CREATE_SCREEN_BUFFER, CsrCreateScreenBuffer),
|
|
|
|
CSRSS_DEFINE_API(SET_SCREEN_BUFFER, CsrSetScreenBuffer),
|
|
|
|
CSRSS_DEFINE_API(SET_TITLE, CsrSetTitle),
|
|
|
|
CSRSS_DEFINE_API(GET_TITLE, CsrGetTitle),
|
|
|
|
CSRSS_DEFINE_API(WRITE_CONSOLE_OUTPUT, CsrWriteConsoleOutput),
|
|
|
|
CSRSS_DEFINE_API(FLUSH_INPUT_BUFFER, CsrFlushInputBuffer),
|
|
|
|
CSRSS_DEFINE_API(SCROLL_CONSOLE_SCREEN_BUFFER, CsrScrollConsoleScreenBuffer),
|
|
|
|
CSRSS_DEFINE_API(READ_CONSOLE_OUTPUT_CHAR, CsrReadConsoleOutputChar),
|
|
|
|
CSRSS_DEFINE_API(READ_CONSOLE_OUTPUT_ATTRIB, CsrReadConsoleOutputAttrib),
|
|
|
|
CSRSS_DEFINE_API(GET_NUM_INPUT_EVENTS, CsrGetNumberOfConsoleInputEvents),
|
|
|
|
CSRSS_DEFINE_API(EXIT_REACTOS, CsrExitReactos),
|
|
|
|
CSRSS_DEFINE_API(PEEK_CONSOLE_INPUT, CsrPeekConsoleInput),
|
|
|
|
CSRSS_DEFINE_API(READ_CONSOLE_OUTPUT, CsrReadConsoleOutput),
|
|
|
|
CSRSS_DEFINE_API(WRITE_CONSOLE_INPUT, CsrWriteConsoleInput),
|
|
|
|
CSRSS_DEFINE_API(SETGET_CONSOLE_HW_STATE, CsrHardwareStateProperty),
|
|
|
|
CSRSS_DEFINE_API(GET_CONSOLE_WINDOW, CsrGetConsoleWindow),
|
|
|
|
CSRSS_DEFINE_API(CREATE_DESKTOP, CsrCreateDesktop),
|
|
|
|
CSRSS_DEFINE_API(SHOW_DESKTOP, CsrShowDesktop),
|
|
|
|
CSRSS_DEFINE_API(HIDE_DESKTOP, CsrHideDesktop),
|
|
|
|
CSRSS_DEFINE_API(SET_CONSOLE_ICON, CsrSetConsoleIcon),
|
|
|
|
CSRSS_DEFINE_API(SET_LOGON_NOTIFY_WINDOW, CsrSetLogonNotifyWindow),
|
|
|
|
CSRSS_DEFINE_API(REGISTER_LOGON_PROCESS, CsrRegisterLogonProcess),
|
|
|
|
CSRSS_DEFINE_API(GET_CONSOLE_CP, CsrGetConsoleCodePage),
|
|
|
|
CSRSS_DEFINE_API(SET_CONSOLE_CP, CsrSetConsoleCodePage),
|
|
|
|
CSRSS_DEFINE_API(GET_CONSOLE_OUTPUT_CP, CsrGetConsoleOutputCodePage),
|
|
|
|
CSRSS_DEFINE_API(SET_CONSOLE_OUTPUT_CP, CsrSetConsoleOutputCodePage),
|
|
|
|
CSRSS_DEFINE_API(GET_PROCESS_LIST, CsrGetProcessList),
|
2008-07-27 00:41:45 +00:00
|
|
|
CSRSS_DEFINE_API(ADD_CONSOLE_ALIAS, CsrAddConsoleAlias),
|
|
|
|
CSRSS_DEFINE_API(GET_CONSOLE_ALIAS, CsrGetConsoleAlias),
|
|
|
|
CSRSS_DEFINE_API(GET_ALL_CONSOLE_ALIASES, CsrGetAllConsoleAliases),
|
|
|
|
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),
|
2008-08-02 17:01:22 +00:00
|
|
|
CSRSS_DEFINE_API(GENERATE_CTRL_EVENT, CsrGenerateCtrlEvent),
|
2010-05-12 03:34:02 +00:00
|
|
|
CSRSS_DEFINE_API(SET_SCREEN_BUFFER_SIZE, CsrSetScreenBufferSize),
|
2010-05-23 22:38:16 +00:00
|
|
|
CSRSS_DEFINE_API(GET_CONSOLE_SELECTION_INFO, CsrGetConsoleSelectionInfo),
|
2010-06-05 00:45:08 +00:00
|
|
|
CSRSS_DEFINE_API(GET_COMMAND_HISTORY_LENGTH, CsrGetCommandHistoryLength),
|
|
|
|
CSRSS_DEFINE_API(GET_COMMAND_HISTORY, CsrGetCommandHistory),
|
|
|
|
CSRSS_DEFINE_API(EXPUNGE_COMMAND_HISTORY, CsrExpungeCommandHistory),
|
|
|
|
CSRSS_DEFINE_API(SET_HISTORY_NUMBER_COMMANDS, CsrSetHistoryNumberCommands),
|
|
|
|
CSRSS_DEFINE_API(GET_HISTORY_INFO, CsrGetHistoryInfo),
|
|
|
|
CSRSS_DEFINE_API(SET_HISTORY_INFO, CsrSetHistoryInfo),
|
Large change to modify NTDLL'S CSR Functions to be compatible with NT. They are external and we should at least try to match the number of arguments (one vs eight? come on!). Because this is also the direction that Emanuele wants to be taking, the whole external calling interface was modified to be more compatible with NT (although internally it still isn't, and does not have a reason to be). API Names are now generated by a macro from the Server ID, like Emanuele and I noticed from traces, and I've entirely removed the concept of a reply structure. CSRSS uses full-duplex one-way structures, not dual-strutures (this would've been incompatible with the external interface anyways). I don't seem to have introduced any new bugs (console-ROS works great for me, as does the GUI), but there is still a chance some obscure bug might happen, so please bear with me, I had to hand-edit over 250 calls. Also, this now allows full removal of ntdll headers and the next commits will clean this up
svn path=/trunk/; revision=16213
2005-06-22 04:02:32 +00:00
|
|
|
{ 0, 0, NULL }
|
2010-05-30 20:00:17 +00:00
|
|
|
};
|
2003-12-02 11:38:47 +00:00
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
BOOL WINAPI
|
2003-12-02 11:38:47 +00:00
|
|
|
DllMain(HANDLE hDll,
|
2010-05-30 20:00:17 +00:00
|
|
|
DWORD dwReason,
|
|
|
|
LPVOID lpReserved)
|
2003-12-02 11:38:47 +00:00
|
|
|
{
|
2010-05-30 20:00:17 +00:00
|
|
|
if (DLL_PROCESS_ATTACH == dwReason)
|
2004-01-19 20:14:28 +00:00
|
|
|
{
|
2010-05-30 20:00:17 +00:00
|
|
|
Win32CsrDllHandle = hDll;
|
|
|
|
InitializeAppSwitchHook();
|
2004-01-19 20:14:28 +00:00
|
|
|
}
|
|
|
|
|
2010-05-30 20:00:17 +00:00
|
|
|
return TRUE;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
|
|
|
|
2010-06-04 06:36:12 +00:00
|
|
|
/* Ensure that a captured buffer is safe to access */
|
|
|
|
BOOL FASTCALL
|
|
|
|
Win32CsrValidateBuffer(PCSRSS_PROCESS_DATA ProcessData, PVOID Buffer,
|
|
|
|
SIZE_T NumElements, SIZE_T ElementSize)
|
|
|
|
{
|
|
|
|
/* Check that the following conditions are true:
|
|
|
|
* 1. The start of the buffer is somewhere within the process's
|
|
|
|
* shared memory section view.
|
|
|
|
* 2. The remaining space in the view is at least as large as the buffer.
|
|
|
|
* (NB: Please don't try to "optimize" this by using multiplication
|
|
|
|
* instead of division; remember that 2147483648 * 2 = 0.)
|
|
|
|
* 3. The buffer is DWORD-aligned.
|
|
|
|
*/
|
|
|
|
ULONG_PTR Offset = (BYTE *)Buffer - (BYTE *)ProcessData->CsrSectionViewBase;
|
|
|
|
if (Offset >= ProcessData->CsrSectionViewSize
|
|
|
|
|| NumElements > (ProcessData->CsrSectionViewSize - Offset) / ElementSize
|
|
|
|
|| (Offset & (sizeof(DWORD) - 1)) != 0)
|
|
|
|
{
|
|
|
|
DPRINT1("Invalid buffer %p(%u*%u); section view is %p(%u)\n",
|
|
|
|
Buffer, NumElements, ElementSize,
|
|
|
|
ProcessData->CsrSectionViewBase, ProcessData->CsrSectionViewSize);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2010-05-22 21:40:20 +00:00
|
|
|
NTSTATUS FASTCALL
|
2005-12-01 22:29:57 +00:00
|
|
|
Win32CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
|
|
|
|
PVOID Context)
|
|
|
|
{
|
2010-05-30 20:00:17 +00:00
|
|
|
return (CsrExports.CsrEnumProcessesProc)(EnumProc, Context);
|
2005-12-01 22:29:57 +00:00
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
static BOOL WINAPI
|
2004-05-28 21:33:41 +00:00
|
|
|
Win32CsrInitComplete(void)
|
|
|
|
{
|
2010-05-30 20:00:17 +00:00
|
|
|
return TRUE;
|
2004-05-28 21:33:41 +00:00
|
|
|
}
|
2003-12-02 11:38:47 +00:00
|
|
|
|
2010-09-27 14:31:13 +00:00
|
|
|
VOID
|
|
|
|
WINAPI
|
|
|
|
PrivateCsrssManualGuiCheck(LONG Check)
|
|
|
|
{
|
|
|
|
NtUserCallOneParam(Check, ONEPARAM_ROUTINE_CSRSS_GUICHECK);
|
|
|
|
}
|
|
|
|
|
2008-11-29 22:48:58 +00:00
|
|
|
BOOL WINAPI
|
2003-12-02 11:38:47 +00:00
|
|
|
Win32CsrInitialization(PCSRSS_API_DEFINITION *ApiDefinitions,
|
2010-05-22 23:47:54 +00:00
|
|
|
PCSRPLUGIN_SERVER_PROCS ServerProcs,
|
2003-12-02 11:38:47 +00:00
|
|
|
PCSRSS_EXPORTED_FUNCS Exports,
|
|
|
|
HANDLE CsrssApiHeap)
|
|
|
|
{
|
2010-05-30 20:00:17 +00:00
|
|
|
NTSTATUS Status;
|
|
|
|
CsrExports = *Exports;
|
|
|
|
Win32CsrApiHeap = CsrssApiHeap;
|
2003-12-02 11:38:47 +00:00
|
|
|
|
2010-05-30 20:00:17 +00:00
|
|
|
Status = NtUserInitialize(0, NULL, NULL);
|
2008-11-01 14:31:54 +00:00
|
|
|
|
2010-05-30 20:00:17 +00:00
|
|
|
PrivateCsrssManualGuiCheck(0);
|
|
|
|
CsrInitConsoleSupport();
|
2003-12-02 11:38:47 +00:00
|
|
|
|
2010-05-30 20:00:17 +00:00
|
|
|
*ApiDefinitions = Win32CsrApiDefinitions;
|
|
|
|
ServerProcs->InitCompleteProc = Win32CsrInitComplete;
|
|
|
|
ServerProcs->HardErrorProc = Win32CsrHardError;
|
|
|
|
ServerProcs->ProcessInheritProc = Win32CsrDuplicateHandleTable;
|
|
|
|
ServerProcs->ProcessDeletedProc = Win32CsrReleaseConsole;
|
2003-12-02 11:38:47 +00:00
|
|
|
|
2010-05-30 20:00:17 +00:00
|
|
|
return TRUE;
|
2003-12-02 11:38:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|