Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing wpcap.dll #380

Open
KainWhite opened this issue Dec 8, 2019 · 5 comments
Open

Missing wpcap.dll #380

KainWhite opened this issue Dec 8, 2019 · 5 comments

Comments

@KainWhite
Copy link

KainWhite commented Dec 8, 2019

Windows 10, MSVS 2019
I have started up with this code:

#ifndef TINS_STATIC
#define TINS_STATIC
#endif  // !TINS_STATIC

#include <tins/tins.h>

#include <iostream>

int main() {
  Tins::Sniffer sniffer("eth0");
  Tins::PDU *pdu = sniffer.next_packet();
  Tins::DNS dns = pdu->rfind_pdu<Tins::RawPDU>().to<Tins::DNS>();
  for (const auto &query : dns.queries()) {
    std::cout << query.dname() << std::endl;
  }
  delete pdu;
}

and tried to build it x86.
Result was a bunch of LNK2019 errors, at the end of which there was this:
"libtins-master\build\lib\Debug\tins.lib : warning LNK4272: library machine type 'x64' conflicts with target machine type 'x86'".
Ok, tried to build it x64, result:
"WpdPack\Include\pcap\pcap.h(47,12): fatal error C1083: Cannot open include file: 'sys/time.h': No such file or directory".
In this file:

#if defined(WIN32)
  #include <pcap-stdinc.h>
#elif defined(MSDOS)
  #include <sys/types.h>
  #include <sys/socket.h>  /* u_int, u_char etc. */
#else /* UN*X */
  #include <sys/types.h>
  #include <sys/time.h>
#endif /* WIN32/MSDOS/UN*X */

OOOOOK. (my code):

#ifndef WIN32
#define WIN32
#endif  // !WIN32

Builded again and finally successfully. But when I run it I got this:
image
I have tried installing Winpcap, that places needed dll in System32 folder, but then there are memory access violation in this code (sniffer.cpp):

if (pcap_activate(get_pcap_handle()) < 0) {
        throw pcap_error(pcap_geterr(get_pcap_handle()));
}

Well, am I doing anything wrong?

@KainWhite KainWhite reopened this Dec 8, 2019
@yeahitsjan
Copy link

Don't know if this is still relevant for you. But instead also define WIN32 in your file. pcap.h shows this:

#if defined(WIN32)
  #include <pcap-stdinc.h>
#elif defined(MSDOS)
  #include <sys/types.h>
  #include <sys/socket.h>  /* u_int, u_char etc. */
#else /* UN*X */
  #include <sys/types.h>
  #include <sys/time.h>
#endif /* WIN32/MSDOS/UN*X */

Should work. Got the same error and fixed it with that.

@rectified95
Copy link

@yeahitsjan Do you mean you were able to fix the missing DLL error by defining WIN32 in the source file?

@mfontanini
Copy link
Owner

I don't use Windows so it's hard for me to reproduce this. This was working fine last I tried it there, but I'm unsure of what version of Windows I used at the time.

@rectified95
Copy link

rectified95 commented Aug 30, 2022

@mfontanini Here are a few issues on Windows 11 I wanted to bring to your attention:

  • Libtins website lists WinPCAP as a dependency on Windows: that project hasn't worked on Windows for a while, and itself instructs users to use NPCAP instead, which has a compatible API - https://npcap.com/
  • The build artifacts expire after a month, so it was impossible to access them until yesterday when a new PR got merged. It'd be awesome if you could extend the retention time or host the binaries somewhere else.

I'm gonna try the pre-built version and update the comment, but letting you know that Libtins seems broken on Windows when building from source.

@rectified95
Copy link

rectified95 commented Aug 30, 2022

I was able to figure it out by reading the NPCAP docs - they do ship wpcap.dll.
I first only downloaded the NPCAP SDK - analogous to libtins saying to get the WinPCAP SDK - but didn't install NPCAP itself - doing that solved this issue: https://npcap.com/#download
I think it can be closed. FYI @mfontanini @KainWhite

It'd be great if the libtins website were updated to reflect needing to use NPCAP instead of WPCAP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants