[Winpcap-users] Access violation when using pcap_findalldevs_ex

Gianluca Varenni gianluca.varenni at cacetech.com
Tue Aug 19 19:58:51 GMT 2008


Can you provide a small sample showing the problem?

Alternatively, can you tell me the address where it crashes within wpcap.dll 
or packet.dll? I can try to load the winpcap dlls with a debugger and the 
symbols, and check where it crashed.

Have a nice day
GV
----- Original Message ----- 
From: "Виталик Rasta " <johanga at sibmail.com>
To: <winpcap-users at winpcap.org>
Sent: Thursday, August 14, 2008 9:01 PM
Subject: [Winpcap-users] Access violation when using pcap_findalldevs_ex


> Hello, everyone!
>
> I have an access violation error when using pcap_findalldevs_ex. I use
> Microsoft
> Visual studio 2005 and winpcap 4.0.2 on WinXP Professional SP2.
>
> There are no errors when I use pcap_finalldevs_ex in other functions.
> Error occurs just in send_packet function.
>
> I don't understand where is the mistake. Please, help me!
>
> I know exactly that error is when pcap_findalldevs_ex runs (I  used
> F10, F11)
>
> here is the code:
> bool send_packet(u_char *data, int size)
> {
>        pcap_if_t *alldev=NULL;
>        pcap_if_t *dev;
>
>        pcap_t *handle;
>
>        char errbuf[PCAP_ERRBUF_SIZE];
>
>        if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL, &alldev, errbuf)
> == -1) {
>
>                std::cout << "Cannot get interface list : " << errbuf <<
> "\n";
>
>                return false;
>        }
>
>        dev = alldev->next;
>
>        if (dev == NULL) {
>
>                std::cout << "Cannot find an interface \n";
>                pcap_freealldevs(alldev);
>
>                return false;
>        }
>
>        handle = pcap_open(dev->name, PCAP_PACKET_PORTION,
> PCAP_OPENFLAG_PROMISCUOUS, PCAP_READ_TIMEOUT, NULL, errbuf);
>
>        if (handle == NULL) {
>
>                std::cout << "Cannot open an interface : " << errbuf << 
> "\n";
>                pcap_freealldevs(alldev);
>
>                return false;
>        }
>
>        if (pcap_datalink(handle) != DLT_EN10MB) {
>
>                std::cout << "This program works only on Ethernet
> networks\n";
>
>                pcap_freealldevs(alldev);
>
>                return false;
>        }
>
>        if (pcap_sendpacket(handle, data, size) != 0) {
>
>                std::cout << "Error sending packet : " <<
> pcap_geterr(handle) << "\n";
>                pcap_freealldevs(alldev);
>
>                return false;
>
>        }
>
>        pcap_freealldevs(alldev);
>
>        return true;
> }
>
>
> -- 
> Best wishes!
> Vitaly                       mailto:johanga at sibmail.com
>
>
>
> _______________________________________________
> Winpcap-users mailing list
> Winpcap-users at winpcap.org
> https://www.winpcap.org/mailman/listinfo/winpcap-users 



More information about the Winpcap-users mailing list