Author: hbelusca
Date: Wed Oct 24 23:19:54 2012
New Revision: 57611
URL:
http://svn.reactos.org/svn/reactos?rev=57611&view=rev
Log:
[WINSRV/WIN32CSR]
- Move the last APIs which should be in winsrv and remove unneeded files and resources
from win32csr. Keep only the desktop things.
- I'm waiting for the patch of Giannis which would act on win32csr, then I will
transfer the needed changes into winsrv and I will remove definitively win32csr.
At the moment, winsrv doesn't compile, but win32csr does.
Added:
branches/ros-csrss/win32ss/user/winsrv/exitros.c
- copied, changed from r57605, branches/ros-csrss/win32ss/user/win32csr/exitros.c
branches/ros-csrss/win32ss/user/winsrv/harderror.c
- copied, changed from r57605, branches/ros-csrss/win32ss/user/win32csr/harderror.c
branches/ros-csrss/win32ss/user/winsrv/winsrv.spec (with props)
Removed:
branches/ros-csrss/win32ss/user/win32csr/exitros.c
branches/ros-csrss/win32ss/user/win32csr/harderror.c
branches/ros-csrss/win32ss/user/win32csr/lang/
branches/ros-csrss/win32ss/user/win32csr/resource.h
branches/ros-csrss/win32ss/user/win32csr/rsrc.rc
branches/ros-csrss/win32ss/user/win32csr/w32csr.h
Modified:
branches/ros-csrss/include/reactos/subsys/csr/csrss.h
branches/ros-csrss/include/reactos/subsys/win/winmsg.h
branches/ros-csrss/win32ss/user/win32csr/CMakeLists.txt
branches/ros-csrss/win32ss/user/win32csr/desktopbg.c
branches/ros-csrss/win32ss/user/win32csr/desktopbg.h
branches/ros-csrss/win32ss/user/win32csr/dllmain.c
branches/ros-csrss/win32ss/user/win32csr/win32csr.h
branches/ros-csrss/win32ss/user/win32csr/win32csr.rc
branches/ros-csrss/win32ss/user/winsrv/init.c (contents, props changed)
branches/ros-csrss/win32ss/user/winsrv/rsrc.rc
branches/ros-csrss/win32ss/user/winsrv/server.c
branches/ros-csrss/win32ss/user/winsrv/winsrv.h
Modified: branches/ros-csrss/include/reactos/subsys/csr/csrss.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
==============================================================================
--- branches/ros-csrss/include/reactos/subsys/csr/csrss.h [iso-8859-1] (original)
+++ branches/ros-csrss/include/reactos/subsys/csr/csrss.h [iso-8859-1] Wed Oct 24 23:19:54
2012
@@ -96,9 +96,11 @@
#define CLOSE_HANDLE (0x26)
#define VERIFY_HANDLE (0x27)
#define DUPLICATE_HANDLE (0x28)
+
#define CREATE_DESKTOP (0x2B)
#define SHOW_DESKTOP (0x2C)
#define HIDE_DESKTOP (0x2D)
+
#define SET_LOGON_NOTIFY_WINDOW (0x2F)
#define REGISTER_LOGON_PROCESS (0x30)
#define GET_INPUT_WAIT_HANDLE (0x35)
Modified: branches/ros-csrss/include/reactos/subsys/win/winmsg.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/include/reactos/subsy…
==============================================================================
--- branches/ros-csrss/include/reactos/subsys/win/winmsg.h [iso-8859-1] (original)
+++ branches/ros-csrss/include/reactos/subsys/win/winmsg.h [iso-8859-1] Wed Oct 24
23:19:54 2012
@@ -7,8 +7,7 @@
#define USERSRV_SERVERDLL_INDEX 3
#define USERSRV_FIRST_API_NUMBER 1024
-/* w32 user server - move to win.h */
-CSR_SERVER_DLL_INIT(UserServerDllInitialization);
+// CSR_SERVER_DLL_INIT(UserServerDllInitialization);
#endif // __WINMSG_H__
Modified: branches/ros-csrss/win32ss/user/win32csr/CMakeLists.txt
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/CMakeLists.txt [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/CMakeLists.txt [iso-8859-1] Wed Oct 24
23:19:54 2012
@@ -11,8 +11,6 @@
list(APPEND SOURCE
desktopbg.c
dllmain.c
- exitros.c
- harderror.c
win32csr.rc
${CMAKE_CURRENT_BINARY_DIR}/win32csr.def)
Modified: branches/ros-csrss/win32ss/user/win32csr/desktopbg.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/desktopbg.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/desktopbg.c [iso-8859-1] Wed Oct 24 23:19:54
2012
@@ -24,14 +24,11 @@
*/
-#include "w32csr.h"
+#include "win32csr.h"
#define NDEBUG
#include <debug.h>
-/***
- *** Move it into winsrv
- ***/
#define DESKTOP_WINDOW_ATOM 32769
#define PM_SHOW_DESKTOP 1
Modified: branches/ros-csrss/win32ss/user/win32csr/desktopbg.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/desktopbg.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/desktopbg.h [iso-8859-1] Wed Oct 24 23:19:54
2012
@@ -8,9 +8,6 @@
#pragma once
-#include <csr/csrsrv.h>
-//#include "api.h"
-
BOOL FASTCALL DtbgIsDesktopVisible(VOID);
/* EOF */
Modified: branches/ros-csrss/win32ss/user/win32csr/dllmain.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/dllmain.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/dllmain.c [iso-8859-1] Wed Oct 24 23:19:54
2012
@@ -8,116 +8,36 @@
/* INCLUDES ******************************************************************/
-#include "w32csr.h"
+#include "win32csr.h"
#define NDEBUG
#include <debug.h>
-
/* GLOBALS *******************************************************************/
HANDLE Win32CsrApiHeap;
HINSTANCE Win32CsrDllHandle = NULL;
-PCSR_API_ROUTINE Win32CsrApiDefinitions[] =
+PCSR_API_ROUTINE Win32CsrApiDefinitions[3] =
{
- CsrGetHandle,
- CsrGetHandle,
- CsrCloseHandle,
- CsrVerifyHandle,
- CsrDuplicateHandle,
- CsrGetInputWaitHandle,
- CsrFillOutputChar,
- CsrReadInputEvent,
- CsrWriteConsoleOutputChar,
- CsrWriteConsoleOutputAttrib,
- CsrFillOutputAttrib,
- CsrSetTextAttrib,
- CsrWriteConsoleOutput,
- CsrFlushInputBuffer,
- CsrReadConsoleOutputChar,
- CsrReadConsoleOutputAttrib,
- CsrExitReactos,
- CsrHardwareStateProperty,
CsrCreateDesktop,
CsrShowDesktop,
CsrHideDesktop,
- CsrSetLogonNotifyWindow,
- CsrRegisterLogonProcess,
- CsrGenerateCtrlEvent,
};
+BOOLEAN Win32CsrApiServerValidTable[3] =
+{
+ FALSE,
+ FALSE,
+ FALSE
+};
-/*
-static CSRSS_API_DEFINITION Win32CsrApiDefinitions[] =
+PCHAR Win32CsrApiNameTable[3] =
{
- CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetHandle),
- CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetHandle),
- 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),
- 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),
- 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),
- CSRSS_DEFINE_API(GENERATE_CTRL_EVENT, CsrGenerateCtrlEvent),
- CSRSS_DEFINE_API(SET_SCREEN_BUFFER_SIZE, CsrSetScreenBufferSize),
- CSRSS_DEFINE_API(GET_CONSOLE_SELECTION_INFO, CsrGetConsoleSelectionInfo),
- 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),
- { 0, 0, NULL }
+ "CsrCreateDesktop",
+ "CsrShowDesktop",
+ "CsrHideDesktop",
};
-*/
static HHOOK hhk = NULL;
@@ -131,149 +51,6 @@
LPARAM lParam)
{
return CallNextHookEx(hhk, nCode, wParam, lParam);
-}
-
-ULONG
-InitializeVideoAddressSpace(VOID)
-{
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING PhysMemName =
RTL_CONSTANT_STRING(L"\\Device\\PhysicalMemory");
- NTSTATUS Status;
- HANDLE PhysMemHandle;
- PVOID BaseAddress;
- LARGE_INTEGER Offset;
- SIZE_T ViewSize;
- CHAR IVTAndBda[1024+256];
-
- /* Free the 1MB pre-reserved region. In reality, ReactOS should simply support us
mapping the view into the reserved area, but it doesn't. */
- BaseAddress = 0;
- ViewSize = 1024 * 1024;
- Status = ZwFreeVirtualMemory(NtCurrentProcess(),
- &BaseAddress,
- &ViewSize,
- MEM_RELEASE);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("Couldn't unmap reserved memory (%x)\n", Status);
- return 0;
- }
-
- /* Open the physical memory section */
- InitializeObjectAttributes(&ObjectAttributes,
- &PhysMemName,
- 0,
- NULL,
- NULL);
- Status = ZwOpenSection(&PhysMemHandle,
- SECTION_ALL_ACCESS,
- &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("Couldn't open \\Device\\PhysicalMemory\n");
- return 0;
- }
-
- /* Map the BIOS and device registers into the address space */
- Offset.QuadPart = 0xa0000;
- ViewSize = 0x100000 - 0xa0000;
- BaseAddress = (PVOID)0xa0000;
- Status = ZwMapViewOfSection(PhysMemHandle,
- NtCurrentProcess(),
- &BaseAddress,
- 0,
- ViewSize,
- &Offset,
- &ViewSize,
- ViewUnmap,
- 0,
- PAGE_EXECUTE_READWRITE);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("Couldn't map physical memory (%x)\n", Status);
- ZwClose(PhysMemHandle);
- return 0;
- }
-
- /* Close physical memory section handle */
- ZwClose(PhysMemHandle);
-
- if (BaseAddress != (PVOID)0xa0000)
- {
- DPRINT1("Couldn't map physical memory at the right address (was
%x)\n",
- BaseAddress);
- return 0;
- }
-
- /* Allocate some low memory to use for the non-BIOS
- * parts of the v86 mode address space
- */
- BaseAddress = (PVOID)0x1;
- ViewSize = 0xa0000 - 0x1000;
- Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
- &BaseAddress,
- 0,
- &ViewSize,
- MEM_RESERVE | MEM_COMMIT,
- PAGE_EXECUTE_READWRITE);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("Failed to allocate virtual memory (Status %x)\n", Status);
- return 0;
- }
- if (BaseAddress != (PVOID)0x0)
- {
- DPRINT1("Failed to allocate virtual memory at right address (was
%x)\n",
- BaseAddress);
- return 0;
- }
-
- /* Get the real mode IVT and BDA from the kernel */
- Status = NtVdmControl(VdmInitialize, IVTAndBda);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtVdmControl failed (status %x)\n", Status);
- return 0;
- }
-
- /* Return success */
- return 1;
-}
-
-/**********************************************************************
- * CsrpInitVideo/3
- *
- * TODO: we need a virtual device for sessions other than
- * TODO: the console one
- */
-NTSTATUS
-CsrpInitVideo (VOID)
-{
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\??\\DISPLAY1");
- IO_STATUS_BLOCK Iosb;
- HANDLE VideoHandle = (HANDLE) 0;
- NTSTATUS Status = STATUS_SUCCESS;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- InitializeVideoAddressSpace();
-
- InitializeObjectAttributes(&ObjectAttributes,
- &DeviceName,
- 0,
- NULL,
- NULL);
- Status = NtOpenFile(&VideoHandle,
- FILE_ALL_ACCESS,
- &ObjectAttributes,
- &Iosb,
- 0,
- 0);
- if (NT_SUCCESS(Status))
- {
- NtClose(VideoHandle);
- }
- return Status;
}
BOOL WINAPI
@@ -296,18 +73,11 @@
return TRUE;
}
-NTSTATUS FASTCALL
-Win32CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
- PVOID Context)
-{
- return CsrEnumProcesses(EnumProc, Context);
-}
-
VOID
WINAPI
PrivateCsrssManualGuiCheck(LONG Check)
{
- NtUserCallOneParam(Check, ONEPARAM_ROUTINE_CSRSS_GUICHECK);
+ NtUserCallOneParam(Check, ONEPARAM_ROUTINE_CSRSS_GUICHECK);
}
DWORD
@@ -326,25 +96,23 @@
NTSTATUS Status;
Win32CsrApiHeap = RtlGetProcessHeap();
-
- CsrpInitVideo(); // Must go into winsrv.dll
NtUserInitialize(0, NULL, NULL);
PrivateCsrssManualGuiCheck(0);
/* Setup the DLL Object */
- LoadedServerDll->ApiBase = USERSRV_FIRST_API_NUMBER;
- LoadedServerDll->HighestApiSupported = UserpMaxApiNumber;
+ LoadedServerDll->ApiBase = 4;
+ LoadedServerDll->HighestApiSupported = 3;
LoadedServerDll->DispatchTable = Win32CsrApiDefinitions;
- // LoadedServerDll->ValidTable = Win32CsrApiServerValidTable;
- // LoadedServerDll->NameTable = Win32CsrApiNameTable;
+ LoadedServerDll->ValidTable = Win32CsrApiServerValidTable;
+ LoadedServerDll->NameTable = Win32CsrApiNameTable;
// LoadedServerDll->SizeOfProcessData = 0;
// LoadedServerDll->ConnectCallback = NULL;
// LoadedServerDll->DisconnectCallback = NULL;
- LoadedServerDll->HardErrorCallback = Win32CsrHardError;
- LoadedServerDll->NewProcessCallback = NULL;
- LoadedServerDll->DisconnectCallback = NULL;
+ // LoadedServerDll->HardErrorCallback = Win32CsrHardError;
+ // LoadedServerDll->NewProcessCallback = NULL;
+ // LoadedServerDll->DisconnectCallback = NULL;
/* Start Raw Input Threads */
Status = RtlCreateUserThread(NtCurrentProcess(), NULL, TRUE, 0, 0, 0,
(PTHREAD_START_ROUTINE)CreateSystemThreads, (PVOID)0, &ServerThread, &ClientId);
Removed: branches/ros-csrss/win32ss/user/win32csr/exitros.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/exitros.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/exitros.c (removed)
@@ -1,937 +1,0 @@
-/* $Id: exitros.c 57570 2012-10-17 23:10:40Z hbelusca $
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS CSRSS subsystem
- * FILE: subsys/csrss/win32csr/exitros.c
- * PURPOSE: Logout/shutdown
- */
-
-
-/***
- *** Move it into winsrv
- ***/
-
-/* INCLUDES ******************************************************************/
-
-#include "w32csr.h"
-#include <sddl.h>
-
-#define NDEBUG
-#include <debug.h>
-
-static HWND LogonNotifyWindow = NULL;
-static HANDLE LogonProcess = NULL;
-
-CSR_API(CsrRegisterLogonProcess)
-{
- if (ApiMessage->Data.RegisterLogonProcessRequest.Register)
- {
- if (0 != LogonProcess)
- {
- return STATUS_LOGON_SESSION_EXISTS;
- }
- LogonProcess = ApiMessage->Data.RegisterLogonProcessRequest.ProcessId;
- }
- else
- {
- if (ApiMessage->Header.ClientId.UniqueProcess != LogonProcess)
- {
- DPRINT1("Current logon process 0x%x, can't deregister from process
0x%x\n",
- LogonProcess, ApiMessage->Header.ClientId.UniqueProcess);
- return STATUS_NOT_LOGON_PROCESS;
- }
- LogonProcess = 0;
- }
-
- return STATUS_SUCCESS;
-}
-
-CSR_API(CsrSetLogonNotifyWindow)
-{
- DWORD WindowCreator;
-
- if (0 ==
GetWindowThreadProcessId(ApiMessage->Data.SetLogonNotifyWindowRequest.LogonNotifyWindow,
- &WindowCreator))
- {
- DPRINT1("Can't get window creator\n");
- return STATUS_INVALID_HANDLE;
- }
- if (WindowCreator != (DWORD_PTR)LogonProcess)
- {
- DPRINT1("Trying to register window not created by winlogon as notify
window\n");
- return STATUS_ACCESS_DENIED;
- }
-
- LogonNotifyWindow =
ApiMessage->Data.SetLogonNotifyWindowRequest.LogonNotifyWindow;
-
- return STATUS_SUCCESS;
-}
-
-typedef struct tagSHUTDOWN_SETTINGS
-{
- BOOL AutoEndTasks;
- DWORD HungAppTimeout;
- DWORD WaitToKillAppTimeout;
-} SHUTDOWN_SETTINGS, *PSHUTDOWN_SETTINGS;
-
-#define DEFAULT_AUTO_END_TASKS FALSE
-#define DEFAULT_HUNG_APP_TIMEOUT 5000
-#define DEFAULT_WAIT_TO_KILL_APP_TIMEOUT 20000
-
-typedef struct tagNOTIFY_CONTEXT
-{
- DWORD ProcessId;
- UINT Msg;
- WPARAM wParam;
- LPARAM lParam;
- HDESK Desktop;
- DWORD StartTime;
- DWORD QueryResult;
- HWND Dlg;
- DWORD EndNowResult;
- BOOL ShowUI;
- HANDLE UIThread;
- HWND WndClient;
- PSHUTDOWN_SETTINGS ShutdownSettings;
- LPTHREAD_START_ROUTINE SendMessageProc;
-} NOTIFY_CONTEXT, *PNOTIFY_CONTEXT;
-
-#define QUERY_RESULT_ABORT 0
-#define QUERY_RESULT_CONTINUE 1
-#define QUERY_RESULT_TIMEOUT 2
-#define QUERY_RESULT_ERROR 3
-#define QUERY_RESULT_FORCE 4
-
-static void FASTCALL
-UpdateProgressBar(HWND ProgressBar, PNOTIFY_CONTEXT NotifyContext)
-{
- DWORD Passed;
-
- Passed = GetTickCount() - NotifyContext->StartTime;
- Passed -= NotifyContext->ShutdownSettings->HungAppTimeout;
- if (NotifyContext->ShutdownSettings->WaitToKillAppTimeout < Passed)
- {
- Passed = NotifyContext->ShutdownSettings->WaitToKillAppTimeout;
- }
- SendMessageW(ProgressBar, PBM_SETPOS, Passed / 2, 0);
-}
-
-static INT_PTR CALLBACK
-EndNowDlgProc(HWND Dlg, UINT Msg, WPARAM wParam, LPARAM lParam)
-{
- INT_PTR Result;
- PNOTIFY_CONTEXT NotifyContext;
- HWND ProgressBar;
- DWORD TitleLength;
- int Len;
- LPWSTR Title;
-
- switch(Msg)
- {
- case WM_INITDIALOG:
- NotifyContext = (PNOTIFY_CONTEXT) lParam;
- NotifyContext->EndNowResult = QUERY_RESULT_ABORT;
- SetWindowLongPtrW(Dlg, DWLP_USER, (LONG_PTR) lParam);
- TitleLength = SendMessageW(NotifyContext->WndClient, WM_GETTEXTLENGTH,
- 0, 0) +
- GetWindowTextLengthW(Dlg);
- Title = HeapAlloc(Win32CsrApiHeap, 0, (TitleLength + 1) * sizeof(WCHAR));
- if (NULL != Title)
- {
- Len = GetWindowTextW(Dlg, Title, TitleLength + 1);
- SendMessageW(NotifyContext->WndClient, WM_GETTEXT,
- TitleLength + 1 - Len, (LPARAM) (Title + Len));
- SetWindowTextW(Dlg, Title);
- HeapFree(Win32CsrApiHeap, 0, Title);
- }
- ProgressBar = GetDlgItem(Dlg, IDC_PROGRESS);
- SendMessageW(ProgressBar, PBM_SETRANGE32, 0,
- NotifyContext->ShutdownSettings->WaitToKillAppTimeout / 2);
- UpdateProgressBar(ProgressBar, NotifyContext);
- SetTimer(Dlg, 0, 200, NULL);
- Result = FALSE;
- break;
-
- case WM_TIMER:
- NotifyContext = (PNOTIFY_CONTEXT) GetWindowLongPtrW(Dlg, DWLP_USER);
- ProgressBar = GetDlgItem(Dlg, IDC_PROGRESS);
- UpdateProgressBar(ProgressBar, NotifyContext);
- Result = TRUE;
- break;
-
- case WM_COMMAND:
- if (BN_CLICKED == HIWORD(wParam) && IDC_END_NOW == LOWORD(wParam))
- {
- NotifyContext = (PNOTIFY_CONTEXT) GetWindowLongPtrW(Dlg, DWLP_USER);
- NotifyContext->EndNowResult = QUERY_RESULT_FORCE;
- SendMessageW(Dlg, WM_CLOSE, 0, 0);
- Result = TRUE;
- }
- else
- {
- Result = FALSE;
- }
- break;
-
- case WM_CLOSE:
- DestroyWindow(Dlg);
- Result = TRUE;
- break;
-
- case WM_DESTROY:
- NotifyContext = (PNOTIFY_CONTEXT) GetWindowLongPtrW(Dlg, DWLP_USER);
- NotifyContext->Dlg = NULL;
- KillTimer(Dlg, 0);
- PostQuitMessage(NotifyContext->EndNowResult);
- Result = TRUE;
- break;
-
- default:
- Result = FALSE;
- break;
- }
-
- return Result;
-}
-
-typedef void (WINAPI *INITCOMMONCONTROLS_PROC)(void);
-
-static void
-CallInitCommonControls()
-{
- static BOOL Initialized = FALSE;
- HMODULE Lib;
- INITCOMMONCONTROLS_PROC InitProc;
-
- if (Initialized)
- {
- return;
- }
-
- Lib = LoadLibraryW(L"COMCTL32.DLL");
- if (NULL == Lib)
- {
- return;
- }
- InitProc = (INITCOMMONCONTROLS_PROC) GetProcAddress(Lib,
"InitCommonControls");
- if (NULL == InitProc)
- {
- return;
- }
-
- (*InitProc)();
-
- Initialized = TRUE;
-}
-
-static DWORD WINAPI
-EndNowThreadProc(LPVOID Parameter)
-{
- PNOTIFY_CONTEXT NotifyContext = (PNOTIFY_CONTEXT) Parameter;
- MSG Msg;
-
- SetThreadDesktop(NotifyContext->Desktop);
- SwitchDesktop(NotifyContext->Desktop);
- CallInitCommonControls();
- NotifyContext->Dlg = CreateDialogParam(GetModuleHandleW(L"win32csr"),
- MAKEINTRESOURCE(IDD_END_NOW), NULL,
- EndNowDlgProc, (LPARAM) NotifyContext);
- if (NULL == NotifyContext->Dlg)
- {
- return 0;
- }
- ShowWindow(NotifyContext->Dlg, SW_SHOWNORMAL);
-
- while (GetMessageW(&Msg, NULL, 0, 0))
- {
- if (! IsDialogMessage(NotifyContext->Dlg, &Msg))
- {
- TranslateMessage(&Msg);
- DispatchMessageW(&Msg);
- }
- }
-
- return Msg.wParam;
-}
-
-typedef struct tagMESSAGE_CONTEXT
-{
- HWND Wnd;
- UINT Msg;
- WPARAM wParam;
- LPARAM lParam;
- DWORD Timeout;
-} MESSAGE_CONTEXT, *PMESSAGE_CONTEXT;
-
-static DWORD WINAPI
-SendQueryEndSession(LPVOID Parameter)
-{
- PMESSAGE_CONTEXT Context = (PMESSAGE_CONTEXT) Parameter;
- DWORD_PTR Result;
-
- if (SendMessageTimeoutW(Context->Wnd, WM_QUERYENDSESSION, Context->wParam,
- Context->lParam, SMTO_NORMAL, Context->Timeout,
- &Result))
- {
- return Result ? QUERY_RESULT_CONTINUE : QUERY_RESULT_ABORT;
- }
-
- return 0 == GetLastError() ? QUERY_RESULT_TIMEOUT : QUERY_RESULT_ERROR;
-}
-
-static DWORD WINAPI
-SendEndSession(LPVOID Parameter)
-{
- PMESSAGE_CONTEXT Context = (PMESSAGE_CONTEXT) Parameter;
- DWORD_PTR Result;
-
- if (Context->wParam)
- {
- if (SendMessageTimeoutW(Context->Wnd, WM_ENDSESSION, Context->wParam,
- Context->lParam, SMTO_NORMAL, Context->Timeout,
- &Result))
- {
- return QUERY_RESULT_CONTINUE;
- }
- return 0 == GetLastError() ? QUERY_RESULT_TIMEOUT : QUERY_RESULT_ERROR;
- }
- else
- {
- SendMessage(Context->Wnd, WM_ENDSESSION, Context->wParam,
- Context->lParam);
- return QUERY_RESULT_CONTINUE;
- }
-}
-
-static BOOL CALLBACK
-NotifyTopLevelEnum(HWND Wnd, LPARAM lParam)
-{
- PNOTIFY_CONTEXT NotifyContext = (PNOTIFY_CONTEXT) lParam;
- MESSAGE_CONTEXT MessageContext;
- DWORD Now, Passed;
- DWORD Timeout, WaitStatus;
- DWORD ProcessId;
- HANDLE MessageThread;
- HANDLE Threads[2];
-
- if (0 == GetWindowThreadProcessId(Wnd, &ProcessId))
- {
- NotifyContext->QueryResult = QUERY_RESULT_ERROR;
- return FALSE;
- }
-
- if (ProcessId == NotifyContext->ProcessId)
- {
- Now = GetTickCount();
- if (0 == NotifyContext->StartTime)
- {
- NotifyContext->StartTime = Now;
- }
- /* Note: Passed is computed correctly even when GetTickCount() wraps due
- to unsigned arithmetic */
- Passed = Now - NotifyContext->StartTime;
- MessageContext.Wnd = Wnd;
- MessageContext.Msg = NotifyContext->Msg;
- MessageContext.wParam = NotifyContext->wParam;
- MessageContext.lParam = NotifyContext->lParam;
- MessageContext.Timeout = NotifyContext->ShutdownSettings->HungAppTimeout;
- if (! NotifyContext->ShutdownSettings->AutoEndTasks)
- {
- MessageContext.Timeout +=
NotifyContext->ShutdownSettings->WaitToKillAppTimeout;
- }
- if (Passed < MessageContext.Timeout)
- {
- MessageContext.Timeout -= Passed;
- MessageThread = CreateThread(NULL, 0, NotifyContext->SendMessageProc,
- (LPVOID) &MessageContext, 0, NULL);
- if (NULL == MessageThread)
- {
- NotifyContext->QueryResult = QUERY_RESULT_ERROR;
- return FALSE;
- }
- Timeout = NotifyContext->ShutdownSettings->HungAppTimeout;
- if (Passed < Timeout)
- {
- Timeout -= Passed;
- WaitStatus = WaitForSingleObjectEx(MessageThread, Timeout, FALSE);
- }
- else
- {
- WaitStatus = WAIT_TIMEOUT;
- }
- if (WAIT_TIMEOUT == WaitStatus)
- {
- NotifyContext->WndClient = Wnd;
- if (NULL == NotifyContext->UIThread &&
NotifyContext->ShowUI)
- {
- NotifyContext->UIThread = CreateThread(NULL, 0,
- EndNowThreadProc,
- (LPVOID) NotifyContext,
- 0, NULL);
- }
- Threads[0] = MessageThread;
- Threads[1] = NotifyContext->UIThread;
- WaitStatus = WaitForMultipleObjectsEx(NULL == NotifyContext->UIThread
?
- 1 : 2,
- Threads, FALSE, INFINITE,
- FALSE);
- if (WAIT_OBJECT_0 == WaitStatus)
- {
- if (! GetExitCodeThread(MessageThread,
&NotifyContext->QueryResult))
- {
- NotifyContext->QueryResult = QUERY_RESULT_ERROR;
- }
- }
- else if (WAIT_OBJECT_0 + 1 == WaitStatus)
- {
- if (! GetExitCodeThread(NotifyContext->UIThread,
- &NotifyContext->QueryResult))
- {
- NotifyContext->QueryResult = QUERY_RESULT_ERROR;
- }
- }
- else
- {
- NotifyContext->QueryResult = QUERY_RESULT_ERROR;
- }
- if (WAIT_OBJECT_0 != WaitStatus)
- {
- TerminateThread(MessageThread, QUERY_RESULT_TIMEOUT);
- }
- }
- else if (WAIT_OBJECT_0 == WaitStatus)
- {
- if (! GetExitCodeThread(MessageThread,
- &NotifyContext->QueryResult))
- {
- NotifyContext->QueryResult = QUERY_RESULT_ERROR;
- }
- }
- else
- {
- NotifyContext->QueryResult = QUERY_RESULT_ERROR;
- }
- CloseHandle(MessageThread);
- }
- else
- {
- NotifyContext->QueryResult = QUERY_RESULT_TIMEOUT;
- }
- }
-
- return QUERY_RESULT_CONTINUE == NotifyContext->QueryResult;
-}
-
-static BOOL CALLBACK
-NotifyDesktopEnum(LPWSTR DesktopName, LPARAM lParam)
-{
- PNOTIFY_CONTEXT Context = (PNOTIFY_CONTEXT) lParam;
-
- Context->Desktop = OpenDesktopW(DesktopName, 0, FALSE,
- DESKTOP_ENUMERATE | DESKTOP_SWITCHDESKTOP);
- if (NULL == Context->Desktop)
- {
- DPRINT1("OpenDesktop failed with error %d\n", GetLastError());
- Context->QueryResult = QUERY_RESULT_ERROR;
- return FALSE;
- }
-
- EnumDesktopWindows(Context->Desktop, NotifyTopLevelEnum, lParam);
-
- CloseDesktop(Context->Desktop);
-
- return QUERY_RESULT_CONTINUE == Context->QueryResult;
-}
-
-static BOOL FASTCALL
-NotifyTopLevelWindows(PNOTIFY_CONTEXT Context)
-{
- HWINSTA WindowStation;
-
- WindowStation = GetProcessWindowStation();
- if (NULL == WindowStation)
- {
- DPRINT1("GetProcessWindowStation failed with error %d\n",
GetLastError());
- return TRUE;
- }
-
- EnumDesktopsW(WindowStation, NotifyDesktopEnum, (LPARAM) Context);
-
- return TRUE;
-}
-
-static BOOL FASTCALL
-NotifyAndTerminateProcess(PCSR_PROCESS ProcessData,
- PSHUTDOWN_SETTINGS ShutdownSettings,
- UINT Flags)
-{
- NOTIFY_CONTEXT Context;
- HANDLE Process;
- DWORD QueryResult = QUERY_RESULT_CONTINUE;
-
- Context.QueryResult = QUERY_RESULT_CONTINUE;
-
- if (0 == (Flags & EWX_FORCE))
- {
- if (NULL != ProcessData->Console)
- {
- ConioConsoleCtrlEventTimeout(CTRL_LOGOFF_EVENT, ProcessData,
- ShutdownSettings->WaitToKillAppTimeout);
- }
- else
- {
- Context.ProcessId = (DWORD_PTR) ProcessData->ClientId.UniqueProcess;
- Context.wParam = 0;
- Context.lParam = (0 != (Flags & EWX_INTERNAL_FLAG_LOGOFF) ?
- ENDSESSION_LOGOFF : 0);
- Context.StartTime = 0;
- Context.UIThread = NULL;
- Context.ShowUI = DtbgIsDesktopVisible();
- Context.Dlg = NULL;
- Context.ShutdownSettings = ShutdownSettings;
- Context.SendMessageProc = SendQueryEndSession;
-
- NotifyTopLevelWindows(&Context);
-
- Context.wParam = (QUERY_RESULT_ABORT != Context.QueryResult);
- Context.lParam = (0 != (Flags & EWX_INTERNAL_FLAG_LOGOFF) ?
- ENDSESSION_LOGOFF : 0);
- Context.SendMessageProc = SendEndSession;
- Context.ShowUI = DtbgIsDesktopVisible() &&
- (QUERY_RESULT_ABORT != Context.QueryResult);
- QueryResult = Context.QueryResult;
- Context.QueryResult = QUERY_RESULT_CONTINUE;
-
- NotifyTopLevelWindows(&Context);
-
- if (NULL != Context.UIThread)
- {
- if (NULL != Context.Dlg)
- {
- SendMessageW(Context.Dlg, WM_CLOSE, 0, 0);
- }
- else
- {
- TerminateThread(Context.UIThread, QUERY_RESULT_ERROR);
- }
- CloseHandle(Context.UIThread);
- }
- }
-
- if (QUERY_RESULT_ABORT == QueryResult)
- {
- return FALSE;
- }
- }
-
- /* Terminate this process */
- Process = OpenProcess(PROCESS_TERMINATE, FALSE,
- (DWORD_PTR) ProcessData->ClientId.UniqueProcess);
- if (NULL == Process)
- {
- DPRINT1("Unable to open process %d, error %d\n",
ProcessData->ClientId.UniqueProcess,
- GetLastError());
- return TRUE;
- }
- TerminateProcess(Process, 0);
- CloseHandle(Process);
-
- return TRUE;
-}
-
-typedef struct tagPROCESS_ENUM_CONTEXT
-{
- UINT ProcessCount;
- PCSR_PROCESS *ProcessData;
- TOKEN_ORIGIN TokenOrigin;
- DWORD ShellProcess;
- DWORD CsrssProcess;
-} PROCESS_ENUM_CONTEXT, *PPROCESS_ENUM_CONTEXT;
-
-static NTSTATUS WINAPI
-ExitReactosProcessEnum(PCSR_PROCESS ProcessData, PVOID Data)
-{
- HANDLE Process;
- HANDLE Token;
- TOKEN_ORIGIN Origin;
- DWORD ReturnLength;
- PPROCESS_ENUM_CONTEXT Context = (PPROCESS_ENUM_CONTEXT) Data;
- PCSR_PROCESS *NewData;
-
- /* Do not kill winlogon or csrss */
- if ((DWORD_PTR) ProcessData->ClientId.UniqueProcess == Context->CsrssProcess
||
- ProcessData->ClientId.UniqueProcess == LogonProcess)
- {
- return STATUS_SUCCESS;
- }
-
- /* Get the login session of this process */
- Process = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE,
- (DWORD_PTR) ProcessData->ClientId.UniqueProcess);
- if (NULL == Process)
- {
- DPRINT1("Unable to open process %d, error %d\n",
ProcessData->ClientId.UniqueProcess,
- GetLastError());
- return STATUS_UNSUCCESSFUL;
- }
-
- if (! OpenProcessToken(Process, TOKEN_QUERY, &Token))
- {
- DPRINT1("Unable to open token for process %d, error %d\n",
- ProcessData->ClientId.UniqueProcess, GetLastError());
- CloseHandle(Process);
- return STATUS_UNSUCCESSFUL;
- }
- CloseHandle(Process);
-
- if (! GetTokenInformation(Token, TokenOrigin, &Origin,
- sizeof(TOKEN_ORIGIN), &ReturnLength))
- {
- DPRINT1("GetTokenInformation failed for process %d with error %d\n",
- ProcessData->ClientId.UniqueProcess, GetLastError());
- CloseHandle(Token);
- return STATUS_UNSUCCESSFUL;
- }
- CloseHandle(Token);
-
- /* This process will be killed if it's in the correct logon session */
- if (RtlEqualLuid(&(Context->TokenOrigin.OriginatingLogonSession),
- &(Origin.OriginatingLogonSession)))
- {
- /* Kill the shell process last */
- if ((DWORD_PTR) ProcessData->ClientId.UniqueProcess ==
Context->ShellProcess)
- {
- ProcessData->ShutdownLevel = 0;
- }
- NewData = HeapAlloc(Win32CsrApiHeap, 0, (Context->ProcessCount + 1)
- * sizeof(PCSR_PROCESS));
- if (NULL == NewData)
- {
- return STATUS_NO_MEMORY;
- }
- if (0 != Context->ProcessCount)
- {
- memcpy(NewData, Context->ProcessData,
- Context->ProcessCount * sizeof(PCSR_PROCESS));
- HeapFree(Win32CsrApiHeap, 0, Context->ProcessData);
- }
- Context->ProcessData = NewData;
- Context->ProcessData[Context->ProcessCount] = ProcessData;
- Context->ProcessCount++;
- }
-
- return STATUS_SUCCESS;
-}
-
-static int
-ProcessDataCompare(const void *Elem1, const void *Elem2)
-{
- const PCSR_PROCESS *ProcessData1 = (PCSR_PROCESS *) Elem1;
- const PCSR_PROCESS *ProcessData2 = (PCSR_PROCESS *) Elem2;
-
- if ((*ProcessData1)->ShutdownLevel < (*ProcessData2)->ShutdownLevel)
- {
- return +1;
- }
- else if ((*ProcessData2)->ShutdownLevel < (*ProcessData1)->ShutdownLevel)
- {
- return -1;
- }
- else if ((*ProcessData1)->ClientId.UniqueProcess <
(*ProcessData2)->ClientId.UniqueProcess)
- {
- return +1;
- }
- else if ((*ProcessData2)->ClientId.UniqueProcess <
(*ProcessData1)->ClientId.UniqueProcess)
- {
- return -1;
- }
-
- return 0;
-}
-
-static DWORD FASTCALL
-GetShutdownSetting(HKEY DesktopKey, LPCWSTR ValueName, DWORD DefaultValue)
-{
- BYTE ValueBuffer[16];
- LONG ErrCode;
- DWORD Type;
- DWORD ValueSize;
- UNICODE_STRING StringValue;
- ULONG Value;
-
- ValueSize = sizeof(ValueBuffer);
- ErrCode = RegQueryValueExW(DesktopKey, ValueName, NULL, &Type, ValueBuffer,
- &ValueSize);
- if (ERROR_SUCCESS != ErrCode)
- {
- DPRINT("GetShutdownSetting for %S failed with error code %ld\n",
- ValueName, ErrCode);
- return DefaultValue;
- }
-
- if (REG_SZ == Type)
- {
- RtlInitUnicodeString(&StringValue, (LPCWSTR) ValueBuffer);
- if (! NT_SUCCESS(RtlUnicodeStringToInteger(&StringValue, 10, &Value)))
- {
- DPRINT1("Unable to convert value %S for setting %S\n",
- StringValue.Buffer, ValueName);
- return DefaultValue;
- }
- return (DWORD) Value;
- }
- else if (REG_DWORD == Type)
- {
- return *((DWORD *) ValueBuffer);
- }
-
- DPRINT1("Unexpected registry type %d for setting %S\n", Type, ValueName);
- return DefaultValue;
-}
-
-static void FASTCALL
-LoadShutdownSettings(PSID Sid, PSHUTDOWN_SETTINGS ShutdownSettings)
-{
- static WCHAR Subkey[] = L"\\Control Panel\\Desktop";
- LPWSTR StringSid;
- WCHAR InitialKeyName[128];
- LPWSTR KeyName;
- HKEY DesktopKey;
- LONG ErrCode;
-
- ShutdownSettings->AutoEndTasks = DEFAULT_AUTO_END_TASKS;
- ShutdownSettings->HungAppTimeout = DEFAULT_HUNG_APP_TIMEOUT;
- ShutdownSettings->WaitToKillAppTimeout = DEFAULT_WAIT_TO_KILL_APP_TIMEOUT;
-
- if (! ConvertSidToStringSidW(Sid, &StringSid))
- {
- DPRINT1("ConvertSidToStringSid failed with error %d, using default shutdown
settings\n",
- GetLastError());
- return;
- }
- if (wcslen(StringSid) + wcslen(Subkey) + 1 <=
- sizeof(InitialKeyName) / sizeof(WCHAR))
- {
- KeyName = InitialKeyName;
- }
- else
- {
- KeyName = HeapAlloc(Win32CsrApiHeap, 0,
- (wcslen(StringSid) + wcslen(Subkey) + 1) *
- sizeof(WCHAR));
- if (NULL == KeyName)
- {
- DPRINT1("Failed to allocate memory, using default shutdown
settings\n");
- LocalFree(StringSid);
- return;
- }
- }
- wcscat(wcscpy(KeyName, StringSid), Subkey);
- LocalFree(StringSid);
-
- ErrCode = RegOpenKeyExW(HKEY_USERS, KeyName, 0, KEY_QUERY_VALUE, &DesktopKey);
- if (KeyName != InitialKeyName)
- {
- HeapFree(Win32CsrApiHeap, 0, KeyName);
- }
- if (ERROR_SUCCESS != ErrCode)
- {
- DPRINT1("RegOpenKeyEx failed with error %ld, using default shutdown
settings\n", ErrCode);
- return;
- }
-
- ShutdownSettings->AutoEndTasks = (BOOL) GetShutdownSetting(DesktopKey,
L"AutoEndTasks",
- (DWORD) DEFAULT_AUTO_END_TASKS);
- ShutdownSettings->HungAppTimeout = GetShutdownSetting(DesktopKey,
- L"HungAppTimeout",
- DEFAULT_HUNG_APP_TIMEOUT);
- ShutdownSettings->WaitToKillAppTimeout = GetShutdownSetting(DesktopKey,
- L"WaitToKillAppTimeout",
- DEFAULT_WAIT_TO_KILL_APP_TIMEOUT);
-
- RegCloseKey(DesktopKey);
-}
-
-static NTSTATUS FASTCALL
-InternalExitReactos(DWORD ProcessId, DWORD ThreadId, UINT Flags)
-{
- HANDLE CallerThread;
- HANDLE CallerToken;
- NTSTATUS Status;
- PROCESS_ENUM_CONTEXT Context;
- DWORD ReturnLength;
- HWND ShellWnd;
- UINT ProcessIndex;
- char FixedUserInfo[64];
- TOKEN_USER *UserInfo;
- SHUTDOWN_SETTINGS ShutdownSettings;
-
- if (ProcessId != (DWORD_PTR) LogonProcess)
- {
- DPRINT1("Internal ExitWindowsEx call not from winlogon\n");
- return STATUS_ACCESS_DENIED;
- }
-
- DPRINT1("FIXME: Need to close all user processes!\n");
- return STATUS_SUCCESS;
-
- CallerThread = OpenThread(THREAD_QUERY_INFORMATION, FALSE, ThreadId);
- if (NULL == CallerThread)
- {
- DPRINT1("OpenThread failed with error %d\n", GetLastError());
- return STATUS_UNSUCCESSFUL;
- }
- if (! OpenThreadToken(CallerThread, TOKEN_QUERY, FALSE, &CallerToken))
- {
- DPRINT1("OpenThreadToken failed with error %d\n", GetLastError());
- CloseHandle(CallerThread);
- return STATUS_UNSUCCESSFUL;
- }
- CloseHandle(CallerThread);
-
- Context.ProcessCount = 0;
- Context.ProcessData = NULL;
- if (! GetTokenInformation(CallerToken, TokenOrigin, &Context.TokenOrigin,
- sizeof(TOKEN_ORIGIN), &ReturnLength))
- {
- DPRINT1("GetTokenInformation failed with error %d\n", GetLastError());
- CloseHandle(CallerToken);
- return STATUS_UNSUCCESSFUL;
- }
- if (! GetTokenInformation(CallerToken, TokenUser, FixedUserInfo,
- sizeof(FixedUserInfo), &ReturnLength))
- {
- if (sizeof(FixedUserInfo) < ReturnLength)
- {
- UserInfo = HeapAlloc(Win32CsrApiHeap, 0, ReturnLength);
- if (NULL == UserInfo)
- {
- DPRINT1("Unable to allocate %u bytes for user info\n",
- (unsigned) ReturnLength);
- CloseHandle(CallerToken);
- return STATUS_NO_MEMORY;
- }
- if (! GetTokenInformation(CallerToken, TokenUser, UserInfo,
- ReturnLength, &ReturnLength))
- {
- DPRINT1("GetTokenInformation failed with error %d\n",
- GetLastError());
- HeapFree(Win32CsrApiHeap, 0, UserInfo);
- CloseHandle(CallerToken);
- return STATUS_UNSUCCESSFUL;
- }
- }
- else
- {
- DPRINT1("GetTokenInformation failed with error %d\n",
GetLastError());
- CloseHandle(CallerToken);
- return STATUS_UNSUCCESSFUL;
- }
- }
- else
- {
- UserInfo = (TOKEN_USER *) FixedUserInfo;
- }
- CloseHandle(CallerToken);
- LoadShutdownSettings(UserInfo->User.Sid, &ShutdownSettings);
- if (UserInfo != (TOKEN_USER *) FixedUserInfo)
- {
- HeapFree(Win32CsrApiHeap, 0, UserInfo);
- }
- Context.CsrssProcess = GetCurrentProcessId();
- ShellWnd = GetShellWindow();
- if (NULL == ShellWnd)
- {
- DPRINT("No shell present\n");
- Context.ShellProcess = 0;
- }
- else if (0 == GetWindowThreadProcessId(ShellWnd, &Context.ShellProcess))
- {
- DPRINT1("Can't get process id of shell window\n");
- Context.ShellProcess = 0;
- }
-
- Status = Win32CsrEnumProcesses(ExitReactosProcessEnum, &Context);
- if (! NT_SUCCESS(Status))
- {
- DPRINT1("Failed to enumerate registered processes, status 0x%x\n",
- Status);
- if (NULL != Context.ProcessData)
- {
- HeapFree(Win32CsrApiHeap, 0, Context.ProcessData);
- }
- return Status;
- }
-
- qsort(Context.ProcessData, Context.ProcessCount, sizeof(PCSR_PROCESS),
- ProcessDataCompare);
-
- /* Terminate processes, stop if we find one kicking and screaming it doesn't
- want to die */
- Status = STATUS_SUCCESS;
- for (ProcessIndex = 0;
- ProcessIndex < Context.ProcessCount && NT_SUCCESS(Status);
- ProcessIndex++)
- {
- if (! NotifyAndTerminateProcess(Context.ProcessData[ProcessIndex],
- &ShutdownSettings, Flags))
- {
- Status = STATUS_REQUEST_ABORTED;
- }
- }
-
- /* Cleanup */
- if (NULL != Context.ProcessData)
- {
- HeapFree(Win32CsrApiHeap, 0, Context.ProcessData);
- }
-
- return Status;
-}
-
-static NTSTATUS FASTCALL
-UserExitReactos(DWORD UserProcessId, UINT Flags)
-{
- NTSTATUS Status;
-
- if (NULL == LogonNotifyWindow)
- {
- DPRINT1("No LogonNotifyWindow registered\n");
- return STATUS_NOT_FOUND;
- }
-
- /* FIXME Inside 2000 says we should impersonate the caller here */
- Status = SendMessageW(LogonNotifyWindow, PM_WINLOGON_EXITWINDOWS,
- (WPARAM) UserProcessId,
- (LPARAM) Flags);
- /* If the message isn't handled, the return value is 0, so 0 doesn't
indicate
- success. Success is indicated by a 1 return value, if anything besides 0
- or 1 it's a NTSTATUS value */
- if (1 == Status)
- {
- Status = STATUS_SUCCESS;
- }
- else if (0 == Status)
- {
- Status = STATUS_NOT_IMPLEMENTED;
- }
-
- return Status;
-}
-
-CSR_API(CsrExitReactos)
-{
- if (0 == (ApiMessage->Data.ExitReactosRequest.Flags & EWX_INTERNAL_FLAG))
- {
- return UserExitReactos((DWORD_PTR) ApiMessage->Header.ClientId.UniqueProcess,
- ApiMessage->Data.ExitReactosRequest.Flags);
- }
- else
- {
- return InternalExitReactos((DWORD_PTR)
ApiMessage->Header.ClientId.UniqueProcess,
- (DWORD_PTR)
ApiMessage->Header.ClientId.UniqueThread,
- ApiMessage->Data.ExitReactosRequest.Flags);
- }
-}
-
-/* EOF */
Removed: branches/ros-csrss/win32ss/user/win32csr/harderror.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/harderror.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/harderror.c (removed)
@@ -1,580 +1,0 @@
-/*
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS system libraries
- * FILE: subsys/csrss/win32csr/dllmain.c
- * PURPOSE: Initialization
- * PROGRAMMERS: Dmitry Philippov (shedon(a)mail.ru)
- * Timo Kreuzer (timo.kreuzer(a)reactos.org)
- */
-
-/* INCLUDES ******************************************************************/
-
-#include "w32csr.h"
-
-#define NDEBUG
-#include <debug.h>
-
-#include <strsafe.h>
-
-#define IDTRYAGAIN 10
-#define IDCONTINUE 11
-
-/* FUNCTIONS *****************************************************************/
-
-static
-NTSTATUS
-CsrpGetClientFileName(
- OUT PUNICODE_STRING ClientFileNameU,
- HANDLE hProcess)
-{
- PLIST_ENTRY ModuleListHead;
- PLIST_ENTRY Entry;
- PLDR_DATA_TABLE_ENTRY Module;
- PPEB_LDR_DATA Ldr;
- PROCESS_BASIC_INFORMATION ClientBasicInfo;
- LDR_DATA_TABLE_ENTRY ModuleData;
- PVOID ClientDllBase;
- NTSTATUS Status;
- PPEB Peb;
-
- /* Initialize string */
- ClientFileNameU->MaximumLength = 0;
- ClientFileNameU->Length = 0;
- ClientFileNameU->Buffer = NULL;
-
- /* Query process information */
- Status = NtQueryInformationProcess(hProcess,
- ProcessBasicInformation,
- &ClientBasicInfo,
- sizeof(ClientBasicInfo),
- NULL);
- if (!NT_SUCCESS(Status)) return Status;
-
- Peb = ClientBasicInfo.PebBaseAddress;
- if (!Peb) return STATUS_UNSUCCESSFUL;
-
- Status = NtReadVirtualMemory(hProcess, &Peb->Ldr, &Ldr, sizeof(Ldr),
NULL);
- if (!NT_SUCCESS(Status)) return Status;
-
- ModuleListHead = &Ldr->InLoadOrderModuleList;
- Status = NtReadVirtualMemory(hProcess,
- &ModuleListHead->Flink,
- &Entry,
- sizeof(Entry),
- NULL);
- if (!NT_SUCCESS(Status)) return Status;
-
- if (Entry == ModuleListHead) return STATUS_UNSUCCESSFUL;
-
- Module = CONTAINING_RECORD(Entry, LDR_DATA_TABLE_ENTRY, InLoadOrderLinks);
-
- Status = NtReadVirtualMemory(hProcess,
- Module,
- &ModuleData,
- sizeof(ModuleData),
- NULL);
- if (!NT_SUCCESS(Status)) return Status;
-
- Status = NtReadVirtualMemory(hProcess,
- &Peb->ImageBaseAddress,
- &ClientDllBase,
- sizeof(ClientDllBase),
- NULL);
- if (!NT_SUCCESS(Status)) return Status;
-
- if (ClientDllBase != ModuleData.DllBase) return STATUS_UNSUCCESSFUL;
-
- ClientFileNameU->MaximumLength = ModuleData.BaseDllName.MaximumLength;
- ClientFileNameU->Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
- HEAP_ZERO_MEMORY,
- ClientFileNameU->MaximumLength);
-
- Status = NtReadVirtualMemory(hProcess,
- ModuleData.BaseDllName.Buffer,
- ClientFileNameU->Buffer,
- ClientFileNameU->MaximumLength,
- NULL);
- if (!NT_SUCCESS(Status))
- {
- RtlFreeHeap(RtlGetProcessHeap(), 0, ClientFileNameU->Buffer);
- ClientFileNameU->Buffer = NULL;
- ClientFileNameU->MaximumLength = 0;
- return Status;
- }
-
- ClientFileNameU->Length = wcslen(ClientFileNameU->Buffer)*sizeof(wchar_t);
- DPRINT("ClientFileNameU=\'%wZ\'\n", &ClientFileNameU);
-
- return STATUS_SUCCESS;
-}
-
-static
-VOID
-CsrpFreeStringParameters(
- IN OUT PULONG_PTR Parameters,
- IN PHARDERROR_MSG HardErrorMessage)
-{
- ULONG nParam;
-
- /* Loop all parameters */
- for (nParam = 0; nParam < HardErrorMessage->NumberOfParameters; nParam++)
- {
- /* Check if the current parameter is a string */
- if (HardErrorMessage->UnicodeStringParameterMask & (1 << nParam)
&& Parameters[nParam])
- {
- /* Free the string buffer */
- RtlFreeHeap(RtlGetProcessHeap(), 0, (PVOID)Parameters[nParam]);
- }
- }
-}
-
-static
-NTSTATUS
-CsrpCaptureStringParameters(
- OUT PULONG_PTR Parameters,
- OUT PULONG SizeOfAllUnicodeStrings,
- IN PHARDERROR_MSG HardErrorMessage,
- HANDLE hProcess)
-{
- ULONG nParam, Size = 0;
- NTSTATUS Status = STATUS_SUCCESS;
- UNICODE_STRING TempStringU, ParamStringU;
- ANSI_STRING TempStringA;
-
- /* Read all strings from client space */
- for (nParam = 0; nParam < HardErrorMessage->NumberOfParameters; nParam++)
- {
- Parameters[nParam] = 0;
-
- /* Check if the current parameter is a unicode string */
- if (HardErrorMessage->UnicodeStringParameterMask & (1 << nParam))
- {
- /* Read the UNICODE_STRING from the process memory */
- Status = NtReadVirtualMemory(hProcess,
- (PVOID)HardErrorMessage->Parameters[nParam],
- &ParamStringU,
- sizeof(ParamStringU),
- NULL);
-
- if (!NT_SUCCESS(Status))
- break;
-
- /* Allocate a buffer for the string */
- TempStringU.MaximumLength = ParamStringU.Length;
- TempStringU.Length = ParamStringU.Length;
- TempStringU.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
- HEAP_ZERO_MEMORY,
- TempStringU.MaximumLength);
-
- if (!TempStringU.Buffer)
- {
- DPRINT1("Cannot allocate memory %u\n",
TempStringU.MaximumLength);
- Status = STATUS_NO_MEMORY;
- }
-
- /* Read the string buffer from the process memory */
- Status = NtReadVirtualMemory(hProcess,
- ParamStringU.Buffer,
- TempStringU.Buffer,
- ParamStringU.Length,
- NULL);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtReadVirtualMemory failed with code: %lx\n",
Status);
- RtlFreeHeap(RtlGetProcessHeap(), 0, TempStringU.Buffer);
- break;
- }
-
- DPRINT("ParamString=\'%wZ\'\n", &TempStringU);
-
- /* Allocate a buffer for converted to ANSI string */
- TempStringA.MaximumLength = RtlUnicodeStringToAnsiSize(&TempStringU);
- TempStringA.Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
- HEAP_ZERO_MEMORY,
- TempStringA.MaximumLength);
-
- if (!TempStringA.Buffer)
- {
- DPRINT1("Cannot allocate memory %u\n",
TempStringA.MaximumLength);
- RtlFreeHeap(RtlGetProcessHeap(), 0, TempStringU.Buffer);
- Status = STATUS_NO_MEMORY;
- break;
- }
-
- /* Convert string to ANSI and free temporary buffer */
- Status = RtlUnicodeStringToAnsiString(&TempStringA, &TempStringU,
FALSE);
- RtlFreeHeap(RtlGetProcessHeap(), 0, TempStringU.Buffer);
- if (!NT_SUCCESS(Status))
- {
- RtlFreeHeap(RtlGetProcessHeap(), 0, TempStringA.Buffer);
- break;
- }
-
- /* Note: RtlUnicodeStringToAnsiString returns NULL terminated string */
- Parameters[nParam] = (ULONG_PTR)TempStringA.Buffer;
- Size += TempStringU.Length;
- }
- else
- {
- /* It's not a unicode string */
- Parameters[nParam] = HardErrorMessage->Parameters[nParam];
- }
- }
-
- if (!NT_SUCCESS(Status))
- {
- CsrpFreeStringParameters(Parameters, HardErrorMessage);
- return Status;
- }
-
- *SizeOfAllUnicodeStrings = Size;
- return Status;
-}
-
-static
-NTSTATUS
-CsrpFormatMessages(
- OUT PUNICODE_STRING TextStringU,
- OUT PUNICODE_STRING CaptionStringU,
- IN PULONG_PTR Parameters,
- IN ULONG SizeOfStrings,
- IN PHARDERROR_MSG Message,
- IN HANDLE hProcess)
-{
- NTSTATUS Status;
- UNICODE_STRING FileNameU, TempStringU, FormatU;
- ANSI_STRING FormatA;
- PMESSAGE_RESOURCE_ENTRY MessageResource;
- PWSTR FormatString;
- ULONG Size, ExceptionCode;
-
- /* Get the file name of the client process */
- CsrpGetClientFileName(&FileNameU, hProcess);
-
- /* Check if we have a file name */
- if (!FileNameU.Buffer)
- {
- /* No, use system */
- RtlInitUnicodeString(&FileNameU, L"System");
- }
-
- /* Get text string of the error code */
- Status = RtlFindMessage(GetModuleHandleW(L"ntdll"),
- (ULONG_PTR)RT_MESSAGETABLE,
- LANG_NEUTRAL,
- Message->Status,
- &MessageResource);
-
- if (NT_SUCCESS(Status))
- {
- if (MessageResource->Flags)
- {
- RtlInitUnicodeString(&FormatU, (PWSTR)MessageResource->Text);
- FormatA.Buffer = NULL;
- }
- else
- {
- RtlInitAnsiString(&FormatA, (PCHAR)MessageResource->Text);
- RtlAnsiStringToUnicodeString(&FormatU, &FormatA, TRUE);
- }
- }
- else
- {
- /* Fall back to hardcoded value */
- RtlInitUnicodeString(&FormatU, L"Unknown Hard Error");
- FormatA.Buffer = NULL;
- }
-
- FormatString = FormatU.Buffer;
-
- /* Check whether a caption exists */
- if (FormatString[0] == L'{')
- {
- /* Set caption start */
- TempStringU.Buffer = ++FormatString;
-
- /* Get size of the caption */
- for (Size = 0; *FormatString != 0 && *FormatString != L'}';
Size++)
- FormatString++;
-
- /* Skip '}', '\r', '\n' */
- FormatString += 3;
-
- TempStringU.Length = Size * sizeof(WCHAR);
- TempStringU.MaximumLength = TempStringU.Length;
- }
- else
- {
- /* FIXME: Set string based on severity */
- RtlInitUnicodeString(&TempStringU, L"Application Error");
- }
-
- /* Calculate buffer length for the caption */
- CaptionStringU->MaximumLength = FileNameU.Length + TempStringU.Length +
- 4 * sizeof(WCHAR);
-
- /* Allocate a buffer for the caption */
- CaptionStringU->Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
- HEAP_ZERO_MEMORY,
- CaptionStringU->MaximumLength);
-
- /* Append the file name, seperator and the caption text */
- CaptionStringU->Length = 0;
- RtlAppendUnicodeStringToString(CaptionStringU, &FileNameU);
- RtlAppendUnicodeToString(CaptionStringU, L" - ");
- RtlAppendUnicodeStringToString(CaptionStringU, &TempStringU);
-
- /* Zero terminate the buffer */
- CaptionStringU->Buffer[CaptionStringU->Length / sizeof(WCHAR)] = 0;
-
- /* Free the file name buffer */
- RtlFreeUnicodeString(&FileNameU);
-
- /* Check if this is an exception message */
- if (Message->Status == STATUS_UNHANDLED_EXCEPTION)
- {
- ExceptionCode = Parameters[0];
-
- /* Handle special cases */
- if (ExceptionCode == STATUS_ACCESS_VIOLATION)
- {
- Parameters[0] = Parameters[1];
- Parameters[1] = Parameters[3];
- if (Parameters[2]) Parameters[2] = (ULONG_PTR)L"written";
- else Parameters[2] = (ULONG_PTR)L"read";
- MessageResource = NULL;
- }
- else if (ExceptionCode == STATUS_IN_PAGE_ERROR)
- {
- Parameters[0] = Parameters[1];
- Parameters[1] = Parameters[3];
- MessageResource = NULL;
- }
- else
- {
- /* Fall back to hardcoded value */
- Parameters[2] = Parameters[1];
- Parameters[1] = Parameters[0];
- Parameters[0] = (ULONG_PTR)L"unknown software exception";
- }
-
- if (!MessageResource)
- {
- /* Get text string of the exception code */
- Status = RtlFindMessage(GetModuleHandleW(L"ntdll"),
- (ULONG_PTR)RT_MESSAGETABLE,
- LANG_NEUTRAL,
- ExceptionCode,
- &MessageResource);
-
- if (NT_SUCCESS(Status))
- {
- if (FormatA.Buffer) RtlFreeUnicodeString(&FormatU);
-
- if (MessageResource->Flags)
- {
- RtlInitUnicodeString(&FormatU, (PWSTR)MessageResource->Text);
- FormatA.Buffer = NULL;
- }
- else
- {
- RtlInitAnsiString(&FormatA, (PCHAR)MessageResource->Text);
- RtlAnsiStringToUnicodeString(&FormatU, &FormatA, TRUE);
- }
- FormatString = FormatU.Buffer;
- }
- else
- {
- /* Fall back to hardcoded value */
- Parameters[2] = Parameters[1];
- Parameters[1] = Parameters[0];
- Parameters[0] = (ULONG_PTR)L"unknown software exception";
- }
- }
- }
-
- /* Calculate length of text buffer */
- TextStringU->MaximumLength = FormatU.Length + SizeOfStrings + 42 * sizeof(WCHAR);
-
- /* Allocate a buffer for the text */
- TextStringU->Buffer = RtlAllocateHeap(RtlGetProcessHeap(),
- HEAP_ZERO_MEMORY,
- TextStringU->MaximumLength);
-
- /* Wrap in SEH to protect from invalid string parameters */
- _SEH2_TRY
- {
- /* Print the string into the buffer */
- StringCbPrintfW(TextStringU->Buffer,
- TextStringU->MaximumLength,
- FormatString,
- Parameters[0],
- Parameters[1],
- Parameters[2],
- Parameters[3]);
- Status = STATUS_SUCCESS;
- }
- _SEH2_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
- {
- /* Set error and free buffers */
- Status = _SEH2_GetExceptionCode();
- RtlFreeHeap(RtlGetProcessHeap(), 0, TextStringU->Buffer);
- RtlFreeHeap(RtlGetProcessHeap(), 0, CaptionStringU->Buffer);
- }
- _SEH2_END
-
- if (NT_SUCCESS(Status))
- {
- TextStringU->Length = wcslen(TextStringU->Buffer) * sizeof(WCHAR);
- }
-
- if (FormatA.Buffer) RtlFreeUnicodeString(&FormatU);
-
- return Status;
-}
-
-static
-ULONG
-CsrpMessageBox(
- PWSTR Text,
- PWSTR Caption,
- ULONG ValidResponseOptions,
- ULONG Severity)
-{
- ULONG Type, MessageBoxResponse;
-
- /* Set the message box type */
- switch (ValidResponseOptions)
- {
- case OptionAbortRetryIgnore:
- Type = MB_ABORTRETRYIGNORE;
- break;
- case OptionOk:
- Type = MB_OK;
- break;
- case OptionOkCancel:
- Type = MB_OKCANCEL;
- break;
- case OptionRetryCancel:
- Type = MB_RETRYCANCEL;
- break;
- case OptionYesNo:
- Type = MB_YESNO;
- break;
- case OptionYesNoCancel:
- Type = MB_YESNOCANCEL;
- break;
- case OptionShutdownSystem:
- Type = MB_RETRYCANCEL; // FIXME???
- break;
- /* Anything else is invalid */
- default:
- return ResponseNotHandled;
- }
-
- /* Set severity */
- if (Severity == STATUS_SEVERITY_INFORMATIONAL) Type |= MB_ICONINFORMATION;
- else if (Severity == STATUS_SEVERITY_WARNING) Type |= MB_ICONWARNING;
- else if (Severity == STATUS_SEVERITY_ERROR) Type |= MB_ICONERROR;
-
- Type |= MB_SYSTEMMODAL | MB_SETFOREGROUND;
-
- DPRINT("Text = '%S', Caption = '%S', Severity = %d, Type =
0x%lx\n",
- Text, Caption, Severity, Type);
-
- /* Display a message box */
- MessageBoxResponse = MessageBoxW(0, Text, Caption, Type);
-
- /* Return response value */
- switch (MessageBoxResponse)
- {
- case IDOK: return ResponseOk;
- case IDCANCEL: return ResponseCancel;
- case IDYES: return ResponseYes;
- case IDNO: return ResponseNo;
- case IDABORT: return ResponseAbort;
- case IDIGNORE: return ResponseIgnore;
- case IDRETRY: return ResponseRetry;
- case IDTRYAGAIN: return ResponseTryAgain;
- case IDCONTINUE: return ResponseContinue;
- }
-
- return ResponseNotHandled;
-}
-
-VOID
-WINAPI
-Win32CsrHardError(
- IN PCSR_THREAD ThreadData,
- IN PHARDERROR_MSG Message)
-{
-#if DBG
- PCSR_PROCESS ProcessData = ThreadData->Process;
-#endif
- ULONG_PTR Parameters[MAXIMUM_HARDERROR_PARAMETERS];
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING TextU, CaptionU;
- NTSTATUS Status;
- HANDLE hProcess;
- ULONG Size;
-
- /* Default to not handled */
- ASSERT(ProcessData != NULL);
- Message->Response = ResponseNotHandled;
-
- /* Make sure we don't have too many parameters */
- if (Message->NumberOfParameters > MAXIMUM_HARDERROR_PARAMETERS)
- Message->NumberOfParameters = MAXIMUM_HARDERROR_PARAMETERS;
-
- /* Initialize object attributes */
- InitializeObjectAttributes(&ObjectAttributes, NULL, 0, NULL, NULL);
-
- /* Open client process */
- Status = NtOpenProcess(&hProcess,
- PROCESS_VM_READ | PROCESS_QUERY_INFORMATION,
- &ObjectAttributes,
- &Message->h.ClientId);
-
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtOpenProcess failed with code: %lx\n", Status);
- return;
- }
-
- /* Capture all string parameters from the process memory */
- Status = CsrpCaptureStringParameters(Parameters, &Size, Message, hProcess);
- if (!NT_SUCCESS(Status))
- {
- NtClose(hProcess);
- return;
- }
-
- /* Format the caption and message box text */
- Status = CsrpFormatMessages(&TextU,
- &CaptionU,
- Parameters,
- Size,
- Message,
- hProcess);
-
- /* Cleanup */
- CsrpFreeStringParameters(Parameters, Message);
- NtClose(hProcess);
-
- if (!NT_SUCCESS(Status))
- {
- return;
- }
-
- /* Display the message box */
- Message->Response = CsrpMessageBox(TextU.Buffer,
- CaptionU.Buffer,
- Message->ValidResponseOptions,
- (ULONG)Message->Status >> 30);
-
- RtlFreeUnicodeString(&TextU);
- RtlFreeUnicodeString(&CaptionU);
-
- return;
-}
-
Removed: branches/ros-csrss/win32ss/user/win32csr/resource.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/resource.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/resource.h (removed)
@@ -1,20 +1,0 @@
-/* $Id: resource.h 51293 2011-04-09 12:01:36Z mkupfer $
- *
- * COPYRIGHT: See COPYING in the top level directory
- * PROJECT: ReactOS Win32 subsystem
- * FILE: subsys/csrss/win32csr/resource.h
- * PURPOSE: Resource #defines
- */
-
-#pragma once
-
-#define IDD_END_NOW 10
-#define IDD_NOT_RESPONDING 11
-#define IDD_SWITCH_APP 12
-
-#define IDC_STATIC -1
-#define IDC_PROGRESS 101
-#define IDC_END_NOW 102
-#define IDC_STATIC_CUR_APP 103
-
-/* EOF */
Removed: branches/ros-csrss/win32ss/user/win32csr/rsrc.rc
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/rsrc.rc [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/rsrc.rc (removed)
@@ -1,29 +1,0 @@
-#include <windows.h>
-#include "resource.h"
-
-LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
-
-#include "lang/bg-BG.rc"
-#include "lang/cs-CZ.rc"
-#include "lang/de-DE.rc"
-#include "lang/el-GR.rc"
-#include "lang/en-US.rc"
-#include "lang/es-ES.rc"
-#include "lang/fr-FR.rc"
-#include "lang/id-ID.rc"
-#include "lang/it-IT.rc"
-#include "lang/ja-JP.rc"
-#include "lang/no-NO.rc"
-#include "lang/sk-SK.rc"
-#include "lang/sv-SE.rc"
-#include "lang/zh-CN.rc"
-#include "lang/zh-TW.rc"
-
-// UTF-8
-#pragma code_page(65001)
-#include "lang/pl-PL.rc"
-#include "lang/pt-BR.rc"
-#include "lang/ro-RO.rc"
-#include "lang/ru-RU.rc"
-#include "lang/uk-UA.rc"
-#include "lang/tr-TR.rc"
Removed: branches/ros-csrss/win32ss/user/win32csr/w32csr.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/w32csr.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/w32csr.h (removed)
@@ -1,28 +1,0 @@
-/* PSDK/NDK Headers */
-#define WIN32_NO_STATUS
-#include <windows.h>
-#define NTOS_MODE_USER
-#include <ndk/ntndk.h>
-#include <psapi.h>
-
-/* External Winlogon Header */
-#include <winlogon.h>
-
-/* Internal CSRSS Headers */
-#include <win/winmsg.h>
-//#include <conio.h>
-//#include <csrplugin.h>
-#include <desktopbg.h>
-
-/* Public Win32K Headers */
-#include <ntuser.h>
-
-#include "resource.h"
-
-VOID
-WINAPI
-Win32CsrHardError(
- IN PCSR_THREAD ThreadData,
- IN PHARDERROR_MSG Message);
-
-/* EOF */
Modified: branches/ros-csrss/win32ss/user/win32csr/win32csr.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/win32csr.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/win32csr.h [iso-8859-1] Wed Oct 24 23:19:54
2012
@@ -8,35 +8,34 @@
#pragma once
+/* PSDK/NDK Headers */
+#define WIN32_NO_STATUS
#include <windows.h>
+#define NTOS_MODE_USER
+#include <ndk/ntndk.h>
+#include <psapi.h>
+
+/* External Winlogon Header */
+#include <winlogon.h>
+
+/* CSRSS Header */
+#include <csr/csrsrv.h>
+
+/* Internal CSRSS Headers */
+#include <win/winmsg.h>
+#include <desktopbg.h>
+
+/* Public Win32K Headers */
+#include <ntuser.h>
+
#include <commctrl.h>
extern HANDLE Win32CsrApiHeap;
extern HINSTANCE Win32CsrDllHandle;
-/*
-typedef VOID (WINAPI *CSR_CLEANUP_OBJECT_PROC)(Object_t *Object);
-
-typedef struct tagCSRSS_OBJECT_DEFINITION
-{
- LONG Type;
- CSR_CLEANUP_OBJECT_PROC CsrCleanupObjectProc;
-} CSRSS_OBJECT_DEFINITION, *PCSRSS_OBJECT_DEFINITION;
-*/
-
-NTSTATUS FASTCALL Win32CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
- PVOID Context);
-
/* desktopbg.c */
CSR_API(CsrCreateDesktop);
CSR_API(CsrShowDesktop);
CSR_API(CsrHideDesktop);
-// CSR_API(CsrRegisterSystemClasses);
-
-/* exitros.c */
-/// Must go to winsrv.dll
-CSR_API(CsrExitReactos);
-CSR_API(CsrSetLogonNotifyWindow);
-CSR_API(CsrRegisterLogonProcess);
/* EOF */
Modified: branches/ros-csrss/win32ss/user/win32csr/win32csr.rc
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/win32csr…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/win32csr.rc [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/win32csr/win32csr.rc [iso-8859-1] Wed Oct 24 23:19:54
2012
@@ -1,10 +1,5 @@
-#include <win32csr.h>
-#include "resource.h"
-
#define REACTOS_VERSION_DLL
#define REACTOS_STR_FILE_DESCRIPTION "CSRSS subsystem usermode code\0"
#define REACTOS_STR_INTERNAL_NAME "win32csr\0"
#define REACTOS_STR_ORIGINAL_FILENAME "win32csr.dll\0"
#include <reactos/version.rc>
-
-#include "rsrc.rc"
Copied: branches/ros-csrss/win32ss/user/winsrv/exitros.c (from r57605,
branches/ros-csrss/win32ss/user/win32csr/exitros.c)
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/e…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/exitros.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/winsrv/exitros.c [iso-8859-1] Wed Oct 24 23:19:54
2012
@@ -1,16 +1,10 @@
-/* $Id: exitros.c 57570 2012-10-17 23:10:40Z hbelusca $
- *
+/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS CSRSS subsystem
- * FILE: subsys/csrss/win32csr/exitros.c
+ * FILE: win32ss/user/winsrv/exitros.c
* PURPOSE: Logout/shutdown
*/
-
-/***
- *** Move it into winsrv
- ***/
-
/* INCLUDES ******************************************************************/
#include "w32csr.h"
@@ -19,8 +13,20 @@
#define NDEBUG
#include <debug.h>
+
+
static HWND LogonNotifyWindow = NULL;
static HANDLE LogonProcess = NULL;
+
+
+/* FUNCTIONS *****************************************************************/
+
+NTSTATUS FASTCALL
+Win32CsrEnumProcesses(CSRSS_ENUM_PROCESS_PROC EnumProc,
+ PVOID Context)
+{
+ return CsrEnumProcesses(EnumProc, Context);
+}
CSR_API(CsrRegisterLogonProcess)
{
Copied: branches/ros-csrss/win32ss/user/winsrv/harderror.c (from r57605,
branches/ros-csrss/win32ss/user/win32csr/harderror.c)
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/h…
==============================================================================
--- branches/ros-csrss/win32ss/user/win32csr/harderror.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/winsrv/harderror.c [iso-8859-1] Wed Oct 24 23:19:54
2012
@@ -1,7 +1,7 @@
/*
* COPYRIGHT: See COPYING in the top level directory
* PROJECT: ReactOS system libraries
- * FILE: subsys/csrss/win32csr/dllmain.c
+ * FILE: win32ss/user/winsrv/dllmain.c
* PURPOSE: Initialization
* PROGRAMMERS: Dmitry Philippov (shedon(a)mail.ru)
* Timo Kreuzer (timo.kreuzer(a)reactos.org)
Modified: branches/ros-csrss/win32ss/user/winsrv/init.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/i…
==============================================================================
--- branches/ros-csrss/win32ss/user/winsrv/init.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/winsrv/init.c [iso-8859-1] Wed Oct 24 23:19:54 2012
@@ -1,5 +1,4 @@
-/* $Id$
- *
+/*
* init.c - ReactOS/Win32 Console+User Enviroment Subsystem Server - Initialization
*
* ReactOS Operating System
@@ -22,109 +21,408 @@
*
* --------------------------------------------------------------------
*/
+
#include "winsrv.h"
-//#define NDEBUG
+#define NDEBUG
#include <debug.h>
-HANDLE WinSrvApiPort = NULL;
+HANDLE DllHandle = NULL;
+// HANDLE WinSrvApiPort = NULL;
+
+/* Memory */
+HANDLE UserSrvHeap = NULL; // Our own heap.
+// HANDLE BaseSrvSharedHeap = NULL; // Shared heap with CSR.
(CsrSrvSharedSectionHeap)
+// PBASE_STATIC_SERVER_DATA BaseStaticServerData = NULL; // Data that we can share
amongst processes. Initialized inside BaseSrvSharedHeap.
+
+
+PCSR_API_ROUTINE UserServerApiDispatchTable[UserpMaxApiNumber] =
+{
+ SrvExitWindowsEx,
+ SrvEndTask,
+ SrvLogon,
+ SrvRegisterServicesProcess, // Not present in Win7
+ SrvActivateDebugger,
+ SrvGetThreadConsoleDesktop, // Not present in Win7
+ SrvDeviceEvent,
+ SrvRegisterLogonProcess, // Not present in Win7
+ SrvCreateSystemThreads,
+ SrvRecordShutdownReason,
+ SrvCancelShutdown, // Added in Vista
+ SrvConsoleHandleOperation, // Added in Win7
+ SrvGetSetShutdownBlockReason, // Added in Vista
+};
+
+BOOLEAN UserServerApiServerValidTable[UserpMaxApiNumber] =
+{
+
+ // FALSE
+};
+
+PCHAR UserServerApiNameTable[UserpMaxApiNumber] =
+{
+ "SrvExitWindowsEx",
+ "SrvEndTask",
+ "SrvLogon",
+ "SrvRegisterServicesProcess",
+ "SrvActivateDebugger",
+ "SrvGetThreadConsoleDesktop",
+ "SrvDeviceEvent",
+ "SrvRegisterLogonProcess",
+ "SrvCreateSystemThreads",
+ "SrvRecordShutdownReason",
+ "SrvCancelShutdown",
+ "SrvConsoleHandleOperation",
+ "SrvGetSetShutdownBlockReason",
+
+ // NULL
+};
+
+/*
+PCSR_API_ROUTINE Win32CsrApiDefinitions[] =
+{
+ CsrGetHandle,
+ CsrGetHandle,
+ CsrCloseHandle,
+ CsrVerifyHandle,
+ CsrDuplicateHandle,
+ CsrGetInputWaitHandle,
+ CsrFillOutputChar,
+ CsrReadInputEvent,
+ CsrWriteConsoleOutputChar,
+ CsrWriteConsoleOutputAttrib,
+ CsrFillOutputAttrib,
+ CsrSetTextAttrib,
+ CsrWriteConsoleOutput,
+ CsrFlushInputBuffer,
+ CsrReadConsoleOutputChar,
+ CsrReadConsoleOutputAttrib,
+ CsrExitReactos,
+ CsrHardwareStateProperty,
+ CsrCreateDesktop,
+ CsrShowDesktop,
+ CsrHideDesktop,
+ CsrSetLogonNotifyWindow,
+ CsrRegisterLogonProcess,
+ CsrGenerateCtrlEvent,
+};
+
+static CSRSS_API_DEFINITION Win32CsrApiDefinitions[] =
+{
+ CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetHandle),
+ CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetHandle),
+ 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),
+ 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),
+ 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),
+ CSRSS_DEFINE_API(GENERATE_CTRL_EVENT, CsrGenerateCtrlEvent),
+ CSRSS_DEFINE_API(SET_SCREEN_BUFFER_SIZE, CsrSetScreenBufferSize),
+ CSRSS_DEFINE_API(GET_CONSOLE_SELECTION_INFO, CsrGetConsoleSelectionInfo),
+ 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),
+ { 0, 0, NULL }
+};
+*/
+
+
+/* FUNCTIONS ******************************************************************/
+
+/*
+VOID WINAPI UserStaticServerThread(PVOID x)
+{
+ // NTSTATUS Status = STATUS_SUCCESS;
+ PPORT_MESSAGE Request = (PPORT_MESSAGE)x;
+ PPORT_MESSAGE Reply = NULL;
+ ULONG MessageType = 0;
+
+ DPRINT("WINSRV: %s(%08lx) called\n", __FUNCTION__, x);
+
+ MessageType = Request->u2.s2.Type;
+ DPRINT("WINSRV: %s(%08lx) received a message (Type=%d)\n",
+ __FUNCTION__, x, MessageType);
+ switch (MessageType)
+ {
+ default:
+ Reply = Request;
+ /\* Status = *\/ NtReplyPort(WinSrvApiPort, Reply);
+ break;
+ }
+}
+*/
+
+ULONG
+InitializeVideoAddressSpace(VOID)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING PhysMemName =
RTL_CONSTANT_STRING(L"\\Device\\PhysicalMemory");
+ NTSTATUS Status;
+ HANDLE PhysMemHandle;
+ PVOID BaseAddress;
+ LARGE_INTEGER Offset;
+ SIZE_T ViewSize;
+ CHAR IVTAndBda[1024+256];
+
+ /* Free the 1MB pre-reserved region. In reality, ReactOS should simply support us
mapping the view into the reserved area, but it doesn't. */
+ BaseAddress = 0;
+ ViewSize = 1024 * 1024;
+ Status = ZwFreeVirtualMemory(NtCurrentProcess(),
+ &BaseAddress,
+ &ViewSize,
+ MEM_RELEASE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Couldn't unmap reserved memory (%x)\n", Status);
+ return 0;
+ }
+
+ /* Open the physical memory section */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &PhysMemName,
+ 0,
+ NULL,
+ NULL);
+ Status = ZwOpenSection(&PhysMemHandle,
+ SECTION_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Couldn't open \\Device\\PhysicalMemory\n");
+ return 0;
+ }
+
+ /* Map the BIOS and device registers into the address space */
+ Offset.QuadPart = 0xa0000;
+ ViewSize = 0x100000 - 0xa0000;
+ BaseAddress = (PVOID)0xa0000;
+ Status = ZwMapViewOfSection(PhysMemHandle,
+ NtCurrentProcess(),
+ &BaseAddress,
+ 0,
+ ViewSize,
+ &Offset,
+ &ViewSize,
+ ViewUnmap,
+ 0,
+ PAGE_EXECUTE_READWRITE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Couldn't map physical memory (%x)\n", Status);
+ ZwClose(PhysMemHandle);
+ return 0;
+ }
+
+ /* Close physical memory section handle */
+ ZwClose(PhysMemHandle);
+
+ if (BaseAddress != (PVOID)0xa0000)
+ {
+ DPRINT1("Couldn't map physical memory at the right address (was
%x)\n",
+ BaseAddress);
+ return 0;
+ }
+
+ /* Allocate some low memory to use for the non-BIOS
+ * parts of the v86 mode address space
+ */
+ BaseAddress = (PVOID)0x1;
+ ViewSize = 0xa0000 - 0x1000;
+ Status = ZwAllocateVirtualMemory(NtCurrentProcess(),
+ &BaseAddress,
+ 0,
+ &ViewSize,
+ MEM_RESERVE | MEM_COMMIT,
+ PAGE_EXECUTE_READWRITE);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("Failed to allocate virtual memory (Status %x)\n", Status);
+ return 0;
+ }
+ if (BaseAddress != (PVOID)0x0)
+ {
+ DPRINT1("Failed to allocate virtual memory at right address (was
%x)\n",
+ BaseAddress);
+ return 0;
+ }
+
+ /* Get the real mode IVT and BDA from the kernel */
+ Status = NtVdmControl(VdmInitialize, IVTAndBda);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtVdmControl failed (status %x)\n", Status);
+ return 0;
+ }
+
+ /* Return success */
+ return 1;
+}
/**********************************************************************
- * NAME PRIVATE
- * ConStaticServerThread/1
+ * CsrpInitVideo/3
+ *
+ * TODO: we need a virtual device for sessions other than
+ * TODO: the console one
*/
-VOID WINAPI ConStaticServerThread (PVOID x)
-{
- NTSTATUS Status = STATUS_SUCCESS;
- PPORT_MESSAGE Request = (PPORT_MESSAGE) x;
- PPORT_MESSAGE Reply = NULL;
- ULONG MessageType = 0;
-
- DPRINT("WINSRV: %s(%08lx) called\n", __FUNCTION__, x);
-
- MessageType = Request->u2.s2.Type;
- DPRINT("WINSRV: %s(%08lx) received a message (Type=%d)\n",
- __FUNCTION__, x, MessageType);
- switch (MessageType)
- {
- default:
- Reply = Request;
- Status = NtReplyPort (WinSrvApiPort, Reply);
- break;
- }
-}
-
-/**********************************************************************
- * NAME PRIVATE
- * UserStaticServerThread/1
- */
-VOID WINAPI UserStaticServerThread (PVOID x)
-{
- NTSTATUS Status = STATUS_SUCCESS;
- PPORT_MESSAGE Request = (PPORT_MESSAGE) x;
- PPORT_MESSAGE Reply = NULL;
- ULONG MessageType = 0;
-
- DPRINT("WINSRV: %s(%08lx) called\n", __FUNCTION__, x);
-
- MessageType = Request->u2.s2.Type;
- DPRINT("WINSRV: %s(%08lx) received a message (Type=%d)\n",
- __FUNCTION__, x, MessageType);
- switch (MessageType)
- {
- default:
- Reply = Request;
- Status = NtReplyPort (WinSrvApiPort, Reply);
- break;
- }
-}
-
-/*=====================================================================
- * PUBLIC API
- *===================================================================*/
-
-NTSTATUS WINAPI ConServerDllInitialization (ULONG ArgumentCount,
- LPWSTR *Argument)
-{
- NTSTATUS Status = STATUS_SUCCESS;
-
- DPRINT("WINSRV: %s called\n", __FUNCTION__);
-
- // Get the listening port from csrsrv.dll
- WinSrvApiPort = CsrQueryApiPort ();
- if (NULL == WinSrvApiPort)
- {
- return STATUS_UNSUCCESSFUL;
- }
- // Register our message dispatcher
- Status = CsrAddStaticServerThread (ConStaticServerThread);
- if (NT_SUCCESS(Status))
- {
- //TODO: perform the real console server internal initialization here
- }
- return Status;
-}
-
-NTSTATUS WINAPI UserServerDllInitialization (ULONG ArgumentCount,
- LPWSTR *Argument)
-{
- NTSTATUS Status = STATUS_SUCCESS;
-
- DPRINT("WINSRV: %s called\n", __FUNCTION__);
-
- // Get the listening port from csrsrv.dll
- WinSrvApiPort = CsrQueryApiPort ();
- if (NULL == WinSrvApiPort)
- {
- return STATUS_UNSUCCESSFUL;
- }
- // Register our message dispatcher
- Status = CsrAddStaticServerThread (UserStaticServerThread);
- if (NT_SUCCESS(Status))
- {
- //TODO: perform the real user server internal initialization here
- }
- return Status;
+NTSTATUS
+CsrpInitVideo (VOID)
+{
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING DeviceName = RTL_CONSTANT_STRING(L"\\??\\DISPLAY1");
+ IO_STATUS_BLOCK Iosb;
+ HANDLE VideoHandle = (HANDLE) 0;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ InitializeVideoAddressSpace();
+
+ InitializeObjectAttributes(&ObjectAttributes,
+ &DeviceName,
+ 0,
+ NULL,
+ NULL);
+ Status = NtOpenFile(&VideoHandle,
+ FILE_ALL_ACCESS,
+ &ObjectAttributes,
+ &Iosb,
+ 0,
+ 0);
+ if (NT_SUCCESS(Status))
+ {
+ NtClose(VideoHandle);
+ }
+
+ return Status;
+}
+
+VOID
+WINAPI
+PrivateCsrssManualGuiCheck(LONG Check)
+{
+ NtUserCallOneParam(Check, ONEPARAM_ROUTINE_CSRSS_GUICHECK);
+}
+
+CSR_SERVER_DLL_INIT(UserServerDllInitialization)
+{
+/*
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ DPRINT("WINSRV: %s called\n", __FUNCTION__);
+
+ // Get the listening port from csrsrv.dll
+ WinSrvApiPort = CsrQueryApiPort ();
+ if (NULL == WinSrvApiPort)
+ {
+ return STATUS_UNSUCCESSFUL;
+ }
+ // Register our message dispatcher
+ Status = CsrAddStaticServerThread (UserStaticServerThread);
+ if (NT_SUCCESS(Status))
+ {
+ //TODO: perform the real user server internal initialization here
+ }
+ return Status;
+*/
+
+ /* Initialize memory */
+ UserSrvHeap = RtlGetProcessHeap(); // Initialize our own heap.
+ // BaseSrvSharedHeap = LoadedServerDll->SharedSection; // Get the CSR shared
heap.
+ // LoadedServerDll->SharedSection = BaseStaticServerData;
+
+ CsrpInitVideo();
+ NtUserInitialize(0, NULL, NULL);
+ PrivateCsrssManualGuiCheck(0);
+
+ /* Setup the DLL Object */
+ LoadedServerDll->ApiBase = USERSRV_FIRST_API_NUMBER;
+ LoadedServerDll->HighestApiSupported = UserpMaxApiNumber;
+ LoadedServerDll->DispatchTable = UserServerApiDispatchTable;
+ LoadedServerDll->ValidTable = UserServerApiServerValidTable;
+ LoadedServerDll->NameTable = UserServerApiNameTable;
+ LoadedServerDll->SizeOfProcessData = 0;
+ LoadedServerDll->ConnectCallback = NULL;
+ // LoadedServerDll->DisconnectCallback = Win32CsrReleaseConsole;
+ // LoadedServerDll->NewProcessCallback = Win32CsrDuplicateHandleTable;
+ LoadedServerDll->HardErrorCallback = Win32CsrHardError;
+
+ /* All done */
+ return STATUS_SUCCESS;
+}
+
+// PUSER_SOUND_SENTRY. Used in basesrv.dll
+BOOL WINAPI _UserSoundSentry(VOID)
+{
+ // Do something.
+ return TRUE;
+}
+
+BOOL
+WINAPI
+DllMain(IN HANDLE hDll,
+ IN DWORD dwReason,
+ IN LPVOID lpReserved)
+{
+ UNREFERENCED_PARAMETER(dwReason);
+ UNREFERENCED_PARAMETER(lpReserved);
+
+ if (DLL_PROCESS_ATTACH == dwReason)
+ {
+ DllHandle = hDll;
+ }
+
+ return TRUE;
}
/* EOF */
Propchange: branches/ros-csrss/win32ss/user/winsrv/init.c
------------------------------------------------------------------------------
--- svn:keywords (original)
+++ svn:keywords (removed)
@@ -1,1 +1,0 @@
-author date id revision
Modified: branches/ros-csrss/win32ss/user/winsrv/rsrc.rc
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/r…
==============================================================================
--- branches/ros-csrss/win32ss/user/winsrv/rsrc.rc [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/winsrv/rsrc.rc [iso-8859-1] Wed Oct 24 23:19:54 2012
@@ -2,8 +2,6 @@
#include "resource.h"
LANGUAGE LANG_NEUTRAL, SUBLANG_NEUTRAL
-
-1 ICON DISCARDABLE res/terminal.ico
#include "lang/bg-BG.rc"
#include "lang/cs-CZ.rc"
Modified: branches/ros-csrss/win32ss/user/winsrv/server.c
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/s…
==============================================================================
--- branches/ros-csrss/win32ss/user/winsrv/server.c [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/winsrv/server.c [iso-8859-1] Wed Oct 24 23:19:54 2012
@@ -28,7 +28,7 @@
#include "winsrv.h"
-//#define NDEBUG
+#define NDEBUG
#include <debug.h>
Modified: branches/ros-csrss/win32ss/user/winsrv/winsrv.h
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/w…
==============================================================================
--- branches/ros-csrss/win32ss/user/winsrv/winsrv.h [iso-8859-1] (original)
+++ branches/ros-csrss/win32ss/user/winsrv/winsrv.h [iso-8859-1] Wed Oct 24 23:19:54 2012
@@ -11,7 +11,33 @@
#include <win/base.h>
#include <win/windows.h>
-
+VOID
+WINAPI
+Win32CsrHardError(IN PCSR_THREAD ThreadData,
+ IN PHARDERROR_MSG Message);
+
CSR_API(SrvRegisterServicesProcess);
+
+
+/*****************************
+
+/\*
+typedef VOID (WINAPI *CSR_CLEANUP_OBJECT_PROC)(Object_t *Object);
+
+typedef struct tagCSRSS_OBJECT_DEFINITION
+{
+ LONG Type;
+ CSR_CLEANUP_OBJECT_PROC CsrCleanupObjectProc;
+} CSRSS_OBJECT_DEFINITION, *PCSRSS_OBJECT_DEFINITION;
+*\/
+
+/\* exitros.c *\/
+CSR_API(CsrExitReactos);
+CSR_API(CsrSetLogonNotifyWindow);
+CSR_API(CsrRegisterLogonProcess);
+// CSR_API(CsrRegisterSystemClasses);
+
+*****************************/
+
/* EOF */
Added: branches/ros-csrss/win32ss/user/winsrv/winsrv.spec
URL:
http://svn.reactos.org/svn/reactos/branches/ros-csrss/win32ss/user/winsrv/w…
==============================================================================
--- branches/ros-csrss/win32ss/user/winsrv/winsrv.spec (added)
+++ branches/ros-csrss/win32ss/user/winsrv/winsrv.spec [iso-8859-1] Wed Oct 24 23:19:54
2012
@@ -1,0 +1,2 @@
+@ stdcall UserServerDllInitialization(ptr)
+@ stdcall _UserSoundSentry()
Propchange: branches/ros-csrss/win32ss/user/winsrv/winsrv.spec
------------------------------------------------------------------------------
svn:eol-style = native