mirror of
https://github.com/reactos/reactos.git
synced 2024-07-06 20:55:16 +00:00
[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. svn path=/trunk/; revision=46051
This commit is contained in:
parent
fc4574d166
commit
1cd9cb22ef
|
@ -670,6 +670,7 @@ boot\bootdata\bootcdregtest\regtest.cmd 7 optional
|
|||
; 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
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <csrss.h>
|
||||
#include <srv.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <csrss.h>
|
||||
#include <srv.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
@ -153,6 +153,65 @@ CsrInsertThread(IN PCSRSS_PROCESS_DATA Process,
|
|||
#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
|
||||
CsrCreateThreadData(IN PCSRSS_PROCESS_DATA CsrProcess,
|
||||
|
@ -933,8 +992,21 @@ CSR_API(CsrCreateThread)
|
|||
|
||||
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;
|
|
@ -11,7 +11,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <csrss.h>
|
||||
#include <srv.h>
|
||||
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
/* INCLUDES ******************************************************************/
|
||||
|
||||
#include <csrss.h>
|
||||
#include <srv.h>
|
||||
|
||||
#define NDEBUG
|
||||
|
20
reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild
Normal file
20
reactos/subsystems/win32/csrss/csrsrv/csrsrv.rbuild
Normal file
|
@ -0,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>
|
5
reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc
Normal file
5
reactos/subsystems/win32/csrss/csrsrv/csrsrv.rc
Normal file
|
@ -0,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>
|
35
reactos/subsystems/win32/csrss/csrsrv/csrsrv.spec
Normal file
35
reactos/subsystems/win32/csrss/csrsrv/csrsrv.spec
Normal file
|
@ -0,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)
|
|
@ -1,47 +1,128 @@
|
|||
/* $Id$
|
||||
*
|
||||
* reactos/subsys/csrss/init.c
|
||||
*
|
||||
* Initialize the CSRSS subsystem server process.
|
||||
*
|
||||
* ReactOS Operating System
|
||||
*
|
||||
/*
|
||||
* 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 <csrss.h>
|
||||
/* INCLUDES *******************************************************************/
|
||||
|
||||
#include "srv.h"
|
||||
#define NDEBUG
|
||||
#include <debug.h>
|
||||
|
||||
/* GLOBALS ******************************************************************/
|
||||
/* 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;
|
||||
|
||||
/**********************************************************************
|
||||
* CsrpAddInitCompleteProc/1
|
||||
*/
|
||||
/* 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)
|
||||
{
|
||||
|
@ -513,48 +594,6 @@ CsrpRegisterSubsystem (int argc, char ** argv, char ** envp)
|
|||
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
|
||||
*/
|
||||
|
@ -565,26 +604,26 @@ CsrpLoadKernelModeDriver (int argc, char ** argv, char ** envp)
|
|||
WCHAR Data [MAX_PATH + 1];
|
||||
ULONG DataLength = sizeof Data;
|
||||
ULONG DataType = 0;
|
||||
UNICODE_STRING Environment;
|
||||
//UNICODE_STRING Environment;
|
||||
|
||||
|
||||
DPRINT("SM: %s called\n", __FUNCTION__);
|
||||
DPRINT1("SM: %s called\n", __FUNCTION__);
|
||||
|
||||
|
||||
EnvpToUnicodeString (envp, & Environment);
|
||||
//EnvpToUnicodeString (envp, & Environment);
|
||||
Status = SmLookupSubsystem (L"Kmode",
|
||||
Data,
|
||||
& DataLength,
|
||||
& DataType,
|
||||
Environment.Buffer);
|
||||
RtlFreeUnicodeString (& Environment);
|
||||
NULL);
|
||||
//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);
|
||||
wcscpy (ImagePath, L"\\??\\c:\\reactos\\system32\\win32k.sys");
|
||||
// wcscat (ImagePath, Data);
|
||||
RtlInitUnicodeString (& ModuleName, ImagePath);
|
||||
Status = NtSetSystemInformation(/* FIXME: SystemLoadAndCallImage */
|
||||
SystemExtendServiceTableInformation,
|
||||
|
@ -592,7 +631,7 @@ CsrpLoadKernelModeDriver (int argc, char ** argv, char ** envp)
|
|||
sizeof ModuleName);
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT("WIN: %s: loading Kmode failed (Status=0x%08lx)\n",
|
||||
DPRINT1("WIN: %s: loading Kmode failed (Status=0x%08lx)\n",
|
||||
__FUNCTION__, Status);
|
||||
}
|
||||
}
|
||||
|
@ -718,22 +757,12 @@ struct {
|
|||
{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
|
||||
)
|
||||
/* PUBLIC FUNCTIONS ***********************************************************/
|
||||
|
||||
NTSTATUS
|
||||
NTAPI
|
||||
CsrServerInitialization(ULONG ArgumentCount,
|
||||
PCHAR Arguments[])
|
||||
{
|
||||
UINT i = 0;
|
||||
NTSTATUS Status = STATUS_SUCCESS;
|
||||
|
@ -742,7 +771,7 @@ CsrServerInitialization (
|
|||
|
||||
for (i=0; i < (sizeof InitRoutine / sizeof InitRoutine[0]); i++)
|
||||
{
|
||||
Status = InitRoutine[i].EntryPoint(argc,argv,envp);
|
||||
Status = InitRoutine[i].EntryPoint(ArgumentCount,Arguments,NULL);
|
||||
if(!NT_SUCCESS(Status))
|
||||
{
|
||||
DPRINT1("CSR: %s: failed to %s (Status=%08lx)\n",
|
||||
|
@ -758,9 +787,23 @@ CsrServerInitialization (
|
|||
if (CallInitComplete())
|
||||
{
|
||||
Status = SmCompleteSession (hSmApiPort,hSbApiPort,hApiPort);
|
||||
return TRUE;
|
||||
return STATUS_SUCCESS;
|
||||
}
|
||||
return FALSE;
|
||||
|
||||
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 */
|
|
@ -1,14 +1,16 @@
|
|||
/* PSDK/NDK Headers */
|
||||
#define NTOS_MODE_USER
|
||||
#include <stdio.h>
|
||||
#define WIN32_NO_STATUS
|
||||
#include <windows.h>
|
||||
#define NTOS_MODE_USER
|
||||
#include <winnt.h>
|
||||
#include <ndk/ntndk.h>
|
||||
|
||||
#include <intrin.h>
|
||||
/* CSR Header */
|
||||
//#include <csr/server.h>
|
||||
|
||||
/* Build Number */
|
||||
#include <reactos/buildno.h>
|
||||
/* PSEH for SEH Support */
|
||||
#include <pseh/pseh2.h>
|
||||
|
||||
/* Subsystem Manager Header */
|
||||
#include <sm/helper.h>
|
||||
|
@ -17,5 +19,3 @@
|
|||
#include <api.h>
|
||||
#include <conio.h>
|
||||
#include <csrplugin.h>
|
||||
|
||||
/* EOF */
|
|
@ -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 */
|
||||
|
|
|
@ -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>
|
||||
|
|
|
@ -13,6 +13,14 @@
|
|||
|
||||
#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
|
||||
{
|
||||
CsrShutdownCsrProcess = 1,
|
||||
|
@ -179,7 +187,7 @@ NTSTATUS FASTCALL CsrRegisterObjectDefinitions(PCSRSS_OBJECT_DEFINITION NewDefin
|
|||
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 );
|
||||
|
|
|
@ -1,61 +0,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 */
|
|
@ -1,111 +0,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 */
|
Loading…
Reference in a new issue