From a6618ffdc9ed8ad28aeecf902b45c39e2f3b9d93 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 3 Jun 2016 13:29:43 -0700 Subject: Move npf_sys_is_running() from wsutil to caputils. It has nothing to do with controlling privileges; it only tests whether the NPF or Npcap service (driver) is running, so it belongs in caputils. While we're at it, fix its signature (in C, a function with no arguments must have "void" as the argument list, for backwards compatibility with pre-function-prototype C), and close the handles it opens, so we don't have open handles leaked. Change-Id: Ia99e99d81617ed2e8cda2c44e53061b4502a2b58 Reviewed-on: https://code.wireshark.org/review/15714 Petri-Dish: Guy Harris Reviewed-by: Guy Harris --- wsutil/privileges.c | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'wsutil/privileges.c') diff --git a/wsutil/privileges.c b/wsutil/privileges.c index 2ce1cf33e9..3fee9d7927 100644 --- a/wsutil/privileges.c +++ b/wsutil/privileges.c @@ -71,8 +71,6 @@ init_process_policies(void) PSetProcessDEPPolicy(PROCESS_DEP_ENABLE); } } - - npf_sys_is_running(); } /* @@ -127,33 +125,6 @@ get_cur_groupname(void) { return groupname; } -/* - * If npf.sys is running, return TRUE. - */ -gboolean -npf_sys_is_running() { - SC_HANDLE h_scm, h_serv; - SERVICE_STATUS ss; - - h_scm = OpenSCManager(NULL, NULL, 0); - if (!h_scm) - return FALSE; - - h_serv = OpenService(h_scm, _T("npf"), SC_MANAGER_CONNECT|SERVICE_QUERY_STATUS); - if (!h_serv) { - h_serv = OpenService(h_scm, _T("npcap"), SC_MANAGER_CONNECT|SERVICE_QUERY_STATUS); - if (!h_serv) - return FALSE; - } - - if (QueryServiceStatus(h_serv, &ss)) { - if (ss.dwCurrentState & SERVICE_RUNNING) - return TRUE; - } - return FALSE; -} - - #else /* _WIN32 */ #ifdef HAVE_SYS_TYPES_H -- cgit v1.2.1