Windows: prioritize Npcap over WinPcap

It is now considered stable enough to be our default capture driver if present

Change-Id: I7f3cdabcbaea526949afa47164e520202e6b93f2
Reviewed-on: https://code.wireshark.org/review/27393
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
This commit is contained in:
Pascal Quantin 2018-05-07 23:37:31 +02:00
parent 8756d0ad12
commit e9c5d937b5
2 changed files with 13 additions and 27 deletions

View File

@ -1072,7 +1072,7 @@ get_runtime_caplibs_version(GString *str)
g_string_append_printf(str, "WinPcap (%s)", packetVer);
}
} else
g_string_append(str, "without WinPcap");
g_string_append(str, "without Npcap or WinPcap");
}
/*
@ -1088,9 +1088,9 @@ npf_sys_is_running(void)
if (!h_scm)
return FALSE;
h_serv = OpenService(h_scm, _T("npf"), SC_MANAGER_CONNECT|SERVICE_QUERY_STATUS);
h_serv = OpenService(h_scm, _T("npcap"), SC_MANAGER_CONNECT|SERVICE_QUERY_STATUS);
if (!h_serv) {
h_serv = OpenService(h_scm, _T("npcap"), SC_MANAGER_CONNECT|SERVICE_QUERY_STATUS);
h_serv = OpenService(h_scm, _T("npf"), SC_MANAGER_CONNECT|SERVICE_QUERY_STATUS);
if (!h_serv) {
CloseServiceHandle(h_scm);
return FALSE;

View File

@ -491,32 +491,18 @@ init_dll_load_paths()
gboolean
ws_init_dll_search_path()
{
gboolean dll_dir_set = FALSE, npf_found = FALSE;
gboolean dll_dir_set = FALSE;
wchar_t *program_path_w;
wchar_t npcap_path_w[MAX_PATH];
unsigned int retval;
SC_HANDLE h_scm, h_serv;
dll_dir_set = SetDllDirectory(_T(""));
if (dll_dir_set) {
/* Do not systematically add Npcap path as long as we favor WinPcap over Npcap. */
h_scm = OpenSCManager(NULL, NULL, 0);
if (h_scm) {
h_serv = OpenService(h_scm, _T("npf"), SC_MANAGER_CONNECT|SERVICE_QUERY_STATUS);
if (h_serv) {
CloseServiceHandle(h_serv);
npf_found = TRUE;
}
CloseServiceHandle(h_scm);
}
if (!npf_found) {
/* npf service was not found, so WinPcap is not (properly) installed.
Add Npcap folder to libraries search path. */
retval = GetSystemDirectoryW(npcap_path_w, MAX_PATH);
if (0 < retval && retval <= MAX_PATH) {
wcscat_s(npcap_path_w, MAX_PATH, L"\\Npcap");
dll_dir_set = SetDllDirectory(npcap_path_w);
}
/* Add Npcap folder to libraries search path. */
retval = GetSystemDirectoryW(npcap_path_w, MAX_PATH);
if (0 < retval && retval <= MAX_PATH) {
wcscat_s(npcap_path_w, MAX_PATH, L"\\Npcap");
dll_dir_set = SetDllDirectory(npcap_path_w);
}
}
@ -595,8 +581,8 @@ ws_module_open(gchar *module_name, GModuleFlags flags)
}
}
/* Next try the system directory */
full_path = g_module_build_path(system_path, module_name);
/* Next try the Npcap directory */
full_path = g_module_build_path(npcap_path, module_name);
if (full_path) {
mod = g_module_open(full_path, flags);
@ -606,8 +592,8 @@ ws_module_open(gchar *module_name, GModuleFlags flags)
}
}
/* At last try the Npcap directory */
full_path = g_module_build_path(npcap_path, module_name);
/* At last try the system directory */
full_path = g_module_build_path(system_path, module_name);
if (full_path) {
mod = g_module_open(full_path, flags);