[Winpcap-users] Access Violation when using first pcap
function(pcap_findalldevs_ex) in debug mode...
Ravi Sankar
s_rsy at yahoo.com
Fri Jul 15 05:17:52 GMT 2005
Hello All,
The Visual Studio Version 6.0 with Service Pack 6.
I have tried to run the sample programs it also has
same problem.
Project "Build Active configuration" is "Win32 -
Debug"
The code is properly compiled. Few times in Debug mode
(F5) with / without break point it executes fine. but
most of time it fails
When I run the program ( Ctrl + F5) it executes fine.
When I put break point in any place in the code and
Debug (F5), it gives "Access Violation" at
"pcap_findalldevs_ex".
If I put break point in "pcap_findalldevs_ex" and
debug (F5) it executes properly until that point and
if I "Step In (F11)" or "Step Over (F10)" it gives
access violation.
My guess where the problem may be
1. Any initilizing issues - After I see all the
replies and sample programs I feel
"pcap_findalldevs_ex" can be used directly with out
any initialising. So this may not be a problem.
2. If unloading of Packet.DLL properly or stop the
capturing properly or not closing the handle properly,
it may give "Access Violoation". I am using
"pcap_loop" function with a handler "packet_handler"
similar as in "netmeter" sample. When closing the
application i terminate thread and use "pcap_close" to
close the adaptor and Wait for the thread to stop. The
code written while closing the application
// Terminate the monitor thread
BOOL res=TerminateThread(m_hMonitorThread,0);
if(res==false){
AfxMessageBox("Fatal Error: cannot terminate the
capture thread");
exit(0);
}
pcap_close (m_pCaptureHandle);
//wait the end of the capture thread
WaitForSingleObject(m_hMonitorThread, INFINITE);
Please let me know if any more cleaning to be done.
One more clarification.
In the help it is mentioned that "pcap_loop" and
"pcap_dispatch" is discouraged function. When i
searched for any function with message handler
function i could not find any thing more. That means,
we have to use "pcap_open" for opening adaptor and
then capture using "pcap_next_ex" and close using
"pcap_close"?
Thanks for your time
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