[Winpcap-users] Code for unhandled exceptation error

Gianluca Varenni gianluca.varenni at cacetech.com
Tue Apr 22 00:20:56 GMT 2008


did you find the source of the problem?

Have a nice day

  ----- Original Message ----- 
  From: Golnaz Honarpisheh 
  To: winpcap-users at winpcap.org 
  Sent: Friday, April 18, 2008 12:37 PM
  Subject: [Winpcap-users] Code for unhandled exceptation error

  Here is my code,However i think problem is not from code because even when i make it short to open only the file i will get same error.Another thing is that evrytime i open my file in a project i have to go to project menu and settings to set manually the wincap.lib ,in this way there is no error in buil process but in run time i will get myfilename.exe error and in reports shows that message;unhandled exceptation

  #include "pcap.h"
  #include <stdio.h>
  #include <stdlib.h>
  #include <iostream>
  using namespace std;
  #define LINE_LEN 16
  void find_device(pcap_if_t **all_devices);
   main(int argc, char **argv) {
          int res,i=0;
    struct pcap{};
          char errbuf[PCAP_ERRBUF_SIZE];    /* Error string */
    struct pcap_pkthdr *header; /* The header that pcap gives us */
    struct pcap_pkthdr *pcap_header;
    const u_char *packet;  /* The actual packet */
    pcap_t *handle;   /* Session handle */
          char error[PCAP_ERRBUF_SIZE];
          FILE *capfile;
          char *capture_file;
    char *pkt_data;
          int caplen;
           pcap_t *pcap_open_offline(char *scapturefile,char *errbuf);
      /* Grab a packet
          int code  = pcap_next_ex(handle,&header,&packet);
          if (code < 0)
                  cout << "Error in pcap_next_ex\n";
          /* Print its length
          cout << "length of packet is" << header->len << " bytes\n"; 
          printf("%ld: \n", header->len);

          /* And close the session 
          return(0); */
    /* Retrieve the packets from the file */
      while((res = pcap_next_ex( handle, &header, &packet)) >= 0){
          /* print pkt timestamp and pkt len */
          printf("%ld:%ld (%ld)\n", header->ts.tv_sec, header->ts.tv_usec, header->len);          
          /* Print the packet */
          for (i=1; (i < header->caplen + 1 ) ; i++)
              printf("%.2x ", pkt_data[i-1]);
              if ( (i % LINE_LEN) == 0) printf("\n");
      if(res == -1){
          printf("Error reading the packets: %s\n", pcap_geterr(handle));
      return 0;

  Be a better friend, newshound, and know-it-all with Yahoo! Mobile. Try it now.


  Winpcap-users mailing list
  Winpcap-users at winpcap.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winpcap.org/pipermail/winpcap-users/attachments/20080422/b079a481/attachment.htm

More information about the Winpcap-users mailing list