[Winpcap-users] Access Violation when using first pcap function
	(pcap_findalldevs_ex) in debug mode...
    Ravi Sankar 
    s_rsy at yahoo.com
       
    Thu Jul 14 11:20:59 GMT 2005
    
    
  
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 
 
    
    
More information about the Winpcap-users
mailing list