2008-03-28 17:56:00 +01:00
|
|
|
/*
|
|
|
|
* Services.exe - RPC functions
|
|
|
|
*
|
|
|
|
* Copyright 2007 Google (Mikolaj Zalewski)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
2015-02-28 17:30:54 +01:00
|
|
|
#define NONAMELESSUNION
|
2008-03-28 17:56:00 +01:00
|
|
|
|
|
|
|
#include <stdarg.h>
|
|
|
|
#include <windows.h>
|
|
|
|
#include <winternl.h>
|
|
|
|
#include <winsvc.h>
|
|
|
|
#include <ntsecapi.h>
|
|
|
|
#include <rpc.h>
|
|
|
|
|
|
|
|
#include "wine/list.h"
|
|
|
|
#include "wine/unicode.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
#include "services.h"
|
|
|
|
#include "svcctl.h"
|
|
|
|
|
2008-12-16 16:37:46 +01:00
|
|
|
extern HANDLE CDECL __wine_make_process_system(void);
|
2008-03-28 17:56:00 +01:00
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(service);
|
|
|
|
|
|
|
|
static const GENERIC_MAPPING g_scm_generic =
|
|
|
|
{
|
|
|
|
(STANDARD_RIGHTS_READ | SC_MANAGER_ENUMERATE_SERVICE | SC_MANAGER_QUERY_LOCK_STATUS),
|
|
|
|
(STANDARD_RIGHTS_WRITE | SC_MANAGER_CREATE_SERVICE | SC_MANAGER_MODIFY_BOOT_CONFIG),
|
|
|
|
(STANDARD_RIGHTS_EXECUTE | SC_MANAGER_CONNECT | SC_MANAGER_LOCK),
|
|
|
|
SC_MANAGER_ALL_ACCESS
|
|
|
|
};
|
|
|
|
|
2008-03-15 16:42:38 +01:00
|
|
|
static const GENERIC_MAPPING g_svc_generic =
|
|
|
|
{
|
|
|
|
(STANDARD_RIGHTS_READ | SERVICE_QUERY_CONFIG | SERVICE_QUERY_STATUS | SERVICE_INTERROGATE | SERVICE_ENUMERATE_DEPENDENTS),
|
|
|
|
(STANDARD_RIGHTS_WRITE | SERVICE_CHANGE_CONFIG),
|
|
|
|
(STANDARD_RIGHTS_EXECUTE | SERVICE_START | SERVICE_STOP | SERVICE_PAUSE_CONTINUE | SERVICE_USER_DEFINED_CONTROL),
|
|
|
|
SERVICE_ALL_ACCESS
|
|
|
|
};
|
|
|
|
|
2008-03-28 17:56:00 +01:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
SC_HTYPE_DONT_CARE = 0,
|
|
|
|
SC_HTYPE_MANAGER,
|
|
|
|
SC_HTYPE_SERVICE
|
|
|
|
} SC_HANDLE_TYPE;
|
|
|
|
|
|
|
|
struct sc_handle
|
|
|
|
{
|
|
|
|
SC_HANDLE_TYPE type;
|
|
|
|
DWORD access;
|
|
|
|
};
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_manager_handle /* service control manager handle */
|
2008-03-28 17:56:00 +01:00
|
|
|
{
|
|
|
|
struct sc_handle hdr;
|
2008-03-28 18:08:12 +01:00
|
|
|
struct scmdatabase *db;
|
2008-03-28 17:56:00 +01:00
|
|
|
};
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_service_handle /* service handle */
|
2008-03-15 16:42:38 +01:00
|
|
|
{
|
|
|
|
struct sc_handle hdr;
|
|
|
|
struct service_entry *service_entry;
|
|
|
|
};
|
|
|
|
|
2008-03-28 18:06:43 +01:00
|
|
|
struct sc_lock
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct scmdatabase *db;
|
2008-03-28 18:06:43 +01:00
|
|
|
};
|
|
|
|
|
2012-10-22 14:26:10 +02:00
|
|
|
static HANDLE timeout_queue_event;
|
|
|
|
static CRITICAL_SECTION timeout_queue_cs;
|
|
|
|
static CRITICAL_SECTION_DEBUG timeout_queue_cs_debug =
|
|
|
|
{
|
|
|
|
0, 0, &timeout_queue_cs,
|
|
|
|
{ &timeout_queue_cs_debug.ProcessLocksList, &timeout_queue_cs_debug.ProcessLocksList },
|
|
|
|
0, 0, { (DWORD_PTR)(__FILE__ ": timeout_queue_cs") }
|
|
|
|
};
|
|
|
|
static CRITICAL_SECTION timeout_queue_cs = { &timeout_queue_cs_debug, -1, 0, 0, 0, 0 };
|
|
|
|
static struct list timeout_queue = LIST_INIT(timeout_queue);
|
|
|
|
struct timeout_queue_elem
|
|
|
|
{
|
|
|
|
struct list entry;
|
|
|
|
|
|
|
|
FILETIME time;
|
2016-04-20 14:51:30 +02:00
|
|
|
void (*func)(struct process_entry *);
|
|
|
|
struct process_entry *process;
|
2012-10-22 14:26:10 +02:00
|
|
|
};
|
|
|
|
|
2016-04-20 14:51:30 +02:00
|
|
|
static void run_after_timeout(void (*func)(struct process_entry *), struct process_entry *process, DWORD timeout)
|
2012-10-22 14:26:10 +02:00
|
|
|
{
|
|
|
|
struct timeout_queue_elem *elem = HeapAlloc(GetProcessHeap(), 0, sizeof(struct timeout_queue_elem));
|
|
|
|
ULARGE_INTEGER time;
|
|
|
|
|
|
|
|
if(!elem) {
|
2016-04-20 14:51:30 +02:00
|
|
|
func(process);
|
2012-10-22 14:26:10 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
elem->func = func;
|
2016-04-20 14:51:30 +02:00
|
|
|
elem->process = grab_process(process);
|
2012-10-22 14:26:10 +02:00
|
|
|
|
|
|
|
GetSystemTimeAsFileTime(&elem->time);
|
2012-10-28 19:44:51 +01:00
|
|
|
time.u.LowPart = elem->time.dwLowDateTime;
|
|
|
|
time.u.HighPart = elem->time.dwHighDateTime;
|
2016-03-02 07:24:22 +01:00
|
|
|
time.QuadPart += (ULONGLONG)timeout * 10000;
|
2012-10-28 19:44:51 +01:00
|
|
|
elem->time.dwLowDateTime = time.u.LowPart;
|
|
|
|
elem->time.dwHighDateTime = time.u.HighPart;
|
2012-10-22 14:26:10 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&timeout_queue_cs);
|
|
|
|
list_add_head(&timeout_queue, &elem->entry);
|
|
|
|
LeaveCriticalSection(&timeout_queue_cs);
|
|
|
|
|
|
|
|
SetEvent(timeout_queue_event);
|
|
|
|
}
|
|
|
|
|
2010-10-22 10:35:49 +02:00
|
|
|
static void free_service_strings(struct service_entry *old, struct service_entry *new)
|
2009-12-04 16:58:20 +01:00
|
|
|
{
|
2010-10-22 10:35:49 +02:00
|
|
|
QUERY_SERVICE_CONFIGW *old_cfg = &old->config;
|
|
|
|
QUERY_SERVICE_CONFIGW *new_cfg = &new->config;
|
|
|
|
|
2009-12-04 16:58:20 +01:00
|
|
|
if (old_cfg->lpBinaryPathName != new_cfg->lpBinaryPathName)
|
|
|
|
HeapFree(GetProcessHeap(), 0, old_cfg->lpBinaryPathName);
|
|
|
|
|
|
|
|
if (old_cfg->lpLoadOrderGroup != new_cfg->lpLoadOrderGroup)
|
|
|
|
HeapFree(GetProcessHeap(), 0, old_cfg->lpLoadOrderGroup);
|
|
|
|
|
|
|
|
if (old_cfg->lpServiceStartName != new_cfg->lpServiceStartName)
|
|
|
|
HeapFree(GetProcessHeap(), 0, old_cfg->lpServiceStartName);
|
|
|
|
|
|
|
|
if (old_cfg->lpDisplayName != new_cfg->lpDisplayName)
|
|
|
|
HeapFree(GetProcessHeap(), 0, old_cfg->lpDisplayName);
|
2010-10-22 10:35:49 +02:00
|
|
|
|
|
|
|
if (old->dependOnServices != new->dependOnServices)
|
|
|
|
HeapFree(GetProcessHeap(), 0, old->dependOnServices);
|
|
|
|
|
|
|
|
if (old->dependOnGroups != new->dependOnGroups)
|
|
|
|
HeapFree(GetProcessHeap(), 0, old->dependOnGroups);
|
2009-12-04 16:58:20 +01:00
|
|
|
}
|
|
|
|
|
2008-03-15 16:42:38 +01:00
|
|
|
/* Check if the given handle is of the required type and allows the requested access. */
|
|
|
|
static DWORD validate_context_handle(SC_RPC_HANDLE handle, DWORD type, DWORD needed_access, struct sc_handle **out_hdr)
|
|
|
|
{
|
2009-01-29 11:15:03 +01:00
|
|
|
struct sc_handle *hdr = handle;
|
2008-03-15 16:42:38 +01:00
|
|
|
|
|
|
|
if (type != SC_HTYPE_DONT_CARE && hdr->type != type)
|
|
|
|
{
|
|
|
|
WINE_ERR("Handle is of an invalid type (%d, %d)\n", hdr->type, type);
|
|
|
|
return ERROR_INVALID_HANDLE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((needed_access & hdr->access) != needed_access)
|
|
|
|
{
|
|
|
|
WINE_ERR("Access denied - handle created with access %x, needed %x\n", hdr->access, needed_access);
|
|
|
|
return ERROR_ACCESS_DENIED;
|
|
|
|
}
|
|
|
|
|
|
|
|
*out_hdr = hdr;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
static DWORD validate_scm_handle(SC_RPC_HANDLE handle, DWORD needed_access, struct sc_manager_handle **manager)
|
2008-03-15 16:42:38 +01:00
|
|
|
{
|
|
|
|
struct sc_handle *hdr;
|
|
|
|
DWORD err = validate_context_handle(handle, SC_HTYPE_MANAGER, needed_access, &hdr);
|
|
|
|
if (err == ERROR_SUCCESS)
|
2008-03-28 18:08:12 +01:00
|
|
|
*manager = (struct sc_manager_handle *)hdr;
|
2008-03-15 16:42:38 +01:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
static DWORD validate_service_handle(SC_RPC_HANDLE handle, DWORD needed_access, struct sc_service_handle **service)
|
2008-03-15 16:42:38 +01:00
|
|
|
{
|
|
|
|
struct sc_handle *hdr;
|
|
|
|
DWORD err = validate_context_handle(handle, SC_HTYPE_SERVICE, needed_access, &hdr);
|
|
|
|
if (err == ERROR_SUCCESS)
|
2008-03-28 18:08:12 +01:00
|
|
|
*service = (struct sc_service_handle *)hdr;
|
2008-03-15 16:42:38 +01:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_OpenSCManagerW(
|
2008-03-28 17:56:00 +01:00
|
|
|
MACHINE_HANDLEW MachineName, /* Note: this parameter is ignored */
|
|
|
|
LPCWSTR DatabaseName,
|
|
|
|
DWORD dwAccessMask,
|
|
|
|
SC_RPC_HANDLE *handle)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_manager_handle *manager;
|
2008-03-28 17:56:00 +01:00
|
|
|
|
|
|
|
WINE_TRACE("(%s, %s, %x)\n", wine_dbgstr_w(MachineName), wine_dbgstr_w(DatabaseName), dwAccessMask);
|
|
|
|
|
|
|
|
if (DatabaseName != NULL && DatabaseName[0])
|
|
|
|
{
|
|
|
|
if (strcmpW(DatabaseName, SERVICES_FAILED_DATABASEW) == 0)
|
|
|
|
return ERROR_DATABASE_DOES_NOT_EXIST;
|
|
|
|
if (strcmpW(DatabaseName, SERVICES_ACTIVE_DATABASEW) != 0)
|
|
|
|
return ERROR_INVALID_NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!(manager = HeapAlloc(GetProcessHeap(), 0, sizeof(*manager))))
|
|
|
|
return ERROR_NOT_ENOUGH_SERVER_MEMORY;
|
|
|
|
|
|
|
|
manager->hdr.type = SC_HTYPE_MANAGER;
|
|
|
|
|
|
|
|
if (dwAccessMask & MAXIMUM_ALLOWED)
|
|
|
|
dwAccessMask |= SC_MANAGER_ALL_ACCESS;
|
|
|
|
manager->hdr.access = dwAccessMask;
|
|
|
|
RtlMapGenericMask(&manager->hdr.access, &g_scm_generic);
|
2008-03-28 18:08:12 +01:00
|
|
|
manager->db = active_database;
|
2008-03-28 17:56:00 +01:00
|
|
|
*handle = &manager->hdr;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void SC_RPC_HANDLE_destroy(SC_RPC_HANDLE handle)
|
|
|
|
{
|
2009-01-29 11:15:03 +01:00
|
|
|
struct sc_handle *hdr = handle;
|
2008-03-28 17:56:00 +01:00
|
|
|
switch (hdr->type)
|
|
|
|
{
|
|
|
|
case SC_HTYPE_MANAGER:
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_manager_handle *manager = (struct sc_manager_handle *)hdr;
|
2008-03-28 17:56:00 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, manager);
|
|
|
|
break;
|
|
|
|
}
|
2008-03-15 16:42:38 +01:00
|
|
|
case SC_HTYPE_SERVICE:
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_service_handle *service = (struct sc_service_handle *)hdr;
|
2008-03-15 16:42:38 +01:00
|
|
|
release_service(service->service_entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, service);
|
|
|
|
break;
|
|
|
|
}
|
2008-03-28 17:56:00 +01:00
|
|
|
default:
|
|
|
|
WINE_ERR("invalid handle type %d\n", hdr->type);
|
|
|
|
RpcRaiseException(ERROR_INVALID_HANDLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_GetServiceDisplayNameW(
|
2008-03-16 22:12:08 +01:00
|
|
|
SC_RPC_HANDLE hSCManager,
|
|
|
|
LPCWSTR lpServiceName,
|
|
|
|
WCHAR *lpBuffer,
|
2009-03-24 12:26:12 +01:00
|
|
|
DWORD *cchBufSize)
|
2008-03-16 22:12:08 +01:00
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_manager_handle *manager;
|
2008-03-16 22:12:08 +01:00
|
|
|
struct service_entry *entry;
|
|
|
|
DWORD err;
|
|
|
|
|
2009-03-24 12:26:12 +01:00
|
|
|
WINE_TRACE("(%s, %d)\n", wine_dbgstr_w(lpServiceName), *cchBufSize);
|
2008-03-16 22:12:08 +01:00
|
|
|
|
|
|
|
if ((err = validate_scm_handle(hSCManager, 0, &manager)) != ERROR_SUCCESS)
|
|
|
|
return err;
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
scmdatabase_lock(manager->db);
|
2008-03-16 22:12:08 +01:00
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
entry = scmdatabase_find_service(manager->db, lpServiceName);
|
2008-03-16 22:12:08 +01:00
|
|
|
if (entry != NULL)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
LPCWSTR name;
|
2009-03-24 12:26:12 +01:00
|
|
|
int len;
|
2008-03-28 18:08:12 +01:00
|
|
|
name = get_display_name(entry);
|
2009-03-24 12:26:12 +01:00
|
|
|
len = strlenW(name);
|
|
|
|
if (len <= *cchBufSize)
|
2008-03-16 22:12:08 +01:00
|
|
|
{
|
|
|
|
err = ERROR_SUCCESS;
|
2009-03-24 12:26:12 +01:00
|
|
|
memcpy(lpBuffer, name, (len + 1)*sizeof(*name));
|
2008-03-16 22:12:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
err = ERROR_INSUFFICIENT_BUFFER;
|
2009-03-24 12:26:12 +01:00
|
|
|
*cchBufSize = len;
|
2008-03-16 22:12:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
err = ERROR_SERVICE_DOES_NOT_EXIST;
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
scmdatabase_unlock(manager->db);
|
|
|
|
|
2009-03-24 12:26:12 +01:00
|
|
|
if (err != ERROR_SUCCESS)
|
2008-03-16 22:12:08 +01:00
|
|
|
lpBuffer[0] = 0;
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_GetServiceKeyNameW(
|
2008-03-16 22:12:08 +01:00
|
|
|
SC_RPC_HANDLE hSCManager,
|
|
|
|
LPCWSTR lpServiceDisplayName,
|
|
|
|
WCHAR *lpBuffer,
|
2009-03-24 12:26:12 +01:00
|
|
|
DWORD *cchBufSize)
|
2008-03-16 22:12:08 +01:00
|
|
|
{
|
|
|
|
struct service_entry *entry;
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_manager_handle *manager;
|
2008-03-16 22:12:08 +01:00
|
|
|
DWORD err;
|
|
|
|
|
2009-03-24 12:26:12 +01:00
|
|
|
WINE_TRACE("(%s, %d)\n", wine_dbgstr_w(lpServiceDisplayName), *cchBufSize);
|
2008-03-16 22:12:08 +01:00
|
|
|
|
|
|
|
if ((err = validate_scm_handle(hSCManager, 0, &manager)) != ERROR_SUCCESS)
|
|
|
|
return err;
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
scmdatabase_lock(manager->db);
|
2008-03-16 22:12:08 +01:00
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
entry = scmdatabase_find_service_by_displayname(manager->db, lpServiceDisplayName);
|
2008-03-16 22:12:08 +01:00
|
|
|
if (entry != NULL)
|
|
|
|
{
|
2009-03-24 12:26:12 +01:00
|
|
|
int len;
|
|
|
|
len = strlenW(entry->name);
|
|
|
|
if (len <= *cchBufSize)
|
2008-03-16 22:12:08 +01:00
|
|
|
{
|
|
|
|
err = ERROR_SUCCESS;
|
2009-03-24 12:26:12 +01:00
|
|
|
memcpy(lpBuffer, entry->name, (len + 1)*sizeof(*entry->name));
|
2008-03-16 22:12:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
err = ERROR_INSUFFICIENT_BUFFER;
|
2009-03-24 12:26:12 +01:00
|
|
|
*cchBufSize = len;
|
2008-03-16 22:12:08 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
err = ERROR_SERVICE_DOES_NOT_EXIST;
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
scmdatabase_unlock(manager->db);
|
|
|
|
|
2009-03-24 12:26:12 +01:00
|
|
|
if (err != ERROR_SUCCESS)
|
2008-03-16 22:12:08 +01:00
|
|
|
lpBuffer[0] = 0;
|
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-03-15 16:42:38 +01:00
|
|
|
static DWORD create_handle_for_service(struct service_entry *entry, DWORD dwDesiredAccess, SC_RPC_HANDLE *phService)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_service_handle *service;
|
2008-03-15 16:42:38 +01:00
|
|
|
|
|
|
|
if (!(service = HeapAlloc(GetProcessHeap(), 0, sizeof(*service))))
|
|
|
|
{
|
|
|
|
release_service(entry);
|
|
|
|
return ERROR_NOT_ENOUGH_SERVER_MEMORY;
|
|
|
|
}
|
|
|
|
|
2015-12-22 19:29:16 +01:00
|
|
|
if (dwDesiredAccess & MAXIMUM_ALLOWED)
|
|
|
|
dwDesiredAccess |= SERVICE_ALL_ACCESS;
|
|
|
|
|
2008-03-15 16:42:38 +01:00
|
|
|
service->hdr.type = SC_HTYPE_SERVICE;
|
|
|
|
service->hdr.access = dwDesiredAccess;
|
|
|
|
RtlMapGenericMask(&service->hdr.access, &g_svc_generic);
|
|
|
|
service->service_entry = entry;
|
|
|
|
|
|
|
|
*phService = &service->hdr;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_OpenServiceW(
|
2008-03-15 16:42:38 +01:00
|
|
|
SC_RPC_HANDLE hSCManager,
|
|
|
|
LPCWSTR lpServiceName,
|
|
|
|
DWORD dwDesiredAccess,
|
|
|
|
SC_RPC_HANDLE *phService)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_manager_handle *manager;
|
2008-03-15 16:42:38 +01:00
|
|
|
struct service_entry *entry;
|
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
WINE_TRACE("(%s, 0x%x)\n", wine_dbgstr_w(lpServiceName), dwDesiredAccess);
|
|
|
|
|
|
|
|
if ((err = validate_scm_handle(hSCManager, 0, &manager)) != ERROR_SUCCESS)
|
|
|
|
return err;
|
|
|
|
if (!validate_service_name(lpServiceName))
|
|
|
|
return ERROR_INVALID_NAME;
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
scmdatabase_lock(manager->db);
|
2008-03-28 18:08:12 +01:00
|
|
|
entry = scmdatabase_find_service(manager->db, lpServiceName);
|
2008-03-15 16:42:38 +01:00
|
|
|
if (entry != NULL)
|
2009-03-24 12:25:35 +01:00
|
|
|
InterlockedIncrement(&entry->ref_count);
|
2008-03-28 18:08:12 +01:00
|
|
|
scmdatabase_unlock(manager->db);
|
2008-03-15 16:42:38 +01:00
|
|
|
|
|
|
|
if (entry == NULL)
|
|
|
|
return ERROR_SERVICE_DOES_NOT_EXIST;
|
|
|
|
|
|
|
|
return create_handle_for_service(entry, dwDesiredAccess, phService);
|
|
|
|
}
|
|
|
|
|
2010-10-22 10:35:49 +02:00
|
|
|
static DWORD parse_dependencies(const WCHAR *dependencies, struct service_entry *entry)
|
|
|
|
{
|
|
|
|
WCHAR *services = NULL, *groups, *s;
|
|
|
|
DWORD len, len_services = 0, len_groups = 0;
|
|
|
|
const WCHAR *ptr = dependencies;
|
|
|
|
|
|
|
|
if (!dependencies || !dependencies[0])
|
|
|
|
{
|
|
|
|
entry->dependOnServices = NULL;
|
|
|
|
entry->dependOnGroups = NULL;
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (*ptr)
|
|
|
|
{
|
|
|
|
len = strlenW(ptr) + 1;
|
|
|
|
if (ptr[0] == '+' && ptr[1])
|
|
|
|
len_groups += len - 1;
|
|
|
|
else
|
|
|
|
len_services += len;
|
|
|
|
ptr += len;
|
|
|
|
}
|
|
|
|
if (!len_services) entry->dependOnServices = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
services = HeapAlloc(GetProcessHeap(), 0, (len_services + 1) * sizeof(WCHAR));
|
|
|
|
if (!services)
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
|
|
|
|
s = services;
|
|
|
|
ptr = dependencies;
|
|
|
|
while (*ptr)
|
|
|
|
{
|
|
|
|
len = strlenW(ptr) + 1;
|
|
|
|
if (*ptr != '+')
|
|
|
|
{
|
|
|
|
strcpyW(s, ptr);
|
|
|
|
s += len;
|
|
|
|
}
|
|
|
|
ptr += len;
|
|
|
|
}
|
|
|
|
*s = 0;
|
|
|
|
entry->dependOnServices = services;
|
|
|
|
}
|
|
|
|
if (!len_groups) entry->dependOnGroups = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
groups = HeapAlloc(GetProcessHeap(), 0, (len_groups + 1) * sizeof(WCHAR));
|
|
|
|
if (!groups)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, services);
|
|
|
|
return ERROR_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
s = groups;
|
|
|
|
ptr = dependencies;
|
|
|
|
while (*ptr)
|
|
|
|
{
|
|
|
|
len = strlenW(ptr) + 1;
|
|
|
|
if (ptr[0] == '+' && ptr[1])
|
|
|
|
{
|
|
|
|
strcpyW(s, ptr + 1);
|
|
|
|
s += len - 1;
|
|
|
|
}
|
|
|
|
ptr += len;
|
|
|
|
}
|
|
|
|
*s = 0;
|
|
|
|
entry->dependOnGroups = groups;
|
|
|
|
}
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:20:48 +01:00
|
|
|
static DWORD create_serviceW(
|
2008-03-15 16:42:38 +01:00
|
|
|
SC_RPC_HANDLE hSCManager,
|
|
|
|
LPCWSTR lpServiceName,
|
|
|
|
LPCWSTR lpDisplayName,
|
|
|
|
DWORD dwDesiredAccess,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwStartType,
|
|
|
|
DWORD dwErrorControl,
|
|
|
|
LPCWSTR lpBinaryPathName,
|
|
|
|
LPCWSTR lpLoadOrderGroup,
|
|
|
|
DWORD *lpdwTagId,
|
|
|
|
const BYTE *lpDependencies,
|
|
|
|
DWORD dwDependenciesSize,
|
|
|
|
LPCWSTR lpServiceStartName,
|
|
|
|
const BYTE *lpPassword,
|
|
|
|
DWORD dwPasswordSize,
|
2015-02-26 23:20:48 +01:00
|
|
|
SC_RPC_HANDLE *phService,
|
|
|
|
BOOL is_wow64)
|
2008-03-15 16:42:38 +01:00
|
|
|
{
|
2014-06-04 21:54:17 +02:00
|
|
|
struct service_entry *entry, *found;
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_manager_handle *manager;
|
2008-03-15 16:42:38 +01:00
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
WINE_TRACE("(%s, %s, 0x%x, %s)\n", wine_dbgstr_w(lpServiceName), wine_dbgstr_w(lpDisplayName), dwDesiredAccess, wine_dbgstr_w(lpBinaryPathName));
|
|
|
|
|
|
|
|
if ((err = validate_scm_handle(hSCManager, SC_MANAGER_CREATE_SERVICE, &manager)) != ERROR_SUCCESS)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (!validate_service_name(lpServiceName))
|
|
|
|
return ERROR_INVALID_NAME;
|
|
|
|
if (!check_multisz((LPCWSTR)lpDependencies, dwDependenciesSize) || !lpServiceName[0] || !lpBinaryPathName[0])
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (lpPassword)
|
|
|
|
WINE_FIXME("Don't know how to add a password\n"); /* I always get ERROR_GEN_FAILURE */
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
err = service_create(lpServiceName, &entry);
|
|
|
|
if (err != ERROR_SUCCESS)
|
|
|
|
return err;
|
2010-10-22 10:35:49 +02:00
|
|
|
|
|
|
|
err = parse_dependencies((LPCWSTR)lpDependencies, entry);
|
2012-10-09 13:39:29 +02:00
|
|
|
if (err != ERROR_SUCCESS) {
|
|
|
|
free_service_entry(entry);
|
2010-10-22 10:35:49 +02:00
|
|
|
return err;
|
2012-10-09 13:39:29 +02:00
|
|
|
}
|
2010-10-22 10:35:49 +02:00
|
|
|
|
2015-02-26 23:30:54 +01:00
|
|
|
entry->is_wow64 = is_wow64;
|
2008-11-25 11:56:33 +01:00
|
|
|
entry->config.dwServiceType = entry->status.dwServiceType = dwServiceType;
|
2008-03-15 16:42:38 +01:00
|
|
|
entry->config.dwStartType = dwStartType;
|
|
|
|
entry->config.dwErrorControl = dwErrorControl;
|
|
|
|
entry->config.lpBinaryPathName = strdupW(lpBinaryPathName);
|
|
|
|
entry->config.lpLoadOrderGroup = strdupW(lpLoadOrderGroup);
|
|
|
|
entry->config.lpServiceStartName = strdupW(lpServiceStartName);
|
|
|
|
entry->config.lpDisplayName = strdupW(lpDisplayName);
|
|
|
|
|
2008-04-22 08:18:14 +02:00
|
|
|
if (lpdwTagId) /* TODO: In most situations a non-NULL TagId will generate an ERROR_INVALID_PARAMETER. */
|
2008-03-15 16:42:38 +01:00
|
|
|
entry->config.dwTagId = *lpdwTagId;
|
|
|
|
else
|
|
|
|
entry->config.dwTagId = 0;
|
|
|
|
|
|
|
|
/* other fields NULL*/
|
|
|
|
|
|
|
|
if (!validate_service_config(entry))
|
|
|
|
{
|
|
|
|
WINE_ERR("Invalid data while trying to create service\n");
|
|
|
|
free_service_entry(entry);
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
scmdatabase_lock(manager->db);
|
2008-03-15 16:42:38 +01:00
|
|
|
|
2014-06-04 21:54:17 +02:00
|
|
|
if ((found = scmdatabase_find_service(manager->db, lpServiceName)))
|
2008-03-15 16:42:38 +01:00
|
|
|
{
|
2014-06-04 21:54:17 +02:00
|
|
|
err = is_marked_for_delete(found) ? ERROR_SERVICE_MARKED_FOR_DELETE : ERROR_SERVICE_EXISTS;
|
2008-03-28 18:08:12 +01:00
|
|
|
scmdatabase_unlock(manager->db);
|
2008-03-15 16:42:38 +01:00
|
|
|
free_service_entry(entry);
|
2014-06-04 21:54:17 +02:00
|
|
|
return err;
|
2008-03-15 16:42:38 +01:00
|
|
|
}
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
if (scmdatabase_find_service_by_displayname(manager->db, get_display_name(entry)))
|
2008-03-15 16:42:38 +01:00
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
scmdatabase_unlock(manager->db);
|
2008-03-15 16:42:38 +01:00
|
|
|
free_service_entry(entry);
|
|
|
|
return ERROR_DUPLICATE_SERVICE_NAME;
|
|
|
|
}
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
err = scmdatabase_add_service(manager->db, entry);
|
2008-03-15 16:42:38 +01:00
|
|
|
if (err != ERROR_SUCCESS)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
scmdatabase_unlock(manager->db);
|
2008-03-15 16:42:38 +01:00
|
|
|
free_service_entry(entry);
|
|
|
|
return err;
|
|
|
|
}
|
2008-03-28 18:08:12 +01:00
|
|
|
scmdatabase_unlock(manager->db);
|
2008-03-15 16:42:38 +01:00
|
|
|
|
|
|
|
return create_handle_for_service(entry, dwDesiredAccess, phService);
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:20:48 +01:00
|
|
|
DWORD __cdecl svcctl_CreateServiceW(
|
|
|
|
SC_RPC_HANDLE hSCManager,
|
|
|
|
LPCWSTR lpServiceName,
|
|
|
|
LPCWSTR lpDisplayName,
|
|
|
|
DWORD dwDesiredAccess,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwStartType,
|
|
|
|
DWORD dwErrorControl,
|
|
|
|
LPCWSTR lpBinaryPathName,
|
|
|
|
LPCWSTR lpLoadOrderGroup,
|
|
|
|
DWORD *lpdwTagId,
|
|
|
|
const BYTE *lpDependencies,
|
|
|
|
DWORD dwDependenciesSize,
|
|
|
|
LPCWSTR lpServiceStartName,
|
|
|
|
const BYTE *lpPassword,
|
|
|
|
DWORD dwPasswordSize,
|
|
|
|
SC_RPC_HANDLE *phService)
|
|
|
|
{
|
|
|
|
WINE_TRACE("(%s, %s, 0x%x, %s)\n", wine_dbgstr_w(lpServiceName), wine_dbgstr_w(lpDisplayName), dwDesiredAccess, wine_dbgstr_w(lpBinaryPathName));
|
|
|
|
return create_serviceW(hSCManager, lpServiceName, lpDisplayName, dwDesiredAccess, dwServiceType, dwStartType,
|
|
|
|
dwErrorControl, lpBinaryPathName, lpLoadOrderGroup, lpdwTagId, lpDependencies, dwDependenciesSize, lpServiceStartName,
|
|
|
|
lpPassword, dwPasswordSize, phService, FALSE);
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_DeleteService(
|
2008-03-15 16:42:38 +01:00
|
|
|
SC_RPC_HANDLE hService)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_service_handle *service;
|
2008-03-15 16:42:38 +01:00
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
if ((err = validate_service_handle(hService, DELETE, &service)) != ERROR_SUCCESS)
|
|
|
|
return err;
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
service_lock(service->service_entry);
|
2008-03-15 16:42:38 +01:00
|
|
|
|
|
|
|
if (!is_marked_for_delete(service->service_entry))
|
2014-06-04 21:54:17 +02:00
|
|
|
err = mark_for_delete(service->service_entry);
|
2008-03-15 16:42:38 +01:00
|
|
|
else
|
|
|
|
err = ERROR_SERVICE_MARKED_FOR_DELETE;
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
service_unlock(service->service_entry);
|
2008-03-15 16:42:38 +01:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_QueryServiceConfigW(
|
2008-03-15 16:42:40 +01:00
|
|
|
SC_RPC_HANDLE hService,
|
2015-02-26 23:16:40 +01:00
|
|
|
QUERY_SERVICE_CONFIGW *config,
|
|
|
|
DWORD buf_size,
|
|
|
|
DWORD *needed_size)
|
2008-03-15 16:42:40 +01:00
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_service_handle *service;
|
2008-03-15 16:42:40 +01:00
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
WINE_TRACE("(%p)\n", config);
|
|
|
|
|
|
|
|
if ((err = validate_service_handle(hService, SERVICE_QUERY_CONFIG, &service)) != 0)
|
|
|
|
return err;
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
service_lock(service->service_entry);
|
2008-03-15 16:42:40 +01:00
|
|
|
config->dwServiceType = service->service_entry->config.dwServiceType;
|
|
|
|
config->dwStartType = service->service_entry->config.dwStartType;
|
|
|
|
config->dwErrorControl = service->service_entry->config.dwErrorControl;
|
|
|
|
config->lpBinaryPathName = strdupW(service->service_entry->config.lpBinaryPathName);
|
|
|
|
config->lpLoadOrderGroup = strdupW(service->service_entry->config.lpLoadOrderGroup);
|
|
|
|
config->dwTagId = service->service_entry->config.dwTagId;
|
|
|
|
config->lpDependencies = NULL; /* TODO */
|
|
|
|
config->lpServiceStartName = strdupW(service->service_entry->config.lpServiceStartName);
|
|
|
|
config->lpDisplayName = strdupW(service->service_entry->config.lpDisplayName);
|
2008-03-28 18:08:12 +01:00
|
|
|
service_unlock(service->service_entry);
|
2008-03-15 16:42:40 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_ChangeServiceConfigW(
|
2008-03-15 19:11:12 +01:00
|
|
|
SC_RPC_HANDLE hService,
|
|
|
|
DWORD dwServiceType,
|
|
|
|
DWORD dwStartType,
|
|
|
|
DWORD dwErrorControl,
|
|
|
|
LPCWSTR lpBinaryPathName,
|
|
|
|
LPCWSTR lpLoadOrderGroup,
|
|
|
|
DWORD *lpdwTagId,
|
|
|
|
const BYTE *lpDependencies,
|
|
|
|
DWORD dwDependenciesSize,
|
|
|
|
LPCWSTR lpServiceStartName,
|
|
|
|
const BYTE *lpPassword,
|
|
|
|
DWORD dwPasswordSize,
|
|
|
|
LPCWSTR lpDisplayName)
|
|
|
|
{
|
2008-04-24 13:53:21 +02:00
|
|
|
struct service_entry new_entry, *entry;
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_service_handle *service;
|
2008-03-15 19:11:12 +01:00
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
WINE_TRACE("\n");
|
|
|
|
|
|
|
|
if ((err = validate_service_handle(hService, SERVICE_CHANGE_CONFIG, &service)) != 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (!check_multisz((LPCWSTR)lpDependencies, dwDependenciesSize))
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
/* first check if the new configuration is correct */
|
2016-03-02 07:21:17 +01:00
|
|
|
service_lock(service->service_entry);
|
2008-03-15 19:11:12 +01:00
|
|
|
|
|
|
|
if (is_marked_for_delete(service->service_entry))
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
service_unlock(service->service_entry);
|
2008-03-15 19:11:12 +01:00
|
|
|
return ERROR_SERVICE_MARKED_FOR_DELETE;
|
|
|
|
}
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
if (lpDisplayName != NULL &&
|
2008-04-24 13:53:21 +02:00
|
|
|
(entry = scmdatabase_find_service_by_displayname(service->service_entry->db, lpDisplayName)) &&
|
|
|
|
(entry != service->service_entry))
|
2008-03-15 19:11:12 +01:00
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
service_unlock(service->service_entry);
|
2008-03-15 19:11:12 +01:00
|
|
|
return ERROR_DUPLICATE_SERVICE_NAME;
|
|
|
|
}
|
|
|
|
|
|
|
|
new_entry = *service->service_entry;
|
|
|
|
|
|
|
|
if (dwServiceType != SERVICE_NO_CHANGE)
|
|
|
|
new_entry.config.dwServiceType = dwServiceType;
|
|
|
|
|
|
|
|
if (dwStartType != SERVICE_NO_CHANGE)
|
|
|
|
new_entry.config.dwStartType = dwStartType;
|
|
|
|
|
|
|
|
if (dwErrorControl != SERVICE_NO_CHANGE)
|
|
|
|
new_entry.config.dwErrorControl = dwErrorControl;
|
|
|
|
|
|
|
|
if (lpBinaryPathName != NULL)
|
|
|
|
new_entry.config.lpBinaryPathName = (LPWSTR)lpBinaryPathName;
|
|
|
|
|
|
|
|
if (lpLoadOrderGroup != NULL)
|
|
|
|
new_entry.config.lpLoadOrderGroup = (LPWSTR)lpLoadOrderGroup;
|
|
|
|
|
|
|
|
if (lpdwTagId != NULL)
|
|
|
|
WINE_FIXME("Changing tag id not supported\n");
|
|
|
|
|
|
|
|
if (lpServiceStartName != NULL)
|
|
|
|
new_entry.config.lpServiceStartName = (LPWSTR)lpServiceStartName;
|
|
|
|
|
|
|
|
if (lpPassword != NULL)
|
|
|
|
WINE_FIXME("Setting password not supported\n");
|
|
|
|
|
|
|
|
if (lpDisplayName != NULL)
|
|
|
|
new_entry.config.lpDisplayName = (LPWSTR)lpDisplayName;
|
|
|
|
|
2010-10-22 10:35:49 +02:00
|
|
|
err = parse_dependencies((LPCWSTR)lpDependencies, &new_entry);
|
|
|
|
if (err != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
service_unlock(service->service_entry);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-03-15 19:11:12 +01:00
|
|
|
if (!validate_service_config(&new_entry))
|
|
|
|
{
|
2008-04-07 11:03:01 +02:00
|
|
|
WINE_ERR("The configuration after the change wouldn't be valid\n");
|
2008-03-28 18:08:12 +01:00
|
|
|
service_unlock(service->service_entry);
|
2008-03-15 19:11:12 +01:00
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* configuration OK. The strings needs to be duplicated */
|
|
|
|
if (lpBinaryPathName != NULL)
|
|
|
|
new_entry.config.lpBinaryPathName = strdupW(lpBinaryPathName);
|
|
|
|
|
|
|
|
if (lpLoadOrderGroup != NULL)
|
|
|
|
new_entry.config.lpLoadOrderGroup = strdupW(lpLoadOrderGroup);
|
|
|
|
|
|
|
|
if (lpServiceStartName != NULL)
|
|
|
|
new_entry.config.lpServiceStartName = strdupW(lpServiceStartName);
|
|
|
|
|
|
|
|
if (lpDisplayName != NULL)
|
|
|
|
new_entry.config.lpDisplayName = strdupW(lpDisplayName);
|
|
|
|
|
2009-12-04 16:58:20 +01:00
|
|
|
/* try to save to Registry, commit or rollback depending on success */
|
|
|
|
err = save_service_config(&new_entry);
|
|
|
|
if (ERROR_SUCCESS == err)
|
|
|
|
{
|
2010-10-22 10:35:49 +02:00
|
|
|
free_service_strings(service->service_entry, &new_entry);
|
2009-12-04 16:58:20 +01:00
|
|
|
*service->service_entry = new_entry;
|
|
|
|
}
|
2010-10-22 10:35:49 +02:00
|
|
|
else free_service_strings(&new_entry, service->service_entry);
|
2008-03-28 18:08:12 +01:00
|
|
|
service_unlock(service->service_entry);
|
2008-03-15 19:11:12 +01:00
|
|
|
|
2009-12-04 16:58:20 +01:00
|
|
|
return err;
|
2008-03-15 19:11:12 +01:00
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_SetServiceStatus(
|
2008-03-28 18:06:32 +01:00
|
|
|
SC_RPC_HANDLE hServiceStatus,
|
|
|
|
LPSERVICE_STATUS lpServiceStatus)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_service_handle *service;
|
2016-04-20 14:51:30 +02:00
|
|
|
struct process_entry *process;
|
2008-03-28 18:06:32 +01:00
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
WINE_TRACE("(%p, %p)\n", hServiceStatus, lpServiceStatus);
|
|
|
|
|
|
|
|
if ((err = validate_service_handle(hServiceStatus, SERVICE_SET_STATUS, &service)) != 0)
|
|
|
|
return err;
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
service_lock(service->service_entry);
|
2008-03-28 18:06:32 +01:00
|
|
|
/* FIXME: be a bit more discriminant about what parts of the status we set
|
|
|
|
* and check that fields are valid */
|
|
|
|
service->service_entry->status.dwServiceType = lpServiceStatus->dwServiceType;
|
|
|
|
service->service_entry->status.dwCurrentState = lpServiceStatus->dwCurrentState;
|
|
|
|
service->service_entry->status.dwControlsAccepted = lpServiceStatus->dwControlsAccepted;
|
|
|
|
service->service_entry->status.dwWin32ExitCode = lpServiceStatus->dwWin32ExitCode;
|
|
|
|
service->service_entry->status.dwServiceSpecificExitCode = lpServiceStatus->dwServiceSpecificExitCode;
|
|
|
|
service->service_entry->status.dwCheckPoint = lpServiceStatus->dwCheckPoint;
|
|
|
|
service->service_entry->status.dwWaitHint = lpServiceStatus->dwWaitHint;
|
2016-04-20 14:51:30 +02:00
|
|
|
if ((process = service->service_entry->process))
|
|
|
|
{
|
|
|
|
if (lpServiceStatus->dwCurrentState == SERVICE_STOPPED)
|
|
|
|
run_after_timeout(process_terminate, process, service_kill_timeout);
|
|
|
|
else
|
|
|
|
SetEvent(process->status_changed_event);
|
|
|
|
}
|
2008-03-28 18:08:12 +01:00
|
|
|
service_unlock(service->service_entry);
|
2008-03-28 18:06:32 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-02-25 06:57:20 +01:00
|
|
|
DWORD __cdecl svcctl_ChangeServiceConfig2W( SC_RPC_HANDLE hService, SC_RPC_CONFIG_INFOW config )
|
2008-11-26 14:35:30 +01:00
|
|
|
{
|
|
|
|
struct sc_service_handle *service;
|
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
if ((err = validate_service_handle(hService, SERVICE_CHANGE_CONFIG, &service)) != 0)
|
|
|
|
return err;
|
|
|
|
|
2015-02-25 06:57:20 +01:00
|
|
|
switch (config.dwInfoLevel)
|
2008-11-26 14:35:30 +01:00
|
|
|
{
|
|
|
|
case SERVICE_CONFIG_DESCRIPTION:
|
|
|
|
{
|
|
|
|
WCHAR *descr = NULL;
|
|
|
|
|
2015-02-28 17:30:54 +01:00
|
|
|
if (config.u.descr->lpDescription[0])
|
2008-11-26 14:35:30 +01:00
|
|
|
{
|
2015-02-28 17:30:54 +01:00
|
|
|
if (!(descr = strdupW( config.u.descr->lpDescription )))
|
2008-11-26 14:35:30 +01:00
|
|
|
return ERROR_NOT_ENOUGH_MEMORY;
|
|
|
|
}
|
|
|
|
|
|
|
|
WINE_TRACE( "changing service %p descr to %s\n", service, wine_dbgstr_w(descr) );
|
2016-03-02 07:21:17 +01:00
|
|
|
service_lock( service->service_entry );
|
2008-11-26 14:35:30 +01:00
|
|
|
HeapFree( GetProcessHeap(), 0, service->service_entry->description );
|
|
|
|
service->service_entry->description = descr;
|
|
|
|
save_service_config( service->service_entry );
|
|
|
|
service_unlock( service->service_entry );
|
|
|
|
}
|
|
|
|
break;
|
2009-01-27 11:27:45 +01:00
|
|
|
case SERVICE_CONFIG_FAILURE_ACTIONS:
|
|
|
|
WINE_FIXME( "SERVICE_CONFIG_FAILURE_ACTIONS not implemented: period %u msg %s cmd %s\n",
|
2015-02-28 17:30:54 +01:00
|
|
|
config.u.actions->dwResetPeriod,
|
|
|
|
wine_dbgstr_w(config.u.actions->lpRebootMsg),
|
|
|
|
wine_dbgstr_w(config.u.actions->lpCommand) );
|
2009-01-27 11:27:45 +01:00
|
|
|
break;
|
2011-11-30 15:28:26 +01:00
|
|
|
case SERVICE_CONFIG_PRESHUTDOWN_INFO:
|
|
|
|
WINE_TRACE( "changing service %p preshutdown timeout to %d\n",
|
2015-02-28 17:30:54 +01:00
|
|
|
service, config.u.preshutdown->dwPreshutdownTimeout );
|
2016-03-02 07:21:17 +01:00
|
|
|
service_lock( service->service_entry );
|
2015-02-28 17:30:54 +01:00
|
|
|
service->service_entry->preshutdown_timeout = config.u.preshutdown->dwPreshutdownTimeout;
|
2011-11-30 15:28:26 +01:00
|
|
|
save_service_config( service->service_entry );
|
|
|
|
service_unlock( service->service_entry );
|
|
|
|
break;
|
2008-11-26 14:35:30 +01:00
|
|
|
default:
|
2015-02-25 06:57:20 +01:00
|
|
|
WINE_FIXME("level %u not implemented\n", config.dwInfoLevel);
|
2008-11-26 14:35:30 +01:00
|
|
|
err = ERROR_INVALID_LEVEL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_QueryServiceConfig2W( SC_RPC_HANDLE hService, DWORD level,
|
|
|
|
BYTE *buffer, DWORD size, LPDWORD needed )
|
2009-01-19 20:18:24 +01:00
|
|
|
{
|
|
|
|
struct sc_service_handle *service;
|
|
|
|
DWORD err;
|
|
|
|
|
2009-03-24 12:26:35 +01:00
|
|
|
memset(buffer, 0, size);
|
|
|
|
|
2009-01-19 20:18:24 +01:00
|
|
|
if ((err = validate_service_handle(hService, SERVICE_QUERY_STATUS, &service)) != 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
switch (level)
|
|
|
|
{
|
|
|
|
case SERVICE_CONFIG_DESCRIPTION:
|
|
|
|
{
|
|
|
|
SERVICE_DESCRIPTIONW *descr = (SERVICE_DESCRIPTIONW *)buffer;
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
service_lock(service->service_entry);
|
2009-01-19 20:18:24 +01:00
|
|
|
*needed = sizeof(*descr);
|
|
|
|
if (service->service_entry->description)
|
|
|
|
*needed += (strlenW(service->service_entry->description) + 1) * sizeof(WCHAR);
|
|
|
|
if (size >= *needed)
|
|
|
|
{
|
|
|
|
if (service->service_entry->description)
|
|
|
|
{
|
|
|
|
/* store a buffer offset instead of a pointer */
|
|
|
|
descr->lpDescription = (WCHAR *)((BYTE *)(descr + 1) - buffer);
|
|
|
|
strcpyW( (WCHAR *)(descr + 1), service->service_entry->description );
|
|
|
|
}
|
|
|
|
else descr->lpDescription = NULL;
|
|
|
|
}
|
|
|
|
else err = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
service_unlock(service->service_entry);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2011-11-30 15:28:26 +01:00
|
|
|
case SERVICE_CONFIG_PRESHUTDOWN_INFO:
|
2016-03-02 07:21:17 +01:00
|
|
|
service_lock(service->service_entry);
|
2011-11-30 15:28:26 +01:00
|
|
|
|
|
|
|
*needed = sizeof(SERVICE_PRESHUTDOWN_INFO);
|
|
|
|
if (size >= *needed)
|
|
|
|
((LPSERVICE_PRESHUTDOWN_INFO)buffer)->dwPreshutdownTimeout =
|
|
|
|
service->service_entry->preshutdown_timeout;
|
|
|
|
else err = ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
|
|
|
|
service_unlock(service->service_entry);
|
|
|
|
break;
|
|
|
|
|
2009-01-19 20:18:24 +01:00
|
|
|
default:
|
|
|
|
WINE_FIXME("level %u not implemented\n", level);
|
|
|
|
err = ERROR_INVALID_LEVEL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_QueryServiceStatusEx(
|
2008-03-28 18:06:32 +01:00
|
|
|
SC_RPC_HANDLE hService,
|
|
|
|
SC_STATUS_TYPE InfoLevel,
|
|
|
|
BYTE *lpBuffer,
|
|
|
|
DWORD cbBufSize,
|
|
|
|
LPDWORD pcbBytesNeeded)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_service_handle *service;
|
2008-03-28 18:06:32 +01:00
|
|
|
DWORD err;
|
|
|
|
LPSERVICE_STATUS_PROCESS pSvcStatusData;
|
|
|
|
|
2009-03-24 12:26:35 +01:00
|
|
|
memset(lpBuffer, 0, cbBufSize);
|
|
|
|
|
2008-03-28 18:06:32 +01:00
|
|
|
if ((err = validate_service_handle(hService, SERVICE_QUERY_STATUS, &service)) != 0)
|
|
|
|
return err;
|
|
|
|
|
|
|
|
if (InfoLevel != SC_STATUS_PROCESS_INFO)
|
|
|
|
return ERROR_INVALID_LEVEL;
|
|
|
|
|
|
|
|
pSvcStatusData = (LPSERVICE_STATUS_PROCESS) lpBuffer;
|
|
|
|
if (pSvcStatusData == NULL)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if (cbBufSize < sizeof(SERVICE_STATUS_PROCESS))
|
|
|
|
{
|
|
|
|
if( pcbBytesNeeded != NULL)
|
|
|
|
*pcbBytesNeeded = sizeof(SERVICE_STATUS_PROCESS);
|
|
|
|
|
|
|
|
return ERROR_INSUFFICIENT_BUFFER;
|
|
|
|
}
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
service_lock(service->service_entry);
|
2008-03-28 18:06:32 +01:00
|
|
|
|
|
|
|
pSvcStatusData->dwServiceType = service->service_entry->status.dwServiceType;
|
|
|
|
pSvcStatusData->dwCurrentState = service->service_entry->status.dwCurrentState;
|
|
|
|
pSvcStatusData->dwControlsAccepted = service->service_entry->status.dwControlsAccepted;
|
|
|
|
pSvcStatusData->dwWin32ExitCode = service->service_entry->status.dwWin32ExitCode;
|
|
|
|
pSvcStatusData->dwServiceSpecificExitCode = service->service_entry->status.dwServiceSpecificExitCode;
|
|
|
|
pSvcStatusData->dwCheckPoint = service->service_entry->status.dwCheckPoint;
|
|
|
|
pSvcStatusData->dwWaitHint = service->service_entry->status.dwWaitHint;
|
|
|
|
pSvcStatusData->dwProcessId = service->service_entry->status.dwProcessId;
|
|
|
|
pSvcStatusData->dwServiceFlags = service->service_entry->status.dwServiceFlags;
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
service_unlock(service->service_entry);
|
2008-03-28 18:06:32 +01:00
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-03-28 18:07:39 +01:00
|
|
|
/******************************************************************************
|
|
|
|
* service_accepts_control
|
|
|
|
*/
|
|
|
|
static BOOL service_accepts_control(const struct service_entry *service, DWORD dwControl)
|
|
|
|
{
|
|
|
|
DWORD a = service->status.dwControlsAccepted;
|
|
|
|
|
|
|
|
switch (dwControl)
|
|
|
|
{
|
|
|
|
case SERVICE_CONTROL_INTERROGATE:
|
|
|
|
return TRUE;
|
|
|
|
case SERVICE_CONTROL_STOP:
|
|
|
|
if (a&SERVICE_ACCEPT_STOP)
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case SERVICE_CONTROL_SHUTDOWN:
|
|
|
|
if (a&SERVICE_ACCEPT_SHUTDOWN)
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case SERVICE_CONTROL_PAUSE:
|
|
|
|
case SERVICE_CONTROL_CONTINUE:
|
|
|
|
if (a&SERVICE_ACCEPT_PAUSE_CONTINUE)
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case SERVICE_CONTROL_PARAMCHANGE:
|
|
|
|
if (a&SERVICE_ACCEPT_PARAMCHANGE)
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case SERVICE_CONTROL_NETBINDADD:
|
|
|
|
case SERVICE_CONTROL_NETBINDREMOVE:
|
|
|
|
case SERVICE_CONTROL_NETBINDENABLE:
|
|
|
|
case SERVICE_CONTROL_NETBINDDISABLE:
|
|
|
|
if (a&SERVICE_ACCEPT_NETBINDCHANGE)
|
|
|
|
return TRUE;
|
|
|
|
case SERVICE_CONTROL_HARDWAREPROFILECHANGE:
|
|
|
|
if (a&SERVICE_ACCEPT_HARDWAREPROFILECHANGE)
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case SERVICE_CONTROL_POWEREVENT:
|
|
|
|
if (a&SERVICE_ACCEPT_POWEREVENT)
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case SERVICE_CONTROL_SESSIONCHANGE:
|
|
|
|
if (a&SERVICE_ACCEPT_SESSIONCHANGE)
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-05-20 11:49:02 +02:00
|
|
|
/******************************************************************************
|
2016-03-03 06:28:16 +01:00
|
|
|
* process_send_command
|
2011-05-20 11:49:02 +02:00
|
|
|
*/
|
2016-03-03 06:28:16 +01:00
|
|
|
BOOL process_send_command(struct process_entry *process, const void *data, DWORD size, DWORD *result)
|
2011-05-20 11:49:02 +02:00
|
|
|
{
|
2011-05-20 12:31:27 +02:00
|
|
|
OVERLAPPED overlapped;
|
2011-12-09 13:33:45 +01:00
|
|
|
DWORD count, ret;
|
2011-05-20 11:49:02 +02:00
|
|
|
BOOL r;
|
|
|
|
|
2016-03-03 06:28:16 +01:00
|
|
|
overlapped.hEvent = process->overlapped_event;
|
|
|
|
r = WriteFile(process->control_pipe, data, size, &count, &overlapped);
|
2011-05-20 12:31:27 +02:00
|
|
|
if (!r && GetLastError() == ERROR_IO_PENDING)
|
|
|
|
{
|
2016-03-03 06:28:16 +01:00
|
|
|
ret = WaitForSingleObject(process->overlapped_event, service_pipe_timeout);
|
2011-12-09 13:33:45 +01:00
|
|
|
if (ret == WAIT_TIMEOUT)
|
|
|
|
{
|
|
|
|
WINE_ERR("sending command timed out\n");
|
|
|
|
*result = ERROR_SERVICE_REQUEST_TIMEOUT;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2016-03-03 06:28:16 +01:00
|
|
|
r = GetOverlappedResult(process->control_pipe, &overlapped, &count, FALSE);
|
2011-05-20 12:31:27 +02:00
|
|
|
}
|
2011-05-20 11:49:02 +02:00
|
|
|
if (!r || count != size)
|
|
|
|
{
|
|
|
|
WINE_ERR("service protocol error - failed to write pipe!\n");
|
2011-12-09 13:33:45 +01:00
|
|
|
*result = (!r ? GetLastError() : ERROR_WRITE_FAULT);
|
2011-05-20 11:49:02 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2016-03-03 06:28:16 +01:00
|
|
|
r = ReadFile(process->control_pipe, result, sizeof *result, &count, &overlapped);
|
2011-05-20 12:31:27 +02:00
|
|
|
if (!r && GetLastError() == ERROR_IO_PENDING)
|
|
|
|
{
|
2016-03-03 06:28:16 +01:00
|
|
|
ret = WaitForSingleObject(process->overlapped_event, service_pipe_timeout);
|
2011-12-09 13:33:45 +01:00
|
|
|
if (ret == WAIT_TIMEOUT)
|
|
|
|
{
|
|
|
|
WINE_ERR("receiving command result timed out\n");
|
|
|
|
*result = ERROR_SERVICE_REQUEST_TIMEOUT;
|
|
|
|
return FALSE;
|
|
|
|
}
|
2016-03-03 06:28:16 +01:00
|
|
|
r = GetOverlappedResult(process->control_pipe, &overlapped, &count, FALSE);
|
2011-05-20 12:31:27 +02:00
|
|
|
}
|
2011-05-20 11:49:02 +02:00
|
|
|
if (!r || count != sizeof *result)
|
|
|
|
{
|
|
|
|
WINE_ERR("service protocol error - failed to read pipe "
|
|
|
|
"r = %d count = %d!\n", r, count);
|
2011-12-09 13:33:45 +01:00
|
|
|
*result = (!r ? GetLastError() : ERROR_READ_FAULT);
|
2011-05-20 11:49:02 +02:00
|
|
|
return FALSE;
|
|
|
|
}
|
2011-12-09 13:33:45 +01:00
|
|
|
|
|
|
|
*result = ERROR_SUCCESS;
|
|
|
|
return TRUE;
|
2011-05-20 11:49:02 +02:00
|
|
|
}
|
|
|
|
|
2008-03-28 18:07:39 +01:00
|
|
|
/******************************************************************************
|
2016-03-16 04:32:34 +01:00
|
|
|
* process_send_control
|
2008-03-28 18:07:39 +01:00
|
|
|
*/
|
2016-03-16 04:32:34 +01:00
|
|
|
static BOOL process_send_control(struct process_entry *process, const WCHAR *name, DWORD dwControl, DWORD *result)
|
2008-03-28 18:07:39 +01:00
|
|
|
{
|
2008-05-08 18:08:41 +02:00
|
|
|
service_start_info *ssi;
|
2011-05-20 11:49:02 +02:00
|
|
|
DWORD len;
|
2008-03-28 18:07:39 +01:00
|
|
|
BOOL r;
|
|
|
|
|
2008-05-08 18:08:41 +02:00
|
|
|
/* calculate how much space we need to send the startup info */
|
2016-03-16 04:32:34 +01:00
|
|
|
len = strlenW(name) + 1;
|
2008-05-08 18:08:41 +02:00
|
|
|
|
|
|
|
ssi = HeapAlloc(GetProcessHeap(),0,FIELD_OFFSET(service_start_info, data[len]));
|
|
|
|
ssi->cmd = WINESERV_SENDCONTROL;
|
|
|
|
ssi->control = dwControl;
|
|
|
|
ssi->total_size = FIELD_OFFSET(service_start_info, data[len]);
|
2016-03-16 04:32:34 +01:00
|
|
|
ssi->name_size = strlenW(name) + 1;
|
|
|
|
strcpyW(ssi->data, name);
|
2008-05-08 18:08:41 +02:00
|
|
|
|
2016-03-16 04:32:34 +01:00
|
|
|
r = process_send_command(process, ssi, ssi->total_size, result);
|
2011-05-20 11:49:02 +02:00
|
|
|
HeapFree( GetProcessHeap(), 0, ssi );
|
2008-03-28 18:07:39 +01:00
|
|
|
return r;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_StartServiceW(
|
2008-03-28 18:07:39 +01:00
|
|
|
SC_RPC_HANDLE hService,
|
|
|
|
DWORD dwNumServiceArgs,
|
|
|
|
LPCWSTR *lpServiceArgVectors)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_service_handle *service;
|
2008-03-28 18:07:39 +01:00
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
WINE_TRACE("(%p, %d, %p)\n", hService, dwNumServiceArgs, lpServiceArgVectors);
|
|
|
|
|
|
|
|
if ((err = validate_service_handle(hService, SERVICE_START, &service)) != 0)
|
|
|
|
return err;
|
|
|
|
|
2011-08-29 19:53:04 +02:00
|
|
|
if (service->service_entry->config.dwStartType == SERVICE_DISABLED)
|
|
|
|
return ERROR_SERVICE_DISABLED;
|
|
|
|
|
2008-04-11 12:00:11 +02:00
|
|
|
err = service_start(service->service_entry, dwNumServiceArgs, lpServiceArgVectors);
|
2008-03-28 18:07:39 +01:00
|
|
|
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_ControlService(
|
2008-03-28 18:07:39 +01:00
|
|
|
SC_RPC_HANDLE hService,
|
|
|
|
DWORD dwControl,
|
|
|
|
SERVICE_STATUS *lpServiceStatus)
|
|
|
|
{
|
|
|
|
DWORD access_required;
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_service_handle *service;
|
2016-04-18 17:08:37 +02:00
|
|
|
struct process_entry *process;
|
2011-12-09 13:33:45 +01:00
|
|
|
DWORD result;
|
2008-03-28 18:07:39 +01:00
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
WINE_TRACE("(%p, %d, %p)\n", hService, dwControl, lpServiceStatus);
|
|
|
|
|
|
|
|
switch (dwControl)
|
|
|
|
{
|
|
|
|
case SERVICE_CONTROL_CONTINUE:
|
|
|
|
case SERVICE_CONTROL_NETBINDADD:
|
|
|
|
case SERVICE_CONTROL_NETBINDDISABLE:
|
|
|
|
case SERVICE_CONTROL_NETBINDENABLE:
|
|
|
|
case SERVICE_CONTROL_NETBINDREMOVE:
|
|
|
|
case SERVICE_CONTROL_PARAMCHANGE:
|
|
|
|
case SERVICE_CONTROL_PAUSE:
|
|
|
|
access_required = SERVICE_PAUSE_CONTINUE;
|
|
|
|
break;
|
|
|
|
case SERVICE_CONTROL_INTERROGATE:
|
|
|
|
access_required = SERVICE_INTERROGATE;
|
|
|
|
break;
|
|
|
|
case SERVICE_CONTROL_STOP:
|
|
|
|
access_required = SERVICE_STOP;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
if (dwControl >= 128 && dwControl <= 255)
|
|
|
|
access_required = SERVICE_USER_DEFINED_CONTROL;
|
|
|
|
else
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2011-12-09 13:33:45 +01:00
|
|
|
if ((result = validate_service_handle(hService, access_required, &service)) != 0)
|
|
|
|
return result;
|
2008-03-28 18:07:39 +01:00
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
service_lock(service->service_entry);
|
2008-03-28 18:07:39 +01:00
|
|
|
|
2011-12-12 11:03:55 +01:00
|
|
|
result = ERROR_SUCCESS;
|
2008-03-28 18:07:39 +01:00
|
|
|
switch (service->service_entry->status.dwCurrentState)
|
|
|
|
{
|
|
|
|
case SERVICE_STOPPED:
|
2011-12-12 11:03:55 +01:00
|
|
|
result = ERROR_SERVICE_NOT_ACTIVE;
|
|
|
|
break;
|
2008-03-28 18:07:39 +01:00
|
|
|
case SERVICE_START_PENDING:
|
|
|
|
if (dwControl==SERVICE_CONTROL_STOP)
|
|
|
|
break;
|
2012-05-15 10:15:32 +02:00
|
|
|
/* fall through */
|
2008-03-28 18:07:39 +01:00
|
|
|
case SERVICE_STOP_PENDING:
|
2011-12-12 11:03:55 +01:00
|
|
|
result = ERROR_SERVICE_CANNOT_ACCEPT_CTRL;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-03-03 06:26:26 +01:00
|
|
|
if (result == ERROR_SUCCESS && service->service_entry->force_shutdown)
|
|
|
|
{
|
2011-12-12 11:04:46 +01:00
|
|
|
result = ERROR_SERVICE_CANNOT_ACCEPT_CTRL;
|
|
|
|
service_terminate(service->service_entry);
|
|
|
|
}
|
|
|
|
|
2011-12-12 11:03:55 +01:00
|
|
|
if (result != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
if (lpServiceStatus)
|
|
|
|
{
|
|
|
|
lpServiceStatus->dwServiceType = service->service_entry->status.dwServiceType;
|
|
|
|
lpServiceStatus->dwCurrentState = service->service_entry->status.dwCurrentState;
|
|
|
|
lpServiceStatus->dwControlsAccepted = service->service_entry->status.dwControlsAccepted;
|
|
|
|
lpServiceStatus->dwWin32ExitCode = service->service_entry->status.dwWin32ExitCode;
|
|
|
|
lpServiceStatus->dwServiceSpecificExitCode = service->service_entry->status.dwServiceSpecificExitCode;
|
|
|
|
lpServiceStatus->dwCheckPoint = service->service_entry->status.dwCheckPoint;
|
|
|
|
lpServiceStatus->dwWaitHint = service->service_entry->status.dwWaitHint;
|
|
|
|
}
|
2008-03-28 18:08:12 +01:00
|
|
|
service_unlock(service->service_entry);
|
2011-12-12 11:03:55 +01:00
|
|
|
return result;
|
2008-03-28 18:07:39 +01:00
|
|
|
}
|
|
|
|
|
2011-08-29 19:55:17 +02:00
|
|
|
if (!service_accepts_control(service->service_entry, dwControl))
|
|
|
|
{
|
|
|
|
service_unlock(service->service_entry);
|
|
|
|
return ERROR_INVALID_SERVICE_CONTROL;
|
|
|
|
}
|
|
|
|
|
2016-03-03 06:26:26 +01:00
|
|
|
/* Remember that we tried to shutdown this service. When the service is
|
|
|
|
* still running on the second invocation, it will be forcefully killed. */
|
2008-03-28 18:07:39 +01:00
|
|
|
if (dwControl == SERVICE_CONTROL_STOP)
|
2016-03-03 06:26:26 +01:00
|
|
|
service->service_entry->force_shutdown = TRUE;
|
2008-03-28 18:07:39 +01:00
|
|
|
|
2016-04-18 17:08:37 +02:00
|
|
|
/* Hold a reference to the process while sending the command. */
|
|
|
|
process = grab_process(service->service_entry->process);
|
2008-03-28 18:08:12 +01:00
|
|
|
service_unlock(service->service_entry);
|
2008-03-28 18:07:39 +01:00
|
|
|
|
2016-04-20 14:51:30 +02:00
|
|
|
if (!process)
|
|
|
|
return ERROR_SERVICE_CANNOT_ACCEPT_CTRL;
|
|
|
|
|
2016-04-18 17:08:37 +02:00
|
|
|
ret = WaitForSingleObject(process->control_mutex, 30000);
|
2016-03-03 06:26:26 +01:00
|
|
|
if (ret != WAIT_OBJECT_0)
|
2016-04-18 17:08:37 +02:00
|
|
|
{
|
|
|
|
release_process(process);
|
2016-03-03 06:26:26 +01:00
|
|
|
return ERROR_SERVICE_REQUEST_TIMEOUT;
|
2016-04-18 17:08:37 +02:00
|
|
|
}
|
2011-12-12 11:03:55 +01:00
|
|
|
|
2016-04-18 17:08:37 +02:00
|
|
|
process_send_control(process, service->service_entry->name, dwControl, &result);
|
2008-03-28 18:07:39 +01:00
|
|
|
|
2016-03-03 06:26:26 +01:00
|
|
|
if (lpServiceStatus)
|
2008-03-28 18:07:39 +01:00
|
|
|
{
|
2016-03-03 06:26:26 +01:00
|
|
|
service_lock(service->service_entry);
|
|
|
|
lpServiceStatus->dwServiceType = service->service_entry->status.dwServiceType;
|
|
|
|
lpServiceStatus->dwCurrentState = service->service_entry->status.dwCurrentState;
|
|
|
|
lpServiceStatus->dwControlsAccepted = service->service_entry->status.dwControlsAccepted;
|
|
|
|
lpServiceStatus->dwWin32ExitCode = service->service_entry->status.dwWin32ExitCode;
|
|
|
|
lpServiceStatus->dwServiceSpecificExitCode = service->service_entry->status.dwServiceSpecificExitCode;
|
|
|
|
lpServiceStatus->dwCheckPoint = service->service_entry->status.dwCheckPoint;
|
|
|
|
lpServiceStatus->dwWaitHint = service->service_entry->status.dwWaitHint;
|
|
|
|
service_unlock(service->service_entry);
|
2008-03-28 18:07:39 +01:00
|
|
|
}
|
2016-03-03 06:26:26 +01:00
|
|
|
|
2016-04-18 17:08:37 +02:00
|
|
|
ReleaseMutex(process->control_mutex);
|
|
|
|
release_process(process);
|
2016-03-03 06:26:26 +01:00
|
|
|
return result;
|
2008-03-28 18:07:39 +01:00
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_CloseServiceHandle(
|
2008-03-28 17:56:00 +01:00
|
|
|
SC_RPC_HANDLE *handle)
|
|
|
|
{
|
|
|
|
WINE_TRACE("(&%p)\n", *handle);
|
|
|
|
|
|
|
|
SC_RPC_HANDLE_destroy(*handle);
|
|
|
|
*handle = NULL;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-03-28 18:06:43 +01:00
|
|
|
static void SC_RPC_LOCK_destroy(SC_RPC_LOCK hLock)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_lock *lock = hLock;
|
|
|
|
scmdatabase_unlock_startup(lock->db);
|
|
|
|
HeapFree(GetProcessHeap(), 0, lock);
|
2008-03-28 18:06:43 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
void __RPC_USER SC_RPC_LOCK_rundown(SC_RPC_LOCK hLock)
|
|
|
|
{
|
|
|
|
SC_RPC_LOCK_destroy(hLock);
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_LockServiceDatabase(
|
2008-03-28 18:06:43 +01:00
|
|
|
SC_RPC_HANDLE hSCManager,
|
|
|
|
SC_RPC_LOCK *phLock)
|
|
|
|
{
|
2008-03-28 18:08:12 +01:00
|
|
|
struct sc_manager_handle *manager;
|
2008-07-17 19:24:58 +02:00
|
|
|
struct sc_lock *lock;
|
2008-03-28 18:06:43 +01:00
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
WINE_TRACE("(%p, %p)\n", hSCManager, phLock);
|
|
|
|
|
|
|
|
if ((err = validate_scm_handle(hSCManager, SC_MANAGER_LOCK, &manager)) != ERROR_SUCCESS)
|
|
|
|
return err;
|
|
|
|
|
2008-03-28 18:08:12 +01:00
|
|
|
err = scmdatabase_lock_startup(manager->db);
|
2008-03-28 18:06:43 +01:00
|
|
|
if (err != ERROR_SUCCESS)
|
|
|
|
return err;
|
|
|
|
|
2008-07-17 19:24:58 +02:00
|
|
|
lock = HeapAlloc(GetProcessHeap(), 0, sizeof(struct sc_lock));
|
|
|
|
if (!lock)
|
2008-03-28 18:08:12 +01:00
|
|
|
{
|
|
|
|
scmdatabase_unlock_startup(manager->db);
|
2008-03-28 18:06:43 +01:00
|
|
|
return ERROR_NOT_ENOUGH_SERVER_MEMORY;
|
2008-03-28 18:08:12 +01:00
|
|
|
}
|
2008-03-28 18:06:43 +01:00
|
|
|
|
2008-07-17 19:24:58 +02:00
|
|
|
lock->db = manager->db;
|
|
|
|
*phLock = lock;
|
|
|
|
|
2008-03-28 18:06:43 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_UnlockServiceDatabase(
|
2008-03-28 18:06:43 +01:00
|
|
|
SC_RPC_LOCK *phLock)
|
|
|
|
{
|
|
|
|
WINE_TRACE("(&%p)\n", *phLock);
|
|
|
|
|
|
|
|
SC_RPC_LOCK_destroy(*phLock);
|
|
|
|
*phLock = NULL;
|
|
|
|
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2010-10-27 12:03:28 +02:00
|
|
|
static BOOL map_state(DWORD state, DWORD mask)
|
|
|
|
{
|
|
|
|
switch (state)
|
|
|
|
{
|
|
|
|
case SERVICE_START_PENDING:
|
|
|
|
case SERVICE_STOP_PENDING:
|
|
|
|
case SERVICE_RUNNING:
|
|
|
|
case SERVICE_CONTINUE_PENDING:
|
|
|
|
case SERVICE_PAUSE_PENDING:
|
|
|
|
case SERVICE_PAUSED:
|
|
|
|
if (SERVICE_ACTIVE & mask) return TRUE;
|
|
|
|
break;
|
|
|
|
case SERVICE_STOPPED:
|
|
|
|
if (SERVICE_INACTIVE & mask) return TRUE;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
WINE_ERR("unknown state %u\n", state);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_EnumServicesStatusW(
|
2010-10-27 12:03:28 +02:00
|
|
|
SC_RPC_HANDLE hmngr,
|
|
|
|
DWORD type,
|
|
|
|
DWORD state,
|
|
|
|
BYTE *buffer,
|
|
|
|
DWORD size,
|
|
|
|
LPDWORD needed,
|
2015-02-25 07:07:59 +01:00
|
|
|
LPDWORD returned,
|
|
|
|
LPDWORD resume)
|
2010-10-27 12:03:28 +02:00
|
|
|
{
|
|
|
|
DWORD err, sz, total_size, num_services;
|
|
|
|
DWORD_PTR offset;
|
|
|
|
struct sc_manager_handle *manager;
|
|
|
|
struct service_entry *service;
|
|
|
|
ENUM_SERVICE_STATUSW *s;
|
|
|
|
|
2015-02-25 07:07:59 +01:00
|
|
|
WINE_TRACE("(%p, 0x%x, 0x%x, %p, %u, %p, %p, %p)\n", hmngr, type, state, buffer, size, needed, returned, resume);
|
2010-10-27 12:03:28 +02:00
|
|
|
|
|
|
|
if (!type || !state)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if ((err = validate_scm_handle(hmngr, SC_MANAGER_ENUMERATE_SERVICE, &manager)) != ERROR_SUCCESS)
|
|
|
|
return err;
|
|
|
|
|
2015-02-25 07:07:59 +01:00
|
|
|
if (resume)
|
|
|
|
WINE_FIXME("resume index not supported\n");
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
scmdatabase_lock(manager->db);
|
2010-10-27 12:03:28 +02:00
|
|
|
|
|
|
|
total_size = num_services = 0;
|
|
|
|
LIST_FOR_EACH_ENTRY(service, &manager->db->services, struct service_entry, entry)
|
|
|
|
{
|
|
|
|
if ((service->status.dwServiceType & type) && map_state(service->status.dwCurrentState, state))
|
|
|
|
{
|
|
|
|
total_size += sizeof(ENUM_SERVICE_STATUSW);
|
|
|
|
total_size += (strlenW(service->name) + 1) * sizeof(WCHAR);
|
|
|
|
if (service->config.lpDisplayName)
|
|
|
|
{
|
|
|
|
total_size += (strlenW(service->config.lpDisplayName) + 1) * sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*returned = 0;
|
|
|
|
*needed = total_size;
|
|
|
|
if (total_size > size)
|
|
|
|
{
|
|
|
|
scmdatabase_unlock(manager->db);
|
|
|
|
return ERROR_MORE_DATA;
|
|
|
|
}
|
|
|
|
s = (ENUM_SERVICE_STATUSW *)buffer;
|
|
|
|
offset = num_services * sizeof(ENUM_SERVICE_STATUSW);
|
|
|
|
LIST_FOR_EACH_ENTRY(service, &manager->db->services, struct service_entry, entry)
|
|
|
|
{
|
|
|
|
if ((service->status.dwServiceType & type) && map_state(service->status.dwCurrentState, state))
|
|
|
|
{
|
|
|
|
sz = (strlenW(service->name) + 1) * sizeof(WCHAR);
|
|
|
|
memcpy(buffer + offset, service->name, sz);
|
|
|
|
s->lpServiceName = (WCHAR *)offset; /* store a buffer offset instead of a pointer */
|
|
|
|
offset += sz;
|
|
|
|
|
|
|
|
if (!service->config.lpDisplayName) s->lpDisplayName = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sz = (strlenW(service->config.lpDisplayName) + 1) * sizeof(WCHAR);
|
|
|
|
memcpy(buffer + offset, service->config.lpDisplayName, sz);
|
|
|
|
s->lpDisplayName = (WCHAR *)offset;
|
|
|
|
offset += sz;
|
|
|
|
}
|
|
|
|
memcpy(&s->ServiceStatus, &service->status, sizeof(SERVICE_STATUS));
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*returned = num_services;
|
2010-10-29 12:53:37 +02:00
|
|
|
*needed = 0;
|
|
|
|
scmdatabase_unlock(manager->db);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2011-03-16 08:29:47 +01:00
|
|
|
static struct service_entry *find_service_by_group(struct scmdatabase *db, const WCHAR *group)
|
2010-10-29 12:53:37 +02:00
|
|
|
{
|
|
|
|
struct service_entry *service;
|
|
|
|
LIST_FOR_EACH_ENTRY(service, &db->services, struct service_entry, entry)
|
|
|
|
{
|
|
|
|
if (service->config.lpLoadOrderGroup && !strcmpiW(group, service->config.lpLoadOrderGroup))
|
|
|
|
return service;
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL match_group(const WCHAR *g1, const WCHAR *g2)
|
|
|
|
{
|
|
|
|
if (!g2) return TRUE;
|
|
|
|
if (!g2[0] && (!g1 || !g1[0])) return TRUE;
|
|
|
|
if (g1 && !strcmpW(g1, g2)) return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_EnumServicesStatusExA(
|
|
|
|
SC_RPC_HANDLE scmanager,
|
|
|
|
SC_ENUM_TYPE info_level,
|
|
|
|
DWORD service_type,
|
|
|
|
DWORD service_state,
|
|
|
|
BYTE *buffer,
|
|
|
|
DWORD buf_size,
|
|
|
|
DWORD *needed_size,
|
|
|
|
DWORD *services_count,
|
|
|
|
DWORD *resume_index,
|
|
|
|
LPCSTR groupname)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_EnumServicesStatusExW(
|
2010-10-29 12:53:37 +02:00
|
|
|
SC_RPC_HANDLE hmngr,
|
2015-02-26 23:16:40 +01:00
|
|
|
SC_ENUM_TYPE info_level,
|
2010-10-29 12:53:37 +02:00
|
|
|
DWORD type,
|
|
|
|
DWORD state,
|
|
|
|
BYTE *buffer,
|
|
|
|
DWORD size,
|
|
|
|
LPDWORD needed,
|
|
|
|
LPDWORD returned,
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD *resume_handle,
|
2010-10-29 12:53:37 +02:00
|
|
|
LPCWSTR group)
|
|
|
|
{
|
|
|
|
DWORD err, sz, total_size, num_services;
|
|
|
|
DWORD_PTR offset;
|
|
|
|
struct sc_manager_handle *manager;
|
|
|
|
struct service_entry *service;
|
|
|
|
ENUM_SERVICE_STATUS_PROCESSW *s;
|
|
|
|
|
|
|
|
WINE_TRACE("(%p, 0x%x, 0x%x, %p, %u, %p, %p, %s)\n", hmngr, type, state, buffer, size,
|
|
|
|
needed, returned, wine_dbgstr_w(group));
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
if (resume_handle)
|
|
|
|
FIXME("resume handle not supported\n");
|
|
|
|
|
2010-10-29 12:53:37 +02:00
|
|
|
if (!type || !state)
|
|
|
|
return ERROR_INVALID_PARAMETER;
|
|
|
|
|
|
|
|
if ((err = validate_scm_handle(hmngr, SC_MANAGER_ENUMERATE_SERVICE, &manager)) != ERROR_SUCCESS)
|
|
|
|
return err;
|
|
|
|
|
2016-03-02 07:21:17 +01:00
|
|
|
scmdatabase_lock(manager->db);
|
2010-10-29 12:53:37 +02:00
|
|
|
|
|
|
|
if (group && !find_service_by_group(manager->db, group))
|
|
|
|
{
|
|
|
|
scmdatabase_unlock(manager->db);
|
|
|
|
return ERROR_SERVICE_DOES_NOT_EXIST;
|
|
|
|
}
|
|
|
|
|
|
|
|
total_size = num_services = 0;
|
|
|
|
LIST_FOR_EACH_ENTRY(service, &manager->db->services, struct service_entry, entry)
|
|
|
|
{
|
|
|
|
if ((service->status.dwServiceType & type) && map_state(service->status.dwCurrentState, state)
|
|
|
|
&& match_group(service->config.lpLoadOrderGroup, group))
|
|
|
|
{
|
|
|
|
total_size += sizeof(ENUM_SERVICE_STATUS_PROCESSW);
|
|
|
|
total_size += (strlenW(service->name) + 1) * sizeof(WCHAR);
|
|
|
|
if (service->config.lpDisplayName)
|
|
|
|
{
|
|
|
|
total_size += (strlenW(service->config.lpDisplayName) + 1) * sizeof(WCHAR);
|
|
|
|
}
|
|
|
|
num_services++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*returned = 0;
|
|
|
|
*needed = total_size;
|
|
|
|
if (total_size > size)
|
|
|
|
{
|
|
|
|
scmdatabase_unlock(manager->db);
|
|
|
|
return ERROR_MORE_DATA;
|
|
|
|
}
|
|
|
|
s = (ENUM_SERVICE_STATUS_PROCESSW *)buffer;
|
|
|
|
offset = num_services * sizeof(ENUM_SERVICE_STATUS_PROCESSW);
|
|
|
|
LIST_FOR_EACH_ENTRY(service, &manager->db->services, struct service_entry, entry)
|
|
|
|
{
|
|
|
|
if ((service->status.dwServiceType & type) && map_state(service->status.dwCurrentState, state)
|
|
|
|
&& match_group(service->config.lpLoadOrderGroup, group))
|
|
|
|
{
|
|
|
|
sz = (strlenW(service->name) + 1) * sizeof(WCHAR);
|
|
|
|
memcpy(buffer + offset, service->name, sz);
|
|
|
|
s->lpServiceName = (WCHAR *)offset; /* store a buffer offset instead of a pointer */
|
|
|
|
offset += sz;
|
|
|
|
|
|
|
|
if (!service->config.lpDisplayName) s->lpDisplayName = NULL;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sz = (strlenW(service->config.lpDisplayName) + 1) * sizeof(WCHAR);
|
|
|
|
memcpy(buffer + offset, service->config.lpDisplayName, sz);
|
|
|
|
s->lpDisplayName = (WCHAR *)offset;
|
|
|
|
offset += sz;
|
|
|
|
}
|
|
|
|
s->ServiceStatusProcess = service->status;
|
|
|
|
s++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*returned = num_services;
|
2010-10-27 12:03:28 +02:00
|
|
|
*needed = 0;
|
|
|
|
scmdatabase_unlock(manager->db);
|
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_unknown43(void)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_CreateServiceWOW64A(
|
|
|
|
SC_RPC_HANDLE scmanager,
|
|
|
|
LPCSTR servicename,
|
|
|
|
LPCSTR displayname,
|
|
|
|
DWORD accessmask,
|
|
|
|
DWORD service_type,
|
|
|
|
DWORD start_type,
|
|
|
|
DWORD error_control,
|
|
|
|
LPCSTR imagepath,
|
|
|
|
LPCSTR loadordergroup,
|
|
|
|
DWORD *tagid,
|
|
|
|
const BYTE *dependencies,
|
|
|
|
DWORD depend_size,
|
|
|
|
LPCSTR start_name,
|
|
|
|
const BYTE *password,
|
|
|
|
DWORD password_size,
|
|
|
|
SC_RPC_HANDLE *service)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_CreateServiceWOW64W(
|
|
|
|
SC_RPC_HANDLE scmanager,
|
|
|
|
LPCWSTR servicename,
|
|
|
|
LPCWSTR displayname,
|
|
|
|
DWORD accessmask,
|
|
|
|
DWORD service_type,
|
|
|
|
DWORD start_type,
|
|
|
|
DWORD error_control,
|
|
|
|
LPCWSTR imagepath,
|
|
|
|
LPCWSTR loadordergroup,
|
|
|
|
DWORD *tagid,
|
|
|
|
const BYTE *dependencies,
|
|
|
|
DWORD depend_size,
|
|
|
|
LPCWSTR start_name,
|
|
|
|
const BYTE *password,
|
|
|
|
DWORD password_size,
|
|
|
|
SC_RPC_HANDLE *service)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
2015-02-26 23:20:48 +01:00
|
|
|
WINE_TRACE("(%s, %s, 0x%x, %s)\n", wine_dbgstr_w(servicename), wine_dbgstr_w(displayname), accessmask, wine_dbgstr_w(imagepath));
|
|
|
|
return create_serviceW(scmanager, servicename, displayname, accessmask, service_type, start_type, error_control, imagepath,
|
|
|
|
loadordergroup, tagid, dependencies, depend_size, start_name, password, password_size, service, TRUE);
|
2008-03-28 18:08:27 +01:00
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_unknown46(void)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
2008-03-28 18:08:27 +01:00
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_NotifyServiceStatusChange(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
SC_RPC_NOTIFY_PARAMS params,
|
|
|
|
GUID *clientprocessguid,
|
|
|
|
GUID *scmprocessguid,
|
|
|
|
BOOL *createremotequeue,
|
|
|
|
SC_NOTIFY_RPC_HANDLE *notify)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_GetNotifyResults(
|
|
|
|
SC_NOTIFY_RPC_HANDLE notify,
|
2015-03-05 08:56:53 +01:00
|
|
|
SC_RPC_NOTIFY_PARAMS_LIST **params)
|
2015-02-26 23:16:40 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_CloseNotifyHandle(
|
|
|
|
SC_NOTIFY_RPC_HANDLE *notify,
|
|
|
|
BOOL *apc_fired)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_ControlServiceExA(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
DWORD control,
|
|
|
|
DWORD info_level,
|
|
|
|
SC_RPC_SERVICE_CONTROL_IN_PARAMSA *in_params,
|
|
|
|
SC_RPC_SERVICE_CONTROL_OUT_PARAMSA *out_params)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_ControlServiceExW(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
DWORD control,
|
|
|
|
DWORD info_level,
|
|
|
|
SC_RPC_SERVICE_CONTROL_IN_PARAMSW *in_params,
|
|
|
|
SC_RPC_SERVICE_CONTROL_OUT_PARAMSW *out_params)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_unknown52(void)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_unknown53(void)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_unknown54(void)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_unknown55(void)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_QueryServiceConfigEx(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
DWORD info_level,
|
|
|
|
SC_RPC_CONFIG_INFOW *info)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_QueryServiceObjectSecurity(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
SECURITY_INFORMATION info,
|
|
|
|
BYTE *descriptor,
|
|
|
|
DWORD buf_size,
|
|
|
|
DWORD *needed_size)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
2008-03-28 18:08:27 +01:00
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_SetServiceObjectSecurity(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
SECURITY_INFORMATION info,
|
|
|
|
BYTE *descriptor,
|
|
|
|
DWORD buf_size)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_QueryServiceStatus(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
SERVICE_STATUS *status)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_NotifyBootConfigStatus(
|
|
|
|
SVCCTL_HANDLEW machinename,
|
|
|
|
DWORD boot_acceptable)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_SCSetServiceBitsW(void)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_EnumDependentServicesW(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
DWORD state,
|
|
|
|
BYTE *services,
|
|
|
|
DWORD buf_size,
|
|
|
|
DWORD *needed_size,
|
|
|
|
DWORD *services_ret)
|
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
DWORD __cdecl svcctl_QueryServiceLockStatusW(
|
|
|
|
SC_RPC_HANDLE scmanager,
|
|
|
|
QUERY_SERVICE_LOCK_STATUSW *status,
|
|
|
|
DWORD buf_size,
|
|
|
|
DWORD *needed_size)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_SCSetServiceBitsA(void)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_ChangeServiceConfigA(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
DWORD service_type,
|
|
|
|
DWORD start_type,
|
|
|
|
DWORD error_control,
|
|
|
|
LPSTR binarypath,
|
|
|
|
LPSTR loadordergroup,
|
|
|
|
DWORD *tagid,
|
|
|
|
BYTE *dependencies,
|
|
|
|
DWORD depend_size,
|
|
|
|
LPSTR startname,
|
|
|
|
BYTE *password,
|
|
|
|
DWORD password_size,
|
|
|
|
LPSTR displayname)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_CreateServiceA(
|
|
|
|
SC_RPC_HANDLE scmanager,
|
|
|
|
LPCSTR servicename,
|
|
|
|
LPCSTR displayname,
|
|
|
|
DWORD desiredaccess,
|
|
|
|
DWORD service_type,
|
|
|
|
DWORD start_type,
|
|
|
|
DWORD error_control,
|
|
|
|
LPCSTR binarypath,
|
|
|
|
LPCSTR loadordergroup,
|
|
|
|
DWORD *tagid,
|
|
|
|
const BYTE *dependencies,
|
|
|
|
DWORD depend_size,
|
|
|
|
LPCSTR startname,
|
|
|
|
const BYTE *password,
|
|
|
|
DWORD password_size,
|
|
|
|
SC_RPC_HANDLE *service)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_EnumDependentServicesA(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
DWORD state,
|
|
|
|
BYTE *services,
|
|
|
|
DWORD buf_size,
|
|
|
|
DWORD *needed_size,
|
|
|
|
DWORD *services_ret)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_EnumServicesStatusA(
|
|
|
|
SC_RPC_HANDLE hmngr,
|
|
|
|
DWORD type,
|
|
|
|
DWORD state,
|
|
|
|
BYTE *buffer,
|
|
|
|
DWORD size,
|
|
|
|
DWORD *needed,
|
|
|
|
DWORD *returned,
|
|
|
|
DWORD *resume)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_OpenSCManagerA(
|
|
|
|
MACHINE_HANDLEA MachineName,
|
|
|
|
LPCSTR DatabaseName,
|
|
|
|
DWORD dwAccessMask,
|
|
|
|
SC_RPC_HANDLE *handle)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_OpenServiceA(
|
|
|
|
SC_RPC_HANDLE hSCManager,
|
|
|
|
LPCSTR lpServiceName,
|
|
|
|
DWORD dwDesiredAccess,
|
|
|
|
SC_RPC_HANDLE *phService)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_QueryServiceConfigA(
|
|
|
|
SC_RPC_HANDLE hService,
|
|
|
|
QUERY_SERVICE_CONFIGA *config,
|
|
|
|
DWORD buf_size,
|
|
|
|
DWORD *needed_size)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_QueryServiceLockStatusA(
|
|
|
|
SC_RPC_HANDLE scmanager,
|
|
|
|
QUERY_SERVICE_LOCK_STATUSA *status,
|
|
|
|
DWORD buf_size,
|
|
|
|
DWORD *needed_size)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_StartServiceA(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
DWORD argc,
|
|
|
|
LPCSTR *args)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_GetServiceDisplayNameA(
|
|
|
|
SC_RPC_HANDLE hSCManager,
|
|
|
|
LPCSTR servicename,
|
|
|
|
CHAR buffer[],
|
|
|
|
DWORD *buf_size)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_GetServiceKeyNameA(
|
|
|
|
SC_RPC_HANDLE hSCManager,
|
|
|
|
LPCSTR servicename,
|
|
|
|
CHAR buffer[],
|
|
|
|
DWORD *buf_size)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2011-06-10 13:40:05 +02:00
|
|
|
DWORD __cdecl svcctl_GetCurrentGroupStateW(void)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_EnumServiceGroupW(
|
|
|
|
SC_RPC_HANDLE scmanager,
|
|
|
|
DWORD service_type,
|
|
|
|
DWORD service_state,
|
|
|
|
BYTE *buffer,
|
|
|
|
DWORD buf_size,
|
|
|
|
DWORD *needed_size,
|
|
|
|
DWORD *returned_size,
|
|
|
|
DWORD *resume_index,
|
|
|
|
LPCWSTR groupname)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_ChangeServiceConfig2A(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
SC_RPC_CONFIG_INFOA info)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
DWORD __cdecl svcctl_QueryServiceConfig2A(
|
|
|
|
SC_RPC_HANDLE service,
|
|
|
|
DWORD info_level,
|
|
|
|
BYTE *buffer,
|
|
|
|
DWORD buf_size,
|
|
|
|
DWORD *needed_size)
|
2008-03-28 18:08:27 +01:00
|
|
|
{
|
|
|
|
WINE_FIXME("\n");
|
|
|
|
return ERROR_CALL_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
2008-04-11 11:59:51 +02:00
|
|
|
DWORD RPC_Init(void)
|
2008-03-28 17:56:00 +01:00
|
|
|
{
|
|
|
|
WCHAR transport[] = SVCCTL_TRANSPORT;
|
|
|
|
WCHAR endpoint[] = SVCCTL_ENDPOINT;
|
|
|
|
DWORD err;
|
|
|
|
|
|
|
|
if ((err = RpcServerUseProtseqEpW(transport, 0, endpoint, NULL)) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WINE_ERR("RpcServerUseProtseq failed with error %u\n", err);
|
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((err = RpcServerRegisterIf(svcctl_v2_0_s_ifspec, 0, 0)) != ERROR_SUCCESS)
|
|
|
|
{
|
2008-04-07 11:03:01 +02:00
|
|
|
WINE_ERR("RpcServerRegisterIf failed with error %u\n", err);
|
2008-03-28 17:56:00 +01:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ((err = RpcServerListen(1, RPC_C_LISTEN_MAX_CALLS_DEFAULT, TRUE)) != ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
WINE_ERR("RpcServerListen failed with error %u\n", err);
|
|
|
|
return err;
|
|
|
|
}
|
2008-04-11 11:59:51 +02:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2012-10-22 14:26:10 +02:00
|
|
|
DWORD events_loop(void)
|
2008-04-11 11:59:51 +02:00
|
|
|
{
|
2012-10-22 14:26:10 +02:00
|
|
|
struct timeout_queue_elem *iter, *iter_safe;
|
2008-04-11 11:59:51 +02:00
|
|
|
DWORD err;
|
2015-02-26 14:46:14 +01:00
|
|
|
HANDLE wait_handles[MAXIMUM_WAIT_OBJECTS];
|
2012-10-22 14:26:10 +02:00
|
|
|
DWORD timeout = INFINITE;
|
|
|
|
|
|
|
|
wait_handles[0] = __wine_make_process_system();
|
|
|
|
wait_handles[1] = CreateEventW(NULL, FALSE, FALSE, NULL);
|
|
|
|
timeout_queue_event = wait_handles[1];
|
2008-03-28 17:56:00 +01:00
|
|
|
|
|
|
|
SetEvent(g_hStartedEvent);
|
2008-04-11 11:59:51 +02:00
|
|
|
|
|
|
|
WINE_TRACE("Entered main loop\n");
|
|
|
|
|
2008-03-28 17:56:00 +01:00
|
|
|
do
|
|
|
|
{
|
2015-02-26 14:46:14 +01:00
|
|
|
DWORD num_handles = 2;
|
|
|
|
|
|
|
|
/* monitor tracked process handles for process end */
|
|
|
|
EnterCriticalSection(&timeout_queue_cs);
|
|
|
|
LIST_FOR_EACH_ENTRY(iter, &timeout_queue, struct timeout_queue_elem, entry)
|
|
|
|
{
|
|
|
|
if(num_handles == MAXIMUM_WAIT_OBJECTS){
|
|
|
|
WINE_TRACE("Exceeded maximum wait object count\n");
|
|
|
|
break;
|
|
|
|
}
|
2016-04-20 14:51:30 +02:00
|
|
|
wait_handles[num_handles] = iter->process->process;
|
2015-02-26 14:46:14 +01:00
|
|
|
num_handles++;
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&timeout_queue_cs);
|
|
|
|
|
|
|
|
err = WaitForMultipleObjects(num_handles, wait_handles, FALSE, timeout);
|
2008-03-28 17:56:00 +01:00
|
|
|
WINE_TRACE("Wait returned %d\n", err);
|
2012-10-22 14:26:10 +02:00
|
|
|
|
2015-02-26 14:46:14 +01:00
|
|
|
if(err > WAIT_OBJECT_0 || err == WAIT_TIMEOUT)
|
2012-10-22 14:26:10 +02:00
|
|
|
{
|
|
|
|
FILETIME cur_time;
|
|
|
|
ULARGE_INTEGER time;
|
2015-02-26 14:46:14 +01:00
|
|
|
DWORD idx = 0;
|
2012-10-22 14:26:10 +02:00
|
|
|
|
|
|
|
GetSystemTimeAsFileTime(&cur_time);
|
2012-10-28 19:44:51 +01:00
|
|
|
time.u.LowPart = cur_time.dwLowDateTime;
|
|
|
|
time.u.HighPart = cur_time.dwHighDateTime;
|
2012-10-22 14:26:10 +02:00
|
|
|
|
|
|
|
EnterCriticalSection(&timeout_queue_cs);
|
|
|
|
timeout = INFINITE;
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(iter, iter_safe, &timeout_queue, struct timeout_queue_elem, entry)
|
|
|
|
{
|
2015-02-26 14:46:14 +01:00
|
|
|
if(CompareFileTime(&cur_time, &iter->time) >= 0 ||
|
|
|
|
(err > WAIT_OBJECT_0 + 1 && idx == err - WAIT_OBJECT_0 - 2))
|
2012-10-22 14:26:10 +02:00
|
|
|
{
|
|
|
|
LeaveCriticalSection(&timeout_queue_cs);
|
2016-04-20 14:51:30 +02:00
|
|
|
iter->func(iter->process);
|
2012-10-22 14:26:10 +02:00
|
|
|
EnterCriticalSection(&timeout_queue_cs);
|
|
|
|
|
2016-04-20 14:51:30 +02:00
|
|
|
release_process(iter->process);
|
2012-10-22 14:26:10 +02:00
|
|
|
list_remove(&iter->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, iter);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ULARGE_INTEGER time_diff;
|
|
|
|
|
2012-10-28 19:44:51 +01:00
|
|
|
time_diff.u.LowPart = iter->time.dwLowDateTime;
|
|
|
|
time_diff.u.HighPart = iter->time.dwHighDateTime;
|
2012-10-22 14:26:10 +02:00
|
|
|
time_diff.QuadPart = (time_diff.QuadPart-time.QuadPart)/10000;
|
|
|
|
|
|
|
|
if(time_diff.QuadPart < timeout)
|
|
|
|
timeout = time_diff.QuadPart;
|
|
|
|
}
|
2015-02-26 14:46:14 +01:00
|
|
|
idx++;
|
2012-10-22 14:26:10 +02:00
|
|
|
}
|
|
|
|
LeaveCriticalSection(&timeout_queue_cs);
|
|
|
|
|
|
|
|
if(timeout != INFINITE)
|
|
|
|
timeout += 1000;
|
|
|
|
}
|
2008-03-28 17:56:00 +01:00
|
|
|
} while (err != WAIT_OBJECT_0);
|
|
|
|
|
|
|
|
WINE_TRACE("Object signaled - wine shutdown\n");
|
2012-10-22 14:26:10 +02:00
|
|
|
EnterCriticalSection(&timeout_queue_cs);
|
|
|
|
LIST_FOR_EACH_ENTRY_SAFE(iter, iter_safe, &timeout_queue, struct timeout_queue_elem, entry)
|
|
|
|
{
|
|
|
|
LeaveCriticalSection(&timeout_queue_cs);
|
2016-04-20 14:51:30 +02:00
|
|
|
iter->func(iter->process);
|
2012-10-22 14:26:10 +02:00
|
|
|
EnterCriticalSection(&timeout_queue_cs);
|
|
|
|
|
2016-04-20 14:51:30 +02:00
|
|
|
release_process(iter->process);
|
2012-10-22 14:26:10 +02:00
|
|
|
list_remove(&iter->entry);
|
|
|
|
HeapFree(GetProcessHeap(), 0, iter);
|
|
|
|
}
|
|
|
|
LeaveCriticalSection(&timeout_queue_cs);
|
|
|
|
|
|
|
|
CloseHandle(wait_handles[0]);
|
|
|
|
CloseHandle(wait_handles[1]);
|
2008-03-28 17:56:00 +01:00
|
|
|
return ERROR_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
void __RPC_USER SC_RPC_HANDLE_rundown(SC_RPC_HANDLE handle)
|
|
|
|
{
|
|
|
|
SC_RPC_HANDLE_destroy(handle);
|
|
|
|
}
|
|
|
|
|
2015-02-26 23:16:40 +01:00
|
|
|
void __RPC_USER SC_NOTIFY_RPC_HANDLE_rundown(SC_NOTIFY_RPC_HANDLE handle)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2009-01-30 14:46:17 +01:00
|
|
|
void __RPC_FAR * __RPC_USER MIDL_user_allocate(SIZE_T len)
|
2008-03-28 17:56:00 +01:00
|
|
|
{
|
|
|
|
return HeapAlloc(GetProcessHeap(), 0, len);
|
|
|
|
}
|
|
|
|
|
|
|
|
void __RPC_USER MIDL_user_free(void __RPC_FAR * ptr)
|
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, ptr);
|
|
|
|
}
|