Lua Proxy Dll Two |
|
The utility requires using of MinGW development system.
Prerequisites:
mkproxy.lua:
-- Goal: Create a proxy dll that redirects all calls to the "real" dll -- Written by: Shmuel Zeigerman -- CONFIGURATION local DEFFILE = "liblua5.1.def" -- name of definition file local REALPATH = "c:\\exe" -- path of forwarded DLL local REALNAME = "lua5.1" -- name of forwarded DLL (without extension) local PROXYNAME = "lua51" -- name of forwarder (proxy) DLL -- END OF CONFIGURATION local cfile = assert(io.open("temp.c", "w")) cfile:write[[ #include <windows.h> BOOL WINAPI DllMain (HINSTANCE hinstDLL, DWORD Reason, LPVOID Reserved) { return TRUE; } ]] cfile:close() local cmdline = table.concat ({ "gcc --add-stdcall-alias -shared -s -nostdlib temp.o", DEFFILE, "-L" .. REALPATH, "-l" .. REALNAME, "-o" .. PROXYNAME .. ".dll", }, " ") os.execute("gcc -c temp.c -o temp.o") os.execute(cmdline) ----------------------------------------------------------------------
The following build is for MSVC2005. It uses the "nodefaultlib" linker option. The final proxy DLL was about 9 KB.
local DEFFILE = "lua5.1.def" -- .def file for lua5.1.dll local LIBFILE = "lua5.1.lib" -- .lib file for lua5.1.dll local CFILE = "luaproxy.c"-- output file local MAKFILE = "luaproxy.mak" -- output file ---------------------------------------------------------------------- local cfile = assert(io.open(CFILE, "w")) cfile:write [=[ #include <windows.h> BOOL APIENTRY DllMain(HANDLE module, DWORD reason, LPVOID reserved) { return TRUE; } ]=] cfile:close() ---------------------------------------------------------------------- local makfile = assert(io.open(MAKFILE, "w")) makfile:write(string.format([=[ lua51.dll : luaproxy.c cl -I../lua/src /O2 /LD /GS- luaproxy.c /link /def:%s %s \ /out:lua51.dll /nodefaultlib /entry:DllMain ]=], DEFFILE, LIBFILE)) makfile:close() ----------------------------------------------------------------------
It seems that what you are doing is building an empty C file which links to the stubs in the import library, and reexposing those stubs as a dll interface. This would mean that the DLL you generate:
Tell me if I misunderstood your code.