]> git.unchartedbackwaters.co.uk Git - francis/winuae.git/commitdiff
Native npcap support.
authorToni Wilen <twilen@winuae.net>
Sun, 22 Oct 2017 12:33:12 +0000 (15:33 +0300)
committerToni Wilen <twilen@winuae.net>
Sun, 22 Oct 2017 12:33:12 +0000 (15:33 +0300)
od-win32/win32_uaenet.cpp

index d073d93e07e57f813da5bf27bd9a687b247521c1..982524c9dbfd93296c8c38d91410012e3ee144b0 100644 (file)
 
 #define HAVE_REMOTE
 #define WPCAP
+#define PCAP_DONT_INCLUDE_PCAP_BPF_H
 #include "pcap.h"
-
 #include "packet32.h"
+#include "pcap/dlt.h"
+
 #include "ntddndis.h"
 
 #include "options.h"
@@ -365,22 +367,35 @@ struct netdriverdata *uaenet_enumerate (const TCHAR *name)
        int val;
        TCHAR *ss;
        bool npcap = true;
+       TCHAR sname[MAX_DPATH];
+       int isdll;
 
        if (enumerated) {
                return enumit (name);
        }
        tcp = tds;
-       wpcap = LoadLibrary(_T("npcap\\wpcap.dll"));
+
+       int len = GetSystemDirectory(sname, MAX_DPATH);
+       if (len) {
+               _tcscat(sname, _T("\\Npcap"));
+               SetDllDirectory(sname);
+       }
+       wpcap = LoadLibrary(_T("wpcap.dll"));
+       packet = LoadLibrary(_T("packet.dll"));
+       isdll = isdllversion(_T("wpcap.dll"), 4, 0, 0, 0);
+       SetDllDirectory(_T(""));
        if (wpcap == NULL) {
+               FreeLibrary(packet);
                int err = GetLastError();
                wpcap = LoadLibrary (_T("wpcap.dll"));
+               packet = LoadLibrary(_T("packet.dll"));
+               isdll = isdllversion(_T("wpcap.dll"), 4, 0, 0, 0);
                if (wpcap == NULL) {
                        write_log (_T("uaenet: npcap/winpcap not installed (wpcap.dll)\n"));
                        return NULL;
                }
                npcap = false;
        }
-       packet = LoadLibrary (npcap ? _T("npcap\\packet.dll") : _T("packet.dll"));
        if (packet == NULL) {
                write_log (_T("uaenet: npcap/winpcap not installed (packet.dll)\n"));
                FreeLibrary(wpcap);
@@ -388,7 +403,7 @@ struct netdriverdata *uaenet_enumerate (const TCHAR *name)
                return NULL;
        }
 
-       if (!isdllversion (npcap ? _T("npcap\\wpcap.dll") : _T("wpcap.dll"), 4, 0, 0, 0)) {
+       if (!isdll) {
                write_log (_T("uaenet: too old npcap/winpcap, v4 or newer required\n"));
                return NULL;
        }