This is our old Q&A Site. Please post any new questions and answers at

I was wondering if it would be possible to run a C dll from LUA in wireshark. Let me explain.

I already have the code in C that can take a string of the data that comes over the network and returns a string in XML.

I would like to write a LUA script that takes that XML string returned by the C DLL and translate it directly to the tree structure in Wireshark.

I know it is possible to run C DLLs in LUA, but is it possible to do that using LUA in Wireshark?

Are there any premade LUA scripts out there that will take an XML string and convert it directly to the Tree View in wireshark?

Are there any resources you can point me to that do just this?

I realize this is probably not the prefered way to acomplish my task, but it seems like it is probably the easiest solution since I know nothing about LUA or Wireshark. This task is for work, and due to the nature of the client I cannot reveal any specifics or source code.

Thank you for your time, Brandon

asked 05 Jul '11, 09:58

officialhopsof's gravatar image

accept rate: 100%

@officialhopsof - Can you post the code you use to run the C DLL in Lua?

(07 Sep '11, 07:18) SwDevMan81

One way will be to create a wrapper for your dll --either by making a separate dll which makes calls into your current one, or by adding a Lua interface to your current library. I have successfully created a Lua-based dissector using this method, so the idea is sound. You will need the following --at a minimum --in your dll to expose functionality to Lua:

#define LUA_LIB /* Do this early. Preferably first */
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h> /* You may be able to get away without this one */
/* Forward declare your Lua-exposed functions as so*/
static int your_function(lua_State *L);

static const luaL_reg your_libnamelib[] = /* You could call this anything you want */
    {"your_functions_lua_name", your_function},
    {NULL, NULL}

LUALIB_API int luaopen_your_libname(lua_State *L)
    luaL_register(L, "your_libname", your_libnamelib);
    return 1;

static int your_function(lua_State *L)
    /* Do your work/call other C functions, etc. */
    return 0; /* return the number of items returned to Lua */

You can find more information in Programming in Lua.

permanent link

answered 07 Sep '11, 07:43

multipleinterfaces's gravatar image

accept rate: 12%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 05 Jul '11, 09:58

question was seen: 5,897 times

last updated: 07 Sep '11, 07:43

p​o​w​e​r​e​d by O​S​Q​A