luagcrypt icon indicating copy to clipboard operation
luagcrypt copied to clipboard

Deploy luagcrypt.dll via Github or others

Open MeFisto94 opened this issue 5 years ago • 1 comments

So I try to use luagcrypt for a wireshark dissector and do not have any Lua/Build environment running and thus it would be much more convenient to just drop in luagcrypt.dll together with some dissectors, without having to build them manually.

MeFisto94 avatar Nov 06 '20 00:11 MeFisto94

Indeed. I tried to install luarocks for half an hour and failed everywhere. I decided to give up, make myself a MSVC project manually and build it that way.

Targeting Wireshark 4.4.0

Lua https://sourceforge.net/projects/luabinaries/files/5.4.2/Windows%20Libraries/Dynamic/ lua-5.4.2_Win64_dll17_lib.zip Wireshark should be lua 5.4.6, but the lua website doesn't have any downloads for it?? Libgcrypt 1.8.3 64bit (Link in this projects readme)

Make a MSVC dll project.

Add include paths for the downloaded lua and libgcrypt D:\temp\libgcrypt-1.8.3-win64ws\include;D:\temp\lua\include Add additional library directories D:\temp\lua;D:\temp\libgcrypt-1.8.3-win64ws\bin Add Additional Dependencies lua54.lib;libgcrypt-20.lib

Add https://github.com/Lekensteyn/luagcrypt/blob/master/luagcrypt.c to the project (and remove dllamin.cpp) turn precompiled headers off on the imported file

edit luagcrypt.c Add __declspec(dllexport) before BOTH int luaopen_luagcrypt(

Set C++ code generation runtime library to /MT

Build. Tadaa. You don't need the pdb file, I just included it to show I haven't tampered with it. luagcrypt_wireshark440.zip

Side note. You have to call .init() before using it or it will error. If you call .init() twice, if the current application already initialized, it throws an error and your script gets killed because of it. And there is no way to check if anyone else already called init.. What a great idea is that?

So to fix that. Edit lgcrypt_init function into this

static int
lgcrypt_init(lua_State *L)
{
    if (gcry_control(GCRYCTL_INITIALIZATION_FINISHED_P)) {
        //luaL_error(L, "Libgcrypt was already initialized");
        return 0;
    }
    gcry_check_version(NULL);
    gcry_control(GCRYCTL_DISABLE_SECMEM, 0);
    gcry_control(GCRYCTL_INITIALIZATION_FINISHED, 0);
    return 0;
}

I've included that in my build above.

dedmen avatar Oct 09 '24 14:10 dedmen

Yes. If anyone is interested in older versions, here's the luagcrypt.dll for Lua 5.2 that I was able to build with Luarocks. I tested it with my Wireshark version which is older than 4.2.

luagcrypt.zip

tomer8007 avatar Oct 26 '25 20:10 tomer8007