Fix: Unable to access memory when renamed main function and call it in a loop in new main function.
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?