[Winpcap-users] Access Violation when using first pcap function(pcap_findalldevs_ex) in debug mode...

Gianluca Varenni gianluca.varenni at gmail.com
Thu Jul 14 15:52:34 GMT 2005


Hi Ravi.

Have you tried using one of the sample programs in the developer's pack and 
see it works or fails?
For example, you can try pktdump_ex.

Moreover, have you installed Service Pack 5 (or 6) for Visual Studio 6? It 
corrects some bugs that caused weird accesss violations errors. You can find 
it on the microsoft web site.

Have a nice day
GV



----- Original Message ----- 
From: "Ravi Sankar" <s_rsy at yahoo.com>
To: <winpcap-users at winpcap.org>
Sent: Thursday, July 14, 2005 4:20 AM
Subject: [Winpcap-users] Access Violation when using first pcap 
function(pcap_findalldevs_ex) in debug mode...


> Hello All,
>
> I am developing an recording application in Windows
> 2000 using VC++ Ver 6.
>
> When I try to use "pcap_findalldevs_ex" it gives
> access violation. Error message "Unhandled Expression
> in test.exe": 0x00000005:Access Violation". The code
> what i have written
>
> pcap_if_t *alldevs = NULL;
> char errbuf[PCAP_ERRBUF_SIZE];
>
> ZeroMemory (errbuf, PCAP_ERRBUF_SIZE);
>
> /* Retrieve the device list */
> if (pcap_findalldevs_ex(PCAP_SRC_IF_STRING, NULL,
> &alldevs, errbuf) == -1)
> {
> AfxMessageBox ("Error in finding devices");
> return FALSE;
> }
>
> /* Jump to the selected adapter */
> for(d=alldevs, i=0; i< 1;d=d->next, i++); //to be
> modified
>
> /* Open the adapter */
> if ( (m_pCaptureHandle= pcap_open(d->name, // name of
> the device
> 65536, // portion of the packet to capture.
> // 65536 grants that the whole packet will
> be captured on all the MACs.
> PCAP_OPENFLAG_PROMISCUOUS, // promiscuous
> mode
> 1000, // read timeout
> NULL, // remote authentication
> errbuf // error buffer
> ) ) == NULL)
> {
> l_strTemp.Format ("Unable to open the adapter : %s",
> d->name);
> AfxMessageBox (l_strTemp);
> /* Free the device list */
> pcap_freealldevs(alldevs);
> return FALSE;
> }
>
> While debugging it executes safely until ZeroMemory
> but when executing pcap_findalldevs_ex it fails.
>
> I tried to comment pcap_findalldevs_ex function and
> run the next command "pcap_open" command then also it
> fails at that function.
>
> When running the program directly with out debugging
> it is working fine. Only during debugging i face this
> problem.
>
> Is there any function to be called to initialize the
> pcap library? If not can any one suggest what may be
> problem?
>
> Version of WinPCap: 3.1beta4
>
> Thanks in advance
> Ravi
>
>
>
> ____________________________________________________
> Start your day with Yahoo! - make it your home page
> http://www.yahoo.com/r/hs
>
> _______________________________________________
> 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