diff --git a/reactos/apps/tests/lpc/lpcclt.c b/reactos/apps/tests/lpc/lpcclt.c index 92abb31a8a2..3c43cd97322 100644 --- a/reactos/apps/tests/lpc/lpcclt.c +++ b/reactos/apps/tests/lpc/lpcclt.c @@ -24,12 +24,14 @@ void main(int argc, char* argv[]) NTSTATUS Status; HANDLE PortHandle; LPCMESSAGE Request; + ULONG ConnectInfoLength; printf("(lpcclt.exe) Lpc client\n"); RtlInitUnicodeString(&PortName, L"\\TestPort"); printf("(lpcclt.exe) Connecting to port\n"); + ConnectInfoLength = 0; Status = NtConnectPort(&PortHandle, &PortName, NULL, @@ -37,7 +39,7 @@ void main(int argc, char* argv[]) 0, 0, NULL, - 0); + &ConnectInfoLength); if (!NT_SUCCESS(Status)) { printf("(lpcclt.exe) Failed to connect\n"); diff --git a/reactos/apps/tests/shm/shmsrv.c b/reactos/apps/tests/shm/shmsrv.c index fafb4b58374..97d7676d4e2 100644 --- a/reactos/apps/tests/shm/shmsrv.c +++ b/reactos/apps/tests/shm/shmsrv.c @@ -1,4 +1,4 @@ -/* $Id: shmsrv.c,v 1.2 1999/12/02 20:53:52 dwelch Exp $ +/* $Id: shmsrv.c,v 1.3 1999/12/30 01:51:36 dwelch Exp $ * * FILE : reactos/apps/shm/shmsrv.c * AUTHOR: David Welch @@ -8,30 +8,7 @@ #include #include -HANDLE OutputHandle; -HANDLE InputHandle; - -void debug_printf(char* fmt, ...) -{ - va_list args; - char buffer[255]; - - va_start(args,fmt); - vsprintf(buffer,fmt,args); - WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL); - va_end(args); -} - -VOID STDCALL ApcRoutine(PVOID Context, - PIO_STATUS_BLOCK IoStatus, - ULONG Reserved) -{ - printf("(apc.exe) ApcRoutine(Context %x)\n", (UINT) Context); -} - - -int -main(int argc, char* argv[]) +int main(int argc, char* argv[]) { HANDLE Section; PVOID BaseAddress; @@ -41,7 +18,6 @@ main(int argc, char* argv[]) Section = CreateFileMappingW ( (HANDLE) 0xFFFFFFFF, NULL, -// PAGE_EXECUTE_READWRITE, invalid parameter PAGE_READWRITE, 0, 8192, @@ -53,6 +29,7 @@ main(int argc, char* argv[]) return 1; } + printf("Mapping view of section\n"); BaseAddress = MapViewOfFile(Section, FILE_MAP_ALL_ACCESS, 0, diff --git a/reactos/drivers/dd/ide/ide.c b/reactos/drivers/dd/ide/ide.c index 7a1d6f81f8f..7db4821a53c 100644 --- a/reactos/drivers/dd/ide/ide.c +++ b/reactos/drivers/dd/ide/ide.c @@ -1,4 +1,4 @@ -/* $Id: ide.c,v 1.24 1999/12/22 14:48:27 dwelch Exp $ +/* $Id: ide.c,v 1.25 1999/12/30 01:51:40 dwelch Exp $ * * IDE.C - IDE Disk driver * written by Rex Jolliff @@ -1384,6 +1384,7 @@ IDEStartIo(IN PDEVICE_OBJECT DeviceObject, default: Irp->IoStatus.Status = STATUS_NOT_SUPPORTED; Irp->IoStatus.Information = 0; + KeBugCheck(Irp); IoCompleteRequest(Irp, IO_NO_INCREMENT); IoStartNextPacket(DeviceObject, FALSE); break; diff --git a/reactos/drivers/dd/ide/ide.h b/reactos/drivers/dd/ide/ide.h index a51f052f271..3e12aed646a 100644 --- a/reactos/drivers/dd/ide/ide.h +++ b/reactos/drivers/dd/ide/ide.h @@ -26,7 +26,8 @@ extern "C" { #define IDE_MAX_BUSY_RETRIES 100 //#define IDE_MAX_BUSY_RETRIES 100000 #define IDE_MAX_DRQ_RETRIES 10000 -#define IDE_MAX_CMD_RETRIES 1 +//#define IDE_MAX_CMD_RETRIES 1 +#define IDE_MAX_CMD_RETRIES 0 #define IDE_CMD_TIMEOUT 5 #define IDE_RESET_PULSE_LENGTH 500 /* maybe a little too long */ #define IDE_RESET_BUSY_TIMEOUT 31 diff --git a/reactos/drivers/fs/vfat/blockdev.c b/reactos/drivers/fs/vfat/blockdev.c index 6795c4bd747..3e2038d8a2c 100644 --- a/reactos/drivers/fs/vfat/blockdev.c +++ b/reactos/drivers/fs/vfat/blockdev.c @@ -61,11 +61,11 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject, return FALSE; } - DPRINT("Calling IO Driver...\n"); + DPRINT("Calling IO Driver... with irp %x\n", irp); status = IoCallDriver(pDeviceObject, irp); - DPRINT("Waiting for IO Operation...\n"); + DPRINT("Waiting for IO Operation for %x\n", irp); if (status == STATUS_PENDING) { DPRINT("Operation pending\n"); @@ -74,7 +74,7 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject, KernelMode, FALSE, NULL); - DPRINT("Getting IO Status...\n"); + DPRINT("Getting IO Status... for %x\n", irp); status = ioStatus.Status; } @@ -88,7 +88,7 @@ BOOLEAN VFATReadSectors(IN PDEVICE_OBJECT pDeviceObject, sectorNumber.u.LowPart); return FALSE; } - DPRINT("Block request succeeded\n"); + DPRINT("Block request succeeded for %x\n", irp); return TRUE; } diff --git a/reactos/include/csrss/csrss.h b/reactos/include/csrss/csrss.h index bbe179e0f21..bff68bd6852 100644 --- a/reactos/include/csrss/csrss.h +++ b/reactos/include/csrss/csrss.h @@ -10,7 +10,7 @@ typedef struct #define CSRSS_TERMINATE_PROCESS (0x2) #define CSRSS_WRITE_CONSOLE (0x3) #define CSRSS_READ_CONSOLE (0x4) -#define CSRSS_ALLOC_CONSO (0x5) +#define CSRSS_ALLOC_CONSOLE (0x5) #define CSRSS_FREE_CONSOLE (0x6) #define CSRSS_CONNECT_PROCESS (0x7) @@ -27,4 +27,15 @@ typedef struct HANDLE Handle; } CSRSS_API_REPLY, *PCSRSS_API_REPLY; +typedef struct +{ + ULONG NewProcessId; + ULONG Flags; +} CSRSS_CREATE_PROCESS_REQUEST, *PCSRSS_CREATE_PROCESS_REQUEST; + +/* + * lib/ntdll/csr/api.c + */ +NTSTATUS CsrConnectToServer(VOID); + #endif diff --git a/reactos/include/internal/nt.h b/reactos/include/internal/nt.h index 223374baa27..028429413d6 100644 --- a/reactos/include/internal/nt.h +++ b/reactos/include/internal/nt.h @@ -1,2 +1,3 @@ VOID NtInitializeEventImplementation(VOID); +VOID NtInitializeSemaphoreImplementation(VOID); NTSTATUS NiInitPort(VOID); diff --git a/reactos/install.sh b/reactos/install.sh index 3e1c6ce3c77..087a559d238 100644 --- a/reactos/install.sh +++ b/reactos/install.sh @@ -19,6 +19,7 @@ cp apps/args/args.exe $1/reactos/bin cp apps/bench/bench-thread.exe $1/reactos/bin cp apps/cat/cat.exe $1/reactos/bin cp subsys/smss/smss.exe $1/reactos/system32 +cp subsys/csrss/csrss.exe $1/reactos/system32 cp subsys/win32k/win32k.sys $1/reactos/system32/drivers cp apps/apc/apc.exe $1/reactos/bin cp apps/shm/shmsrv.exe $1/reactos/bin diff --git a/reactos/lib/kernel32/mem/section.c b/reactos/lib/kernel32/mem/section.c index daf6ced1aca..065c202964a 100644 --- a/reactos/lib/kernel32/mem/section.c +++ b/reactos/lib/kernel32/mem/section.c @@ -1,4 +1,4 @@ -/* $Id: section.c,v 1.7 1999/11/24 11:51:44 dwelch Exp $ +/* $Id: section.c,v 1.8 1999/12/30 01:51:37 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -13,9 +13,7 @@ /* FUNCTIONS *****************************************************************/ -HANDLE -STDCALL -CreateFileMappingA ( +HANDLE STDCALL CreateFileMappingA ( HANDLE hFile, LPSECURITY_ATTRIBUTES lpFileMappingAttributes, DWORD flProtect, @@ -57,13 +55,13 @@ CreateFileMappingA ( flProtect, 0, hFile); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return NULL; - } - - return SectionHandle; + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return NULL; + } + + return SectionHandle; } @@ -109,13 +107,13 @@ CreateFileMappingW ( flProtect, 0, hFile); - if (!NT_SUCCESS(Status)) - { - SetLastError(RtlNtStatusToDosError(Status)); - return NULL; - } - - return SectionHandle; + if (!NT_SUCCESS(Status)) + { + SetLastError(RtlNtStatusToDosError(Status)); + return NULL; + } + + return SectionHandle; } diff --git a/reactos/lib/ntdll/csr/api.c b/reactos/lib/ntdll/csr/api.c index 6b0c49cd856..84e2931d565 100644 --- a/reactos/lib/ntdll/csr/api.c +++ b/reactos/lib/ntdll/csr/api.c @@ -1,4 +1,4 @@ -/* $Id: api.c,v 1.1 1999/12/26 15:50:46 dwelch Exp $ +/* $Id: api.c,v 1.2 1999/12/30 01:51:38 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -9,6 +9,9 @@ /* INCLUDES *****************************************************************/ #include +#include + +#include #define NDEBUG #include @@ -19,18 +22,56 @@ static HANDLE WindowsApiPort; /* FUNCTIONS *****************************************************************/ +NTSTATUS CsrClientCallServer(PCSRSS_API_REQUEST Request, + PCSRSS_API_REPLY Reply) +{ + LPCMESSAGE LpcRequest; + LPCMESSAGE LpcReply; + NTSTATUS Status; + + LpcRequest.ActualMessageLength = MAX_MESSAGE_DATA; + LpcRequest.TotalMessageLength = sizeof(LPCMESSAGE); + memcpy(LpcRequest.MessageData, Request, sizeof(CSRSS_API_REQUEST)); + + Status = NtRequestWaitReplyPort(WindowsApiPort, + &LpcRequest, + &LpcReply); + return(Status); +} + NTSTATUS CsrConnectToServer(VOID) { NTSTATUS Status; UNICODE_STRING PortName; + ULONG ConnectInfoLength; + CSRSS_API_REQUEST Request; + CSRSS_API_REPLY Reply; RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort"); - + ConnectInfoLength = 0; Status = NtConnectPort(&WindowsApiPort, &PortName, NULL, NULL, NULL, NULL, - + NULL, + &ConnectInfoLength); + if (!NT_SUCCESS(Status)) + { + return(Status); + } + + Request.Type = CSRSS_CONNECT_PROCESS; + Status = CsrClientCallServer(&Request, + &Reply); + if (!NT_SUCCESS(Status)) + { + return(Status); + } + if (!NT_SUCCESS(Reply.Status)) + { + return(Reply.Status); + } + return(STATUS_SUCCESS); } diff --git a/reactos/lib/ntdll/ldr/startup.c b/reactos/lib/ntdll/ldr/startup.c index 0b0fabffad1..80a325b74f7 100644 --- a/reactos/lib/ntdll/ldr/startup.c +++ b/reactos/lib/ntdll/ldr/startup.c @@ -1,4 +1,4 @@ -/* $Id: startup.c,v 1.13 1999/12/08 12:58:06 ekohl Exp $ +/* $Id: startup.c,v 1.14 1999/12/30 01:51:38 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -127,7 +127,16 @@ VOID LdrStartup(PPEB Peb, dprintf("Failed to initialize image\n"); ZwTerminateProcess(NtCurrentProcess(),STATUS_UNSUCCESSFUL); } - + + /* + * + */ + Status = CsrConnectToServer(); + if (!NT_SUCCESS(Status)) + { + dprintf("Failed to connect to csrss.exe: expect trouble\n"); + } + // dprintf("Transferring control to image at %x\n",EntryPoint); Status = EntryPoint(Peb); ZwTerminateProcess(NtCurrentProcess(),Status); diff --git a/reactos/lib/ntdll/makefile b/reactos/lib/ntdll/makefile index ecdc30c94ad..67de086b9f6 100644 --- a/reactos/lib/ntdll/makefile +++ b/reactos/lib/ntdll/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.31 1999/12/30 01:33:47 ekohl Exp $ +# $Id: makefile,v 1.32 1999/12/30 01:51:37 dwelch Exp $ # # ReactOS Operating System # @@ -23,6 +23,8 @@ endif all: $(DLLTARGET) +CSR_OBJECTS = csr/api.o + DBG_OBJECTS = dbg/brkpoint.o RTL_OBJECTS = rtl/critical.o rtl/error.o rtl/heap.o rtl/largeint.o \ @@ -46,7 +48,7 @@ STRING_OBJECTS = string/ctype.o string/memccpy.o string/memchr.o \ OBJECTS = napi.o ldr/startup.o $(DBG_OBJECTS) $(RTL_OBJECTS) \ stdio/vsprintf.o $(STDLIB_OBJECTS) $(STRING_OBJECTS) \ - stubs/stubs.o ldr/utils.o $(TARGET).coff + stubs/stubs.o ldr/utils.o $(CSR_OBJECTS) $(TARGET).coff ifeq ($(DOSCLI),yes) CLEAN_FILES = napi.o ldr\*.o rtl\*.o stdio\*.o stdlib\*.o string\*.o stubs\*.o \ diff --git a/reactos/lib/ntdll/stubs/stubs.c b/reactos/lib/ntdll/stubs/stubs.c index 65bb949bdc8..0ecbd3e0c21 100644 --- a/reactos/lib/ntdll/stubs/stubs.c +++ b/reactos/lib/ntdll/stubs/stubs.c @@ -18,7 +18,6 @@ STUB(CsrAllocateMessagePointer) STUB(CsrCaptureMessageBuffer) STUB(CsrCaptureMessageString) STUB(CsrCaptureTimeout) -STUB(CsrClientCallServer) STUB(CsrClientConnectToServer) STUB(CsrFreeCaptureBuffer) STUB(CsrIdentifyAlertableThread) diff --git a/reactos/ntoskrnl/io/buildirp.c b/reactos/ntoskrnl/io/buildirp.c index 2a3d96b0509..4cc796666c5 100644 --- a/reactos/ntoskrnl/io/buildirp.c +++ b/reactos/ntoskrnl/io/buildirp.c @@ -89,6 +89,7 @@ PIRP IoBuildFilesystemControlRequest(ULONG MinorFunction, } Irp->UserIosb = IoStatusBlock; + DPRINT("Irp->UserIosb %x\n", Irp->UserIosb); Irp->UserEvent = UserEvent; Irp->Tail.Overlay.Thread = PsGetCurrentThread(); @@ -155,6 +156,7 @@ PIRP IoBuildAsynchronousFsdRequest(ULONG MajorFunction, } Irp->UserIosb = IoStatusBlock; + DPRINT("Irp->UserIosb %x\n", Irp->UserIosb); Irp->Tail.Overlay.Thread = PsGetCurrentThread(); StackPtr = IoGetNextIrpStackLocation(Irp); @@ -252,6 +254,7 @@ PIRP IoBuildDeviceIoControlRequest(ULONG IoControlCode, Irp->UserEvent = Event; Irp->UserIosb = IoStatusBlock; + DPRINT("Irp->UserIosb %x\n", Irp->UserIosb); Irp->Tail.Overlay.Thread = PsGetCurrentThread(); StackPtr = IoGetNextIrpStackLocation(Irp); @@ -403,6 +406,7 @@ PIRP IoBuildSynchronousFsdRequest(ULONG MajorFunction, Irp->UserEvent = Event; Irp->UserIosb = IoStatusBlock; + DPRINT("Irp->UserIosb %x\n", Irp->UserIosb); Irp->Tail.Overlay.Thread = PsGetCurrentThread(); StackPtr = IoGetNextIrpStackLocation(Irp); @@ -491,6 +495,7 @@ PIRP IoBuildSynchronousFsdRequestWithMdl(ULONG MajorFunction, Irp->UserEvent = Event; Irp->UserIosb = IoStatusBlock; + DPRINT("Irp->UserIosb %x\n", Irp->UserIosb); Irp->Tail.Overlay.Thread = PsGetCurrentThread(); StackPtr = IoGetNextIrpStackLocation(Irp); diff --git a/reactos/ntoskrnl/io/cleanup.c b/reactos/ntoskrnl/io/cleanup.c index 06f99603248..02771e32664 100644 --- a/reactos/ntoskrnl/io/cleanup.c +++ b/reactos/ntoskrnl/io/cleanup.c @@ -199,6 +199,9 @@ VOID IoSecondStageCompletion(PIRP Irp, CCHAR PriorityBoost) return; } + DPRINT("Irp->UserIosb %x &Irp->UserIosb %x\n", + Irp->UserIosb, + &Irp->UserIosb); if (Irp->UserIosb!=NULL) { *Irp->UserIosb=Irp->IoStatus; diff --git a/reactos/ntoskrnl/io/queue.c b/reactos/ntoskrnl/io/queue.c index e4a72b2cd2a..9daf6587d0b 100644 --- a/reactos/ntoskrnl/io/queue.c +++ b/reactos/ntoskrnl/io/queue.c @@ -31,16 +31,21 @@ VOID IoStartNextPacketByKey(PDEVICE_OBJECT DeviceObject, PKDEVICE_QUEUE_ENTRY entry; PIRP Irp; - entry = KeRemoveByKeyDeviceQueue(&DeviceObject->DeviceQueue,Key); + entry = KeRemoveByKeyDeviceQueue(&DeviceObject->DeviceQueue, + Key); - if (entry!=NULL) + if (entry != NULL) { - Irp = CONTAINING_RECORD(entry,IRP,Tail.Overlay.DeviceQueueEntry); + Irp = CONTAINING_RECORD(entry, + IRP, + Tail.Overlay.DeviceQueueEntry); DeviceObject->CurrentIrp = Irp; - DeviceObject->DriverObject->DriverStartIo(DeviceObject,Irp); + DPRINT("Next irp is %x\n", Irp); + DeviceObject->DriverObject->DriverStartIo(DeviceObject, Irp); } else { + DPRINT("No next irp\n"); DeviceObject->CurrentIrp = NULL; } } @@ -89,7 +94,9 @@ VOID IoStartPacket(PDEVICE_OBJECT DeviceObject, { BOOLEAN stat; KIRQL oldirql; - + + DPRINT("IoStartPacket(Irp %x)\n", Irp); + ASSERT_IRQL(DISPATCH_LEVEL); IoAcquireCancelSpinLock(&oldirql); diff --git a/reactos/ntoskrnl/ke/kqueue.c b/reactos/ntoskrnl/ke/kqueue.c index 722a1a7838f..907393173b5 100644 --- a/reactos/ntoskrnl/ke/kqueue.c +++ b/reactos/ntoskrnl/ke/kqueue.c @@ -20,17 +20,7 @@ VOID InsertBeforeEntryInList(PLIST_ENTRY Head, PLIST_ENTRY After, PLIST_ENTRY Entry) { - if (After->Blink!=NULL) - { - After->Blink->Flink = Entry; - } - else - { - Head->Flink = Entry; - } - Entry->Blink = After->Blink; - Entry->Flink = After; - After->Blink = Entry; + InsertHeadList(After, Entry); } BOOLEAN KeInsertByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue, @@ -41,6 +31,8 @@ BOOLEAN KeInsertByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue, PLIST_ENTRY current; PKDEVICE_QUEUE_ENTRY entry; + DPRINT("KeInsertByKeyDeviceQueue()\n"); + DeviceQueueEntry->Key=SortKey; KeAcquireSpinLock(&DeviceQueue->Lock,&oldlvl); @@ -59,7 +51,8 @@ BOOLEAN KeInsertByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue, if (entry->Key < SortKey) { InsertBeforeEntryInList(&DeviceQueue->ListHead, - &DeviceQueueEntry->Entry,current); + &DeviceQueueEntry->Entry, + current); KeReleaseSpinLock(&DeviceQueue->Lock,oldlvl); return(TRUE); } @@ -84,18 +77,12 @@ PKDEVICE_QUEUE_ENTRY KeRemoveByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue, KeAcquireSpinLock(&DeviceQueue->Lock,&oldlvl); - if (IsListEmpty(&DeviceQueue->ListHead)) - { - DeviceQueue->Busy=FALSE; - KeReleaseSpinLock(&DeviceQueue->Lock,oldlvl); - return(NULL); - } - current = DeviceQueue->ListHead.Flink; - for(;;) + while (current != &DeviceQueue->ListHead) { entry = CONTAINING_RECORD(current,KDEVICE_QUEUE_ENTRY,Entry); - if (entry->Key < SortKey || current->Flink == NULL) + if (entry->Key < SortKey || + current->Flink == &DeviceQueue->ListHead) { RemoveEntryList(current); KeReleaseSpinLock(&DeviceQueue->Lock,oldlvl); @@ -103,6 +90,9 @@ PKDEVICE_QUEUE_ENTRY KeRemoveByKeyDeviceQueue(PKDEVICE_QUEUE DeviceQueue, } current = current->Flink; } + DeviceQueue->Busy = FALSE; + KeReleaseSpinLock(&DeviceQueue->Lock, oldlvl); + return(NULL); } PKDEVICE_QUEUE_ENTRY KeRemoveDeviceQueue(PKDEVICE_QUEUE DeviceQueue) @@ -173,7 +163,8 @@ BOOLEAN KeInsertDeviceQueue(PKDEVICE_QUEUE DeviceQueue, return(FALSE); } - InsertTailList(&DeviceQueue->ListHead,&DeviceQueueEntry->Entry); + InsertTailList(&DeviceQueue->ListHead, + &DeviceQueueEntry->Entry); DeviceQueueEntry->Key=0; KeReleaseSpinLock(&DeviceQueue->Lock,oldlvl); diff --git a/reactos/ntoskrnl/mm/section.c b/reactos/ntoskrnl/mm/section.c index ab23346f9a2..337bf928bc9 100644 --- a/reactos/ntoskrnl/mm/section.c +++ b/reactos/ntoskrnl/mm/section.c @@ -1,4 +1,4 @@ -/* $Id: section.c,v 1.20 1999/12/22 14:48:25 dwelch Exp $ +/* $Id: section.c,v 1.21 1999/12/30 01:51:39 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -58,6 +58,7 @@ PVOID MiTryToSharePageInSection(PSECTION_OBJECT Section, Address); MmReferencePage((PVOID)PhysPage); KeReleaseSpinLock(&Section->ViewListLock, oldIrql); + DPRINT("MiTryToSharePageInSection() = %x\n", PhysPage); return((PVOID)PhysPage); } @@ -65,6 +66,7 @@ PVOID MiTryToSharePageInSection(PSECTION_OBJECT Section, } KeReleaseSpinLock(&Section->ViewListLock, oldIrql); + DPRINT("MiTryToSharePageInSection() finished\n"); return(NULL); } @@ -177,6 +179,7 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle, DesiredAccess, ObjectAttributes, MmSectionType); + DPRINT("SectionHandle %x\n", SectionHandle); if (Section == NULL) { return(STATUS_UNSUCCESSFUL); @@ -195,7 +198,7 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle, InitializeListHead(&Section->ViewListHead); KeInitializeSpinLock(&Section->ViewListLock); - if (FileHandle != NULL) + if (FileHandle != (HANDLE)0xffffffff) { Status = ObReferenceObjectByHandle(FileHandle, FILE_READ_DATA, @@ -203,7 +206,7 @@ NTSTATUS STDCALL NtCreateSection (OUT PHANDLE SectionHandle, UserMode, (PVOID*)&Section->FileObject, NULL); - if (Status != STATUS_SUCCESS) + if (!NT_SUCCESS(Status)) { /* * Delete section object diff --git a/reactos/ntoskrnl/nt/nt.c b/reactos/ntoskrnl/nt/nt.c index efa54004df3..808e93c3099 100644 --- a/reactos/ntoskrnl/nt/nt.c +++ b/reactos/ntoskrnl/nt/nt.c @@ -20,5 +20,6 @@ VOID NtInit(VOID) { NtInitializeEventImplementation(); + NtInitializeSemaphoreImplementation(); NiInitPort(); } diff --git a/reactos/ntoskrnl/nt/ntsem.c b/reactos/ntoskrnl/nt/ntsem.c index d27a6106aba..97f24fdcc75 100644 --- a/reactos/ntoskrnl/nt/ntsem.c +++ b/reactos/ntoskrnl/nt/ntsem.c @@ -11,58 +11,147 @@ /* INCLUDES *****************************************************************/ #include +#include #include +/* GLOBALS ******************************************************************/ + +POBJECT_TYPE ExSemaphoreType; + /* FUNCTIONS *****************************************************************/ -NTSTATUS -STDCALL -NtCreateSemaphore ( - OUT PHANDLE SemaphoreHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes OPTIONAL, - IN ULONG InitialCount, - IN ULONG MaximumCount - ) +NTSTATUS NtpCreateSemaphore(PVOID ObjectBody, + PVOID Parent, + PWSTR RemainingPath, + POBJECT_ATTRIBUTES ObjectAttributes) { - UNIMPLEMENTED; + + DPRINT("NtpCreateSemaphore(ObjectBody %x, Parent %x, RemainingPath %w)\n", + ObjectBody, Parent, RemainingPath); + + if (RemainingPath != NULL && wcschr(RemainingPath+1, '\\') != NULL) + { + return(STATUS_UNSUCCESSFUL); + } + + if (Parent != NULL && RemainingPath != NULL) + { + ObAddEntryDirectory(Parent, ObjectBody, RemainingPath+1); + } + return(STATUS_SUCCESS); +} + +VOID NtInitializeSemaphoreImplementation(VOID) +{ + UNICODE_STRING TypeName; + + ExSemaphoreType = ExAllocatePool(NonPagedPool, sizeof(OBJECT_TYPE)); + + RtlInitUnicodeString(&TypeName, L"Event"); + + ExSemaphoreType->TypeName = TypeName; + + ExSemaphoreType->MaxObjects = ULONG_MAX; + ExSemaphoreType->MaxHandles = ULONG_MAX; + ExSemaphoreType->TotalObjects = 0; + ExSemaphoreType->TotalHandles = 0; + ExSemaphoreType->PagedPoolCharge = 0; + ExSemaphoreType->NonpagedPoolCharge = sizeof(KSEMAPHORE); + ExSemaphoreType->Dump = NULL; + ExSemaphoreType->Open = NULL; + ExSemaphoreType->Close = NULL; + ExSemaphoreType->Delete = NULL; + ExSemaphoreType->Parse = NULL; + ExSemaphoreType->Security = NULL; + ExSemaphoreType->QueryName = NULL; + ExSemaphoreType->OkayToClose = NULL; + ExSemaphoreType->Create = NtpCreateSemaphore; +} + +NTSTATUS STDCALL NtCreateSemaphore(OUT PHANDLE SemaphoreHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes, + IN ULONG InitialCount, + IN ULONG MaximumCount) +{ + PKSEMAPHORE Semaphore; + + DPRINT("NtCreateSemaphore()\n"); + Semaphore = ObCreateObject(SemaphoreHandle, + DesiredAccess, + ObjectAttributes, + ExSemaphoreType); + KeInitializeSemaphore(Semaphore, + InitialCount, + MaximumCount); + ObDereferenceObject(Semaphore); + return(STATUS_SUCCESS); } -NTSTATUS -STDCALL -NtOpenSemaphore ( - IN HANDLE SemaphoreHandle, - IN ACCESS_MASK DesiredAccess, - IN POBJECT_ATTRIBUTES ObjectAttributes - ) +NTSTATUS STDCALL NtOpenSemaphore(IN HANDLE SemaphoreHandle, + IN ACCESS_MASK DesiredAccess, + IN POBJECT_ATTRIBUTES ObjectAttributes) { - UNIMPLEMENTED; + NTSTATUS Status; + PKSEMAPHORE Semaphore; + + + Status = ObReferenceObjectByName(ObjectAttributes->ObjectName, + ObjectAttributes->Attributes, + NULL, + DesiredAccess, + ExSemaphoreType, + UserMode, + NULL, + (PVOID*)&Semaphore); + if (Status != STATUS_SUCCESS) + { + return(Status); + } + + Status = ObCreateHandle(PsGetCurrentProcess(), + Semaphore, + DesiredAccess, + FALSE, + SemaphoreHandle); + ObDereferenceObject(Semaphore); + + return(STATUS_SUCCESS); } -NTSTATUS -STDCALL -NtQuerySemaphore ( - HANDLE SemaphoreHandle, - CINT SemaphoreInformationClass, - OUT PVOID SemaphoreInformation, - ULONG Length, - PULONG ReturnLength - ) +NTSTATUS STDCALL NtQuerySemaphore(HANDLE SemaphoreHandle, + CINT SemaphoreInformationClass, + OUT PVOID SemaphoreInformation, + ULONG Length, + PULONG ReturnLength) { - UNIMPLEMENTED; + UNIMPLEMENTED; } - -NTSTATUS -STDCALL -NtReleaseSemaphore ( - IN HANDLE SemaphoreHandle, - IN ULONG ReleaseCount, - IN PULONG PreviousCount - ) +NTSTATUS STDCALL NtReleaseSemaphore(IN HANDLE SemaphoreHandle, + IN ULONG ReleaseCount, + IN PULONG PreviousCount) { - UNIMPLEMENTED; + PKSEMAPHORE Semaphore; + NTSTATUS Status; + + Status = ObReferenceObjectByHandle(SemaphoreHandle, + SEMAPHORE_MODIFY_STATE, + ExSemaphoreType, + UserMode, + (PVOID*)&Semaphore, + NULL); + if (!NT_SUCCESS(Status)) + { + return(Status); + } + KeReleaseSemaphore(Semaphore, + IO_NO_INCREMENT, + ReleaseCount, + FALSE); + ObDereferenceObject(Semaphore); + return(STATUS_SUCCESS); } diff --git a/reactos/ntoskrnl/nt/port.c b/reactos/ntoskrnl/nt/port.c index 191cb7d38a4..f71e7c9f6ed 100644 --- a/reactos/ntoskrnl/nt/port.c +++ b/reactos/ntoskrnl/nt/port.c @@ -1,4 +1,4 @@ -/* $Id: port.c,v 1.14 1999/12/13 22:04:39 dwelch Exp $ +/* $Id: port.c,v 1.15 1999/12/30 01:51:40 dwelch Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -109,14 +109,16 @@ PQUEUEDMESSAGE EiDequeueConnectMessagePort(PEPORT Port) return(Message); } -NTSTATUS EiReplyOrRequestPort(PEPORT Port, PLPCMESSAGE LpcReply, - ULONG MessageType) +NTSTATUS EiReplyOrRequestPort(PEPORT Port, + PLPCMESSAGE LpcReply, + ULONG MessageType, + PEPORT Sender) { KIRQL oldIrql; PQUEUEDMESSAGE MessageReply; MessageReply = ExAllocatePool(NonPagedPool, sizeof(QUEUEDMESSAGE)); - MessageReply->Sender = Port; + MessageReply->Sender = Sender; if (LpcReply != NULL) { @@ -128,9 +130,9 @@ NTSTATUS EiReplyOrRequestPort(PEPORT Port, PLPCMESSAGE LpcReply, MessageReply->Message.MessageType = MessageType; MessageReply->Message.MessageId = InterlockedIncrement(&EiNextLpcMessageId); - KeAcquireSpinLock(&Port->OtherPort->Lock, &oldIrql); - EiEnqueueMessagePort(Port->OtherPort, MessageReply); - KeReleaseSpinLock(&Port->OtherPort->Lock, oldIrql); + KeAcquireSpinLock(&Port->Lock, &oldIrql); + EiEnqueueMessagePort(Port, MessageReply); + KeReleaseSpinLock(&Port->Lock, oldIrql); return(STATUS_SUCCESS); } @@ -207,6 +209,8 @@ static NTSTATUS NiInitializePort(PEPORT Port) Port->OtherPort = NULL; Port->QueueLength = 0; Port->ConnectQueueLength = 0; + InitializeListHead(&Port->QueueListHead); + InitializeListHead(&Port->ConnectQueueListHead); return(STATUS_SUCCESS); } @@ -260,6 +264,7 @@ NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort, ULONG ConnectInfoLength; KIRQL oldIrql; + DPRINT("PortName %x\n", PortName); DPRINT("NtConnectPort(PortName %w)\n", PortName->Buffer); /* @@ -296,17 +301,23 @@ NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort, /* * Create a request message */ + DPRINT("Creating request message\n"); + Request.ActualMessageLength = ConnectInfoLength; Request.TotalMessageLength = sizeof(LPCMESSAGE) + ConnectInfoLength; Request.SharedSectionSize = 0; - memcpy(Request.MessageData, ConnectInfo, ConnectInfoLength); + if (ConnectInfo != NULL && ConnectInfoLength > 0) + { + memcpy(Request.MessageData, ConnectInfo, ConnectInfoLength); + } /* * Queue the message to the named port */ - KeAcquireSpinLock(&NamedPort->Lock, &oldIrql); - EiReplyOrRequestPort(NamedPort, &Request, LPC_CONNECTION_REQUEST); - KeReleaseSpinLock(&NamedPort->Lock, oldIrql); + DPRINT("Queuing message\n"); + + EiReplyOrRequestPort(NamedPort, &Request, LPC_CONNECTION_REQUEST, OurPort); + KeSetEvent(&NamedPort->Event, IO_NO_INCREMENT, FALSE); DPRINT("Waiting for connection completion\n"); @@ -319,6 +330,7 @@ NTSTATUS STDCALL NtConnectPort (OUT PHANDLE ConnectedPort, FALSE, NULL); + DPRINT("Received connection completion\n"); KeAcquireSpinLock(&OurPort->Lock, &oldIrql); Reply = EiDequeueMessagePort(OurPort); KeReleaseSpinLock(&OurPort->Lock, oldIrql); @@ -369,7 +381,7 @@ NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE ServerPortHandle, /* * Create a port object for our side of the connection */ - if (AcceptIt != 1) + if (AcceptIt == 1) { OurPort = ObCreateObject(ServerPortHandle, PORT_ALL_ACCESS, @@ -382,14 +394,15 @@ NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE ServerPortHandle, * Dequeue the connection request */ KeAcquireSpinLock(&NamedPort->Lock, &oldIrql); - ConnectionRequest = EiDequeueConnectMessagePort(OurPort); + ConnectionRequest = EiDequeueConnectMessagePort(NamedPort); KeReleaseSpinLock(&NamedPort->Lock, oldIrql); if (AcceptIt != 1) { EiReplyOrRequestPort(ConnectionRequest->Sender, - LpcMessage, - LPC_CONNECTION_REFUSED); + LpcMessage, + LPC_CONNECTION_REFUSED, + NamedPort); KeSetEvent(&ConnectionRequest->Sender->Event, IO_NO_INCREMENT, FALSE); ExFreePool(ConnectionRequest); ObDereferenceObject(NamedPort); @@ -401,7 +414,10 @@ NTSTATUS STDCALL NtAcceptConnectPort (PHANDLE ServerPortHandle, */ OurPort->OtherPort = ConnectionRequest->Sender; OurPort->OtherPort->OtherPort = OurPort; - EiReplyOrRequestPort(ConnectionRequest->Sender, LpcMessage, LPC_REPLY); + EiReplyOrRequestPort(ConnectionRequest->Sender, + LpcMessage, + LPC_REPLY, + OurPort); ExFreePool(ConnectionRequest); ObDereferenceObject(NamedPort); @@ -415,6 +431,8 @@ NTSTATUS STDCALL NtCompleteConnectPort (HANDLE PortHandle) NTSTATUS Status; PEPORT OurPort; + DPRINT("NtCompleteConnectPort(PortHandle %x)\n", PortHandle); + Status = ObReferenceObjectByHandle(PortHandle, PORT_ALL_ACCESS, ExPortType, @@ -454,6 +472,7 @@ NTSTATUS STDCALL NtListenPort (IN HANDLE PortHandle, NULL, NULL, ConnectMsg); + DPRINT("Got message (type %x)\n", LPC_CONNECTION_REQUEST); if (!NT_SUCCESS(Status) || ConnectMsg->MessageType == LPC_CONNECTION_REQUEST) { @@ -478,7 +497,7 @@ NTSTATUS STDCALL NtReplyPort (IN HANDLE PortHandle, IN PLPCMESSAGE LpcReply) { NTSTATUS Status; - PEPORT Port + PEPORT Port; DPRINT("NtReplyPort(PortHandle %x, LpcReply %x)\n", PortHandle, LpcReply); @@ -494,8 +513,11 @@ NTSTATUS STDCALL NtReplyPort (IN HANDLE PortHandle, return(Status); } - Status = EiReplyOrRequestPort(Port, LpcReply, LPC_REPLY); - KeSetEvent(&Port->Event, IO_NO_INCREMENT, FALSE); + Status = EiReplyOrRequestPort(Port->OtherPort, + LpcReply, + LPC_REPLY, + Port); + KeSetEvent(&Port->OtherPort->Event, IO_NO_INCREMENT, FALSE); ObDereferenceObject(Port); @@ -533,8 +555,11 @@ NTSTATUS STDCALL NtReplyWaitReceivePort (IN HANDLE PortHandle, */ if (LpcReply != NULL) { - Status = EiReplyOrRequestPort(Port, LpcReply, LPC_REPLY); - KeSetEvent(&Port->Event, IO_NO_INCREMENT, FALSE); + Status = EiReplyOrRequestPort(Port->OtherPort, + LpcReply, + LPC_REPLY, + Port); + KeSetEvent(&Port->OtherPort->Event, IO_NO_INCREMENT, FALSE); if (!NT_SUCCESS(Status)) { @@ -546,11 +571,13 @@ NTSTATUS STDCALL NtReplyWaitReceivePort (IN HANDLE PortHandle, /* * Want for a message to be received */ + DPRINT("Entering wait for message\n"); KeWaitForSingleObject(&Port->Event, UserRequest, UserMode, FALSE, NULL); + DPRINT("Woke from wait for message\n"); /* * Dequeue the message @@ -598,8 +625,11 @@ NTSTATUS STDCALL NtRequestPort (IN HANDLE PortHandle, return(Status); } - Status = EiReplyOrRequestPort(Port, LpcMessage, LPC_DATAGRAM); - KeSetEvent(&Port->Event, IO_NO_INCREMENT, FALSE); + Status = EiReplyOrRequestPort(Port->OtherPort, + LpcMessage, + LPC_DATAGRAM, + Port); + KeSetEvent(&Port->OtherPort->Event, IO_NO_INCREMENT, FALSE); ObDereferenceObject(Port); return(Status); @@ -630,8 +660,11 @@ NTSTATUS STDCALL NtRequestWaitReplyPort(IN HANDLE PortHandle, } - Status = EiReplyOrRequestPort(Port, LpcRequest, LPC_REQUEST); - KeSetEvent(&Port->Event, IO_NO_INCREMENT, FALSE); + Status = EiReplyOrRequestPort(Port->OtherPort, + LpcRequest, + LPC_REQUEST, + Port); + KeSetEvent(&Port->OtherPort->Event, IO_NO_INCREMENT, FALSE); if (!NT_SUCCESS(Status)) { diff --git a/reactos/ntoskrnl/rtl/list.c b/reactos/ntoskrnl/rtl/list.c index 6e89023860d..39098087378 100644 --- a/reactos/ntoskrnl/rtl/list.c +++ b/reactos/ntoskrnl/rtl/list.c @@ -109,7 +109,7 @@ VOID InsertTailList(PLIST_ENTRY ListHead, PLIST_ENTRY ListEntry) ListEntry->Blink=Blink; Blink->Flink=ListEntry; ListHead->Blink=ListEntry; - assert( CheckEntry( ListEntry ) ); + assert(CheckEntry(ListEntry)); } VOID InsertHeadList(PLIST_ENTRY ListHead, PLIST_ENTRY ListEntry) diff --git a/reactos/subsys/csrss/api.h b/reactos/subsys/csrss/api.h index 8a7d8ead969..df7bc9feeb8 100644 --- a/reactos/subsys/csrss/api.h +++ b/reactos/subsys/csrss/api.h @@ -16,6 +16,9 @@ typedef struct typedef struct { PCSRSS_CONSOLE Console; + ULONG HandleTableSize; + PVOID* HandleTable; + ULONG ProcessId; } CSRSS_PROCESS_DATA, *PCSRSS_PROCESS_DATA; NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData, @@ -48,3 +51,12 @@ VOID PrintString (char* fmt, ...); /* api/wapi.c */ VOID Thread_Api(PVOID PortHandle); + +extern HANDLE CsrssApiHeap; + +/* api/conio.c */ +VOID CsrInitConsole(PCSRSS_PROCESS_DATA ProcessData, + PCSRSS_CONSOLE Console); + +/* api/process.c */ +PCSRSS_PROCESS_DATA CsrGetProcessData(ULONG ProcessId); diff --git a/reactos/subsys/csrss/api/conio.c b/reactos/subsys/csrss/api/conio.c index 421bac273e1..8cc2c91b384 100644 --- a/reactos/subsys/csrss/api/conio.c +++ b/reactos/subsys/csrss/api/conio.c @@ -1,4 +1,4 @@ -/* $Id: conio.c,v 1.1 1999/12/22 14:48:30 dwelch Exp $ +/* $Id: conio.c,v 1.2 1999/12/30 01:51:42 dwelch Exp $ * * reactos/subsys/csrss/api/conio.c * @@ -11,7 +11,7 @@ #include -#include "csrss.h" +#include #include "api.h" /* GLOBALS *******************************************************************/ @@ -21,18 +21,41 @@ static HANDLE KeyboardDevice; /* FUNCTIONS *****************************************************************/ -NTSTATUS CsrWriteConsole(PCSRSS_CONIO_PROCESS ProcessData, - PCSRSS_REQUEST Message, +NTSTATUS CsrAllocConsole(PCSRSS_PROCESS_DATA ProcessData, + PCSRSS_API_REQUEST LpcMessage, + PHANDLE ReturnedHandle) +{ + return(STATUS_NOT_IMPLEMENTED); +} + +NTSTATUS CsrFreeConsole(PCSRSS_PROCESS_DATA ProcessData, + PCSRSS_API_REQUEST LpcMessage) +{ + return(STATUS_NOT_IMPLEMENTED); +} + +NTSTATUS CsrReadConsole(PCSRSS_PROCESS_DATA ProcessData, + PCSRSS_API_REQUEST LpcMessage, + PULONG CharCount) +{ + return(STATUS_NOT_IMPLEMENTED); +} + + +NTSTATUS CsrWriteConsole(PCSRSS_PROCESS_DATA ProcessData, + PCSRSS_API_REQUEST Message, PULONG CharCount) { NTSTATUS Status; + PCSRSS_CONSOLE Console; if (ProcessData->Console == NULL) { return(STATUS_UNSUCCESSFUL); } + Console = ProcessData->Console; - Status = NtWaitForSingleObject(ProcessData->Console->LockMutant, + Status = NtWaitForSingleObject(Console->LockMutant, TRUE, NULL); if (!NT_SUCCESS(Status)) @@ -45,9 +68,9 @@ NTSTATUS CsrWriteConsole(PCSRSS_CONIO_PROCESS ProcessData, return(Status); } - if (TopLevel == TRUE) + if (Console->TopLevel == TRUE) { - Status = NtReleaseMutant(ProcessData->Console->LockMutant, NULL); + Status = NtReleaseMutant(Console->LockMutant, NULL); if (!NT_SUCCESS(Status)) { return(Status); @@ -57,7 +80,7 @@ NTSTATUS CsrWriteConsole(PCSRSS_CONIO_PROCESS ProcessData, } else { - Status = NtReleaseMutant(ProcessData->Console->LockMutant, NULL); + Status = NtReleaseMutant(Console->LockMutant, NULL); if (!NT_SUCCESS(Status)) { return(Status); @@ -67,25 +90,9 @@ NTSTATUS CsrWriteConsole(PCSRSS_CONIO_PROCESS ProcessData, } } -PCSRSS_CONIO_PROCESS CsrAllocConioProcess(VOID) +VOID CsrInitConsole(PCSRSS_PROCESS_DATA ProcessData, + PCSRSS_CONSOLE Console) { - PCSRSS_CONIO_PROCESS ProcessData; - - ThreadData = RtlAllocHeap(NULL, HEAP_ZERO_MEMORY, - sizeof(PROCESS_CONIO_THREAD)); - if (ThreadData == NULL) - { - return(NULL); - } - ProcessData->Console = NULL; - return(ProcessData); } -VOID CsrFreeConioProcess(PCSRSS_CONIO_PROCESS ProcessData) -{ - RtlFreeHeap(NULL, 0, ProcessData); -} - - - /* EOF */ diff --git a/reactos/subsys/csrss/api/handle.c b/reactos/subsys/csrss/api/handle.c index 870225963b6..6ce15def874 100644 --- a/reactos/subsys/csrss/api/handle.c +++ b/reactos/subsys/csrss/api/handle.c @@ -1,4 +1,4 @@ -/* $Id: handle.c,v 1.1 1999/12/26 15:50:53 dwelch Exp $ +/* $Id: handle.c,v 1.2 1999/12/30 01:51:42 dwelch Exp $ * * reactos/subsys/csrss/api/handle.c * @@ -16,5 +16,49 @@ /* FUNCTIONS *****************************************************************/ -NTSTATUS CsrCreateObject(PHANDLE Handle, +NTSTATUS CsrGetObject(PCSRSS_PROCESS_DATA ProcessData, + HANDLE Handle, + PVOID* Object) +{ + *Object = ProcessData->HandleTable[(ULONG)Handle]; + return(STATUS_SUCCESS); +} + +NTSTATUS CsrReleaseObject(PCSRSS_PROCESS_DATA ProcessData, + PVOID Object) +{ +} + +NTSTATUS CsrInsertObject(PCSRSS_PROCESS_DATA ProcessData, + PHANDLE Handle, PVOID Object) +{ + ULONG i; + PVOID* NewBlock; + + for (i = 0; i < ProcessData->HandleTableSize; i++) + { + if (ProcessData->HandleTable[i] == NULL) + { + ProcessData->HandleTable[i] = Object; + *Handle = (HANDLE)((i << 8) | 0x3); + return(STATUS_SUCCESS); + } + } + NewBlock = RtlAllocateHeap(CsrssApiHeap, + HEAP_ZERO_MEMORY, + (ProcessData->HandleTableSize + 64) * + sizeof(HANDLE)); + if (NewBlock == NULL) + { + return(STATUS_NO_MORE_MEMORY); + } + RtlCopyMemory(NewBlock, + ProcessData->HandleTable, + ProcessData->HandleTableSize * sizeof(HANDLE)); + ProcessData->HandleTable[i] = Object; + *Handle = (HANDLE)((i << 8) | 0x3); + ProcessData->HandleTableSize = ProcessData->HandleTableSize + 64; + + return(STATUS_SUCCESS); +} diff --git a/reactos/subsys/csrss/api/process.c b/reactos/subsys/csrss/api/process.c index d9b194bdb1c..58be7d3b977 100644 --- a/reactos/subsys/csrss/api/process.c +++ b/reactos/subsys/csrss/api/process.c @@ -1,4 +1,4 @@ -/* $Id: process.c,v 1.3 1999/12/22 14:48:30 dwelch Exp $ +/* $Id: process.c,v 1.4 1999/12/30 01:51:42 dwelch Exp $ * * reactos/subsys/csrss/api/process.c * @@ -15,11 +15,71 @@ #include "api.h" +/* GLOBALS *******************************************************************/ + +static ULONG NrProcess; +static PCSRSS_PROCESS_DATA ProcessData[256]; + /* FUNCTIONS *****************************************************************/ +PCSRSS_PROCESS_DATA CsrGetProcessData(ULONG ProcessId) +{ + ULONG i; + + for (i=0; iProcessId == ProcessId) + { + return(ProcessData[i]); + } + } + ProcessData[i] = RtlAllocateHeap(CsrssApiHeap, + HEAP_ZERO_MEMORY, + sizeof(CSRSS_PROCESS_DATA)); + if (ProcessData[i] == NULL) + { + return(NULL); + } + ProcessData[i]->ProcessId = ProcessId; + return(ProcessData[i]); +} + + NTSTATUS CsrCreateProcess (PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST LpcMessage) { + PCSRSS_CREATE_PROCESS_REQUEST Request; + PCSRSS_PROCESS_DATA NewProcessData; + + Request = (PCSRSS_CREATE_PROCESS_REQUEST)LpcMessage->Data; + + NewProcessData = CsrGetProcessData(Request->NewProcessId); + + if (NewProcessData == NULL) + { + return(STATUS_NO_MEMORY); + } + + if (Request->Flags & DETACHED_PROCESS) + { + NewProcessData->Console = NULL; + } + else if (Request->Flags & CREATE_NEW_CONSOLE) + { + PCSRSS_CONSOLE Console; + + Console = RtlAllocateHeap(CsrssApiHeap, + HEAP_ZERO_MEMORY, + sizeof(CSRSS_CONSOLE)); + CsrInitConsole(ProcessData, + Console); + NewProcessData->Console = Console; + } + else + { + NewProcessData->Console = ProcessData->Console; + } + return(STATUS_NOT_IMPLEMENTED); } @@ -29,15 +89,9 @@ NTSTATUS CsrTerminateProcess(PCSRSS_PROCESS_DATA ProcessData, return(STATUS_NOT_IMPLEMENTED); } -NTSTATUS CsrConnectProcess(CSRSS_PROCESS_DATA ProcessData, +NTSTATUS CsrConnectProcess(PCSRSS_PROCESS_DATA ProcessData, PCSRSS_API_REQUEST Request) { - HANDLE ConsoleHandle; - - ConsoleHandle = ((PULONG)Request.MessageData)[0]; - - ProcessData.Console = CsrReferenceConsoleByHandle(ConsoleHandle); - return(STATUS_SUCCESS); } diff --git a/reactos/subsys/csrss/api/wapi.c b/reactos/subsys/csrss/api/wapi.c index b8d8a3f095d..01d1b29f825 100644 --- a/reactos/subsys/csrss/api/wapi.c +++ b/reactos/subsys/csrss/api/wapi.c @@ -1,4 +1,4 @@ -/* $Id: wapi.c,v 1.1 1999/12/22 14:48:30 dwelch Exp $ +/* $Id: wapi.c,v 1.2 1999/12/30 01:51:42 dwelch Exp $ * * reactos/subsys/csrss/init.c * @@ -16,6 +16,10 @@ #include "api.h" +/* GLOBALS *******************************************************************/ + +HANDLE CsrssApiHeap; + /* FUNCTIONS *****************************************************************/ static void Thread_Api2(HANDLE ServerPort) @@ -25,7 +29,7 @@ static void Thread_Api2(HANDLE ServerPort) LPCMESSAGE LpcRequest; PCSRSS_API_REQUEST Request; CSRSS_API_REPLY Reply; - CSRSS_PROCESS_DATA ProcessData; + PCSRSS_PROCESS_DATA ProcessData; LpcReply = NULL; @@ -42,39 +46,48 @@ static void Thread_Api2(HANDLE ServerPort) Request = (PCSRSS_API_REQUEST)LpcRequest.MessageData; + ProcessData = CsrGetProcessData(LpcRequest.ClientProcessId); + DisplayString(L"Received request\n"); switch (Request->Type) { case CSRSS_CREATE_PROCESS: - Reply.Status = CsrCreateProcess(&ProcessData, Request); + Reply.Status = CsrCreateProcess(ProcessData, + Request); break; case CSRSS_TERMINATE_PROCESS: - Reply.Status = CsrTerminateProcess(&ProcessData, Request); + Reply.Status = CsrTerminateProcess(ProcessData, + Request); break; case CSRSS_WRITE_CONSOLE: - Reply.Status = CsrWriteConsole(&ProcessData, Request, + Reply.Status = CsrWriteConsole(ProcessData, + Request, &Reply.Count); break; case CSRSS_READ_CONSOLE: - Reply.Status = CsrReadConsole(&ProcessData, Request, + Reply.Status = CsrReadConsole(ProcessData, + Request, &Reply.Count); break; - case CSRSS_NEW_CONSOLE: - Reply.Status = CsrAllocConsole(&ProcessData, Request, + case CSRSS_ALLOC_CONSOLE: + Reply.Status = CsrAllocConsole(ProcessData, + Request, &Reply.Handle); break; case CSRSS_FREE_CONSOLE: - Reply.Status = CsrFreeConsole(&ProcessData, Request); + Reply.Status = CsrFreeConsole(ProcessData, + Request); break; case CSRSS_CONNECT_PROCESS: - Reply.Status = CsrConnectProcess(&ProcessData, Request); + Reply.Status = CsrConnectProcess(ProcessData, + Request); default: Reply.Status = STATUS_NOT_IMPLEMENTED; @@ -99,6 +112,18 @@ void Thread_Api(PVOID PortHandle) LPCMESSAGE Request; HANDLE ServerPort; + CsrssApiHeap = RtlCreateHeap(HEAP_GROWABLE, + NULL, + 65536, + 65536, + NULL, + NULL); + if (CsrssApiHeap == NULL) + { + PrintString("Failed to create private heap, aborting\n"); + return; + } + for (;;) { Status = NtListenPort(PortHandle, &Request); diff --git a/reactos/subsys/csrss/csrss.c b/reactos/subsys/csrss/csrss.c index 76a82e691b2..8ba0154fcff 100644 --- a/reactos/subsys/csrss/csrss.c +++ b/reactos/subsys/csrss/csrss.c @@ -1,4 +1,4 @@ -/* $Id: csrss.c,v 1.3 1999/12/22 14:48:29 dwelch Exp $ +/* $Id: csrss.c,v 1.4 1999/12/30 01:51:41 dwelch Exp $ * * csrss.c - Client/Server Runtime subsystem * @@ -38,17 +38,6 @@ BOOL TerminationRequestPending = FALSE; BOOL InitializeServer(void); -void DisplayString(LPCWSTR Message) -{ - UNICODE_STRING title; - - title.Buffer = (LPWSTR) Message; - title.Length = wcslen(title.Buffer) * sizeof (WCHAR); - title.MaximumLength = title.Length + sizeof (WCHAR); - NtDisplayString(&title); -} - - /* Native process' entry point */ VOID NtProcessStartup(PPEB Peb) diff --git a/reactos/subsys/csrss/init.c b/reactos/subsys/csrss/init.c index b7c945fcbc4..611b8aef7e9 100644 --- a/reactos/subsys/csrss/init.c +++ b/reactos/subsys/csrss/init.c @@ -1,4 +1,4 @@ -/* $Id: init.c,v 1.3 1999/12/22 14:48:29 dwelch Exp $ +/* $Id: init.c,v 1.4 1999/12/30 01:51:41 dwelch Exp $ * * reactos/subsys/csrss/init.c * @@ -23,63 +23,6 @@ */ static HANDLE ApiPortHandle; -#if 0 -static HANDLE SbApiPortHandle; -#endif - - -#if 0 -/********************************************************************** - * NAME - * Thread_SbApi - * - * DESCRIPTION - * Handle connection requests from clients to the port - * "\Windows\SbApiPort". - */ -static -void -Thread_SbApi(void * pPort) -{ - NTSTATUS Status; - HANDLE Port; - HANDLE ConnectedPort; - - Port = * (HANDLE*) pPort; - - Status = NtListenPort( - Port, - CSRSS_SBAPI_PORT_QUEUE_SIZE - ); - if (!NT_SUCCESS(Status)) - { - return; - } - /* - * Wait for a client to connect - */ - while (TRUE) - { - Status = NtAcceptConnectPort( - Port, - & ConnectedPort - ); - if (NT_SUCCESS(Status)) - { - if (NT_SUCCESS(NtCompleteConnectPort(ConnectedPort))) - { - /* dispatch call */ - continue; - } - /* error: Port.CompleteConnect failed */ - continue; - } - /* error: Port.AcceptConnect failed */ - } -} -#endif - - /********************************************************************** * NAME * InitializeServer @@ -100,7 +43,7 @@ BOOL InitializeServer(void) UNICODE_STRING PortName; /* NEW NAMED PORT: \ApiPort */ - RtlInitUnicodeString(&PortName, L"\\ApiPort"); + RtlInitUnicodeString(&PortName, L"\\Windows\\ApiPort"); InitializeObjectAttributes(&ObAttributes, &PortName, 0, @@ -113,7 +56,7 @@ BOOL InitializeServer(void) 0); if (!NT_SUCCESS(Status)) { - DisplayString(L"Unable to create \\ApiPort (Status %x)\n"); + PrintString("Unable to create \\ApiPort (Status %x)\n", Status); return(FALSE); } @@ -129,36 +72,11 @@ BOOL InitializeServer(void) NULL); if (!NT_SUCCESS(Status)) { - DisplayString(L"Unable to create server thread\n"); + PrintString("Unable to create server thread\n"); NtClose(ApiPortHandle); return FALSE; } -#if 0 - /* NEW NAMED PORT: \SbApiPort */ - Status = NtCreatePort( - &Server.SbApi.Port, - & ObAttributes, - ... - ); - if (!NT_SUCCESS(Status)) - { - NtClose(Server.Api.Port); - return FALSE; - } - Status = NtCreateThread( - & Server.SbApi.Thread, - Thread_SbApi, - (void*) & Server.SbApi.Port - ); - if (!NT_SUCCESS(Status)) - { - NtClose(Server.Api.Port); - NtClose(Server.SbApi.Port); - return FALSE; - } -#endif - return TRUE; } diff --git a/reactos/subsys/csrss/makefile b/reactos/subsys/csrss/makefile index bd683310163..bc4c8939ec7 100644 --- a/reactos/subsys/csrss/makefile +++ b/reactos/subsys/csrss/makefile @@ -1,4 +1,4 @@ -# $Id: makefile,v 1.3 1999/12/22 14:48:29 dwelch Exp $ +# $Id: makefile,v 1.4 1999/12/30 01:51:41 dwelch Exp $ # # CSRSS: Client/server runtime subsystem # @@ -8,11 +8,11 @@ TARGET=csrss BASE_CFLAGS = -I../../include -I. -OBJECTS_API = api/process.o api/wapi.o +OBJECTS_API = api/process.o api/wapi.o api/conio.o OBJECTS_SBAPI = -OBJECTS_MISC = $(TARGET).o init.o $(TARGET).coff +OBJECTS_MISC = $(TARGET).o init.o print.o $(TARGET).coff OBJECTS = $(OBJECTS_API) $(OBJECTS_SBAPI) $(OBJECTS_MISC) diff --git a/reactos/subsys/csrss/print.c b/reactos/subsys/csrss/print.c index 10698b89bce..039cebf6f2f 100644 --- a/reactos/subsys/csrss/print.c +++ b/reactos/subsys/csrss/print.c @@ -1,4 +1,4 @@ -/* $Id: print.c,v 1.1 1999/12/22 14:48:29 dwelch Exp $ +/* $Id: print.c,v 1.2 1999/12/30 01:51:41 dwelch Exp $ * * smss.c - Session Manager * @@ -29,7 +29,7 @@ #include -#include "csrss.h" +#include VOID DisplayString(LPCWSTR lpwString) @@ -40,7 +40,7 @@ VOID DisplayString(LPCWSTR lpwString) NtDisplayString (&us); } -VOID PrintString (char* fmt,. ..) +VOID PrintString (char* fmt, ...) { char buffer[512]; va_list ap; diff --git a/reactos/subsys/smss/init.c b/reactos/subsys/smss/init.c index 6edbd4ed558..5f3c139fe39 100644 --- a/reactos/subsys/smss/init.c +++ b/reactos/subsys/smss/init.c @@ -1,4 +1,4 @@ -/* $Id: init.c,v 1.7 1999/12/24 17:17:51 ekohl Exp $ +/* $Id: init.c,v 1.8 1999/12/30 01:51:42 dwelch Exp $ * * init.c - Session Manager initialization * @@ -157,6 +157,7 @@ InitSessionManager ( /* FIXME: Set environment variables from registry */ /* Load the kernel mode driver win32k.sys */ +#if 0 RtlInitUnicodeString (&CmdLineW, L"\\??\\C:\\reactos\\system32\\drivers\\win32k.sys"); Status = NtLoadDriver (&CmdLineW); @@ -165,33 +166,50 @@ InitSessionManager ( { return FALSE; } - - /* Start the Win32 subsystem (csrss.exe) */ -#if 0 - DisplayString (L"SM: Executing csrss.exe\n"); - RtlInitUnicodeString (&UnicodeString, - L"\\??\\C:\\reactos\\system32\\csrss.exe"); - - Status = RtlCreateUserProcess (&UnicodeString, - NULL, - NULL, - FALSE, - 0, - NULL, - &Children[CHILD_CSRSS], - NULL); - - if (!NT_SUCCESS(Status)) - { - DisplayString (L"SM: Loading csrss.exe failed!\n"); - return FALSE; - } #endif - /* Start the simple shell (shell.exe) */ - DisplayString (L"SM: Executing shell\n"); - RtlInitUnicodeString (&UnicodeString, - L"\\??\\C:\\reactos\\system32\\shell.exe"); +#if 0 + /* Start the Win32 subsystem (csrss.exe) */ + DisplayString (L"SM: Executing csrss.exe\n"); + RtlInitUnicodeString (&UnicodeString, + L"\\??\\C:\\reactos\\system32\\csrss.exe"); + + RtlCreateProcessParameters (&Ppb, + &UnicodeString, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL); + + Status = RtlCreateUserProcess (&UnicodeString, + 0, + Ppb, + NULL, + NULL, + FALSE, + 0, + NULL, + &Children[CHILD_CSRSS], + NULL); + + if (!NT_SUCCESS(Status)) + { + DisplayString (L"SM: Loading csrss.exe failed!\n"); + return FALSE; + } + + RtlDestroyProcessParameters (Ppb); + +#endif + + /* Start the simple shell (shell.exe) */ + DisplayString (L"SM: Executing shell\n"); + RtlInitUnicodeString (&UnicodeString, + L"\\??\\C:\\reactos\\system32\\shell.exe"); #if 0 /* Start the logon process (winlogon.exe) */ RtlInitUnicodeString (&CmdLineW,