Ask Your Question
0

Fix: Unable to access memory when renamed main function and call it in a loop in new main function.

asked 2023-11-26 08:54:52 +0000

omicron2023 gravatar image

updated 2023-11-26 11:37:48 +0000

Hi, I renamed the main function of tshark.c as Tb_Main() Like the code in this link: https://github.com/AkibHossainOmi/wir...

I am following this link to have a tshark shared library to get a json string of a pcap file, https://github.com/AkibHossainOmi/Tsh...

specific code section :

int
main(int argc, char* argv[])
{
    // For debug purpose
    // argc = 4;
    // argv[1] = "-Tjson";
    // argv[2] = "-r";
    // argv[3] = "/home/omi/packet.pcap";
    char* result = Tb_Main(argc, argv);
    free(result);
    return exit_status;
}

I change it to,

int
main(int argc, char* argv[])
{
    // For debug purpose
     argc = 4;
     argv[1] = "-Tjson";
     argv[2] = "-r";
     argv[3] = "D:\\Windows\\files\\packet.pcap";
    while (1)
    {
        char* result = Tb_Main(argc, argv);
        free(result);
        printf("Ok\n");
    }
    return exit_status;
}

Now It is giving the exception,

Exception thrown at 0x00007FF9792E6193 (libwsutil.dll) in tshark.exe: 0xC0000005: Access violation reading                             
location 0xFFFFFFFFFFFFFFFF.
Unhandled exception thrown: read access violation.
map->**table** was 0x111011101110111.

Having the exception in different line each time when I am running and debugging it.

Note: This is running in the first time successfully in most cases and getting exception. This tshark source is supposed to return a json string of a pcap file data by the function Tb_Main().

As long as I understood, the pointers are not initiated when I am calling the function more than once.

How can I fix it?

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2023-11-28 22:46:59 +0000

André gravatar image

I guess you have to ask Akib Hossain Omi for support on his project.

If you have problems compiling using the Wireshark repo https://gitlab.com/wireshark/wireshark and the instructions on Wireshark Developer’s Guide are not clear, you can ask them here or via Discord.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2023-11-26 08:54:52 +0000

Seen: 215 times

Last updated: Nov 28 '23