Skip to content

Commit

Permalink
Prefer Npcap on Windows
Browse files Browse the repository at this point in the history
Set dll search directory to prefer Npcap.
  • Loading branch information
marcusbirkin committed May 25, 2024
1 parent 5a15b1a commit c5a6695
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/pcap/pcapplayback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#ifdef Q_OS_WIN
#include <windows.h>
#include <delayimp.h>
#include <tchar.h>
#endif

PcapPlayback::PcapPlayback(QWidget *parent) :
Expand Down Expand Up @@ -38,6 +39,12 @@ bool PcapPlayback::foundLibPcap()
return EXCEPTION_CONTINUE_SEARCH;
};

// Prefer Npcap
TCHAR npcapDir[BUFSIZ];
GetSystemDirectory(npcapDir, BUFSIZ);
_tcscat_s(npcapDir, BUFSIZ, TEXT("\\Npcap"));
SetDllDirectory(npcapDir);

__try {
HRESULT hr = __HrLoadAllImportsForDll("wpcap.dll");
if (FAILED(hr)) {
Expand Down

0 comments on commit c5a6695

Please sign in to comment.