{
handle_t hBinding = NULL;
RPC_CSTR pszStringBinding;
- RPC_STATUS Status;
+ RPC_STATUS status;
TRACE("EVENTLOG_HANDLE_A_bind() called\n");
- Status = RpcStringBindingComposeA(NULL,
+ status = RpcStringBindingComposeA(NULL,
(RPC_CSTR)"ncacn_np",
(RPC_CSTR)UNCServerName,
(RPC_CSTR)"\\pipe\\EventLog",
NULL,
&pszStringBinding);
- if (Status)
+ if (status)
{
- ERR("RpcStringBindingCompose returned 0x%x\n", Status);
+ ERR("RpcStringBindingCompose returned 0x%x\n", status);
return NULL;
}
/* Set the binding handle that will be used to bind to the server. */
- Status = RpcBindingFromStringBindingA(pszStringBinding,
+ status = RpcBindingFromStringBindingA(pszStringBinding,
&hBinding);
- if (Status != RPC_S_OK)
+ if (status != RPC_S_OK)
{
- ERR("RpcBindingFromStringBinding returned 0x%x\n", Status);
+ ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
}
- Status = RpcStringFreeA(&pszStringBinding);
- if (Status != RPC_S_OK)
+ status = RpcStringFreeA(&pszStringBinding);
+ if (status != RPC_S_OK)
{
- ERR("RpcStringFree returned 0x%x\n", Status);
+ ERR("RpcStringFree returned 0x%x\n", status);
}
return hBinding;
EVENTLOG_HANDLE_A_unbind(EVENTLOG_HANDLE_A UNCServerName,
handle_t hBinding)
{
- RPC_STATUS Status;
+ RPC_STATUS status;
TRACE("EVENTLOG_HANDLE_A_unbind() called\n");
- Status = RpcBindingFree(&hBinding);
- if (Status != RPC_S_OK)
+ status = RpcBindingFree(&hBinding);
+ if (status != RPC_S_OK)
{
- ERR("RpcBindingFree returned 0x%x\n", Status);
+ ERR("RpcBindingFree returned 0x%x\n", status);
}
}
{
handle_t hBinding = NULL;
RPC_WSTR pszStringBinding;
- RPC_STATUS Status;
+ RPC_STATUS status;
TRACE("EVENTLOG_HANDLE_W_bind() called\n");
- Status = RpcStringBindingComposeW(NULL,
+ status = RpcStringBindingComposeW(NULL,
L"ncacn_np",
UNCServerName,
L"\\pipe\\EventLog",
NULL,
&pszStringBinding);
- if (Status != RPC_S_OK)
+ if (status != RPC_S_OK)
{
- ERR("RpcStringBindingCompose returned 0x%x\n", Status);
+ 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,
+ status = RpcBindingFromStringBindingW(pszStringBinding,
&hBinding);
- if (Status != RPC_S_OK)
+ if (status != RPC_S_OK)
{
- ERR("RpcBindingFromStringBinding returned 0x%x\n", Status);
+ ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
}
- Status = RpcStringFreeW(&pszStringBinding);
- if (Status != RPC_S_OK)
+ status = RpcStringFreeW(&pszStringBinding);
+ if (status != RPC_S_OK)
{
- ERR("RpcStringFree returned 0x%x\n", Status);
+ ERR("RpcStringFree returned 0x%x\n", status);
}
return hBinding;
EVENTLOG_HANDLE_W_unbind(EVENTLOG_HANDLE_W UNCServerName,
handle_t hBinding)
{
- RPC_STATUS Status;
+ RPC_STATUS status;
TRACE("EVENTLOG_HANDLE_W_unbind() called\n");
- Status = RpcBindingFree(&hBinding);
- if (Status != RPC_S_OK)
+ status = RpcBindingFree(&hBinding);
+ if (status != RPC_S_OK)
{
- ERR("RpcBindingFree returned 0x%x\n", Status);
+ ERR("RpcBindingFree returned 0x%x\n", status);
}
}
{
Status = ElfrOpenBELW(pUNCServerName,
(PRPC_UNICODE_STRING)BackupFileNameU,
- 1, 1,
+ 1,
+ 1,
(IELF_HANDLE*)phEventLog);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
RtlInitUnicodeString(&UNCServerName, lpUNCServerName);
Status = ElfOpenBackupEventLogW(&UNCServerName, &FileName, &hEventLog);
-
+
if (FileName.Buffer != NULL)
RtlFreeHeap(RtlGetProcessHeap(), 0, FileName.Buffer);
Status = ElfrOpenELA(pUNCServerName,
(PRPC_STRING)SourceNameA,
&EmptyStringA,
- 1, 1,
+ 1,
+ 1,
(IELF_HANDLE*)phEventLog);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
Status = ElfrOpenELW(pUNCServerName,
(PRPC_UNICODE_STRING)SourceNameU,
&EmptyStringU,
- 1, 1,
+ 1,
+ 1,
(IELF_HANDLE*)phEventLog);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
Status = ElfrRegisterEventSourceA(pUNCServerName,
(PRPC_STRING)SourceNameA,
&EmptyStringA,
- 1, 1,
+ 1,
+ 1,
(IELF_HANDLE*)phEventLog);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
Status = ElfrRegisterEventSourceW(pUNCServerName,
(PRPC_UNICODE_STRING)SourceNameU,
&EmptyStringU,
- 1, 1,
+ 1,
+ 1,
(IELF_HANDLE*)phEventLog);
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
/* INCLUDES ******************************************************************/
#include <advapi32.h>
-WINE_DEFAULT_DEBUG_CHANNEL(advapi_service);
+WINE_DEFAULT_DEBUG_CHANNEL(advapi);
/* FUNCTIONS *****************************************************************/
{
handle_t hBinding = NULL;
RPC_CSTR pszStringBinding;
- RPC_STATUS Status;
+ RPC_STATUS status;
TRACE("SVCCTL_HANDLEA_bind(%s)\n",
debugstr_a(szMachineName));
- Status = RpcStringBindingComposeA(NULL,
+ status = RpcStringBindingComposeA(NULL,
(RPC_CSTR)"ncacn_np",
(RPC_CSTR)szMachineName,
(RPC_CSTR)"\\pipe\\ntsvcs",
NULL,
&pszStringBinding);
- if (Status != RPC_S_OK)
+ if (status != RPC_S_OK)
{
- ERR("RpcStringBindingCompose returned 0x%x\n", Status);
+ ERR("RpcStringBindingCompose returned 0x%x\n", status);
return NULL;
}
/* Set the binding handle that will be used to bind to the server. */
- Status = RpcBindingFromStringBindingA(pszStringBinding,
+ status = RpcBindingFromStringBindingA(pszStringBinding,
&hBinding);
- if (Status != RPC_S_OK)
+ if (status != RPC_S_OK)
{
- ERR("RpcBindingFromStringBinding returned 0x%x\n", Status);
+ ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
}
- Status = RpcStringFreeA(&pszStringBinding);
- if (Status != RPC_S_OK)
+ status = RpcStringFreeA(&pszStringBinding);
+ if (status != RPC_S_OK)
{
- ERR("RpcStringFree returned 0x%x\n", Status);
+ ERR("RpcStringFree returned 0x%x\n", status);
}
return hBinding;
SVCCTL_HANDLEA_unbind(SVCCTL_HANDLEA szMachineName,
handle_t hBinding)
{
- RPC_STATUS Status;
+ RPC_STATUS status;
TRACE("SVCCTL_HANDLEA_unbind(%s %p)\n",
debugstr_a(szMachineName), hBinding);
- Status = RpcBindingFree(&hBinding);
- if (Status != RPC_S_OK)
+ status = RpcBindingFree(&hBinding);
+ if (status != RPC_S_OK)
{
- ERR("RpcBindingFree returned 0x%x\n", Status);
+ ERR("RpcBindingFree returned 0x%x\n", status);
}
}
{
handle_t hBinding = NULL;
RPC_WSTR pszStringBinding;
- RPC_STATUS Status;
+ RPC_STATUS status;
TRACE("SVCCTL_HANDLEW_bind(%s)\n",
debugstr_w(szMachineName));
- Status = RpcStringBindingComposeW(NULL,
+ status = RpcStringBindingComposeW(NULL,
L"ncacn_np",
szMachineName,
L"\\pipe\\ntsvcs",
NULL,
&pszStringBinding);
- if (Status != RPC_S_OK)
+ if (status != RPC_S_OK)
{
- ERR("RpcStringBindingCompose returned 0x%x\n", Status);
+ 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,
+ status = RpcBindingFromStringBindingW(pszStringBinding,
&hBinding);
- if (Status != RPC_S_OK)
+ if (status != RPC_S_OK)
{
- ERR("RpcBindingFromStringBinding returned 0x%x\n", Status);
+ ERR("RpcBindingFromStringBinding returned 0x%x\n", status);
}
- Status = RpcStringFreeW(&pszStringBinding);
- if (Status != RPC_S_OK)
+ status = RpcStringFreeW(&pszStringBinding);
+ if (status != RPC_S_OK)
{
- ERR("RpcStringFree returned 0x%x\n", Status);
+ ERR("RpcStringFree returned 0x%x\n", status);
}
return hBinding;
SVCCTL_HANDLEW_unbind(SVCCTL_HANDLEW szMachineName,
handle_t hBinding)
{
- RPC_STATUS Status;
+ RPC_STATUS status;
TRACE("SVCCTL_HANDLEW_unbind(%s %p)\n",
debugstr_w(szMachineName), hBinding);
- Status = RpcBindingFree(&hBinding);
- if (Status != RPC_S_OK)
+ status = RpcBindingFree(&hBinding);
+ if (status != RPC_S_OK)
{
- ERR("RpcBindingFree returned 0x%x\n", Status);
+ ERR("RpcBindingFree returned 0x%x\n", status);
}
}
-/* HACK: because of a problem with rpcrt4, rpcserver is hacked to return 6 for ERROR_SERVICE_DOES_NOT_EXIST */
DWORD
ScmRpcStatusToWinError(RPC_STATUS Status)
{
}
RpcExcept(EXCEPTION_EXECUTE_HANDLER)
{
+ /* HACK: because of a problem with rpcrt4, rpcserver is hacked to return 6 for ERROR_SERVICE_DOES_NOT_EXIST */
dwError = ScmRpcStatusToWinError(RpcExceptionCode());
}
RpcEndExcept;
hEvent = OpenEventW(SYNCHRONIZE, FALSE, SCM_START_EVENT);
if (hEvent == NULL)
{
- if (GetLastError() != ERROR_FILE_NOT_FOUND) return;
+ if (GetLastError() != ERROR_FILE_NOT_FOUND)
+ return;
/* Try to create a new event */
hEvent = CreateEventW(NULL, TRUE, FALSE, SCM_START_EVENT);
- if (hEvent == NULL) return;
+ if (hEvent == NULL)
+ return;
}
/* Wait for 3 minutes */
/* INCLUDES ******************************************************************/
#include <advapi32.h>
-WINE_DEFAULT_DEBUG_CHANNEL(advapi_service);
+WINE_DEFAULT_DEBUG_CHANNEL(advapi);
/* TYPES *********************************************************************/
}
-static DWORD
-ScLookupServiceByServiceName(IN LPCWSTR lpServiceName,
- OUT PACTIVE_SERVICE* pService)
+static PACTIVE_SERVICE
+ScLookupServiceByServiceName(LPCWSTR lpServiceName)
{
DWORD i;
lpServiceName);
if (lpActiveServices[0].bOwnProcess)
- {
- *pService = &lpActiveServices[0];
- return ERROR_SUCCESS;
- }
+ return &lpActiveServices[0];
for (i = 0; i < dwActiveServiceCount; i++)
{
if (_wcsicmp(lpActiveServices[i].ServiceName.Buffer, lpServiceName) == 0)
{
TRACE("Found!\n");
- *pService = &lpActiveServices[i];
- return ERROR_SUCCESS;
+ return &lpActiveServices[i];
}
}
TRACE("No service found!\n");
- *pService = NULL;
- return ERROR_SERVICE_NOT_IN_EXE;
+ return NULL;
}
if (ControlPacket->dwControl == SERVICE_CONTROL_START_OWN)
lpActiveServices[0].bOwnProcess = TRUE;
- dwError = ScLookupServiceByServiceName(lpServiceName, &lpService);
- if ((dwError == ERROR_SUCCESS) && (lpService != NULL))
+ lpService = ScLookupServiceByServiceName(lpServiceName);
+ if (lpService != NULL)
{
/* Execute command */
switch (ControlPacket->dwControl)
break;
}
}
+ else
+ {
+ dwError = ERROR_SERVICE_NOT_IN_EXE;
+ }
}
ReplyPacket.dwError = dwError;
RegisterServiceCtrlHandlerW(LPCWSTR lpServiceName,
LPHANDLER_FUNCTION lpHandlerProc)
{
- DWORD dwError;
PACTIVE_SERVICE Service;
TRACE("RegisterServiceCtrlHandlerW(%s %p %p)\n",
debugstr_w(lpServiceName), lpHandlerProc);
- dwError = ScLookupServiceByServiceName(lpServiceName, &Service);
- if ((dwError != ERROR_SUCCESS) || (Service == NULL))
+ Service = ScLookupServiceByServiceName(lpServiceName);
+ if (Service == NULL)
{
- SetLastError(dwError);
+ SetLastError(ERROR_SERVICE_NOT_IN_EXE);
return NULL;
}
return NULL;
}
- Service->HandlerFunction = lpHandlerProc;
+ Service->HandlerFunction = lpHandlerProc;
Service->HandlerFunctionEx = NULL;
TRACE("RegisterServiceCtrlHandler returning %p\n", Service->hServiceStatus);
LPHANDLER_FUNCTION_EX lpHandlerProc,
LPVOID lpContext)
{
- DWORD dwError;
PACTIVE_SERVICE Service;
TRACE("RegisterServiceCtrlHandlerExW(%s %p %p)\n",
debugstr_w(lpServiceName), lpHandlerProc, lpContext);
- dwError = ScLookupServiceByServiceName(lpServiceName, &Service);
- if ((dwError != ERROR_SUCCESS) || (Service == NULL))
+ Service = ScLookupServiceByServiceName(lpServiceName);
+ if (Service == NULL)
{
- SetLastError(dwError);
+ SetLastError(ERROR_SERVICE_NOT_IN_EXE);
return NULL;
}
return NULL;
}
- Service->HandlerFunction = NULL;
+ Service->HandlerFunction = NULL;
Service->HandlerFunctionEx = lpHandlerProc;
- Service->HandlerContext = lpContext;
+ Service->HandlerContext = lpContext;
- TRACE("RegisterServiceCtrlHandlerEx returning 0x%p\n", Service->hServiceStatus);
+ TRACE("RegisterServiceCtrlHandlerEx returning %p\n", Service->hServiceStatus);
return Service->hServiceStatus;
}
dwActiveServiceCount = i;
- /* Initialize the service table */
+ /* Allocate the service table */
lpActiveServices = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY,
dwActiveServiceCount * sizeof(ACTIVE_SERVICE));
lpActiveServices[i].bOwnProcess = FALSE;
}
- /* Initialize the connection to the SCM */
-
+ /* Connect to the SCM */
dwError = ScConnectControlPipe(&hPipe);
if (dwError != ERROR_SUCCESS)
{
bRet = FALSE;
- goto Done;
+ goto done;
}
dwBufSize = sizeof(SCM_CONTROL_PACKET) +
{
dwError = ERROR_NOT_ENOUGH_MEMORY;
bRet = FALSE;
- goto Done;
+ goto done;
}
ScCreateStatusBinding();
- /* Start the dispatcher loop */
+ /* Call the dispatcher loop */
ScServiceDispatcher(hPipe, ControlPacket, dwBufSize);
- /* Close the connection */
+
ScDestroyStatusBinding();
+
+ /* Close the connection */
CloseHandle(hPipe);
/* Free the control packet */
RtlFreeHeap(RtlGetProcessHeap(), 0, ControlPacket);
-Done:
+done:
/* Free the service table */
for (i = 0; i < dwActiveServiceCount; i++)
{
lpActiveServices = NULL;
dwActiveServiceCount = 0;
- if (!bRet) SetLastError(dwError);
+ if (!bRet)
+ SetLastError(dwError);
return bRet;
}
dwActiveServiceCount = i;
- /* Initialize the service table */
+ /* Allocate the service table */
lpActiveServices = RtlAllocateHeap(RtlGetProcessHeap(),
HEAP_ZERO_MEMORY,
dwActiveServiceCount * sizeof(ACTIVE_SERVICE));
lpActiveServices[i].bOwnProcess = FALSE;
}
- /* Initialize the connection to the SCM */
-
+ /* Connect to the SCM */
dwError = ScConnectControlPipe(&hPipe);
if (dwError != ERROR_SUCCESS)
{
bRet = FALSE;
- goto Done;
+ goto done;
}
dwBufSize = sizeof(SCM_CONTROL_PACKET) +
{
dwError = ERROR_NOT_ENOUGH_MEMORY;
bRet = FALSE;
- goto Done;
+ goto done;
}
ScCreateStatusBinding();
- /* Start the dispatcher loop */
+ /* Call the dispatcher loop */
ScServiceDispatcher(hPipe, ControlPacket, dwBufSize);
- /* Close the connection */
ScDestroyStatusBinding();
+
+ /* Close the connection */
CloseHandle(hPipe);
/* Free the control packet */
RtlFreeHeap(RtlGetProcessHeap(), 0, ControlPacket);
-Done:
+done:
/* Free the service table */
for (i = 0; i < dwActiveServiceCount; i++)
{
lpActiveServices = NULL;
dwActiveServiceCount = 0;
- if (!bRet) SetLastError(dwError);
+ if (!bRet)
+ SetLastError(dwError);
return bRet;
}