nmap / npcap

Nmap Project's Windows packet capture and transmission library
https://npcap.com
Other
2.99k stars 516 forks source link

Can't use the Npcap SDK with the Visual Studio 2008 compiler #421

Closed nuald closed 3 years ago

nuald commented 7 years ago

Python 2.7 C extensions use Visual Studio 2008 compiler (https://www.microsoft.com/en-us/download/details.aspx?id=44266) that is not compatible with the SDK, giving the error:

error C3163: '_vsnprintf': attributes inconsistent with previous declaration

The problem is within the pcap-stdinc.h header file - it has #if _MSC_VER < 1900 check that redefines vsnprintf for CL < 19 (VS2008 uses CL 15). Please note that the original WinPcap SDK has a different condition.

Steps To Reproduce

  1. Download and extract the SDK (tried with both referenced on https://nmap.org/npcap/ and https://github.com/nmap/npcap/releases/tag/v0.07-r9).
  2. Install the compiler by the link above.
  3. Use "Visual C++ 2008 64-bit Command Prompt"
  4. cd npcap-sdk\Examples-pcap\basic_dump
  5. cl basic_dump.c /I ..\..\Include\ /DWIN32 ..\..\Lib\x64\wpcap.lib

Please note that if you install and use Visual Studion 2017 (CL 19), no errors are produced and it compiles the correct exe file.

Proposed Solution

Please note that current libpcap doesn't contain the aforementioned check and it's possible that just rebuilding SDK would be enough to eliminate the problem.

sgeto commented 7 years ago

the SDK could really use an update. The batch file currently throws a few errors during packaging as some header files aren't there or where they used to be.

dmiller-nmap commented 7 years ago

Thanks for the detailed report. I've regenerated the SDK, which hadn't been done since before we updated libpcap to 1.8.1. We may need to regenerate again soon after doing some cleanup, but could you check whether Npcap SDK 0.1 fixes your specific problem?

sgeto commented 7 years ago

Thanks @dmiller-nmap Could you then please also look into updating the examples? They currently only work if npcap is install in "wpcap compatibility mode".

hsluoyz commented 7 years ago

Hi @sgeto,

Those examples are still for WinPcap. For how to support Npcap native mode, you can see our docs here: https://rawgit.com/nmap/npcap/master/docs/npcap-guide-wrapper.html#npcap-feature-native

There is also a WinDump example for Npcap here: https://github.com/hsluoyz/windump

sgeto commented 7 years ago

A delay-loaded DLL! I see. Thanks a lot