Witajcie !
Szukam rozpaczliwie pomocy, gdyż przejrzałem dokumentacje na stronie: http://www.winpcap.org/docs/docs_412/html/main.html , dodatkowo skonfigurowałem VC++ według tego: http://www.codeproject.com/Articles/30234/Introduction-to-the-WinPcap-Networking-Libraries , a także ręczne używałem Debbugera w VC++ i nie potrafię dalej sobie poradzi z problemem.
Polega on na tym, że ten kod:
#include "stdafx.h"
#include <pcap.h>
int _tmain(int argc, _TCHAR* argv[])
{
pcap_if_t * allAdapters;
pcap_if_t * adapter;
char errorBuffer[ PCAP_ERRBUF_SIZE ];
// retrieve the adapters from the computer
if( pcap_findalldevs_ex( PCAP_SRC_IF_STRING, NULL,
&allAdapters, errorBuffer ) == -1 )
{
fprintf( stderr, "Error in pcap_findalldevs_ex function: %s\n",
errorBuffer );
return -1;
}
// if there are no adapters, print an error
if( allAdapters == NULL )
{
printf( "\nNo adapters found! Make sure WinPcap is installed.\n" );
return 0;
}
// print the list of adapters along with basic information about an adapter
int crtAdapter = 0;
for( adapter = allAdapters; adapter != NULL; adapter = adapter->next)
{
printf( "\n%d.%s ", ++crtAdapter, adapter->name );
printf( "-- %s\n", adapter->description );
}
printf( "\n" );
// free the adapter list
pcap_freealldevs( allAdapters );
system( "PAUSE" );
return 0;
}
powinien wyświetli mi listę urządzeń sieciowych. I tak rzeczywiście jest. Ale tylko w trybie Debug. Kiedy chcę wygenerowa sobie wersję Release pojawia się problem, a mianowicie wywala mi: "Unhandled exception at 0x76fb15de in sniffer.exe: 0xC0000005: Access violation."
Ręcznie debbugując linijka po linijce ustaliłem, że wykrzacza się na tej linijce:
if( pcap_findalldevs_ex( PCAP_SRC_IF_STRING, NULL, &allAdapters, errorBuffer ) == -1 )
A właściwie na przekazaniu przez referencję &allAdapters .
Nie mam już żadnego pomysłu czy i jak można rozwiązać. Czy ktoś spotkał się z czymś podobnym, bądź potrafi ten problem rozwiązać ?