From fa81b6d26051f10db30a5c8f34bf23d4505e8de0 Mon Sep 17 00:00:00 2001 From: Eric Kohl Date: Sun, 27 Feb 2000 02:12:07 +0000 Subject: [PATCH] Improved csrss (doesn't crash any more) Improved kernel debugger code Various minor improvements svn path=/trunk/; revision=1015 --- reactos/include/csrss/csrss.h | 12 ++- reactos/include/ntdll/csr.h | 33 +++++++ reactos/include/ntdll/rtl.h | 9 +- reactos/lib/kernel32/internal/dprintf.c | 12 +-- reactos/lib/kernel32/internal/init.c | 12 --- reactos/lib/kernel32/misc/dllmain.c | 51 +++++------ reactos/lib/ntdll/csr/api.c | 23 ++++- reactos/lib/ntdll/def/ntdll.def | 5 +- reactos/lib/ntdll/def/ntdll.edf | 6 +- reactos/lib/ntdll/ldr/startup.c | 37 ++++---- reactos/lib/ntdll/rtl/heap.c | 3 +- reactos/ntoskrnl/dbg/print.c | 15 ++- reactos/ntoskrnl/hal/x86/kdbg.c | 16 +++- reactos/ntoskrnl/kd/kdebug.c | 13 +-- reactos/ntoskrnl/kd/service.c | 9 +- reactos/ntoskrnl/ke/main.c | 3 +- reactos/ntoskrnl/ntoskrnl.def | 117 +++++++++++++++++++++++- reactos/ntoskrnl/ntoskrnl.edf | 16 +++- reactos/subsys/csrss/api.h | 2 + reactos/subsys/csrss/api/process.c | 19 +++- reactos/subsys/csrss/api/wapi.c | 8 +- reactos/subsys/csrss/csrss.c | 77 +++++++++++++--- reactos/subsys/csrss/init.c | 70 +++++++++++++- reactos/subsys/csrss/makefile | 23 ++++- 24 files changed, 455 insertions(+), 136 deletions(-) create mode 100644 reactos/include/ntdll/csr.h delete mode 100644 reactos/lib/kernel32/internal/init.c diff --git a/reactos/include/csrss/csrss.h b/reactos/include/csrss/csrss.h index bff68bd6852..9ab31f49908 100644 --- a/reactos/include/csrss/csrss.h +++ b/reactos/include/csrss/csrss.h @@ -33,9 +33,11 @@ typedef struct ULONG Flags; } CSRSS_CREATE_PROCESS_REQUEST, *PCSRSS_CREATE_PROCESS_REQUEST; -/* - * lib/ntdll/csr/api.c - */ -NTSTATUS CsrConnectToServer(VOID); +BOOL +STDCALL +CsrServerInitialization ( + ULONG ArgumentCount, + PWSTR *ArgumentArray + ); -#endif +#endif /* __INCLUDE_CSRSS_CSRSS_H */ diff --git a/reactos/include/ntdll/csr.h b/reactos/include/ntdll/csr.h new file mode 100644 index 00000000000..e31d7a8e7a1 --- /dev/null +++ b/reactos/include/ntdll/csr.h @@ -0,0 +1,33 @@ +/* $Id: csr.h,v 1.1 2000/02/27 02:01:24 ekohl Exp $ + * + */ + +#ifndef __INCLUDE_NTDLL_CSR_H +#define __INCLUDE_NTDLL_CSR_H + + +/* +NTSTATUS +STDCALL +CsrClientCallServer ( + ULONG Unknown1, + ULONG Unknown2, + ULONG Unknown3, + ULONG Unknown4 + ); +*/ + +NTSTATUS +STDCALL +CsrClientConnectToServer ( + ULONG Unknown1, + ULONG Unknown2, + ULONG Unknown3, + ULONG Unknown4, + ULONG Unknown5, + ULONG Unknown6 + ); + +#endif /* __INCLUDE_NTDLL_CSR_H */ + +/* EOF */ diff --git a/reactos/include/ntdll/rtl.h b/reactos/include/ntdll/rtl.h index a9df15d4004..cac310a77f8 100644 --- a/reactos/include/ntdll/rtl.h +++ b/reactos/include/ntdll/rtl.h @@ -1,7 +1,9 @@ -/* $Id: rtl.h,v 1.11 2000/02/25 23:57:21 ekohl Exp $ +/* $Id: rtl.h,v 1.12 2000/02/27 02:01:24 ekohl Exp $ * */ +#ifndef __INCLUDE_NTDLL_RTL_H +#define __INCLUDE_NTDLL_RTL_H /* * Preliminary data type!! @@ -23,9 +25,6 @@ typedef struct _RTL_USER_PROCESS_INFO } RTL_USER_PROCESS_INFO, *PRTL_USER_PROCESS_INFO; -//VOID WINAPI __RtlInitHeap(PVOID base, -// ULONG minsize, -// ULONG maxsize); #define HEAP_BASE (0xa0000000) @@ -242,4 +241,6 @@ RtlNormalizeProcessParams ( IN OUT PRTL_USER_PROCESS_PARAMETERS ProcessParameters ); +#endif /* __INCLUDE_NTDLL_RTL_H */ + /* EOF */ diff --git a/reactos/lib/kernel32/internal/dprintf.c b/reactos/lib/kernel32/internal/dprintf.c index b5d46f14499..4b9342e60ee 100644 --- a/reactos/lib/kernel32/internal/dprintf.c +++ b/reactos/lib/kernel32/internal/dprintf.c @@ -3,14 +3,14 @@ #include #include -ULONG DbgService( ULONG Service, PVOID Context1, PVOID Context2 ); +/* + * NOTE: Don't call DbgService()! + * It's a ntdll internal function and is NOT exported! + */ VOID STDCALL OutputDebugStringA(LPCSTR lpOutputString) { - ANSI_STRING AnsiString; - AnsiString.Buffer = lpOutputString; - AnsiString.Length = AnsiString.MaximumLength = lstrlenA( lpOutputString ); - DbgService( 1, &AnsiString, NULL ); + DbgPrint( (PSTR)lpOutputString ); } VOID STDCALL OutputDebugStringW(LPCWSTR lpOutputString) @@ -28,7 +28,7 @@ VOID STDCALL OutputDebugStringW(LPCWSTR lpOutputString) if( UnicodeOutput.Length > 512 ) UnicodeOutput.Length = 512; if( NT_SUCCESS( RtlUnicodeStringToAnsiString( &AnsiString, &UnicodeOutput, FALSE ) ) ) - DbgService( 1, &AnsiString, NULL ); + DbgPrint( AnsiString.Buffer ); } diff --git a/reactos/lib/kernel32/internal/init.c b/reactos/lib/kernel32/internal/init.c deleted file mode 100644 index b647b658f29..00000000000 --- a/reactos/lib/kernel32/internal/init.c +++ /dev/null @@ -1,12 +0,0 @@ -#include -#include -#include - -#include - - -VOID KERNEL32_Init() -{ - DPRINT("KERNEL32_Init()\n"); - __HeapInit(0, 4*1024*1024, 4*1024*1024); -} diff --git a/reactos/lib/kernel32/misc/dllmain.c b/reactos/lib/kernel32/misc/dllmain.c index 6891e2a6014..0f03af02e98 100644 --- a/reactos/lib/kernel32/misc/dllmain.c +++ b/reactos/lib/kernel32/misc/dllmain.c @@ -1,4 +1,5 @@ -/* +/* $Id: dllmain.c,v 1.10 2000/02/27 02:04:06 ekohl Exp $ + * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS system libraries * FILE: lib/kernel32/misc/dllmain.c @@ -9,15 +10,14 @@ */ #include +#include #include #include -#include -#include #define NDEBUG #include -WINBOOL STDCALL DllMain (HANDLE hInst, +WINBOOL STDCALL DllMain (HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved); @@ -28,44 +28,43 @@ BOOL WINAPI DllMainCRTStartup(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) return(DllMain(hDll,dwReason,lpReserved)); } -VOID WINAPI __HeapInit(LPVOID base, ULONG minsize, ULONG maxsize); - -WINBOOL STDCALL DllMain(HANDLE hInst, +WINBOOL STDCALL DllMain(HANDLE hInst, ULONG ul_reason_for_call, LPVOID lpReserved) { DPRINT("DllMain(hInst %x, ul_reason_for_call %d)\n", hInst, ul_reason_for_call); - switch (ul_reason_for_call) + + switch (ul_reason_for_call) { case DLL_PROCESS_ATTACH: - { - DPRINT("DLL_PROCESS_ATTACH\n"); - AllocConsole(); - break; - } - case DLL_THREAD_ATTACH: { - // Teb = HeapAlloc(GetProcessHeap(),0,sizeof(NT_TEB)); - // Teb->Peb = GetCurrentPeb(); - // Teb->HardErrorMode = SEM_NOGPFAULTERRORBOX; - // Teb->dwTlsIndex=0; + NTSTATUS Status; + DPRINT("DLL_PROCESS_ATTACH\n"); + + /* + * + */ + Status = CsrClientConnectToServer(0,0,0,0,0,0); + if (!NT_SUCCESS(Status)) + { + DbgPrint("Failed to connect to csrss.exe: expect trouble\n"); + /* return FALSE; */ + } + + AllocConsole(); break; } case DLL_PROCESS_DETACH: { -// HeapFree(GetProcessHeap(),0,Teb); + DPRINT("DLL_PROCESS_DETACH\n"); HeapDestroy(NtCurrentPeb()->ProcessHeap); break; } - case DLL_THREAD_DETACH: - { - // HeapFree(GetProcessHeap(),0,Teb); - break; - } default: break; - } - return TRUE; + return TRUE; } + +/* EOF */ \ No newline at end of file diff --git a/reactos/lib/ntdll/csr/api.c b/reactos/lib/ntdll/csr/api.c index 84e2931d565..2871ee2ac31 100644 --- a/reactos/lib/ntdll/csr/api.c +++ b/reactos/lib/ntdll/csr/api.c @@ -1,4 +1,4 @@ -/* $Id: api.c,v 1.2 1999/12/30 01:51:38 dwelch Exp $ +/* $Id: api.c,v 1.3 2000/02/27 02:05:06 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -9,6 +9,7 @@ /* INCLUDES *****************************************************************/ #include +#include #include #include @@ -22,8 +23,12 @@ static HANDLE WindowsApiPort; /* FUNCTIONS *****************************************************************/ -NTSTATUS CsrClientCallServer(PCSRSS_API_REQUEST Request, - PCSRSS_API_REPLY Reply) +NTSTATUS +STDCALL +CsrClientCallServer(PCSRSS_API_REQUEST Request, + PCSRSS_API_REPLY Reply, + ULONG Unknown3, + ULONG Unknown4) { LPCMESSAGE LpcRequest; LPCMESSAGE LpcReply; @@ -39,7 +44,14 @@ NTSTATUS CsrClientCallServer(PCSRSS_API_REQUEST Request, return(Status); } -NTSTATUS CsrConnectToServer(VOID) +NTSTATUS +STDCALL +CsrClientConnectToServer(ULONG Unknown1, + ULONG Unknown2, + ULONG Unknown3, + ULONG Unknown4, + ULONG Unknown5, + ULONG Unknown6) { NTSTATUS Status; UNICODE_STRING PortName; @@ -64,7 +76,8 @@ NTSTATUS CsrConnectToServer(VOID) Request.Type = CSRSS_CONNECT_PROCESS; Status = CsrClientCallServer(&Request, - &Reply); + &Reply, + 0, 0); if (!NT_SUCCESS(Status)) { return(Status); diff --git a/reactos/lib/ntdll/def/ntdll.def b/reactos/lib/ntdll/def/ntdll.def index 434bc0ba8cb..45013858e09 100644 --- a/reactos/lib/ntdll/def/ntdll.def +++ b/reactos/lib/ntdll/def/ntdll.def @@ -1,13 +1,14 @@ -; $Id: ntdll.def,v 1.41 2000/02/21 22:37:24 ekohl Exp $ +; $Id: ntdll.def,v 1.42 2000/02/27 02:05:40 ekohl Exp $ ; ; ReactOS Operating System ; LIBRARY ntdll.dll EXPORTS +CsrClientCallServer@16 +CsrClientConnectToServer@24 DbgBreakPoint DbgPrint -DbgService DbgUserBreakPoint NlsAnsiCodePage NlsMbCodePageTag diff --git a/reactos/lib/ntdll/def/ntdll.edf b/reactos/lib/ntdll/def/ntdll.edf index 72cc8bd8616..46ecf011ba4 100644 --- a/reactos/lib/ntdll/def/ntdll.edf +++ b/reactos/lib/ntdll/def/ntdll.edf @@ -1,10 +1,12 @@ -; $Id: ntdll.edf,v 1.30 2000/02/18 00:48:50 ekohl Exp $ +; $Id: ntdll.edf,v 1.31 2000/02/27 02:05:40 ekohl Exp $ ; ; ReactOS Operating System ; LIBRARY ntdll.dll EXPORTS +CsrClientCallServer=CsrClientCallServer@16 +CsrClientConnectToServer=CsrClientConnectToServer@24 DbgBreakPoint DbgPrint DbgUserBreakPoint @@ -658,5 +660,3 @@ LdrLoadDll LdrUnloadDll LdrAccessResource LdrFindResource_U -;RtlCopyMemory=RtlCopyMemory@12 -DbgService diff --git a/reactos/lib/ntdll/ldr/startup.c b/reactos/lib/ntdll/ldr/startup.c index 809b466123c..1daddd410fb 100644 --- a/reactos/lib/ntdll/ldr/startup.c +++ b/reactos/lib/ntdll/ldr/startup.c @@ -1,4 +1,4 @@ -/* $Id: startup.c,v 1.19 2000/02/25 00:35:06 ekohl Exp $ +/* $Id: startup.c,v 1.20 2000/02/27 02:05:53 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -29,7 +29,6 @@ DLL LdrDllListHead; extern unsigned int _image_base__; -extern HANDLE __ProcessHeap; /* FUNCTIONS *****************************************************************/ @@ -53,7 +52,6 @@ VOID LdrStartup(VOID) LdrDllListHead.Headers = (PIMAGE_NT_HEADERS)(LdrDllListHead.BaseAddress + PEDosHeader->e_lfanew); - Peb = (PPEB)(PEB_BASE); DPRINT("Peb %x\n", Peb); ImageBase = Peb->ImageBaseAddress; @@ -79,30 +77,27 @@ VOID LdrStartup(VOID) RtlNormalizeProcessParams (Peb->ProcessParameters); NTHeaders = (PIMAGE_NT_HEADERS)(ImageBase + PEDosHeader->e_lfanew); - __ProcessHeap = RtlCreateHeap(0, - (PVOID)HEAP_BASE, - NTHeaders->OptionalHeader.SizeOfHeapCommit, - NTHeaders->OptionalHeader.SizeOfHeapReserve, - NULL, - NULL); - Peb->ProcessHeap = __ProcessHeap; - EntryPoint = LdrPEStartup((PVOID)ImageBase, NULL); + /* create process heap */ + Peb->ProcessHeap = RtlCreateHeap(0, + (PVOID)HEAP_BASE, + NTHeaders->OptionalHeader.SizeOfHeapCommit, + NTHeaders->OptionalHeader.SizeOfHeapReserve, + NULL, + NULL); + if (Peb->ProcessHeap == 0) + { + DbgPrint("Failed to create process heap\n"); + ZwTerminateProcess(NtCurrentProcess(),STATUS_UNSUCCESSFUL); + } + + EntryPoint = LdrPEStartup((PVOID)ImageBase, NULL); if (EntryPoint == NULL) { DbgPrint("Failed to initialize image\n"); ZwTerminateProcess(NtCurrentProcess(),STATUS_UNSUCCESSFUL); } - - /* - * - */ - Status = CsrConnectToServer(); - if (!NT_SUCCESS(Status)) - { - DbgPrint("Failed to connect to csrss.exe: expect trouble\n"); - } - + DbgPrint("Transferring control to image at %x\n",EntryPoint); Status = EntryPoint(Peb); ZwTerminateProcess(NtCurrentProcess(),Status); diff --git a/reactos/lib/ntdll/rtl/heap.c b/reactos/lib/ntdll/rtl/heap.c index fe8ccd039cd..665094ab6b5 100644 --- a/reactos/lib/ntdll/rtl/heap.c +++ b/reactos/lib/ntdll/rtl/heap.c @@ -88,7 +88,6 @@ typedef struct tagHEAP #define HEAP_DEF_SIZE 0x110000 /* Default heap size = 1Mb + 64Kb */ #define HEAP_MIN_BLOCK_SIZE (8+sizeof(ARENA_FREE)) /* Min. heap block size */ -HANDLE __ProcessHeap = 0; /*********************************************************************** * HEAP_Dump @@ -1268,6 +1267,6 @@ BOOL WINAPI RtlValidateHeap( HANDLE WINAPI RtlGetProcessHeap(VOID) { DPRINT("RtlGetProcessHeap()\n"); - return (HANDLE) __ProcessHeap; + return (HANDLE)NtCurrentPeb()->ProcessHeap; } diff --git a/reactos/ntoskrnl/dbg/print.c b/reactos/ntoskrnl/dbg/print.c index 402bc4d25f1..77020af4d37 100644 --- a/reactos/ntoskrnl/dbg/print.c +++ b/reactos/ntoskrnl/dbg/print.c @@ -1,4 +1,4 @@ -/* $Id: print.c,v 1.7 2000/02/13 16:05:17 dwelch Exp $ +/* $Id: print.c,v 1.8 2000/02/27 02:08:33 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,10 +13,12 @@ #include #include +#include /* FUNCTIONS ****************************************************************/ +#if 0 ULONG DbgService (ULONG Service, PVOID Context1, PVOID Context2); __asm__ ("\n\t.global _DbgService\n\t" "_DbgService:\n\t" @@ -25,6 +27,13 @@ __asm__ ("\n\t.global _DbgService\n\t" "mov 12(%esp), %edx\n\t" "int $0x2D\n\t" "ret\n\t"); +#endif + +/* + * Note: DON'T CHANGE THIS FUNCTION!!! + * DON'T CALL HalDisplayString OR SOMETING ELSE!!! + * You'll only break the serial/bochs debugging feature!!! + */ ULONG DbgPrint(PCH Format, ...) { @@ -40,8 +49,8 @@ ULONG DbgPrint(PCH Format, ...) DebugString.Length = vsprintf (Buffer, Format, ap); va_end (ap); - HalDisplayString(Buffer); - + KdpPrintString (&DebugString); + return (ULONG)DebugString.Length; } diff --git a/reactos/ntoskrnl/hal/x86/kdbg.c b/reactos/ntoskrnl/hal/x86/kdbg.c index 66a748466a8..64fd32582cb 100644 --- a/reactos/ntoskrnl/hal/x86/kdbg.c +++ b/reactos/ntoskrnl/hal/x86/kdbg.c @@ -1,4 +1,4 @@ -/* $Id: kdbg.c,v 1.5 2000/02/26 22:41:35 ea Exp $ +/* $Id: kdbg.c,v 1.6 2000/02/27 02:08:53 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -47,6 +47,7 @@ #define SR_MCR_DTR 0x01 #define SR_MCR_RTS 0x02 #define SER_LSR(x) ((x)+5) +#define SR_LSR_DR 0x01 #define SR_LSR_TBE 0x20 #define SER_MSR(x) ((x)+6) #define SR_MSR_CTS 0x10 @@ -264,7 +265,10 @@ KdPortGetByte ( if (PortInitialized == FALSE) return 0; - return (BYTE) 0; + if ((READ_PORT_UCHAR (SER_LSR(PortBase)) & SR_LSR_DR)) + return (BYTE)READ_PORT_UCHAR (SER_RBR(PortBase)); + + return 0; } @@ -275,7 +279,13 @@ KdPortPollByte ( VOID ) { - return (BYTE) 0; + if (PortInitialized == FALSE) + return 0; + + while ((READ_PORT_UCHAR (SER_LSR(PortBase)) & SR_LSR_DR) == 0) + ; + + return (BYTE)READ_PORT_UCHAR (SER_RBR(PortBase)); } diff --git a/reactos/ntoskrnl/kd/kdebug.c b/reactos/ntoskrnl/kd/kdebug.c index bc7420ed742..d50cd1c6b12 100644 --- a/reactos/ntoskrnl/kd/kdebug.c +++ b/reactos/ntoskrnl/kd/kdebug.c @@ -1,4 +1,4 @@ -/* $Id: kdebug.c,v 1.5 2000/02/26 22:41:35 ea Exp $ +/* $Id: kdebug.c,v 1.6 2000/02/27 02:09:40 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -48,15 +48,8 @@ /* VARIABLES ***************************************************************/ -//BYTE STDCALL KdPortPollByte(VOID); - -/* DATA */ - -BOOLEAN -KdDebuggerEnabled = FALSE; - -BOOLEAN -KdDebuggerNotPresent = TRUE; +BOOLEAN KdDebuggerEnabled = FALSE; /* EXPORTED */ +BOOLEAN KdDebuggerNotPresent = TRUE; /* EXPORTED */ /* PRIVATE FUNCTIONS ********************************************************/ diff --git a/reactos/ntoskrnl/kd/service.c b/reactos/ntoskrnl/kd/service.c index e43953882f0..02c27645c8a 100644 --- a/reactos/ntoskrnl/kd/service.c +++ b/reactos/ntoskrnl/kd/service.c @@ -1,4 +1,4 @@ -/* $Id: service.c,v 1.1 2000/01/17 21:02:06 ekohl Exp $ +/* $Id: service.c,v 1.2 2000/02/27 02:09:40 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -15,6 +15,12 @@ /* FUNCTIONS ***************************************************************/ +/* + * Note: DON'T CHANGE THIS FUNCTION!!! + * DON'T CALL HalDisplayString OR SOMETING ELSE!!! + * You'll only break the serial/bochs debugging feature!!! + */ + ULONG KdpServiceDispatcher ( ULONG Service, @@ -27,7 +33,6 @@ KdpServiceDispatcher ( { case 1: /* DbgPrint */ Result = KdpPrintString ((PANSI_STRING)Context1); -// HalDisplayString (((PANSI_STRING)Context1)->Buffer); break; default: diff --git a/reactos/ntoskrnl/ke/main.c b/reactos/ntoskrnl/ke/main.c index c57d9cc9d13..956d16a7508 100644 --- a/reactos/ntoskrnl/ke/main.c +++ b/reactos/ntoskrnl/ke/main.c @@ -1,4 +1,4 @@ -/* $Id: main.c,v 1.36 2000/02/26 22:41:35 ea Exp $ +/* $Id: main.c,v 1.37 2000/02/27 02:10:09 ekohl Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -17,7 +17,6 @@ #include #include #include -#include #include #include #include diff --git a/reactos/ntoskrnl/ntoskrnl.def b/reactos/ntoskrnl/ntoskrnl.def index 13280be8d4b..12a5f06a67d 100644 --- a/reactos/ntoskrnl/ntoskrnl.def +++ b/reactos/ntoskrnl/ntoskrnl.def @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.def,v 1.46 2000/02/26 22:41:34 ea Exp $ +; $Id: ntoskrnl.def,v 1.47 2000/02/27 02:08:12 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -155,6 +155,9 @@ IoStartNextPacket IoStartNextPacketByKey IoStartTimer IoStopTimer +KdDebuggerEnabled DATA +KdDebuggerNotPresent DATA +KdPollBreakIn@0 KeAddSystemServiceTable KeBugCheck KeBugCheckEx @@ -236,6 +239,12 @@ READ_REGISTER_USHORT READ_REGISTER_BUFFER_UCHAR READ_REGISTER_BUFFER_ULONG READ_REGISTER_BUFFER_USHORT +;RtlAbsoluteToSelfRelativeSD +;RtlAddAccessAllowedAce +;RtlAddAce +;RtlAddAtomToAtomTable +;RtlAllocateAndInitializeSid +;RtlAllocateHeap RtlAnsiCharToUnicodeChar@4 RtlAnsiStringToUnicodeSize@4 RtlAnsiStringToUnicodeString@12 @@ -243,21 +252,56 @@ RtlAppendAsciizToString@8 RtlAppendStringToString@8 RtlAppendUnicodeStringToString@8 RtlAppendUnicodeToString@8 +;RtlAreAllAccessesGranted +;RtlAreAnyAccessesGranted +;RtlAreBitsClear +;RtlAreBitsSet +;RtlAssert +;RtlCaptureStackBackTrace RtlCharToInteger@12 +;RtlCheckRegistryKey +;RtlClearAllBits +;RtlClearBits RtlCompareMemory@12 +RtlCompareMemoryUlong@12 RtlCompareString@12 RtlCompareUnicodeString@12 +;RtlCompressBuffer +;RtlCompressChunks RtlConvertLongToLargeInteger@4 +;RtlConvertSidToUnicodeString RtlConvertUlongToLargeInteger@4 RtlCopyLuid@8 +RtlCopySid@12 RtlCopyString@8 RtlCopyUnicodeString@8 +;RtlCreateAcl +;RtlCreateAtomTable +;RtlCreateHeap +;RtlCreateRegistryKey +;RtlCreateSecurityDescriptor RtlCreateUnicodeString@8 +;RtlCustomCPToUnicodeN +;RtlDecompressBuffer +;RtlDecompressChunks +;RtlDecompressFragment +;RtlDelete +;RtlDeleteAtomFromAtomTable +;RtlDeleteElementGenericTable +;RtlDeleteNoSplay +;RtlDeleteRegisterValue +;RtlDescribeChunk +;RtlDestroyAtomTable +;RtlDestroyHeap RtlDowncaseUnicodeString@12 +;RtlEmptyAtomTable RtlEnlargedIntegerMultiply@8 RtlEnlargedUnsignedDivide@16 RtlEnlargedUnsignedMultiply@8 +;RtlEnumerateGenericTable +;RtlEnumerateGenericTableWithoutSplaying RtlEqualLuid@8 +RtlEqualSid@8 RtlEqualString@12 RtlEqualUnicodeString@12 RtlExtendedIntegerMultiply@12 @@ -265,15 +309,43 @@ RtlExtendedLargeIntegerDivide@16 RtlExtendedMagicDivide@20 RtlFillMemory@12 RtlFillMemoryUlong@12 +;RtlFindClearBits +;RtlFindClearBitsAndSet +;RtlFindFirstRunClear +;RtlFindFirstRunSet +;RtlFindLongestRunClear +;RtlFindLongestRunSet +;RtlFindMessage +;RtlFindSetBits +;RtlFindSetBitsAndClear +;RtlFindUnicodePrefix +;RtlFormatCurrentUserKeyPath RtlFreeAnsiString@4 +;RtlFreeHeap RtlFreeOemString@4 RtlFreeUnicodeString@4 +;RtlGenerate8dot3Name +;RtlGetCallersAddress +;RtlGetCompressionWorkSpaceSize +;RtlGetDaclSecurityDescriptor RtlGetDefaultCodePage@8 +;RtlGetElementGenericTable +;RtlGetGroupSecurityDescriptor +;RtlGetOwnerSecurityDescriptor +;RtlImageNtHeader@4 RtlInitAnsiString@8 +;RtlInitCodePageTable RtlInitString@8 RtlInitUnicodeString@8 +;RtlInitializeBitmap +;RtlInitializeGenericTable +RtlInitializeSid@12 +;RtlInitializeUnicodePrefix +;RtlInsertElementGenericTable +;RtlInsertUnicodePrefix RtlIntegerToChar@16 RtlIntegerToUnicodeString@12 +;RtlIsNamelegalDOS8Dot3 RtlLargeIntegerAdd@16 RtlLargeIntegerArithmeticShift@12 RtlLargeIntegerDivide@20 @@ -281,34 +353,76 @@ RtlLargeIntegerNegate@8 RtlLargeIntegerShiftLeft@12 RtlLargeIntegerShiftRight@12 RtlLargeIntegerSubtract@16 +RtlLengthRequiredSid@4 +;RtlLengthRequiredSecurityDescriptor +RtlLengthSid@4 +;RtlLookupAtomInAtomTable +;RtlLookupElementGenericTable +;RtlMapGenericMask RtlMoveMemory@12 RtlMultiByteToUnicodeN@20 RtlMultiByteToUnicodeSize@12 +;RtlNextUnicodePrefix +;RtlNtStatusToDosError +;RtlNtStatusToDosErrorNoTeb +;RtlNumberGenericTableElements +;RtlNumberOfClearBits +;RtlNumberOfSetBits +;RtlOemStringToCountedUnicodeString RtlOemStringToUnicodeSize@4 RtlOemStringToUnicodeString@12 RtlOemToUnicodeN@20 +;RtlPinAtomInAtomTable +;RtlPrefixString +;RtlPrefixUnicodeString +;RtlQueryAtominAtomTable +;RtlQueryRegistryValues +;RtlQueryTimeZoneInformation +;RtlRaiseException +;RtlRandom +;RtlRemoveUnicodePrefix +;RtlReserveChunk RtlSecondsSince1970ToTime@8 RtlSecondsSince1980ToTime@8 +;RtlSetAllBits +;RtlSetBits +;RtlSetDaclSecurityDescriptor +;RtlSetGroupSecurityDescriptor +;RtlSetOwnerSecurityDescriptor +;RtlSetSaclSecurityDescriptor +;RtlSetTimeZoneInformation +;RtlSplay +RtlSubAuthorityCountSid@4 +RtlSubAuthoritySid@8 RtlTimeFieldsToTime@8 RtlTimeToSecondsSince1970@8 RtlTimeToSecondsSince1980@8 RtlTimeToTimeFields@8 RtlUnicodeStringToAnsiSize@4 RtlUnicodeStringToAnsiString@12 +;RtlUnicodeStringToCountedOemString RtlUnicodeStringToInteger@12 RtlUnicodeStringToOemSize@4 RtlUnicodeStringToOemString@12 +;RtlUnicodeToCustomCPN RtlUnicodeToMultiByteN@20 RtlUnicodeToMultiByteSize@12 RtlUnicodeToOemN@20 +;RtlUnwind RtlUpcaseUnicodeChar@4 RtlUpcaseUnicodeString@12 RtlUpcaseUnicodeStringToAnsiString@12 +;RtlUpcaseUnicodeStringToCountedOemString RtlUpcaseUnicodeStringToOemString@12 +;RtlUpcaseUnicodeToCustomCPN RtlUpcaseUnicodeToMultiByteN@20 RtlUpcaseUnicodeToOemN@20 RtlUpperChar@4 RtlUpperString@8 +;RtlValidSecurityDescriptor +RtlValidSid@4 +;RtlWriteRegistryValue +;RtlZeroHeap RtlZeroMemory@8 RtlxAnsiStringToUnicodeSize@4 RtlxOemStringToUnicodeSize@4 @@ -539,7 +653,6 @@ HalSetRealTimeClock ;IoSetPartitionInformation ;IoWritePartitionTable KdComPortInUse DATA -KdPollBreakIn@0 KdPortGetByte@0 KdPortInitialize@12 KdPortPollByte@0 diff --git a/reactos/ntoskrnl/ntoskrnl.edf b/reactos/ntoskrnl/ntoskrnl.edf index aa57a92d1b5..2e76a8a4447 100644 --- a/reactos/ntoskrnl/ntoskrnl.edf +++ b/reactos/ntoskrnl/ntoskrnl.edf @@ -1,4 +1,4 @@ -; $Id: ntoskrnl.edf,v 1.33 2000/02/26 22:41:34 ea Exp $ +; $Id: ntoskrnl.edf,v 1.34 2000/02/27 02:08:12 ekohl Exp $ ; ; reactos/ntoskrnl/ntoskrnl.def ; @@ -155,6 +155,9 @@ IoStartNextPacket IoStartNextPacketByKey IoStartTimer IoStopTimer +KdDebuggerEnabled DATA +KdDebuggerNotPresent DATA +KdPollBreakIn=KdPollBreakIn@0 KeAddSystemServiceTable KeBugCheck KeBugCheckEx @@ -245,11 +248,13 @@ RtlAppendUnicodeStringToString=RtlAppendUnicodeStringToString@8 RtlAppendUnicodeToString=RtlAppendUnicodeToString@8 RtlCharToInteger=RtlCharToInteger@12 RtlCompareMemory=RtlCompareMemory@12 +RtlCompareMemoryUlong=RtlCompareMemoryUlong@12 RtlCompareString=RtlCompareString@12 RtlCompareUnicodeString=RtlCompareUnicodeString@12 RtlConvertLongToLargeInteger=RtlConvertLongToLargeInteger@4 RtlConvertUlongToLargeInteger=RtlConvertUlongToLargeInteger@4 RtlCopyLuid=RtlCopyLuid@8 +RtlCopySid=RtlCopySid@12 RtlCopyString=RtlCopyString@8 RtlCopyUnicodeString=RtlCopyUnicodeString@8 RtlCreateUnicodeString=RtlCreateUnicodeString@8 @@ -258,6 +263,7 @@ RtlEnlargedIntegerMultiply=RtlEnlargedIntegerMultiply@8 RtlEnlargedUnsignedDivide=RtlEnlargedUnsignedDivide@16 RtlEnlargedUnsignedMultiply=RtlEnlargedUnsignedMultiply@8 RtlEqualLuid=RtlEqualLuid@8 +RtlEqualSid=RtlEqualSid@8 RtlEqualString=RtlEqualString@12 RtlEqualUnicodeString=RtlEqualUnicodeString@12 RtlExtendedIntegerMultiply=RtlExtendedIntegerMultiply@12 @@ -269,9 +275,11 @@ RtlFreeAnsiString=RtlFreeAnsiString@4 RtlFreeOemString=RtlFreeOemString@4 RtlFreeUnicodeString=RtlFreeUnicodeString@4 RtlGetDefaultCodePage=RtlGetDefaultCodePage@8 +;RtlImageNtHeader=RtlImageNtHeader@4 RtlInitAnsiString=RtlInitAnsiString@8 RtlInitString=RtlInitString@8 RtlInitUnicodeString=RtlInitUnicodeString@8 +RtlInitializeSid=RtlInitializeSid@12 RtlIntegerToChar=RtlIntegerToChar@16 RtlIntegerToUnicodeString=RtlIntegerToUnicodeString@12 RtlLargeIntegerAdd=RtlLargeIntegerAdd@16 @@ -281,6 +289,8 @@ RtlLargeIntegerNegate=RtlLargeIntegerNegate@8 RtlLargeIntegerShiftLeft=RtlLargeIntegerShiftLeft@12 RtlLargeIntegerShiftRight=RtlLargeIntegerShiftRight@12 RtlLargeIntegerSubtract=RtlLargeIntegerSubtract@16 +RtlLengthRequiredSid=RtlLengthRequiredSid@4 +RtlLengthSid=RtlLengthSid@4 RtlMoveMemory=RtlMoveMemory@12 RtlMultiByteToUnicodeN=RtlMultiByteToUnicodeN@20 RtlMultiByteToUnicodeSize=RtlMultiByteToUnicodeSize@12 @@ -288,6 +298,8 @@ RtlOemStringToUnicodeSize=RtlOemStringToUnicodeSize@4 RtlOemStringToUnicodeString=RtlOemStringToUnicodeString@12 RtlSecondsSince1970ToTime=RtlSecondsSince1970ToTime@8 RtlSecondsSince1980ToTime=RtlSecondsSince1980ToTime@8 +RtlSubAuthorityCountSid=RtlSubAuthorityCountSid@4 +RtlSubAuthoritySid=RtlSubAuthoritySid@8 RtlTimeFieldsToTime=RtlTimeFieldsToTime@8 RtlTimeToSecondsSince1970=RtlTimeToSecondsSince1970@8 RtlTimeToSecondsSince1980=RtlTimeToSecondsSince1980@8 @@ -307,6 +319,7 @@ RtlUpcaseUnicodeToMultiByteN=RtlUpcaseUnicodeToMultiByteN@20 RtlUpcaseUnicodeToOemN=RtlUpcaseUnicodeToOemN@20 RtlUpperChar=RtlUpperChar@4 RtlUpperString=RtlUpperString@8 +RtlValidSid=RtlValidSid@4 RtlZeroMemory=RtlZeroMemory@8 RtlxAnsiStringToUnicodeSize=RtlxAnsiStringToUnicodeSize@4 RtlxOemStringToUnicodeSize=RtlxOemStringToUnicodeSize@4 @@ -537,7 +550,6 @@ HalSetRealTimeClock ;IoSetPartitionInformation ;IoWritePartitionTable KdComPortInUse DATA -KdPollBreakIn=KdPollBreakIn@0 KdPortGetByte=KdPortGetByte@0 KdPortInitialize=KdPortInitialize@12 KdPortPollByte=KdPortPollByte@0 diff --git a/reactos/subsys/csrss/api.h b/reactos/subsys/csrss/api.h index df7bc9feeb8..6f34273d641 100644 --- a/reactos/subsys/csrss/api.h +++ b/reactos/subsys/csrss/api.h @@ -21,6 +21,8 @@ typedef struct ULONG ProcessId; } CSRSS_PROCESS_DATA, *PCSRSS_PROCESS_DATA; +VOID CsrInitProcessData(VOID); + NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST LpcMessage); diff --git a/reactos/subsys/csrss/api/process.c b/reactos/subsys/csrss/api/process.c index 58be7d3b977..e8bb7ffc5c4 100644 --- a/reactos/subsys/csrss/api/process.c +++ b/reactos/subsys/csrss/api/process.c @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.4 1999/12/30 01:51:42 dwelch Exp $ +/* $Id: process.c,v 1.5 2000/02/27 02:12:07 ekohl Exp $ * * reactos/subsys/csrss/api/process.c * @@ -22,13 +22,24 @@ static PCSRSS_PROCESS_DATA ProcessData[256]; /* FUNCTIONS *****************************************************************/ +VOID CsrInitProcessData(VOID) +{ + ULONG i; + + for (i=0; i<256; i++) + { + ProcessData[i] = NULL; + } +} + PCSRSS_PROCESS_DATA CsrGetProcessData(ULONG ProcessId) { ULONG i; - for (i=0; iProcessId == ProcessId) + if (ProcessData[i] && + ProcessData[i]->ProcessId == ProcessId) { return(ProcessData[i]); } @@ -62,7 +73,7 @@ NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData, if (Request->Flags & DETACHED_PROCESS) { - NewProcessData->Console = NULL; + NewProcessData->Console = NULL; } else if (Request->Flags & CREATE_NEW_CONSOLE) { diff --git a/reactos/subsys/csrss/api/wapi.c b/reactos/subsys/csrss/api/wapi.c index 01d1b29f825..f1dfd19a0c9 100644 --- a/reactos/subsys/csrss/api/wapi.c +++ b/reactos/subsys/csrss/api/wapi.c @@ -1,4 +1,4 @@ -/* $Id: wapi.c,v 1.2 1999/12/30 01:51:42 dwelch Exp $ +/* $Id: wapi.c,v 1.3 2000/02/27 02:12:07 ekohl Exp $ * * reactos/subsys/csrss/init.c * @@ -123,7 +123,9 @@ void Thread_Api(PVOID PortHandle) PrintString("Failed to create private heap, aborting\n"); return; } - + + CsrInitProcessData(); + for (;;) { Status = NtListenPort(PortHandle, &Request); @@ -170,4 +172,4 @@ void Thread_Api(PVOID PortHandle) } } } - + diff --git a/reactos/subsys/csrss/csrss.c b/reactos/subsys/csrss/csrss.c index 8ba0154fcff..b177cf0773e 100644 --- a/reactos/subsys/csrss/csrss.c +++ b/reactos/subsys/csrss/csrss.c @@ -1,4 +1,4 @@ -/* $Id: csrss.c,v 1.4 1999/12/30 01:51:41 dwelch Exp $ +/* $Id: csrss.c,v 1.5 2000/02/27 02:11:54 ekohl Exp $ * * csrss.c - Client/Server Runtime subsystem * @@ -32,37 +32,88 @@ * actually does nothing but running). */ #include +#include +#include -BOOL TerminationRequestPending = FALSE; - -BOOL InitializeServer(void); - +VOID PrintString (char* fmt, ...); /* Native process' entry point */ VOID NtProcessStartup(PPEB Peb) { + PRTL_USER_PROCESS_PARAMETERS ProcParams; + PWSTR ArgBuffer; + PWSTR *argv; + ULONG argc = 0; + int i = 0; + int afterlastspace = 0; + DisplayString(L"Client/Server Runtime Subsystem\n"); - if (InitializeServer() == TRUE) + ProcParams = RtlNormalizeProcessParams (Peb->ProcessParameters); + + argv = (PWSTR *)RtlAllocateHeap (Peb->ProcessHeap, + 0, 512 * sizeof(PWSTR)); + ArgBuffer = (PWSTR)RtlAllocateHeap (Peb->ProcessHeap, + 0, + ProcParams->CommandLine.Length + sizeof(WCHAR)); + memcpy (ArgBuffer, + ProcParams->CommandLine.Buffer, + ProcParams->CommandLine.Length + sizeof(WCHAR)); + + while (ArgBuffer[i]) { - while (FALSE == TerminationRequestPending) + if (ArgBuffer[i] == L' ') { - /* Do nothing! Should it - * be the SbApi port's - * thread instead? - */ - NtYieldExecution(); + argc++; + ArgBuffer[i] = L'\0'; + argv[argc-1] = &(ArgBuffer[afterlastspace]); + i++; + while (ArgBuffer[i] == L' ') + i++; + afterlastspace = i; } + else + { + i++; + } + } + + if (ArgBuffer[afterlastspace] != L'\0') + { + argc++; + ArgBuffer[i] = L'\0'; + argv[argc-1] = &(ArgBuffer[afterlastspace]); + } + + if (CsrServerInitialization (argc, argv) == TRUE) + { + DisplayString( L"CSR: Subsystem initialized.\n" ); + + RtlFreeHeap (Peb->ProcessHeap, + 0, argv); + RtlFreeHeap (Peb->ProcessHeap, + 0, + ArgBuffer); + + /* terminate the current thread only */ + NtTerminateThread( NtCurrentThread(), 0 ); } else { DisplayString( L"CSR: Subsystem initialization failed.\n" ); + + RtlFreeHeap (Peb->ProcessHeap, + 0, argv); + RtlFreeHeap (Peb->ProcessHeap, + 0, + ArgBuffer); + /* * Tell SM we failed. */ + NtTerminateProcess( NtCurrentProcess(), 0 ); } - NtTerminateProcess( NtCurrentProcess(), 0 ); } /* EOF */ diff --git a/reactos/subsys/csrss/init.c b/reactos/subsys/csrss/init.c index 611b8aef7e9..7c86eb9482e 100644 --- a/reactos/subsys/csrss/init.c +++ b/reactos/subsys/csrss/init.c @@ -1,4 +1,4 @@ -/* $Id: init.c,v 1.4 1999/12/30 01:51:41 dwelch Exp $ +/* $Id: init.c,v 1.5 2000/02/27 02:11:54 ekohl Exp $ * * reactos/subsys/csrss/init.c * @@ -23,9 +23,57 @@ */ static HANDLE ApiPortHandle; + +HANDLE CsrInitEvent = INVALID_HANDLE_VALUE; +HANDLE CsrHeap = INVALID_HANDLE_VALUE; + +HANDLE CsrObjectDirectory = INVALID_HANDLE_VALUE; +HANDLE CsrApiPort = INVALID_HANDLE_VALUE; +HANDLE CsrSbApiPort = INVALID_HANDLE_VALUE; + +UNICODE_STRING CsrDirectoryName; + + +static NTSTATUS +CsrParseCommandLine ( + ULONG ArgumentCount, + PWSTR *ArgumentArray + ) +{ + NTSTATUS Status; + OBJECT_ATTRIBUTES Attributes; + ANSI_STRING AnsiString; + + ULONG i; + + DbgPrint ("Arguments: %ld\n", ArgumentCount); + for (i = 0; i < ArgumentCount; i++) + { + DbgPrint ("Argument %ld: %S\n", i, ArgumentArray[i]); + } + + + /* create object directory ('\Windows') */ + RtlCreateUnicodeString (&CsrDirectoryName, + L"\\Windows"); + + InitializeObjectAttributes (&Attributes, + &CsrDirectoryName, + 0, + NULL, + NULL); + + Status = NtCreateDirectoryObject(&CsrObjectDirectory, + 0xF000F, + &Attributes); + + return Status; +} + + /********************************************************************** * NAME - * InitializeServer + * CsrServerInitialization * * DESCRIPTION * Create a directory object (\windows) and two named LPC ports: @@ -36,12 +84,24 @@ static HANDLE ApiPortHandle; * RETURN VALUE * TRUE: Initialization OK; otherwise FALSE. */ -BOOL InitializeServer(void) +BOOL +STDCALL +CsrServerInitialization ( + ULONG ArgumentCount, + PWSTR *ArgumentArray + ) { NTSTATUS Status; OBJECT_ATTRIBUTES ObAttributes; UNICODE_STRING PortName; - + + Status = CsrParseCommandLine (ArgumentCount, ArgumentArray); + if (!NT_SUCCESS(Status)) + { + PrintString("Unable to parse the command line (Status: %x)\n", Status); + return(FALSE); + } + /* NEW NAMED PORT: \ApiPort */ RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort"); InitializeObjectAttributes(&ObAttributes, @@ -49,6 +109,7 @@ BOOL InitializeServer(void) 0, NULL, NULL); + Status = NtCreatePort(&ApiPortHandle, &ObAttributes, 260, @@ -80,5 +141,4 @@ BOOL InitializeServer(void) return TRUE; } - /* EOF */ diff --git a/reactos/subsys/csrss/makefile b/reactos/subsys/csrss/makefile index bc4c8939ec7..d69f077f8e8 100644 --- a/reactos/subsys/csrss/makefile +++ b/reactos/subsys/csrss/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.4 1999/12/30 01:51:41 dwelch Exp $ +# $Id: makefile,v 1.5 2000/02/27 02:11:54 ekohl Exp $ # # CSRSS: Client/server runtime subsystem # @@ -43,6 +43,27 @@ $(TARGET).exe: $(OBJECTS) $(LIBS) --subsystem native $(NM) --numeric-sort $(TARGET).exe > $(TARGET).sym + +floppy: $(FLOPPY_DIR)/subsys/$(TARGET).exe + +$(FLOPPY_DIR)/subsys/$(TARGET).exe: $(TARGET).exe +ifeq ($(DOSCLI),yes) + $(CP) $(TARGET).exe $(FLOPPY_DIR)\subsys\$(TARGET).exe +else + $(CP) $(TARGET).exe $(FLOPPY_DIR)/subsys/$(TARGET).exe +endif + + +dist: $(DIST_DIR)/subsys/$(TARGET).exe + +$(DIST_DIR)/subsys/$(TARGET).exe: $(TARGET).exe +ifeq ($(DOSCLI),yes) + $(CP) $(TARGET).exe ..\..\$(DIST_DIR)\subsys\$(TARGET).exe +else + $(CP) $(TARGET).exe ../../$(DIST_DIR)/subsys/$(TARGET).exe +endif + + include ../../rules.mak # EOF