From cea1f1e0a6543e232a790dccbdf246484083b26d Mon Sep 17 00:00:00 2001 From: Emanuele Aliberti Date: Thu, 24 Feb 2005 22:20:43 +0000 Subject: [PATCH] Added some init code for the embedded DBGSS. svn path=/trunk/; revision=13736 --- reactos/subsys/smss/debug.c | 175 ++++++++++++++++++++++++++---------- reactos/subsys/smss/smapi.c | 2 +- 2 files changed, 129 insertions(+), 48 deletions(-) diff --git a/reactos/subsys/smss/debug.c b/reactos/subsys/smss/debug.c index e7848df3d62..abff1600955 100644 --- a/reactos/subsys/smss/debug.c +++ b/reactos/subsys/smss/debug.c @@ -26,66 +26,147 @@ #define NTOS_MODE_USER #include #include -#include #include "smss.h" +#define NDEBUG +#include + + /* GLOBALS ***********************************************************/ -HANDLE DbgSsApiPort = INVALID_HANDLE_VALUE; -HANDLE DbgUiApiPort = INVALID_HANDLE_VALUE; +HANDLE DbgSsApiPort = (HANDLE) 0; +HANDLE DbgUiApiPort = (HANDLE) 0; /* FUNCTIONS *********************************************************/ +static VOID STDCALL +DbgSsApiPortThread (PVOID dummy) +{ + NTSTATUS Status = STATUS_SUCCESS; + LPC_MAX_MESSAGE Request = {{0}}; + + while (TRUE) + { + Status = NtListenPort (DbgSsApiPort, & Request.Header); + if (!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status); + break; + } + /* TODO */ + } + NtTerminateThread(NtCurrentThread(),Status); +} + +static VOID STDCALL +DbgUiApiPortThread (PVOID dummy) +{ + NTSTATUS Status = STATUS_SUCCESS; + LPC_MAX_MESSAGE Request = {{0}}; + + while (TRUE) + { + Status = NtListenPort (DbgUiApiPort, & Request.Header); + if (!NT_SUCCESS(Status)) + { + DPRINT1("SM: %s: NtListenPort() failed! (Status==x%08lx)\n", __FUNCTION__, Status); + break; + } + /* TODO */ + } + NtTerminateThread(NtCurrentThread(),Status); +} + +static NTSTATUS STDCALL +SmpCreatePT (IN OUT PHANDLE hPort, + IN LPWSTR wcPortName, + IN ULONG ulMaxDataSize, + IN ULONG ulMaxMessageSize, + IN ULONG ulPoolCharge OPTIONAL, + IN VOID (STDCALL * procServingThread)(PVOID) OPTIONAL, + IN OUT PHANDLE phServingThread OPTIONAL) +{ + NTSTATUS Status = STATUS_SUCCESS; + UNICODE_STRING PortName = {0}; + OBJECT_ATTRIBUTES ObjectAttributes; + HANDLE Thread = (HANDLE) 0; + CLIENT_ID Cid = {0, 0}; + + RtlInitUnicodeString (& PortName, wcPortName); + InitializeObjectAttributes (& ObjectAttributes, + & PortName, + PORT_ALL_ACCESS, + NULL, + NULL); + Status = NtCreatePort (hPort, + & ObjectAttributes, + ulMaxDataSize, + ulMaxMessageSize, + ulPoolCharge); + if(STATUS_SUCCESS != Status) + { + return Status; + } + /* Create thread for DbgSsApiPort */ + RtlCreateUserThread(NtCurrentProcess(), + NULL, + FALSE, + 0, + NULL, + NULL, + (PTHREAD_START_ROUTINE) procServingThread, + hPort, + & Thread, + & Cid); + if((HANDLE) 0 == Thread) + { + NtClose(*hPort); + Status = STATUS_UNSUCCESSFUL; + } + if(NULL != phServingThread) + { + *phServingThread = Thread; + } + return Status; +} + NTSTATUS SmInitializeDbgSs (VOID) { - NTSTATUS Status; - UNICODE_STRING UnicodeString; - OBJECT_ATTRIBUTES ObjectAttributes; + NTSTATUS Status = STATUS_SUCCESS; + HANDLE hDbgSsApiPortThread = (HANDLE) 0; + DPRINT("SM: %s called\n", __FUNCTION__); - /* Create the \DbgSsApiPort object (LPC) */ - RtlRosInitUnicodeStringFromLiteral(&UnicodeString, - L"\\DbgSsApiPort"); - InitializeObjectAttributes(&ObjectAttributes, - &UnicodeString, - PORT_ALL_ACCESS, - NULL, + /* Create the \DbgSsApiPort object (LPC) */ + Status = SmpCreatePT(& DbgSsApiPort, + SM_DBGSS_PORT_NAME, + 0, /* MaxDataSize */ + 0, /* MaxMessageSize */ + 0, /* PoolCharge */ + DbgSsApiPortThread, + & hDbgSsApiPortThread); + if(!NT_SUCCESS(Status)) + { + DPRINT("SM: %s: DBGSS port not created\n",__FUNCTION__); + return Status; + } + /* Create the \DbgUiApiPort object (LPC) */ + Status = SmpCreatePT(& DbgUiApiPort, + SM_DBGUI_PORT_NAME, + 0, /* MaxDataSize */ + 0, /* MaxMessageSize */ + 0, /* PoolCharge */ + DbgUiApiPortThread, NULL); - - Status = NtCreatePort(&DbgSsApiPort, - &ObjectAttributes, - 0, - 0, - 0); - - if (!NT_SUCCESS(Status)) - { - return(Status); - } - DbgPrint("SMSS: %s: \\DbgSsApiPort created\n",__FUNCTION__); - - /* Create the \DbgUiApiPort object (LPC) */ - RtlRosInitUnicodeStringFromLiteral(&UnicodeString, - L"\\DbgUiApiPort"); - InitializeObjectAttributes(&ObjectAttributes, - &UnicodeString, - PORT_ALL_ACCESS, - NULL, - NULL); - - Status = NtCreatePort(&DbgUiApiPort, - &ObjectAttributes, - 0, - 0, - 0); - if (!NT_SUCCESS(Status)) - { - return(Status); - } - DbgPrint("SMSS: %s: \\DbgUiApiPort created\n",__FUNCTION__); - - return STATUS_SUCCESS; + if(!NT_SUCCESS(Status)) + { + DPRINT("SM: %s: DBGUI port not created\n",__FUNCTION__); + NtClose (hDbgSsApiPortThread); + NtClose (DbgSsApiPort); + return Status; + } + return STATUS_SUCCESS; } /* EOF */ diff --git a/reactos/subsys/smss/smapi.c b/reactos/subsys/smss/smapi.c index 33a062deb9c..78cac41ce83 100644 --- a/reactos/subsys/smss/smapi.c +++ b/reactos/subsys/smss/smapi.c @@ -9,7 +9,7 @@ #include "smss.h" #include -//#define NDEBUG +#define NDEBUG #include /* GLOBAL VARIABLES *********************************************************/