add option to build with Npcap on Windows

This commit is contained in:
Jeffrey Quesnelle
2020-06-16 12:14:46 -04:00
parent 8f6ff86448
commit 7a71a35848
2 changed files with 23 additions and 2 deletions
+15
View File
@@ -27,6 +27,21 @@ bool PCAPDLL::ok() const
PCAPDLL::PCAPDLL()
{
#ifdef NPCAP
BOOL(WINAPI * SetDllDirectory)(LPCTSTR);
char sysdir_name[512];
int len;
SetDllDirectory = (BOOL(WINAPI*)(LPCTSTR)) GetProcAddress(GetModuleHandle("kernel32.dll"), "SetDllDirectoryA");
if (SetDllDirectory != NULL)
{
len = GetSystemDirectory(sysdir_name, 480); // be safe
if (len)
{
strcat(sysdir_name, "\\Npcap");
SetDllDirectory(sysdir_name);
}
}
#endif
dll = LoadLibrary("wpcap.dll");
if(dll == NULL) {