Author: sir_richard
Date: Wed Mar 10 05:59:39 2010
New Revision: 46051
URL:
http://svn.reactos.org/svn/reactos?rev=46051&view=rev
Log:
[CSRSS]: Split off CSRSS into a more Windows-friendly model. CSRSS.EXE is simply a stub
which loads CSRSRV.DLL, where all the actual code is present.
[CSRSRV]: Mostly moved all the current CSRSS code into CSRSRV, with some very minor
changes to get it workking.
[CSRSRV]: Add some more code from Alex's CSRSRV, such as thread
dereferencing/deallocation, hacked to work.
[CSRSRV]: Make CsrTerminateProcess destroy each CSR thread in that process, otherwise we
were always leaking a handle, so processes never died. Because of this, primary tokens
would remain "in use", and when umpnpmgr attempted to do a "Create Process
as User" for the second+ time, the call would fail since the token from the first
process was still around. This fixed that regression from the mailing list.
Added:
trunk/reactos/subsystems/win32/csrss/csrsrv/
trunk/reactos/subsystems/win32/csrss/csrsrv/api/
- copied from r46022, trunk/reactos/subsystems/win32/csrss/api/
trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c
- copied, changed from r46050, trunk/reactos/subsystems/win32/csrss/api/process.c
trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c
- copied, changed from r46050, trunk/reactos/subsystems/win32/csrss/api/wapi.c
trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild (with props)
trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc (with props)
trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.spec (with props)
trunk/reactos/subsystems/win32/csrss/csrsrv/init.c (with props)
trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h (with props)
Removed:
trunk/reactos/subsystems/win32/csrss/api/
trunk/reactos/subsystems/win32/csrss/csrss.h
trunk/reactos/subsystems/win32/csrss/init.c
trunk/reactos/subsystems/win32/csrss/print.c
trunk/reactos/subsystems/win32/csrss/video.c
Modified:
trunk/reactos/boot/bootdata/packages/reactos.dff
trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c
trunk/reactos/subsystems/win32/csrss/csrsrv/api/user.c
trunk/reactos/subsystems/win32/csrss/csrss.c
trunk/reactos/subsystems/win32/csrss/csrss.rbuild
trunk/reactos/subsystems/win32/csrss/include/api.h
Modified: trunk/reactos/boot/bootdata/packages/reactos.dff
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/boot/bootdata/packages/rea…
==============================================================================
--- trunk/reactos/boot/bootdata/packages/reactos.dff [iso-8859-1] (original)
+++ trunk/reactos/boot/bootdata/packages/reactos.dff [iso-8859-1] Wed Mar 10 05:59:39
2010
@@ -670,6 +670,7 @@
; Subsystems
subsystems\win32\csrss\csrss.exe 1
subsystems\win32\csrss\win32csr\win32csr.dll 1
+subsystems\win32\csrss\csrsrv\csrsrv.dll 1
subsystems\ntvdm\ntvdm.exe 1
subsystems\win32\win32k\win32k.sys 1
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/handle.c [iso-8859-1] Wed Mar 10
05:59:39 2010
@@ -9,7 +9,7 @@
/* INCLUDES ******************************************************************/
-#include <csrss.h>
+#include <srv.h>
#define NDEBUG
#include <debug.h>
Copied: trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c (from r46050,
trunk/reactos/subsystems/win32/csrss/api/process.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/api/process.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/process.c [iso-8859-1] Wed Mar 10
05:59:39 2010
@@ -8,7 +8,7 @@
/* INCLUDES ******************************************************************/
-#include <csrss.h>
+#include <srv.h>
#define NDEBUG
#include <debug.h>
@@ -152,6 +152,65 @@
#define CsrAcquireProcessLock() LOCK
#define CsrReleaseProcessLock() UNLOCK
+
+VOID
+NTAPI
+CsrDeallocateThread(IN PCSR_THREAD CsrThread)
+{
+ /* Free the process object from the heap */
+ RtlFreeHeap(CsrHeap, 0, CsrThread);
+}
+
+VOID
+NTAPI
+CsrRemoveThread(IN PCSR_THREAD CsrThread)
+{
+ /* Remove it from the List */
+ RemoveEntryList(&CsrThread->Link);
+
+ /* Decreate the thread count of the process */
+ CsrThread->Process->ThreadCount--;
+
+ /* Remove it from the Hash List as well */
+ if (CsrThread->HashLinks.Flink) RemoveEntryList(&CsrThread->HashLinks);
+
+ /* Check if this is the last Thread */
+ if (!CsrThread->Process->ThreadCount)
+ {
+ /* Check if it's not already been marked for deletion */
+ if (!(CsrThread->Process->Flags & CsrProcessLastThreadTerminated))
+ {
+ /* Let everyone know this process is about to lose the thread */
+ //CsrThread->Process->Flags |= CsrProcessLastThreadTerminated;
+
+ /* Reference the Process */
+ //CsrLockedDereferenceProcess(CsrThread->Process);
+ }
+ }
+
+ /* Mark the thread for deletion */
+ CsrThread->Flags |= CsrThreadInTermination;
+}
+
+VOID
+NTAPI
+CsrThreadRefcountZero(IN PCSR_THREAD CsrThread)
+{
+ /* Remove this thread */
+ CsrRemoveThread(CsrThread);
+
+ /* Release the Process Lock */
+ //CsrReleaseProcessLock();
+
+ /* Close the NT Thread Handle */
+ if (CsrThread->ThreadHandle) NtClose(CsrThread->ThreadHandle);
+
+ /* De-allocate the CSR Thread Object */
+ CsrDeallocateThread(CsrThread);
+
+ /* Remove a reference from the process */
+ //CsrDereferenceProcess(CsrProcess);
+}
NTSTATUS
NTAPI
@@ -933,8 +992,21 @@
CSR_API(CsrTerminateProcess)
{
+ PLIST_ENTRY NextEntry;
+ PCSR_THREAD Thread;
Request->Header.u1.s1.TotalLength = sizeof(CSR_API_MESSAGE);
Request->Header.u1.s1.DataLength = sizeof(CSR_API_MESSAGE) - sizeof(PORT_MESSAGE);
+
+ NextEntry = ProcessData->ThreadList.Flink;
+ while (NextEntry != &ProcessData->ThreadList)
+ {
+ Thread = CONTAINING_RECORD(NextEntry, CSR_THREAD, Link);
+ NextEntry = NextEntry->Flink;
+
+ CsrThreadRefcountZero(Thread);
+
+ }
+
ProcessData->Terminated = TRUE;
return STATUS_SUCCESS;
Modified: trunk/reactos/subsystems/win32/csrss/csrsrv/api/user.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/api/user.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/user.c [iso-8859-1] Wed Mar 10
05:59:39 2010
@@ -11,7 +11,7 @@
/* INCLUDES ******************************************************************/
-#include <csrss.h>
+#include <srv.h>
#define NDEBUG
#include <debug.h>
Copied: trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c (from r46050,
trunk/reactos/subsystems/win32/csrss/api/wapi.c)
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/api/wapi.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/api/wapi.c [iso-8859-1] Wed Mar 10
05:59:39 2010
@@ -10,7 +10,7 @@
/* INCLUDES ******************************************************************/
-#include <csrss.h>
+#include <srv.h>
#define NDEBUG
Added: trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild (added)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild [iso-8859-1] Wed Mar 10
05:59:39 2010
@@ -1,0 +1,20 @@
+<?xml version="1.0"?>
+<!DOCTYPE module SYSTEM "../../../tools/rbuild/project.dtd">
+<module name="csrsrv" type="nativedll"
installbase="system32" installname="csrsrv.dll">
+ <importlibrary definition="csrsrv.spec" />
+ <include base="csrsrv">.</include>
+ <include base="csrss">.</include>
+ <include base="csrss">include</include>
+ <include base="ReactOS">include/reactos/subsys</include>
+ <library>ntdll</library>
+ <library>pseh</library>
+ <library>smdll</library>
+ <directory name="api">
+ <file>handle.c</file>
+ <file>process.c</file>
+ <file>user.c</file>
+ <file>wapi.c</file>
+ </directory>
+ <file>init.c</file>
+ <pch>srv.h</pch>
+</module>
Propchange: trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc (added)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc [iso-8859-1] Wed Mar 10 05:59:39
2010
@@ -1,0 +1,5 @@
+#define REACTOS_VERSION_DLL
+#define REACTOS_STR_FILE_DESCRIPTION "ReactOS CSR Core Server\0"
+#define REACTOS_STR_INTERNAL_NAME "csrsrv\0"
+#define REACTOS_STR_ORIGINAL_FILENAME "csrsrv.dll\0"
+#include <reactos/version.rc>
Propchange: trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.spec
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.spec (added)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.spec [iso-8859-1] Wed Mar 10
05:59:39 2010
@@ -1,0 +1,35 @@
+;@ stdcall CsrAddStaticServerThread(ptr ptr long)
+;@ stdcall CsrCallServerFromServer(ptr ptr)
+;@ stdcall CsrConnectToUser()
+;@ stdcall CsrCreateProcess(ptr ptr ptr ptr long ptr)
+;@ stdcall CsrCreateRemoteThread(ptr ptr)
+;@ stdcall CsrCreateThread(ptr ptr ptr)
+;@ stdcall CsrCreateWait(ptr ptr ptr ptr ptr ptr)
+;@ stdcall CsrDebugProcess(ptr)
+;@ stdcall CsrDebugProcessStop(ptr)
+;@ stdcall CsrDereferenceProcess(ptr)
+;@ stdcall CsrDereferenceThread(ptr)
+;@ stdcall CsrDereferenceWait(ptr)
+;@ stdcall CsrDestroyProcess(ptr long)
+;@ stdcall CsrDestroyThread(ptr)
+;@ stdcall CsrExecServerThread(ptr long)
+;@ stdcall CsrGetProcessLuid(ptr ptr)
+;@ stdcall CsrImpersonateClient(ptr)
+;@ stdcall CsrLockProcessByClientId(ptr ptr)
+;@ stdcall CsrLockThreadByClientId(ptr ptr)
+;@ stdcall CsrMoveSatisfiedWait(ptr ptr)
+;@ stdcall CsrNotifyWait(ptr long ptr ptr)
+;@ stdcall CsrPopulateDosDevices()
+;@ stdcall CsrQueryApiPort()
+;@ stdcall CsrReferenceThread(ptr)
+;@ stdcall CsrRevertToSelf()
+@ stdcall CsrServerInitialization(long ptr)
+;@ stdcall CsrSetBackgroundPriority(ptr)
+;@ stdcall CsrSetCallingSpooler(long)
+;@ stdcall CsrSetForegroundPriority(ptr)
+;@ stdcall CsrShutdownProcesses(ptr long)
+;@ stdcall CsrUnhandledExceptionFilter(ptr)
+;@ stdcall CsrUnlockProcess(ptr)
+;@ stdcall CsrUnlockThread(ptr)
+;@ stdcall CsrValidateMessageBuffer(ptr ptr long long)
+;@ stdcall CsrValidateMessageString(ptr ptr)
Propchange: trunk/reactos/subsystems/win32/csrss/csrsrv/csrsrv.spec
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/init.c (added)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/init.c [iso-8859-1] Wed Mar 10 05:59:39
2010
@@ -1,0 +1,809 @@
+/*
+ * COPYRIGHT: See COPYING in the top level directory
+ * PROJECT: ReactOS CSR Sub System
+ * FILE: subsys/csr/csrsrv/init.c
+ * PURPOSE: CSR Server DLL Initialization
+ * PROGRAMMERS: ReactOS Portable Systems Group
+ */
+
+/* INCLUDES *******************************************************************/
+
+#include "srv.h"
+#define NDEBUG
+#include <debug.h>
+
+/* DATA ***********************************************************************/
+
+HANDLE CsrHeap = (HANDLE) 0;
+HANDLE CsrObjectDirectory = (HANDLE) 0;
+UNICODE_STRING CsrDirectoryName;
+extern HANDLE CsrssApiHeap;
+static unsigned InitCompleteProcCount;
+static CSRPLUGIN_INIT_COMPLETE_PROC *InitCompleteProcs = NULL;
+static unsigned HardErrorProcCount;
+static CSRPLUGIN_HARDERROR_PROC *HardErrorProcs = NULL;
+HANDLE hSbApiPort = (HANDLE) 0;
+HANDLE hBootstrapOk = (HANDLE) 0;
+HANDLE hSmApiPort = (HANDLE) 0;
+HANDLE hApiPort = (HANDLE) 0;
+
+/* PRIVATE FUNCTIONS **********************************************************/
+
+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];
+
+ /* 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_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;
+}
+
+
+static NTSTATUS FASTCALL
+CsrpAddInitCompleteProc(CSRPLUGIN_INIT_COMPLETE_PROC Proc)
+{
+ CSRPLUGIN_INIT_COMPLETE_PROC *NewProcs;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ NewProcs = RtlAllocateHeap(CsrssApiHeap, 0,
+ (InitCompleteProcCount + 1)
+ * sizeof(CSRPLUGIN_INIT_COMPLETE_PROC));
+ if (NULL == NewProcs)
+ {
+ return STATUS_NO_MEMORY;
+ }
+ if (0 != InitCompleteProcCount)
+ {
+ RtlCopyMemory(NewProcs, InitCompleteProcs,
+ InitCompleteProcCount * sizeof(CSRPLUGIN_INIT_COMPLETE_PROC));
+ RtlFreeHeap(CsrssApiHeap, 0, InitCompleteProcs);
+ }
+ NewProcs[InitCompleteProcCount] = Proc;
+ InitCompleteProcs = NewProcs;
+ InitCompleteProcCount++;
+
+ return STATUS_SUCCESS;
+}
+
+static NTSTATUS FASTCALL
+CsrpAddHardErrorProc(CSRPLUGIN_HARDERROR_PROC Proc)
+{
+ CSRPLUGIN_HARDERROR_PROC *NewProcs;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ NewProcs = RtlAllocateHeap(CsrssApiHeap, 0,
+ (HardErrorProcCount + 1)
+ * sizeof(CSRPLUGIN_HARDERROR_PROC));
+ if (NULL == NewProcs)
+ {
+ return STATUS_NO_MEMORY;
+ }
+ if (0 != HardErrorProcCount)
+ {
+ RtlCopyMemory(NewProcs, HardErrorProcs,
+ HardErrorProcCount * sizeof(CSRPLUGIN_HARDERROR_PROC));
+ RtlFreeHeap(CsrssApiHeap, 0, HardErrorProcs);
+ }
+
+ NewProcs[HardErrorProcCount] = Proc;
+ HardErrorProcs = NewProcs;
+ HardErrorProcCount++;
+
+ return STATUS_SUCCESS;
+}
+
+/**********************************************************************
+ * CallInitComplete/0
+ */
+static BOOL FASTCALL
+CallInitComplete(void)
+{
+ BOOL Ok;
+ unsigned i;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ Ok = TRUE;
+ if (0 != InitCompleteProcCount)
+ {
+ for (i = 0; i < InitCompleteProcCount && Ok; i++)
+ {
+ Ok = (*(InitCompleteProcs[i]))();
+ }
+ RtlFreeHeap(CsrssApiHeap, 0, InitCompleteProcs);
+ }
+
+ return Ok;
+}
+
+BOOL
+CallHardError(IN PCSRSS_PROCESS_DATA ProcessData,
+ IN PHARDERROR_MSG HardErrorMessage)
+{
+ BOOL Ok;
+ unsigned i;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ Ok = TRUE;
+ if (0 != HardErrorProcCount)
+ {
+ for (i = 0; i < HardErrorProcCount && Ok; i++)
+ {
+ Ok = (*(HardErrorProcs[i]))(ProcessData, HardErrorMessage);
+ }
+ }
+
+ return Ok;
+}
+
+ULONG
+InitializeVideoAddressSpace(VOID);
+
+/**********************************************************************
+ * CsrpCreateObjectDirectory/3
+ */
+static NTSTATUS
+CsrpCreateObjectDirectory (int argc, char ** argv, char ** envp)
+{
+ NTSTATUS Status;
+ OBJECT_ATTRIBUTES Attributes;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+
+ /* create object directory ('\Windows') */
+ RtlCreateUnicodeString (&CsrDirectoryName,
+ L"\\Windows");
+
+ InitializeObjectAttributes (&Attributes,
+ &CsrDirectoryName,
+ OBJ_OPENIF,
+ NULL,
+ NULL);
+
+ Status = NtOpenDirectoryObject(&CsrObjectDirectory,
+ DIRECTORY_ALL_ACCESS,
+ &Attributes);
+ return Status;
+}
+
+/**********************************************************************
+ * CsrpInitVideo/3
+ *
+ * TODO: we need a virtual device for sessions other than
+ * TODO: the console one
+ */
+static NTSTATUS
+CsrpInitVideo (int argc, char ** argv, char ** envp)
+{
+ 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;
+}
+
+/**********************************************************************
+ * CsrpInitWin32Csr/3
+ *
+ * TODO: this function should be turned more general to load an
+ * TODO: hosted server DLL as received from the command line;
+ * TODO: for instance: ServerDll=winsrv:ConServerDllInitialization,2
+ * TODO: ^method ^dll ^api ^sid
+ * TODO:
+ * TODO: CsrpHostServerDll (LPWSTR DllName,
+ * TODO: LPWSTR ApiName,
+ * TODO: DWORD ServerId)
+ */
+static NTSTATUS
+CsrpInitWin32Csr (int argc, char ** argv, char ** envp)
+{
+ NTSTATUS Status;
+ UNICODE_STRING DllName;
+ HINSTANCE hInst;
+ ANSI_STRING ProcName;
+ CSRPLUGIN_INITIALIZE_PROC InitProc;
+ CSRSS_EXPORTED_FUNCS Exports;
+ PCSRSS_API_DEFINITION ApiDefinitions;
+ PCSRSS_OBJECT_DEFINITION ObjectDefinitions;
+ CSRPLUGIN_INIT_COMPLETE_PROC InitCompleteProc;
+ CSRPLUGIN_HARDERROR_PROC HardErrorProc;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ RtlInitUnicodeString(&DllName, L"win32csr.dll");
+ Status = LdrLoadDll(NULL, 0, &DllName, (PVOID *) &hInst);
+ if (! NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ RtlInitAnsiString(&ProcName, "Win32CsrInitialization");
+ Status = LdrGetProcedureAddress(hInst, &ProcName, 0, (PVOID *) &InitProc);
+ if (! NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ Exports.CsrInsertObjectProc = CsrInsertObject;
+ Exports.CsrGetObjectProc = CsrGetObject;
+ Exports.CsrReleaseObjectByPointerProc = CsrReleaseObjectByPointer;
+ Exports.CsrReleaseObjectProc = CsrReleaseObject;
+ Exports.CsrEnumProcessesProc = CsrEnumProcesses;
+ if (! (*InitProc)(&ApiDefinitions, &ObjectDefinitions, &InitCompleteProc,
+ &HardErrorProc, &Exports, CsrssApiHeap))
+ {
+ return STATUS_UNSUCCESSFUL;
+ }
+
+ Status = CsrApiRegisterDefinitions(ApiDefinitions);
+ if (! NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ Status = CsrRegisterObjectDefinitions(ObjectDefinitions);
+ if (! NT_SUCCESS(Status))
+ {
+ return Status;
+ }
+ if (NULL != InitCompleteProc)
+ {
+ Status = CsrpAddInitCompleteProc(InitCompleteProc);
+ }
+ if (HardErrorProc) Status = CsrpAddHardErrorProc(HardErrorProc);
+
+ return Status;
+}
+
+CSRSS_API_DEFINITION NativeDefinitions[] =
+ {
+ CSRSS_DEFINE_API(CREATE_PROCESS, CsrCreateProcess),
+ CSRSS_DEFINE_API(CREATE_THREAD, CsrCreateThread),
+ CSRSS_DEFINE_API(TERMINATE_PROCESS, CsrTerminateProcess),
+ CSRSS_DEFINE_API(CONNECT_PROCESS, CsrConnectProcess),
+ CSRSS_DEFINE_API(REGISTER_SERVICES_PROCESS, CsrRegisterServicesProcess),
+ CSRSS_DEFINE_API(GET_SHUTDOWN_PARAMETERS, CsrGetShutdownParameters),
+ CSRSS_DEFINE_API(SET_SHUTDOWN_PARAMETERS, CsrSetShutdownParameters),
+ CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetInputHandle),
+ CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetOutputHandle),
+ 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),
+ { 0, 0, NULL }
+ };
+
+static NTSTATUS WINAPI
+CsrpCreateListenPort (IN LPWSTR Name,
+ IN OUT PHANDLE Port,
+ IN PTHREAD_START_ROUTINE ListenThread)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ OBJECT_ATTRIBUTES PortAttributes;
+ UNICODE_STRING PortName;
+ HANDLE ServerThread;
+ CLIENT_ID ClientId;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ RtlInitUnicodeString (& PortName, Name);
+ InitializeObjectAttributes (& PortAttributes,
+ & PortName,
+ 0,
+ NULL,
+ NULL);
+ Status = NtCreatePort ( Port,
+ & PortAttributes,
+ LPC_MAX_DATA_LENGTH, /* TODO: make caller set it*/
+ LPC_MAX_MESSAGE_LENGTH, /* TODO: make caller set it*/
+ 0); /* TODO: make caller set it*/
+ if(!NT_SUCCESS(Status))
+ {
+ DPRINT1("CSR: %s: NtCreatePort failed (Status=%08lx)\n",
+ __FUNCTION__, Status);
+ return Status;
+ }
+ Status = RtlCreateUserThread(NtCurrentProcess(),
+ NULL,
+ TRUE,
+ 0,
+ 0,
+ 0,
+ (PTHREAD_START_ROUTINE) ListenThread,
+ *Port,
+ &ServerThread,
+ &ClientId);
+
+ if (ListenThread == (PVOID)ClientConnectionThread)
+ {
+ CsrAddStaticServerThread(ServerThread, &ClientId, 0);
+ }
+
+ NtResumeThread(ServerThread, NULL);
+ NtClose(ServerThread);
+ return Status;
+}
+
+/* === INIT ROUTINES === */
+
+/**********************************************************************
+ * CsrpCreateBNODirectory/3
+ *
+ * These used to be part of kernel32 startup, but that clearly wasn't a good
+ * idea, as races were definately possible. These are moved (as in the
+ * previous fixmes).
+ */
+static NTSTATUS
+CsrpCreateBNODirectory (int argc, char ** argv, char ** envp)
+{
+ NTSTATUS Status;
+ OBJECT_ATTRIBUTES ObjectAttributes;
+ UNICODE_STRING Name = RTL_CONSTANT_STRING(L"\\BaseNamedObjects");
+ UNICODE_STRING SymName = RTL_CONSTANT_STRING(L"Local");
+ UNICODE_STRING SymName2 = RTL_CONSTANT_STRING(L"Global");
+ HANDLE DirHandle, SymHandle;
+
+ /* Seems like a good place to create these objects which are needed by
+ * win32 processes */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &Name,
+ OBJ_CASE_INSENSITIVE,
+ NULL,
+ NULL);
+
+ Status = NtCreateDirectoryObject(&DirHandle,
+ DIRECTORY_ALL_ACCESS,
+ &ObjectAttributes);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtCreateDirectoryObject() failed %08x\n", Status);
+ }
+
+ /* Create the "local" Symbolic Link.
+ * FIXME: CSR should do this -- Fixed */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SymName,
+ OBJ_CASE_INSENSITIVE,
+ DirHandle,
+ NULL);
+ Status = NtCreateSymbolicLinkObject(&SymHandle,
+ SYMBOLIC_LINK_ALL_ACCESS,
+ &ObjectAttributes,
+ &Name);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtCreateDirectoryObject() failed %08x\n", Status);
+ }
+
+ /* Create the "global" Symbolic Link. */
+ InitializeObjectAttributes(&ObjectAttributes,
+ &SymName2,
+ OBJ_CASE_INSENSITIVE,
+ DirHandle,
+ NULL);
+ Status = NtCreateSymbolicLinkObject(&SymHandle,
+ SYMBOLIC_LINK_ALL_ACCESS,
+ &ObjectAttributes,
+ &Name);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("NtCreateDirectoryObject() failed %08x\n", Status);
+ }
+
+ return Status;
+}
+
+/**********************************************************************
+ * CsrpCreateHeap/3
+ */
+static NTSTATUS
+CsrpCreateHeap (int argc, char ** argv, char ** envp)
+{
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ CsrssApiHeap = RtlCreateHeap(HEAP_GROWABLE,
+ NULL,
+ 65536,
+ 65536,
+ NULL,
+ NULL);
+ if (CsrssApiHeap == NULL)
+ {
+ return STATUS_UNSUCCESSFUL;
+ }
+ return STATUS_SUCCESS;
+}
+
+/**********************************************************************
+ * CsrpCreateCallbackPort/3
+ */
+static NTSTATUS
+CsrpCreateCallbackPort (int argc, char ** argv, char ** envp)
+{
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ return CsrpCreateListenPort (L"\\Windows\\SbApiPort",
+ & hSbApiPort,
+ ServerSbApiPortThread);
+}
+
+/**********************************************************************
+ * CsrpRegisterSubsystem/3
+ */
+static NTSTATUS
+CsrpRegisterSubsystem (int argc, char ** argv, char ** envp)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ OBJECT_ATTRIBUTES BootstrapOkAttributes;
+ UNICODE_STRING Name;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ /*
+ * Create the event object the callback port
+ * thread will signal *if* the SM will
+ * authorize us to bootstrap.
+ */
+ RtlInitUnicodeString (& Name, L"\\CsrssBooting");
+ InitializeObjectAttributes(& BootstrapOkAttributes,
+ & Name,
+ 0, NULL, NULL);
+ Status = NtCreateEvent (& hBootstrapOk,
+ EVENT_ALL_ACCESS,
+ & BootstrapOkAttributes,
+ SynchronizationEvent,
+ FALSE);
+ if(!NT_SUCCESS(Status))
+ {
+ DPRINT("CSR: %s: NtCreateEvent failed (Status=0x%08lx)\n",
+ __FUNCTION__, Status);
+ return Status;
+ }
+ /*
+ * Let's tell the SM a new environment
+ * subsystem server is in the system.
+ */
+ RtlInitUnicodeString (& Name, L"\\Windows\\SbApiPort");
+ DPRINT("CSR: %s: registering with SM for\n IMAGE_SUBSYSTEM_WINDOWS_CUI ==
3\n", __FUNCTION__);
+ Status = SmConnectApiPort (& Name,
+ hSbApiPort,
+ IMAGE_SUBSYSTEM_WINDOWS_CUI,
+ & hSmApiPort);
+ if(!NT_SUCCESS(Status))
+ {
+ DPRINT("CSR: %s unable to connect to the SM (Status=0x%08lx)\n",
+ __FUNCTION__, Status);
+ NtClose (hBootstrapOk);
+ return Status;
+ }
+ /*
+ * Wait for SM to reply OK... If the SM
+ * won't answer, we hang here forever!
+ */
+ DPRINT("CSR: %s: waiting for SM to OK boot...\n", __FUNCTION__);
+ Status = NtWaitForSingleObject (hBootstrapOk,
+ FALSE,
+ NULL);
+ NtClose (hBootstrapOk);
+ return Status;
+}
+
+/**********************************************************************
+ * CsrpLoadKernelModeDriver/3
+ */
+static NTSTATUS
+CsrpLoadKernelModeDriver (int argc, char ** argv, char ** envp)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ WCHAR Data [MAX_PATH + 1];
+ ULONG DataLength = sizeof Data;
+ ULONG DataType = 0;
+ //UNICODE_STRING Environment;
+
+
+ DPRINT1("SM: %s called\n", __FUNCTION__);
+
+
+ //EnvpToUnicodeString (envp, & Environment);
+ Status = SmLookupSubsystem (L"Kmode",
+ Data,
+ & DataLength,
+ & DataType,
+ NULL);
+ //RtlFreeUnicodeString (& Environment);
+ if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0]))
+ {
+ WCHAR ImagePath [MAX_PATH + 1] = {0};
+ UNICODE_STRING ModuleName;
+
+ wcscpy (ImagePath, L"\\??\\c:\\reactos\\system32\\win32k.sys");
+// wcscat (ImagePath, Data);
+ RtlInitUnicodeString (& ModuleName, ImagePath);
+ Status = NtSetSystemInformation(/* FIXME: SystemLoadAndCallImage */
+ SystemExtendServiceTableInformation,
+ & ModuleName,
+ sizeof ModuleName);
+ if(!NT_SUCCESS(Status))
+ {
+ DPRINT1("WIN: %s: loading Kmode failed (Status=0x%08lx)\n",
+ __FUNCTION__, Status);
+ }
+ }
+ return Status;
+}
+
+/**********************************************************************
+ * CsrpCreateApiPort/2
+ */
+static NTSTATUS
+CsrpCreateApiPort (int argc, char ** argv, char ** envp)
+{
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ CsrInitProcessData();
+
+ return CsrpCreateListenPort(L"\\Windows\\ApiPort", &hApiPort,
+ (PTHREAD_START_ROUTINE)ClientConnectionThread);
+}
+
+/**********************************************************************
+ * CsrpApiRegisterDef/0
+ */
+static NTSTATUS
+CsrpApiRegisterDef (int argc, char ** argv, char ** envp)
+{
+ return CsrApiRegisterDefinitions(NativeDefinitions);
+}
+
+/**********************************************************************
+ * CsrpCCTS/2
+ */
+static NTSTATUS
+CsrpCCTS (int argc, char ** argv, char ** envp)
+{
+ ULONG Dummy;
+ ULONG DummyLength = sizeof(Dummy);
+ return CsrClientConnectToServer(L"\\Windows",
+ 0, &Dummy, &DummyLength, NULL);
+}
+
+/**********************************************************************
+ * CsrpRunWinlogon/0
+ *
+ * Start the logon process (winlogon.exe).
+ *
+ * TODO: this should be moved in CsrpCreateSession/x (one per session)
+ * TODO: in its own desktop (one logon desktop per winstation).
+ */
+static NTSTATUS
+CsrpRunWinlogon (int argc, char ** argv, char ** envp)
+{
+ NTSTATUS Status = STATUS_SUCCESS;
+ UNICODE_STRING ImagePath;
+ UNICODE_STRING CommandLine;
+ PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
+ RTL_USER_PROCESS_INFORMATION ProcessInfo;
+
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ /* initialize the process parameters */
+ RtlInitUnicodeString (& ImagePath,
L"\\SystemRoot\\system32\\winlogon.exe");
+ RtlInitUnicodeString (& CommandLine, L"");
+ RtlCreateProcessParameters(& ProcessParameters,
+ & ImagePath,
+ NULL,
+ NULL,
+ & CommandLine,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL);
+ /* Create the winlogon process */
+ Status = RtlCreateUserProcess (& ImagePath,
+ OBJ_CASE_INSENSITIVE,
+ ProcessParameters,
+ NULL,
+ NULL,
+ NULL,
+ FALSE,
+ NULL,
+ NULL,
+ & ProcessInfo);
+ /* Cleanup */
+ RtlDestroyProcessParameters (ProcessParameters);
+ if (!NT_SUCCESS(Status))
+ {
+ DPRINT1("SM: %s: loading winlogon.exe failed (Status=%08lx)\n",
+ __FUNCTION__, Status);
+ }
+
+ ZwResumeThread(ProcessInfo.ThreadHandle, NULL);
+ return Status;
+}
+
+static NTSTATUS
+CsrpCreateHardErrorPort (int argc, char ** argv, char ** envp)
+{
+ return NtSetDefaultHardErrorPort(hApiPort);
+}
+
+typedef NTSTATUS (* CSR_INIT_ROUTINE)(int,char**,char**);
+
+struct {
+ BOOL Required;
+ CSR_INIT_ROUTINE EntryPoint;
+ PCHAR ErrorMessage;
+} InitRoutine [] = {
+ {TRUE, CsrpCreateBNODirectory, "create base named objects
directory"},
+ {TRUE, CsrpCreateCallbackPort, "create the callback port
\\Windows\\SbApiPort"},
+ {TRUE, CsrpRegisterSubsystem, "register with SM"},
+ {TRUE, CsrpCreateHeap, "create the CSR heap"},
+ {TRUE, CsrpCreateApiPort, "create the api port \\Windows\\ApiPort"},
+ {TRUE, CsrpCreateHardErrorPort, "create the hard error port"},
+ {TRUE, CsrpCreateObjectDirectory,"create the object directory \\Windows"},
+ {TRUE, CsrpLoadKernelModeDriver, "load Kmode driver"},
+ {TRUE, CsrpInitVideo, "initialize video"},
+ {TRUE, CsrpApiRegisterDef, "initialize api definitions"},
+ {TRUE, CsrpCCTS, "connect client to server"},
+ {TRUE, CsrpInitWin32Csr, "load usermode dll"},
+ {TRUE, CsrpRunWinlogon, "run WinLogon"},
+};
+
+/* PUBLIC FUNCTIONS ***********************************************************/
+
+NTSTATUS
+NTAPI
+CsrServerInitialization(ULONG ArgumentCount,
+ PCHAR Arguments[])
+{
+ UINT i = 0;
+ NTSTATUS Status = STATUS_SUCCESS;
+
+ DPRINT("CSR: %s called\n", __FUNCTION__);
+
+ for (i=0; i < (sizeof InitRoutine / sizeof InitRoutine[0]); i++)
+ {
+ Status = InitRoutine[i].EntryPoint(ArgumentCount,Arguments,NULL);
+ if(!NT_SUCCESS(Status))
+ {
+ DPRINT1("CSR: %s: failed to %s (Status=%08lx)\n",
+ __FUNCTION__,
+ InitRoutine[i].ErrorMessage,
+ Status);
+ if (InitRoutine[i].Required)
+ {
+ return FALSE;
+ }
+ }
+ }
+ if (CallInitComplete())
+ {
+ Status = SmCompleteSession (hSmApiPort,hSbApiPort,hApiPort);
+ return STATUS_SUCCESS;
+ }
+
+ return STATUS_UNSUCCESSFUL;
+}
+
+BOOL
+NTAPI
+DllMainCRTStartup(HANDLE hDll,
+ DWORD dwReason,
+ LPVOID lpReserved)
+{
+ /* We don't do much */
+ UNREFERENCED_PARAMETER(hDll);
+ UNREFERENCED_PARAMETER(dwReason);
+ UNREFERENCED_PARAMETER(lpReserved);
+ return TRUE;
+}
+
+/* EOF */
Propchange: trunk/reactos/subsystems/win32/csrss/csrsrv/init.c
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h (added)
+++ trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h [iso-8859-1] Wed Mar 10 05:59:39
2010
@@ -1,0 +1,21 @@
+/* PSDK/NDK Headers */
+#define NTOS_MODE_USER
+#include <stdio.h>
+#define WIN32_NO_STATUS
+#include <windows.h>
+#include <winnt.h>
+#include <ndk/ntndk.h>
+
+/* CSR Header */
+//#include <csr/server.h>
+
+/* PSEH for SEH Support */
+#include <pseh/pseh2.h>
+
+/* Subsystem Manager Header */
+#include <sm/helper.h>
+
+/* Internal CSRSS Headers */
+#include <api.h>
+#include <conio.h>
+#include <csrplugin.h>
Propchange: trunk/reactos/subsystems/win32/csrss/csrsrv/srv.h
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/reactos/subsystems/win32/csrss/csrss.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrss.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrss.c [iso-8859-1] Wed Mar 10 05:59:39 2010
@@ -1,62 +1,70 @@
-/* $Id$
- *
- * csrss.c - Client/Server Runtime subsystem
- *
- * ReactOS Operating System
- *
- * --------------------------------------------------------------------
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * --------------------------------------------------------------------
+/*
+ * PROJECT: ReactOS Client Server Runtime SubSystem (CSRSS)
+ * LICENSE: BSD - See COPYING.ARM in root directory
+ * FILE: subsystems/win32/csrss/csrss.c
+ * PURPOSE: Main Executable Code
+ * PROGRAMMERS: Alex Ionescu
+ * ReactOS Portable Systems Group
*/
-#include <csrss.h>
+/* INCLUDES *******************************************************************/
+#define WIN32_NO_STATUS
+#include <windows.h>
+#include <ndk/ntndk.h>
+#include <api.h>
#define NDEBUG
#include <debug.h>
-int _cdecl _main(int argc,
- char *argv[],
- char *envp[],
- int DebugFlag)
+/* FUNCTIONS ******************************************************************/
+
+VOID
+NTAPI
+CsrpSetDefaultProcessHardErrorMode(VOID)
{
- NTSTATUS Status = STATUS_SUCCESS;
+ ULONG DefaultHardErrorMode = 0;
- //PrintString("ReactOS Client/Server Run-Time (Build %s)\n",
- //KERNEL_VERSION_BUILD_STR);
+ /* Disable hard errors */
+ NtSetInformationProcess(NtCurrentProcess(),
+ ProcessDefaultHardErrorMode,
+ &DefaultHardErrorMode,
+ sizeof(DefaultHardErrorMode));
+}
- /*==================================================================
- * Initialize the Win32 environment subsystem server.
- *================================================================*/
- if (CsrServerInitialization (argc, argv, envp) == TRUE)
- {
- /*
- * Terminate the current thread only.
- */
- Status = NtTerminateThread (NtCurrentThread(), 0);
- }
- else
- {
- DisplayString (L"CSR: CsrServerInitialization failed.\n");
- /*
- * Tell the SM we failed.
- */
- Status = NtTerminateProcess (NtCurrentProcess(), 0);
- }
- return (int) Status;
+int
+_cdecl
+_main(int argc,
+ char *argv[],
+ char *envp[],
+ int DebugFlag)
+{
+ KPRIORITY BasePriority = (8 + 1) + 4;
+ NTSTATUS Status;
+
+ /* Set the Priority */
+ NtSetInformationProcess(NtCurrentProcess(),
+ ProcessBasePriority,
+ &BasePriority,
+ sizeof(KPRIORITY));
+
+ /* Initialize CSR through CSRSRV */
+ Status = CsrServerInitialization(argc, argv);
+ if (!NT_SUCCESS(Status))
+ {
+ /* Kill us */
+ DPRINT1("CSRSS: CsrServerInitialization failed:% lx\n", Status);
+ NtTerminateProcess(NtCurrentProcess(), Status);
+ }
+
+ /* Disable errors */
+ CsrpSetDefaultProcessHardErrorMode();
+
+ /* If this is Session 0, make sure killing us bugchecks the system */
+ if (!NtCurrentPeb()->SessionId) RtlSetProcessIsCritical(TRUE, NULL, FALSE);
+
+ /* Kill this thread. CSRSRV keeps us going */
+ NtTerminateThread (NtCurrentThread(), Status);
+ return 0;
}
/* EOF */
Removed: trunk/reactos/subsystems/win32/csrss/csrss.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrss.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrss.h (removed)
@@ -1,21 +1,0 @@
-/* PSDK/NDK Headers */
-#include <stdio.h>
-#define WIN32_NO_STATUS
-#include <windows.h>
-#define NTOS_MODE_USER
-#include <ndk/ntndk.h>
-
-#include <intrin.h>
-
-/* Build Number */
-#include <reactos/buildno.h>
-
-/* Subsystem Manager Header */
-#include <sm/helper.h>
-
-/* Internal CSRSS Headers */
-#include <api.h>
-#include <conio.h>
-#include <csrplugin.h>
-
-/* EOF */
Modified: trunk/reactos/subsystems/win32/csrss/csrss.rbuild
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/csr…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/csrss.rbuild [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/csrss.rbuild [iso-8859-1] Wed Mar 10 05:59:39
2010
@@ -9,21 +9,14 @@
<compilerflag compilerset="gcc">-fms-extensions</compilerflag>
<library>nt</library>
<library>ntdll</library>
- <library>smdll</library>
- <directory name="api">
- <file>handle.c</file>
- <file>process.c</file>
- <file>user.c</file>
- <file>wapi.c</file>
- </directory>
- <pch>csrss.h</pch>
+ <library>csrsrv</library>
<file>csrss.c</file>
- <file>init.c</file>
- <file>print.c</file>
- <file>video.c</file>
<file>csrss.rc</file>
</module>
<directory name="win32csr">
<xi:include href="win32csr/win32csr.rbuild" />
</directory>
+ <directory name="csrsrv">
+ <xi:include href="csrsrv/csrsrv.rbuild" />
+ </directory>
</group>
Modified: trunk/reactos/subsystems/win32/csrss/include/api.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/inc…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/include/api.h [iso-8859-1] Wed Mar 10 05:59:39
2010
@@ -12,6 +12,14 @@
#include <ndk/ntndk.h>
#include <csrss/csrss.h>
+
+typedef enum _CSR_THREAD_FLAGS
+{
+ CsrThreadAltertable = 0x1,
+ CsrThreadInTermination = 0x2,
+ CsrThreadTerminated = 0x4,
+ CsrThreadIsServerThread = 0x10
+} CSR_THREAD_FLAGS, *PCSR_THREAD_FLAGS;
typedef enum _SHUTDOWN_RESULT
{
@@ -179,7 +187,7 @@
NTSTATUS WINAPI CsrInsertObject( PCSRSS_PROCESS_DATA ProcessData, PHANDLE Handle,
Object_t *Object, DWORD Access, BOOL Inheritable );
NTSTATUS WINAPI CsrDuplicateHandleTable(PCSRSS_PROCESS_DATA SourceProcessData,
PCSRSS_PROCESS_DATA TargetProcessData);
NTSTATUS WINAPI CsrGetObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Handle, Object_t
**Object, DWORD Access );
-BOOL WINAPI CsrServerInitialization (int,char**,char**);
+NTSTATUS NTAPI CsrServerInitialization(ULONG ArgumentCount, PCHAR Arguments[]);
NTSTATUS WINAPI CsrReleaseObjectByPointer(Object_t *Object);
NTSTATUS WINAPI CsrReleaseObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
NTSTATUS WINAPI CsrVerifyObject( PCSRSS_PROCESS_DATA ProcessData, HANDLE Object );
Removed: trunk/reactos/subsystems/win32/csrss/init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/ini…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/init.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/init.c (removed)
@@ -1,766 +1,0 @@
-/* $Id$
- *
- * reactos/subsys/csrss/init.c
- *
- * Initialize the CSRSS subsystem server process.
- *
- * ReactOS Operating System
- *
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <csrss.h>
-
-#define NDEBUG
-#include <debug.h>
-
-/* GLOBALS ******************************************************************/
-
-HANDLE CsrHeap = (HANDLE) 0;
-
-HANDLE CsrObjectDirectory = (HANDLE) 0;
-
-UNICODE_STRING CsrDirectoryName;
-
-extern HANDLE CsrssApiHeap;
-
-static unsigned InitCompleteProcCount;
-static CSRPLUGIN_INIT_COMPLETE_PROC *InitCompleteProcs = NULL;
-
-static unsigned HardErrorProcCount;
-static CSRPLUGIN_HARDERROR_PROC *HardErrorProcs = NULL;
-
-HANDLE hSbApiPort = (HANDLE) 0;
-
-HANDLE hBootstrapOk = (HANDLE) 0;
-
-HANDLE hSmApiPort = (HANDLE) 0;
-
-HANDLE hApiPort = (HANDLE) 0;
-
-/**********************************************************************
- * CsrpAddInitCompleteProc/1
- */
-static NTSTATUS FASTCALL
-CsrpAddInitCompleteProc(CSRPLUGIN_INIT_COMPLETE_PROC Proc)
-{
- CSRPLUGIN_INIT_COMPLETE_PROC *NewProcs;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- NewProcs = RtlAllocateHeap(CsrssApiHeap, 0,
- (InitCompleteProcCount + 1)
- * sizeof(CSRPLUGIN_INIT_COMPLETE_PROC));
- if (NULL == NewProcs)
- {
- return STATUS_NO_MEMORY;
- }
- if (0 != InitCompleteProcCount)
- {
- RtlCopyMemory(NewProcs, InitCompleteProcs,
- InitCompleteProcCount * sizeof(CSRPLUGIN_INIT_COMPLETE_PROC));
- RtlFreeHeap(CsrssApiHeap, 0, InitCompleteProcs);
- }
- NewProcs[InitCompleteProcCount] = Proc;
- InitCompleteProcs = NewProcs;
- InitCompleteProcCount++;
-
- return STATUS_SUCCESS;
-}
-
-static NTSTATUS FASTCALL
-CsrpAddHardErrorProc(CSRPLUGIN_HARDERROR_PROC Proc)
-{
- CSRPLUGIN_HARDERROR_PROC *NewProcs;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- NewProcs = RtlAllocateHeap(CsrssApiHeap, 0,
- (HardErrorProcCount + 1)
- * sizeof(CSRPLUGIN_HARDERROR_PROC));
- if (NULL == NewProcs)
- {
- return STATUS_NO_MEMORY;
- }
- if (0 != HardErrorProcCount)
- {
- RtlCopyMemory(NewProcs, HardErrorProcs,
- HardErrorProcCount * sizeof(CSRPLUGIN_HARDERROR_PROC));
- RtlFreeHeap(CsrssApiHeap, 0, HardErrorProcs);
- }
-
- NewProcs[HardErrorProcCount] = Proc;
- HardErrorProcs = NewProcs;
- HardErrorProcCount++;
-
- return STATUS_SUCCESS;
-}
-
-/**********************************************************************
- * CallInitComplete/0
- */
-static BOOL FASTCALL
-CallInitComplete(void)
-{
- BOOL Ok;
- unsigned i;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- Ok = TRUE;
- if (0 != InitCompleteProcCount)
- {
- for (i = 0; i < InitCompleteProcCount && Ok; i++)
- {
- Ok = (*(InitCompleteProcs[i]))();
- }
- RtlFreeHeap(CsrssApiHeap, 0, InitCompleteProcs);
- }
-
- return Ok;
-}
-
-BOOL
-CallHardError(IN PCSRSS_PROCESS_DATA ProcessData,
- IN PHARDERROR_MSG HardErrorMessage)
-{
- BOOL Ok;
- unsigned i;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- Ok = TRUE;
- if (0 != HardErrorProcCount)
- {
- for (i = 0; i < HardErrorProcCount && Ok; i++)
- {
- Ok = (*(HardErrorProcs[i]))(ProcessData, HardErrorMessage);
- }
- }
-
- return Ok;
-}
-
-ULONG
-InitializeVideoAddressSpace(VOID);
-
-/**********************************************************************
- * CsrpCreateObjectDirectory/3
- */
-static NTSTATUS
-CsrpCreateObjectDirectory (int argc, char ** argv, char ** envp)
-{
- NTSTATUS Status;
- OBJECT_ATTRIBUTES Attributes;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
-
- /* create object directory ('\Windows') */
- RtlCreateUnicodeString (&CsrDirectoryName,
- L"\\Windows");
-
- InitializeObjectAttributes (&Attributes,
- &CsrDirectoryName,
- OBJ_OPENIF,
- NULL,
- NULL);
-
- Status = NtOpenDirectoryObject(&CsrObjectDirectory,
- DIRECTORY_ALL_ACCESS,
- &Attributes);
- return Status;
-}
-
-/**********************************************************************
- * CsrpInitVideo/3
- *
- * TODO: we need a virtual device for sessions other than
- * TODO: the console one
- */
-static NTSTATUS
-CsrpInitVideo (int argc, char ** argv, char ** envp)
-{
- 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;
-}
-
-/**********************************************************************
- * CsrpInitWin32Csr/3
- *
- * TODO: this function should be turned more general to load an
- * TODO: hosted server DLL as received from the command line;
- * TODO: for instance: ServerDll=winsrv:ConServerDllInitialization,2
- * TODO: ^method ^dll ^api ^sid
- * TODO:
- * TODO: CsrpHostServerDll (LPWSTR DllName,
- * TODO: LPWSTR ApiName,
- * TODO: DWORD ServerId)
- */
-static NTSTATUS
-CsrpInitWin32Csr (int argc, char ** argv, char ** envp)
-{
- NTSTATUS Status;
- UNICODE_STRING DllName;
- HINSTANCE hInst;
- ANSI_STRING ProcName;
- CSRPLUGIN_INITIALIZE_PROC InitProc;
- CSRSS_EXPORTED_FUNCS Exports;
- PCSRSS_API_DEFINITION ApiDefinitions;
- PCSRSS_OBJECT_DEFINITION ObjectDefinitions;
- CSRPLUGIN_INIT_COMPLETE_PROC InitCompleteProc;
- CSRPLUGIN_HARDERROR_PROC HardErrorProc;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- RtlInitUnicodeString(&DllName, L"win32csr.dll");
- Status = LdrLoadDll(NULL, 0, &DllName, (PVOID *) &hInst);
- if (! NT_SUCCESS(Status))
- {
- return Status;
- }
- RtlInitAnsiString(&ProcName, "Win32CsrInitialization");
- Status = LdrGetProcedureAddress(hInst, &ProcName, 0, (PVOID *) &InitProc);
- if (! NT_SUCCESS(Status))
- {
- return Status;
- }
- Exports.CsrInsertObjectProc = CsrInsertObject;
- Exports.CsrGetObjectProc = CsrGetObject;
- Exports.CsrReleaseObjectByPointerProc = CsrReleaseObjectByPointer;
- Exports.CsrReleaseObjectProc = CsrReleaseObject;
- Exports.CsrEnumProcessesProc = CsrEnumProcesses;
- if (! (*InitProc)(&ApiDefinitions, &ObjectDefinitions, &InitCompleteProc,
- &HardErrorProc, &Exports, CsrssApiHeap))
- {
- return STATUS_UNSUCCESSFUL;
- }
-
- Status = CsrApiRegisterDefinitions(ApiDefinitions);
- if (! NT_SUCCESS(Status))
- {
- return Status;
- }
- Status = CsrRegisterObjectDefinitions(ObjectDefinitions);
- if (! NT_SUCCESS(Status))
- {
- return Status;
- }
- if (NULL != InitCompleteProc)
- {
- Status = CsrpAddInitCompleteProc(InitCompleteProc);
- }
- if (HardErrorProc) Status = CsrpAddHardErrorProc(HardErrorProc);
-
- return Status;
-}
-
-CSRSS_API_DEFINITION NativeDefinitions[] =
- {
- CSRSS_DEFINE_API(CREATE_PROCESS, CsrCreateProcess),
- CSRSS_DEFINE_API(CREATE_THREAD, CsrCreateThread),
- CSRSS_DEFINE_API(TERMINATE_PROCESS, CsrTerminateProcess),
- CSRSS_DEFINE_API(CONNECT_PROCESS, CsrConnectProcess),
- CSRSS_DEFINE_API(REGISTER_SERVICES_PROCESS, CsrRegisterServicesProcess),
- CSRSS_DEFINE_API(GET_SHUTDOWN_PARAMETERS, CsrGetShutdownParameters),
- CSRSS_DEFINE_API(SET_SHUTDOWN_PARAMETERS, CsrSetShutdownParameters),
- CSRSS_DEFINE_API(GET_INPUT_HANDLE, CsrGetInputHandle),
- CSRSS_DEFINE_API(GET_OUTPUT_HANDLE, CsrGetOutputHandle),
- 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),
- { 0, 0, NULL }
- };
-
-static NTSTATUS WINAPI
-CsrpCreateListenPort (IN LPWSTR Name,
- IN OUT PHANDLE Port,
- IN PTHREAD_START_ROUTINE ListenThread)
-{
- NTSTATUS Status = STATUS_SUCCESS;
- OBJECT_ATTRIBUTES PortAttributes;
- UNICODE_STRING PortName;
- HANDLE ServerThread;
- CLIENT_ID ClientId;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- RtlInitUnicodeString (& PortName, Name);
- InitializeObjectAttributes (& PortAttributes,
- & PortName,
- 0,
- NULL,
- NULL);
- Status = NtCreatePort ( Port,
- & PortAttributes,
- LPC_MAX_DATA_LENGTH, /* TODO: make caller set it*/
- LPC_MAX_MESSAGE_LENGTH, /* TODO: make caller set it*/
- 0); /* TODO: make caller set it*/
- if(!NT_SUCCESS(Status))
- {
- DPRINT1("CSR: %s: NtCreatePort failed (Status=%08lx)\n",
- __FUNCTION__, Status);
- return Status;
- }
- Status = RtlCreateUserThread(NtCurrentProcess(),
- NULL,
- TRUE,
- 0,
- 0,
- 0,
- (PTHREAD_START_ROUTINE) ListenThread,
- *Port,
- &ServerThread,
- &ClientId);
-
- if (ListenThread == (PVOID)ClientConnectionThread)
- {
- CsrAddStaticServerThread(ServerThread, &ClientId, 0);
- }
-
- NtResumeThread(ServerThread, NULL);
- NtClose(ServerThread);
- return Status;
-}
-
-/* === INIT ROUTINES === */
-
-/**********************************************************************
- * CsrpCreateBNODirectory/3
- *
- * These used to be part of kernel32 startup, but that clearly wasn't a good
- * idea, as races were definately possible. These are moved (as in the
- * previous fixmes).
- */
-static NTSTATUS
-CsrpCreateBNODirectory (int argc, char ** argv, char ** envp)
-{
- NTSTATUS Status;
- OBJECT_ATTRIBUTES ObjectAttributes;
- UNICODE_STRING Name = RTL_CONSTANT_STRING(L"\\BaseNamedObjects");
- UNICODE_STRING SymName = RTL_CONSTANT_STRING(L"Local");
- UNICODE_STRING SymName2 = RTL_CONSTANT_STRING(L"Global");
- HANDLE DirHandle, SymHandle;
-
- /* Seems like a good place to create these objects which are needed by
- * win32 processes */
- InitializeObjectAttributes(&ObjectAttributes,
- &Name,
- OBJ_CASE_INSENSITIVE,
- NULL,
- NULL);
-
- Status = NtCreateDirectoryObject(&DirHandle,
- DIRECTORY_ALL_ACCESS,
- &ObjectAttributes);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtCreateDirectoryObject() failed %08x\n", Status);
- }
-
- /* Create the "local" Symbolic Link.
- * FIXME: CSR should do this -- Fixed */
- InitializeObjectAttributes(&ObjectAttributes,
- &SymName,
- OBJ_CASE_INSENSITIVE,
- DirHandle,
- NULL);
- Status = NtCreateSymbolicLinkObject(&SymHandle,
- SYMBOLIC_LINK_ALL_ACCESS,
- &ObjectAttributes,
- &Name);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtCreateDirectoryObject() failed %08x\n", Status);
- }
-
- /* Create the "global" Symbolic Link. */
- InitializeObjectAttributes(&ObjectAttributes,
- &SymName2,
- OBJ_CASE_INSENSITIVE,
- DirHandle,
- NULL);
- Status = NtCreateSymbolicLinkObject(&SymHandle,
- SYMBOLIC_LINK_ALL_ACCESS,
- &ObjectAttributes,
- &Name);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("NtCreateDirectoryObject() failed %08x\n", Status);
- }
-
- return Status;
-}
-
-/**********************************************************************
- * CsrpCreateHeap/3
- */
-static NTSTATUS
-CsrpCreateHeap (int argc, char ** argv, char ** envp)
-{
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- CsrssApiHeap = RtlCreateHeap(HEAP_GROWABLE,
- NULL,
- 65536,
- 65536,
- NULL,
- NULL);
- if (CsrssApiHeap == NULL)
- {
- return STATUS_UNSUCCESSFUL;
- }
- return STATUS_SUCCESS;
-}
-
-/**********************************************************************
- * CsrpCreateCallbackPort/3
- */
-static NTSTATUS
-CsrpCreateCallbackPort (int argc, char ** argv, char ** envp)
-{
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- return CsrpCreateListenPort (L"\\Windows\\SbApiPort",
- & hSbApiPort,
- ServerSbApiPortThread);
-}
-
-/**********************************************************************
- * CsrpRegisterSubsystem/3
- */
-static NTSTATUS
-CsrpRegisterSubsystem (int argc, char ** argv, char ** envp)
-{
- NTSTATUS Status = STATUS_SUCCESS;
- OBJECT_ATTRIBUTES BootstrapOkAttributes;
- UNICODE_STRING Name;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- /*
- * Create the event object the callback port
- * thread will signal *if* the SM will
- * authorize us to bootstrap.
- */
- RtlInitUnicodeString (& Name, L"\\CsrssBooting");
- InitializeObjectAttributes(& BootstrapOkAttributes,
- & Name,
- 0, NULL, NULL);
- Status = NtCreateEvent (& hBootstrapOk,
- EVENT_ALL_ACCESS,
- & BootstrapOkAttributes,
- SynchronizationEvent,
- FALSE);
- if(!NT_SUCCESS(Status))
- {
- DPRINT("CSR: %s: NtCreateEvent failed (Status=0x%08lx)\n",
- __FUNCTION__, Status);
- return Status;
- }
- /*
- * Let's tell the SM a new environment
- * subsystem server is in the system.
- */
- RtlInitUnicodeString (& Name, L"\\Windows\\SbApiPort");
- DPRINT("CSR: %s: registering with SM for\n IMAGE_SUBSYSTEM_WINDOWS_CUI ==
3\n", __FUNCTION__);
- Status = SmConnectApiPort (& Name,
- hSbApiPort,
- IMAGE_SUBSYSTEM_WINDOWS_CUI,
- & hSmApiPort);
- if(!NT_SUCCESS(Status))
- {
- DPRINT("CSR: %s unable to connect to the SM (Status=0x%08lx)\n",
- __FUNCTION__, Status);
- NtClose (hBootstrapOk);
- return Status;
- }
- /*
- * Wait for SM to reply OK... If the SM
- * won't answer, we hang here forever!
- */
- DPRINT("CSR: %s: waiting for SM to OK boot...\n", __FUNCTION__);
- Status = NtWaitForSingleObject (hBootstrapOk,
- FALSE,
- NULL);
- NtClose (hBootstrapOk);
- return Status;
-}
-
-/**********************************************************************
- * EnvpToUnicodeString/2
- */
-static ULONG FASTCALL
-EnvpToUnicodeString (char ** envp, PUNICODE_STRING UnicodeEnv)
-{
- ULONG CharCount = 0;
- ULONG Index = 0;
- ANSI_STRING AnsiEnv;
-
- UnicodeEnv->Buffer = NULL;
-
- for (Index=0; NULL != envp[Index]; Index++)
- {
- CharCount += strlen (envp[Index]);
- ++ CharCount;
- }
- ++ CharCount;
-
- AnsiEnv.Buffer = RtlAllocateHeap (RtlGetProcessHeap(), 0, CharCount);
- if (NULL != AnsiEnv.Buffer)
- {
-
- PCHAR WritePos = AnsiEnv.Buffer;
-
- for (Index=0; NULL != envp[Index]; Index++)
- {
- strcpy (WritePos, envp[Index]);
- WritePos += strlen (envp[Index]) + 1;
- }
-
- /* FIXME: the last (double) nullterm should perhaps not be included in Length
- * but only in MaximumLength. -Gunnar */
- AnsiEnv.Buffer [CharCount-1] = '\0';
- AnsiEnv.Length = CharCount;
- AnsiEnv.MaximumLength = CharCount;
-
- RtlAnsiStringToUnicodeString (UnicodeEnv, & AnsiEnv, TRUE);
- RtlFreeHeap (RtlGetProcessHeap(), 0, AnsiEnv.Buffer);
- }
- return CharCount;
-}
-/**********************************************************************
- * CsrpLoadKernelModeDriver/3
- */
-static NTSTATUS
-CsrpLoadKernelModeDriver (int argc, char ** argv, char ** envp)
-{
- NTSTATUS Status = STATUS_SUCCESS;
- WCHAR Data [MAX_PATH + 1];
- ULONG DataLength = sizeof Data;
- ULONG DataType = 0;
- UNICODE_STRING Environment;
-
-
- DPRINT("SM: %s called\n", __FUNCTION__);
-
-
- EnvpToUnicodeString (envp, & Environment);
- Status = SmLookupSubsystem (L"Kmode",
- Data,
- & DataLength,
- & DataType,
- Environment.Buffer);
- RtlFreeUnicodeString (& Environment);
- if((STATUS_SUCCESS == Status) && (DataLength > sizeof Data[0]))
- {
- WCHAR ImagePath [MAX_PATH + 1] = {0};
- UNICODE_STRING ModuleName;
-
- wcscpy (ImagePath, L"\\??\\");
- wcscat (ImagePath, Data);
- RtlInitUnicodeString (& ModuleName, ImagePath);
- Status = NtSetSystemInformation(/* FIXME: SystemLoadAndCallImage */
- SystemExtendServiceTableInformation,
- & ModuleName,
- sizeof ModuleName);
- if(!NT_SUCCESS(Status))
- {
- DPRINT("WIN: %s: loading Kmode failed (Status=0x%08lx)\n",
- __FUNCTION__, Status);
- }
- }
- return Status;
-}
-
-/**********************************************************************
- * CsrpCreateApiPort/2
- */
-static NTSTATUS
-CsrpCreateApiPort (int argc, char ** argv, char ** envp)
-{
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- CsrInitProcessData();
-
- return CsrpCreateListenPort(L"\\Windows\\ApiPort", &hApiPort,
- (PTHREAD_START_ROUTINE)ClientConnectionThread);
-}
-
-/**********************************************************************
- * CsrpApiRegisterDef/0
- */
-static NTSTATUS
-CsrpApiRegisterDef (int argc, char ** argv, char ** envp)
-{
- return CsrApiRegisterDefinitions(NativeDefinitions);
-}
-
-/**********************************************************************
- * CsrpCCTS/2
- */
-static NTSTATUS
-CsrpCCTS (int argc, char ** argv, char ** envp)
-{
- ULONG Dummy;
- ULONG DummyLength = sizeof(Dummy);
- return CsrClientConnectToServer(L"\\Windows",
- 0, &Dummy, &DummyLength, NULL);
-}
-
-/**********************************************************************
- * CsrpRunWinlogon/0
- *
- * Start the logon process (winlogon.exe).
- *
- * TODO: this should be moved in CsrpCreateSession/x (one per session)
- * TODO: in its own desktop (one logon desktop per winstation).
- */
-static NTSTATUS
-CsrpRunWinlogon (int argc, char ** argv, char ** envp)
-{
- NTSTATUS Status = STATUS_SUCCESS;
- UNICODE_STRING ImagePath;
- UNICODE_STRING CommandLine;
- PRTL_USER_PROCESS_PARAMETERS ProcessParameters = NULL;
- RTL_USER_PROCESS_INFORMATION ProcessInfo;
-
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- /* initialize the process parameters */
- RtlInitUnicodeString (& ImagePath,
L"\\SystemRoot\\system32\\winlogon.exe");
- RtlInitUnicodeString (& CommandLine, L"");
- RtlCreateProcessParameters(& ProcessParameters,
- & ImagePath,
- NULL,
- NULL,
- & CommandLine,
- NULL,
- NULL,
- NULL,
- NULL,
- NULL);
- /* Create the winlogon process */
- Status = RtlCreateUserProcess (& ImagePath,
- OBJ_CASE_INSENSITIVE,
- ProcessParameters,
- NULL,
- NULL,
- NULL,
- FALSE,
- NULL,
- NULL,
- & ProcessInfo);
- /* Cleanup */
- RtlDestroyProcessParameters (ProcessParameters);
- if (!NT_SUCCESS(Status))
- {
- DPRINT1("SM: %s: loading winlogon.exe failed (Status=%08lx)\n",
- __FUNCTION__, Status);
- }
-
- ZwResumeThread(ProcessInfo.ThreadHandle, NULL);
- return Status;
-}
-
-static NTSTATUS
-CsrpCreateHardErrorPort (int argc, char ** argv, char ** envp)
-{
- return NtSetDefaultHardErrorPort(hApiPort);
-}
-
-typedef NTSTATUS (* CSR_INIT_ROUTINE)(int,char**,char**);
-
-struct {
- BOOL Required;
- CSR_INIT_ROUTINE EntryPoint;
- PCHAR ErrorMessage;
-} InitRoutine [] = {
- {TRUE, CsrpCreateBNODirectory, "create base named objects
directory"},
- {TRUE, CsrpCreateCallbackPort, "create the callback port
\\Windows\\SbApiPort"},
- {TRUE, CsrpRegisterSubsystem, "register with SM"},
- {TRUE, CsrpCreateHeap, "create the CSR heap"},
- {TRUE, CsrpCreateApiPort, "create the api port \\Windows\\ApiPort"},
- {TRUE, CsrpCreateHardErrorPort, "create the hard error port"},
- {TRUE, CsrpCreateObjectDirectory,"create the object directory \\Windows"},
- {TRUE, CsrpLoadKernelModeDriver, "load Kmode driver"},
- {TRUE, CsrpInitVideo, "initialize video"},
- {TRUE, CsrpApiRegisterDef, "initialize api definitions"},
- {TRUE, CsrpCCTS, "connect client to server"},
- {TRUE, CsrpInitWin32Csr, "load usermode dll"},
- {TRUE, CsrpRunWinlogon, "run WinLogon"},
-};
-
-/**********************************************************************
- * NAME
- * CsrServerInitialization
- *
- * DESCRIPTION
- * Initialize the Win32 environment subsystem server.
- *
- * RETURN VALUE
- * TRUE: Initialization OK; otherwise FALSE.
- */
-BOOL WINAPI
-CsrServerInitialization (
- int argc,
- char ** argv,
- char ** envp
- )
-{
- UINT i = 0;
- NTSTATUS Status = STATUS_SUCCESS;
-
- DPRINT("CSR: %s called\n", __FUNCTION__);
-
- for (i=0; i < (sizeof InitRoutine / sizeof InitRoutine[0]); i++)
- {
- Status = InitRoutine[i].EntryPoint(argc,argv,envp);
- if(!NT_SUCCESS(Status))
- {
- DPRINT1("CSR: %s: failed to %s (Status=%08lx)\n",
- __FUNCTION__,
- InitRoutine[i].ErrorMessage,
- Status);
- if (InitRoutine[i].Required)
- {
- return FALSE;
- }
- }
- }
- if (CallInitComplete())
- {
- Status = SmCompleteSession (hSmApiPort,hSbApiPort,hApiPort);
- return TRUE;
- }
- return FALSE;
-}
-
-/* EOF */
Removed: trunk/reactos/subsystems/win32/csrss/print.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/pri…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/print.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/print.c (removed)
@@ -1,61 +1,0 @@
-/* $Id$
- *
- * smss.c - Session Manager
- *
- * ReactOS Operating System
- *
- * --------------------------------------------------------------------
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
- *
- * --------------------------------------------------------------------
- *
- * 19990529 (Emanuele Aliberti)
- * Compiled successfully with egcs 1.1.2
- */
-
-#include <csrss.h>
-
-#define NDEBUG
-#include <debug.h>
-
-VOID WINAPI DisplayString(LPCWSTR lpwString)
-{
- UNICODE_STRING us;
-
- RtlInitUnicodeString (&us, lpwString);
- ZwDisplayString (&us);
-}
-
-VOID WINAPI PrintString (char* fmt, ...)
-{
- char buffer[512];
- va_list ap;
- UNICODE_STRING UnicodeString;
- ANSI_STRING AnsiString;
-
- va_start(ap, fmt);
- vsprintf(buffer, fmt, ap);
- va_end(ap);
-
- RtlInitAnsiString (&AnsiString, buffer);
- RtlAnsiStringToUnicodeString (&UnicodeString,
- &AnsiString,
- TRUE);
- NtDisplayString(&UnicodeString);
- RtlFreeUnicodeString (&UnicodeString);
-}
-
-/* EOF */
Removed: trunk/reactos/subsystems/win32/csrss/video.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/subsystems/win32/csrss/vid…
==============================================================================
--- trunk/reactos/subsystems/win32/csrss/video.c [iso-8859-1] (original)
+++ trunk/reactos/subsystems/win32/csrss/video.c (removed)
@@ -1,111 +1,0 @@
-/*
- * PROJECT: ReactOS Client/Server Runtime subsystem
- * LICENSE: GPL v2 or later - See COPYING in the top level directory
- * FILE: subsystems/win32/csrss/video.c
- * PURPOSE: Video memory initialization.
- * PROGRAMMERS: ReactOS Development Team
- */
-
-/* INCLUDES ******************************************************************/
-
-#include <csrss.h>
-
-#define NDEBUG
-#include <debug.h>
-
-/* FUNCTIONS *****************************************************************/
-
-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];
-
- /* 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_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;
-}
-
-/* EOF */