Author: ekohl Date: Wed Mar 17 00:10:03 2010 New Revision: 46233
URL: http://svn.reactos.org/svn/reactos?rev=46233&view=rev Log: [ADVAPI32] - Create a service status handle when a service starts and destroy it after it has been stopped.
Modified: trunk/reactos/dll/win32/advapi32/service/scm.c trunk/reactos/dll/win32/advapi32/service/sctrl.c
Modified: trunk/reactos/dll/win32/advapi32/service/scm.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service/... ============================================================================== --- trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/service/scm.c [iso-8859-1] Wed Mar 17 00:10:03 2010 @@ -122,61 +122,6 @@ RPC_STATUS status;
TRACE("SVCCTL_HANDLEW_unbind() called\n"); - - status = RpcBindingFree(&hBinding); - if (status != RPC_S_OK) - { - ERR("RpcBindingFree returned 0x%x\n", status); - } -} - - -handle_t __RPC_USER -RPC_SERVICE_STATUS_HANDLE_bind(RPC_SERVICE_STATUS_HANDLE hServiceStatus) -{ - handle_t hBinding = NULL; - LPWSTR pszStringBinding; - RPC_STATUS status; - - TRACE("RPC_SERVICE_STATUS_HANDLE_bind() called\n"); - - status = RpcStringBindingComposeW(NULL, - L"ncacn_np", - NULL, - L"\pipe\ntsvcs", - NULL, - &pszStringBinding); - if (status != RPC_S_OK) - { - ERR("RpcStringBindingCompose returned 0x%x\n", status); - return NULL; - } - - /* Set the binding handle that will be used to bind to the server. */ - status = RpcBindingFromStringBindingW(pszStringBinding, - &hBinding); - if (status != RPC_S_OK) - { - ERR("RpcBindingFromStringBinding returned 0x%x\n", status); - } - - status = RpcStringFreeW(&pszStringBinding); - if (status != RPC_S_OK) - { - ERR("RpcStringFree returned 0x%x\n", status); - } - - return hBinding; -} - - -void __RPC_USER -RPC_SERVICE_STATUS_HANDLE_unbind(RPC_SERVICE_STATUS_HANDLE hServiceStatus, - handle_t hBinding) -{ - RPC_STATUS status; - - TRACE("RPC_SERVICE_STATUS_HANDLE_unbind() called\n");
status = RpcBindingFree(&hBinding); if (status != RPC_S_OK)
Modified: trunk/reactos/dll/win32/advapi32/service/sctrl.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/advapi32/service/... ============================================================================== --- trunk/reactos/dll/win32/advapi32/service/sctrl.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/advapi32/service/sctrl.c [iso-8859-1] Wed Mar 17 00:10:03 2010 @@ -41,9 +41,86 @@
static DWORD dwActiveServiceCount = 0; static PACTIVE_SERVICE lpActiveServices = NULL; +static handle_t hStatusBinding = NULL;
/* FUNCTIONS *****************************************************************/ + +handle_t __RPC_USER +RPC_SERVICE_STATUS_HANDLE_bind(RPC_SERVICE_STATUS_HANDLE hServiceStatus) +{ + return hStatusBinding; +} + + +void __RPC_USER +RPC_SERVICE_STATUS_HANDLE_unbind(RPC_SERVICE_STATUS_HANDLE hServiceStatus, + handle_t hBinding) +{ +} + + +static RPC_STATUS +ScCreateStatusBinding(VOID) +{ + LPWSTR pszStringBinding; + RPC_STATUS status; + + TRACE("ScCreateStatusBinding() called\n"); + + status = RpcStringBindingComposeW(NULL, + L"ncacn_np", + NULL, + L"\pipe\ntsvcs", + NULL, + &pszStringBinding); + if (status != RPC_S_OK) + { + ERR("RpcStringBindingCompose returned 0x%x\n", status); + return status; + } + + /* Set the binding handle that will be used to bind to the server. */ + status = RpcBindingFromStringBindingW(pszStringBinding, + &hStatusBinding); + if (status != RPC_S_OK) + { + ERR("RpcBindingFromStringBinding returned 0x%x\n", status); + } + + status = RpcStringFreeW(&pszStringBinding); + if (status != RPC_S_OK) + { + ERR("RpcStringFree returned 0x%x\n", status); + } + + return status; +} + + +static RPC_STATUS +ScDestroyStatusBinding(VOID) +{ + RPC_STATUS status; + + TRACE("ScDestroyStatusBinding() called\n"); + + if (hStatusBinding == NULL) + return RPC_S_OK; + + status = RpcBindingFree(&hStatusBinding); + if (status != RPC_S_OK) + { + ERR("RpcBindingFree returned 0x%x\n", status); + } + else + { + hStatusBinding = NULL; + } + + return status; +} +
static PACTIVE_SERVICE ScLookupServiceByServiceName(LPCWSTR lpServiceName) @@ -259,7 +336,6 @@
TRACE("Sent Process ID %lu\n", dwProcessId);
- return ERROR_SUCCESS; }
@@ -403,7 +479,7 @@ } else { - dwError = ERROR_NOT_FOUND; + dwError = ERROR_SERVICE_DOES_NOT_EXIST; }
ReplyPacket.dwError = dwError; @@ -747,7 +823,12 @@ return FALSE; }
+ ScCreateStatusBinding(); + ScServiceDispatcher(hPipe, lpMessageBuffer, 256); + + ScDestroyStatusBinding(); + CloseHandle(hPipe);
/* Free the message buffer */ @@ -837,7 +918,12 @@ return FALSE; }
+ ScCreateStatusBinding(); + ScServiceDispatcher(hPipe, lpMessageBuffer, 256); + + ScDestroyStatusBinding(); + CloseHandle(hPipe);
/* Free the message buffer */