[Winpcap-users] Access Violation when using first pcap
function(pcap_findalldevs_ex) in debug mode...
Hadriel Kaplan
HKaplan at acmepacket.com
Thu Jul 14 14:44:52 GMT 2005
Assuming it's not the memory leak (since you only call it once and the error
code is different), are you absolutely sure it's failing in
pcap_findalldevs_ex? I use it all the time in VC++ 6.0 with 3.1beta4. Have
you tried setting a break point at that function and stepping through it in
debug mode (F5, F11, etc.)?
Also, I don't see "pcap_if_t *d;" and "CString l_strTemp;" in your
declarations (although VC++ would have failed to compile without it, so you
must have them somewhere).
When you say it works fine when not debugging, I assume you mean when you
compile it in Release mode, vs. running the version compiled in debug mode?
If so, what are your project settings for debug mode? (and more importantly
how are they different from Release mode - specifically the preprocessor and
link settings)
You should also try compiling and running some of the example app code that
comes with the developer pack and make sure they work for you in debug mode.
Most (if not all) of them use pcap_findalldevs_ex.
-hadriel
-----Original Message-----
From: winpcap-users-bounces at winpcap.org
[mailto:winpcap-users-bounces at winpcap.org] On Behalf Of Ravi Sankar
Sent: Thursday, July 14, 2005 7:21 AM
To: winpcap-users at winpcap.org
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