aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/file_util.c
diff options
context:
space:
mode:
Diffstat (limited to 'wsutil/file_util.c')
-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);
+ }
}
}
}