[1/2] wmi: Implement StartMode property for service class
Nikolay Sivov
nsivov at codeweavers.com
Mon Aug 27 00:16:57 CDT 2012
For http://bugs.winehq.org/show_bug.cgi?id=31521
-------------- next part --------------
>From 190b27fdd0f105d5cb2c51c5c8636296f4d8577c Mon Sep 17 00:00:00 2001
From: Nikolay Sivov <nsivov at codeweavers.com>
Date: Sun, 26 Aug 2012 21:29:29 +0400
Subject: [PATCH 3/5] Implement StartMode property for service class
---
dlls/wbemprox/builtin.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 45 insertions(+), 0 deletions(-)
diff --git a/dlls/wbemprox/builtin.c b/dlls/wbemprox/builtin.c
index ce18b92..f20a279 100644
--- a/dlls/wbemprox/builtin.c
+++ b/dlls/wbemprox/builtin.c
@@ -143,6 +143,8 @@ static const WCHAR prop_serialnumberW[] =
{'S','e','r','i','a','l','N','u','m','b','e','r',0};
static const WCHAR prop_servicetypeW[] =
{'S','e','r','v','i','c','e','T','y','p','e',0};
+static const WCHAR prop_startmodeW[] =
+ {'S','t','a','r','t','M','o','d','e',0};
static const WCHAR prop_sizeW[] =
{'S','i','z','e',0};
static const WCHAR prop_speedW[] =
@@ -259,6 +261,7 @@ static const struct column col_service[] =
{ prop_nameW, CIM_STRING|COL_FLAG_DYNAMIC|COL_FLAG_KEY },
{ prop_processidW, CIM_UINT32 },
{ prop_servicetypeW, CIM_STRING },
+ { prop_startmodeW, CIM_STRING },
{ prop_stateW, CIM_STRING }
};
static const struct column col_stdregprov[] =
@@ -395,6 +398,7 @@ struct record_service
const WCHAR *name;
UINT32 process_id;
const WCHAR *servicetype;
+ const WCHAR *startmode;
const WCHAR *state;
};
struct record_stdregprov
@@ -836,6 +840,28 @@ static const WCHAR *get_service_state( DWORD state )
}
}
+static const WCHAR *get_service_startmode( DWORD mode )
+{
+ static const WCHAR bootW[] = {'B','o','o','t',0};
+ static const WCHAR systemW[] = {'S','y','s','t','e','m',0};
+ static const WCHAR autoW[] = {'A','u','t','o',0};
+ static const WCHAR manualW[] = {'M','a','n','u','a','l',0};
+ static const WCHAR disabledW[] = {'D','i','s','a','b','l','e','d',0};
+ static const WCHAR unknownW[] = {'U','n','k','n','o','w','n',0};
+
+ switch (mode)
+ {
+ case SERVICE_BOOT_START: return bootW;
+ case SERVICE_SYSTEM_START: return systemW;
+ case SERVICE_AUTO_START: return autoW;
+ case SERVICE_DEMAND_START: return manualW;
+ case SERVICE_DISABLED: return disabledW;
+ default:
+ ERR("unknown mode 0x%x\n", mode);
+ return unknownW;
+ }
+}
+
static void fill_service( struct table *table )
{
struct record_service *rec;
@@ -866,6 +892,24 @@ static void fill_service( struct table *table )
for (i = 0; i < count; i++)
{
+ QUERY_SERVICE_CONFIGW *config;
+ SC_HANDLE service;
+ DWORD startmode;
+ DWORD size;
+
+ service = OpenServiceW(manager, services[i].lpServiceName, GENERIC_READ);
+ QueryServiceConfigW(service, NULL, 0, &size);
+ config = heap_alloc(size);
+ if (QueryServiceConfigW(service, config, size, &size))
+ startmode = config->dwStartType;
+ else
+ {
+ ERR("failed to get %s service config data\n", debugstr_w(services[i].lpServiceName));
+ startmode = SERVICE_DISABLED;
+ }
+ CloseServiceHandle(service);
+ heap_free(config);
+
status = &services[i].ServiceStatusProcess;
rec = (struct record_service *)(table->data + offset);
rec->accept_pause = (status->dwControlsAccepted & SERVICE_ACCEPT_PAUSE_CONTINUE) ? -1 : 0;
@@ -874,6 +918,7 @@ static void fill_service( struct table *table )
rec->name = heap_strdupW( services[i].lpServiceName );
rec->process_id = status->dwProcessId;
rec->servicetype = get_service_type( status->dwServiceType );
+ rec->startmode = get_service_startmode( startmode );
rec->state = get_service_state( status->dwCurrentState );
offset += sizeof(*rec);
num_rows++;
--
1.5.6.5
More information about the wine-patches
mailing list