mirror of
https://github.com/reactos/reactos.git
synced 2025-08-03 18:35:41 +00:00
[ADVAPI32]
- Create a service status handle when a service starts and destroy it after it has been stopped. svn path=/trunk/; revision=46233
This commit is contained in:
parent
4670adcf35
commit
174145f20c
2 changed files with 88 additions and 57 deletions
|
@ -131,61 +131,6 @@ SVCCTL_HANDLEW_unbind(SVCCTL_HANDLEW szMachineName,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
ERR("RpcBindingFree returned 0x%x\n", status);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
DWORD
|
DWORD
|
||||||
ScmRpcStatusToWinError(RPC_STATUS Status)
|
ScmRpcStatusToWinError(RPC_STATUS Status)
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,10 +41,87 @@ typedef struct _ACTIVE_SERVICE
|
||||||
|
|
||||||
static DWORD dwActiveServiceCount = 0;
|
static DWORD dwActiveServiceCount = 0;
|
||||||
static PACTIVE_SERVICE lpActiveServices = NULL;
|
static PACTIVE_SERVICE lpActiveServices = NULL;
|
||||||
|
static handle_t hStatusBinding = NULL;
|
||||||
|
|
||||||
|
|
||||||
/* FUNCTIONS *****************************************************************/
|
/* 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
|
static PACTIVE_SERVICE
|
||||||
ScLookupServiceByServiceName(LPCWSTR lpServiceName)
|
ScLookupServiceByServiceName(LPCWSTR lpServiceName)
|
||||||
{
|
{
|
||||||
|
@ -259,7 +336,6 @@ ScConnectControlPipe(HANDLE *hPipe)
|
||||||
|
|
||||||
TRACE("Sent Process ID %lu\n", dwProcessId);
|
TRACE("Sent Process ID %lu\n", dwProcessId);
|
||||||
|
|
||||||
|
|
||||||
return ERROR_SUCCESS;
|
return ERROR_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -403,7 +479,7 @@ ScServiceDispatcher(HANDLE hPipe,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
dwError = ERROR_NOT_FOUND;
|
dwError = ERROR_SERVICE_DOES_NOT_EXIST;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReplyPacket.dwError = dwError;
|
ReplyPacket.dwError = dwError;
|
||||||
|
@ -747,7 +823,12 @@ StartServiceCtrlDispatcherA(const SERVICE_TABLE_ENTRYA * lpServiceStartTable)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScCreateStatusBinding();
|
||||||
|
|
||||||
ScServiceDispatcher(hPipe, lpMessageBuffer, 256);
|
ScServiceDispatcher(hPipe, lpMessageBuffer, 256);
|
||||||
|
|
||||||
|
ScDestroyStatusBinding();
|
||||||
|
|
||||||
CloseHandle(hPipe);
|
CloseHandle(hPipe);
|
||||||
|
|
||||||
/* Free the message buffer */
|
/* Free the message buffer */
|
||||||
|
@ -837,7 +918,12 @@ StartServiceCtrlDispatcherW(const SERVICE_TABLE_ENTRYW * lpServiceStartTable)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ScCreateStatusBinding();
|
||||||
|
|
||||||
ScServiceDispatcher(hPipe, lpMessageBuffer, 256);
|
ScServiceDispatcher(hPipe, lpMessageBuffer, 256);
|
||||||
|
|
||||||
|
ScDestroyStatusBinding();
|
||||||
|
|
||||||
CloseHandle(hPipe);
|
CloseHandle(hPipe);
|
||||||
|
|
||||||
/* Free the message buffer */
|
/* Free the message buffer */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue