aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPascal Quantin <pascal.quantin@gmail.com>2017-10-18 10:11:56 +0200
committerAnders Broman <a.broman58@gmail.com>2017-10-20 04:18:09 +0000
commitd64c300522ffa830e061adeb81e75255b3f955ac (patch)
treea5afe1d50210a5aca41ae3c2500f7a03cc2bd65e
parent4273eced0c24442e5e713762e97cba5457b23284 (diff)
Do not add Npcap path if npf.sys service is found
Otherwise you can end with 2 Packet.dll (the one from WinPcap and the one from Npcap) being loaded at the same time, which can create incompatibilities. Bug: 14134 Change-Id: Ia06066fd54b60296e55dbfce6c6f2ddd99367479 Reviewed-on: https://code.wireshark.org/review/23969 Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--wsutil/file_util.c23
1 files changed, 18 insertions, 5 deletions
diff --git a/wsutil/file_util.c b/wsutil/file_util.c
index abd4ccab03..72ed16d813 100644
--- a/wsutil/file_util.c
+++ b/wsutil/file_util.c
@@ -504,10 +504,11 @@ init_dll_load_paths()
gboolean
ws_init_dll_search_path()
{
- gboolean dll_dir_set = FALSE;
+ gboolean dll_dir_set = FALSE, npf_found = FALSE;
wchar_t *program_path_w;
wchar_t npcap_path_w[MAX_PATH];
unsigned int retval;
+ SC_HANDLE h_scm;
typedef BOOL (WINAPI *SetDllDirectoryHandler)(LPCTSTR);
SetDllDirectoryHandler PSetDllDirectory;
@@ -516,10 +517,22 @@ ws_init_dll_search_path()
if (PSetDllDirectory) {
dll_dir_set = PSetDllDirectory(_T(""));
if (dll_dir_set) {
- 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 = PSetDllDirectory(npcap_path_w);
+ /* Do not systematically add Npcap path as long as we favor WinPcap over Npcap. */
+ h_scm = OpenSCManager(NULL, NULL, 0);
+ if (h_scm) {
+ if (OpenService(h_scm, _T("npf"), SC_MANAGER_CONNECT|SERVICE_QUERY_STATUS)) {
+ 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 = PSetDllDirectory(npcap_path_w);
+ }
}
}
}