From 4ba0bf4f6f2f43107f62dd742b0d5e06422276a9 Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Sat, 6 Nov 2021 15:15:08 -0700 Subject: NPF: handle ERROR_INVALID_FUNCTION from PacketGetTimestampModes(). This is probably due to the driver that Packet.dll is using being a driver for an older version of Npcap, or for WinPcap, so that the BIOCGTIMESTAMPMODES DeviceIoControl is rejected as being unsupported. Tell the user to try unindtalling Npcap - and WinPcap if it's installed - and re-installing from npcap.org. --- pcap-npf.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'pcap-npf.c') diff --git a/pcap-npf.c b/pcap-npf.c index 8efebce5..6f419a47 100644 --- a/pcap-npf.c +++ b/pcap-npf.c @@ -1576,6 +1576,29 @@ pcap_create_interface(const char *device _U_, char *ebuf) */ error = GetLastError(); if (error != ERROR_MORE_DATA) { + /* + * No, did it fail with ERROR_INVALID_FUNCTION? + */ + if (error == ERROR_INVALID_FUNCTION) { + /* + * This is probably due to + * the driver with which Packet.dll + * communicates being older, or + * being a WinPcap driver, so + * that it doesn't support + * BIOCGTIMESTAMPMODES. + * + * Tell the user to try uninstalling + * Npcap - and WinPcap if installed - + * and re-installing it, to flush + * out all older drivers. + */ + snprintf(errbuf, PCAP_ERRBUF_SIZE, + "PacketGetTimestampModes() failed with ERROR_INVALID_FUNCTION; try uninstalling Npcap, and WinPcap if installed, and re-installing it from npcap.org"); + pcap_close(p); + return (NULL); + } + /* * No, some other error. Fail. */ -- cgit v1.2.1