diff options
author | Yang Luo <hsluoyz@gmail.com> | 2016-06-03 12:25:28 +0800 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2016-06-03 19:31:55 +0000 |
commit | 6a860e948d9fd811fe14c4cb07d5dc0a0f694f81 (patch) | |
tree | 3a893bf8d9f7ad53be519907d8280172f83d5426 /wsutil | |
parent | da84de5dff3f619ea9ee0af698b1e182aae2586c (diff) |
Add support for Npcap native mode:
1) Start Npcap service for capturing packets on
Windows if WinPcap service is unavailable.
2) Search Npcap DLLs (wpcap.dll, Packet.dll) also in
"system32\Npcap" folder after "system32" is searched.
Change-Id: I6810382db431a4e7fe309edd08757db60d8ade38
Reviewed-on: https://code.wireshark.org/review/15707
Reviewed-by: Yang Luo <hsluoyz@gmail.com>
Petri-Dish: Guy Harris <guy@alum.mit.edu>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Guy Harris <guy@alum.mit.edu>
Diffstat (limited to 'wsutil')
-rw-r--r-- | wsutil/file_util.c | 35 | ||||
-rw-r--r-- | wsutil/privileges.c | 7 |
2 files changed, 38 insertions, 4 deletions
diff --git a/wsutil/file_util.c b/wsutil/file_util.c index 4f749fb517..da8f91487c 100644 --- a/wsutil/file_util.c +++ b/wsutil/file_util.c @@ -73,6 +73,7 @@ static gchar *program_path = NULL; static gchar *system_path = NULL; +static gchar *npcap_path = NULL; /** * g_open: @@ -472,7 +473,7 @@ init_dll_load_paths() { TCHAR path_w[MAX_PATH]; - if (program_path && system_path) + if (program_path && system_path && npcap_path) return TRUE; /* XXX - Duplicate code in filesystem.c:init_progfile_dir */ @@ -496,7 +497,13 @@ init_dll_load_paths() system_path = g_utf16_to_utf8(path_w, -1, NULL, NULL, NULL); } - if (program_path && system_path) + _tcscat_s(path_w, MAX_PATH, _T("\\Npcap")); + + if (!npcap_path) { + npcap_path = g_utf16_to_utf8(path_w, -1, NULL, NULL, NULL); + } + + if (program_path && system_path && npcap_path) return TRUE; return FALSE; @@ -568,6 +575,19 @@ ws_load_library(const gchar *library_name) } } + /* At last try the Npcap directory */ + full_path = g_module_build_path(npcap_path, library_name); + full_path_w = g_utf8_to_utf16(full_path, -1, NULL, NULL, NULL); + + if (full_path && full_path_w) { + dll_h = LoadLibraryW(full_path_w); + if (dll_h) { + g_free(full_path); + g_free(full_path_w); + return dll_h; + } + } + return NULL; } @@ -602,6 +622,17 @@ ws_module_open(gchar *module_name, GModuleFlags flags) } } + /* At last try the Npcap directory */ + full_path = g_module_build_path(npcap_path, module_name); + + if (full_path) { + mod = g_module_open(full_path, flags); + if (mod) { + g_free(full_path); + return mod; + } + } + return NULL; } diff --git a/wsutil/privileges.c b/wsutil/privileges.c index 46889885f4..2ce1cf33e9 100644 --- a/wsutil/privileges.c +++ b/wsutil/privileges.c @@ -140,8 +140,11 @@ npf_sys_is_running() { return FALSE; h_serv = OpenService(h_scm, _T("npf"), SC_MANAGER_CONNECT|SERVICE_QUERY_STATUS); - if (!h_serv) - return FALSE; + 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) |