well my function is in the dll that i export for my dissector to use. here's the code:
(_AppendMultiMsg)( target, bnpLength ); // adds current tvb to the buffer in my dll multiMsgSize = (_GetMultiMsgSize)(); // size of whole buffer as int next_tvb = tvb_new_real_data((const guint8 *)(_GetMultiMsg)(), multiMsgSize, multiMsgSize); //new tvb that holds the buffer from my dll tvb_set_free_cb(next_tvb, (_FreeMultiMemory)); // FreeMultiMemory is the function that will free the void* multiMsg object in my dll that is holding the buffer in the first place add_new_data_source(pinfo, next_tvb, "Multi-Part Message"); dissectPacket( next_tvb, bnp_tree, pinfo ); So i was wondering a way to put my buffer from dll into a new buffer, free the memory from my dll, but have it copied in wireshark memory to use. I had something like this before, would this work?: (_AppendMultiMsg)( target, bnpLength ); multiMsgSize = (_GetMultiMsgSize)(); free(target); target = ep_alloc(multiMsgSize); memcpy(target, (_GetMultiMsg)(), multiMsgSize); target = (_GetMultiMsg)(); next_tvb = tvb_new_real_data((const guint8 *)target, multiMsgSize, multiMsgSize);*/ (_FreeMultiMemory)(); add_new_data_source(pinfo, next_tvb, "Multi-Part Message"); dissectPacket( next_tvb, bnp_tree, pinfo ); Thanks for the help, Greg ---- didier <dgauthe...@magic.fr> wrote: ============= Hi, Le mercredi 22 avril 2009 à 18:34 +0000, gogr...@wi.rr.com a écrit : > Thank you both you and Jeff, this is exactly what i was looking for. However, > run into a bit of a problem. The buffer that i create, is returned from a dll > where i allocate and free the memory from. I put wrapper type of functions in > my wireshark dissector that frees the memory after each packet. I ended up > with fe ee fe ee fe ee (etc) as my buffer which means it is freed memory. I > was wondering if there is a place to put my free memory call, or if there is > a way to kind of copy data over to the dissector, free my dll memory, and > have wireshark then be incharge of freeing the memory it allocated. I hope > you understand what my situation is. > add a call to tvb_set_free_cb() after tvb_new_read_data() next_tvb = tvb_new_real_data(data, datalen, datalen); tvb_set_free_cb(new_tvb, my_free); my_free() is called when next_tvb is freed. for example if data is a g_malloc buffer, g_free will do it. Didier ___________________________________________________________________________ Sent via: Wireshark-dev mailing list <wireshark-dev@wireshark.org> Archives: http://www.wireshark.org/lists/wireshark-dev Unsubscribe: https://wireshark.org/mailman/options/wireshark-dev mailto:wireshark-dev-requ...@wireshark.org?subject=unsubscribe