diff options
author | Gerald Combs <gerald@wireshark.org> | 2007-09-15 00:18:17 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2007-09-15 00:18:17 +0000 |
commit | d2d4fcd903f3c675d85a4d32bff280f4a5bc8e6e (patch) | |
tree | 88cf3b0551436062acb26b33f60dd27417944d81 /epan | |
parent | d0c2725672061a344852cc3f7473e36826522638 (diff) |
Add routines under Windows to check if npf.sys is running, and to
fetch the major OS version. If we're running Windows >= 6 (Vista)
_and_ npf.sys isn't running, warn the user in Wireshark and TShark.
Add a recent prefs item to disable the warning in Wireshark.
svn path=/trunk/; revision=22877
Diffstat (limited to 'epan')
-rw-r--r-- | epan/libwireshark.def | 1 | ||||
-rw-r--r-- | epan/privileges.c | 41 | ||||
-rw-r--r-- | epan/privileges.h | 8 |
3 files changed, 50 insertions, 0 deletions
diff --git a/epan/libwireshark.def b/epan/libwireshark.def index 319d4733e3..0d91ef50a6 100644 --- a/epan/libwireshark.def +++ b/epan/libwireshark.def @@ -504,6 +504,7 @@ mtp3_addr_to_str_buf mtp3_service_indicator_code_short_vals DATA new_create_dissector_handle new_register_dissector +npf_sys_is_running nstime_delta nstime_is_unset nstime_is_zero diff --git a/epan/privileges.c b/epan/privileges.c index 54b294522e..a44bc69c44 100644 --- a/epan/privileges.c +++ b/epan/privileges.c @@ -32,6 +32,9 @@ #ifdef _WIN32 #include "emem.h" +#include <windows.h> +#include <wchar.h> +#include <tchar.h> /* * Called when the program starts, to save whatever credential information @@ -40,6 +43,7 @@ void get_credential_info(void) { +npf_sys_is_running(); } /* @@ -94,6 +98,30 @@ 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) + return FALSE; + + if (QueryServiceStatus(h_serv, &ss)) { + if (ss.dwCurrentState & SERVICE_RUNNING) + return TRUE; + } + return FALSE; +} + + #else /* _WIN32 */ #ifdef HAVE_SYS_TYPES_H @@ -242,3 +270,16 @@ get_cur_groupname(void) { } #endif /* _WIN32 */ + +/* + * Editor modelines + * + * Local Variables: + * c-basic-offset: 8 + * tab-width: 8 + * indent-tabs-mode: tabs + * End: + * + * ex: set shiftwidth=8 tabstop=8 noexpandtab + * :indentSize=8:tabSize=8:noTabs=false: + */ diff --git a/epan/privileges.h b/epan/privileges.h index a3612e4936..29777c8546 100644 --- a/epan/privileges.h +++ b/epan/privileges.h @@ -61,3 +61,11 @@ extern gchar *get_cur_username(void); */ extern gchar *get_cur_groupname(void); +#ifdef _WIN32 +/** + * Check to see if npf.sys is running. + * @return TRUE if npf.sys is running, FALSE if it's not or if there was + * an error checking its status. + */ +extern gboolean npf_sys_is_running(); +#endif |