[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Proxy DLL for Lua 5.1; can't get it to work with statically linked liblua
- From: Ulrich Schmidt <u.sch.zw@...>
- Date: Wed, 27 Nov 2013 12:35:47 +0100
Why not change the Value of local var reallib in mkforwardlib.lua?
Let it point to your exe, before you call the link command in
mkforwardlib.lua
This way the proxy-dll will point to your .exe.
I modified mkforwardlib.lua for my scenario. and attached it to this
mail. You need to call it inside a Widows SDK command window. It uses
dumpbin.exe to read the exports from <param1> and writes <param2>.dll
and <param2>.lib using lib.exe.
Ulrich.
Am 27.11.2013 06:03, schrieb Paul K:
Hi Jerome,
Did you try http://lua-users.org/wiki/LuaProxyDllThree ? The main
advantage is that it produces a DLL with no code, only metadata for
the Windows DLL loader, so there is less chance of a crash. Also it
produces a very tiny file, if size matters to you.
Yes, I'm familiar with ProxyDllThree as I'm using it to support LfW
modules that depend on Lua5.1.dll (which proxies requests to my
Lua51.dll). In this case I need to proxy the requests to a statically
compiled lua.exe and it seems like this method only proxies calls to a
dll.
Paul.
--
Ulrich Schmidt, 08060 Zwickau, Werdauer Str. 90
Tel.: +49 (172) 7928 968
local util = require "util"
local reallib
local fakelib
local machine
local errmsg
if arg[1] then reallib = arg[1] end
if arg[2] then fakelib = arg[2] end
if arg[3] then machine = arg[3] else machine = "X86" end
if #arg<2 then
errmsg = "not enough parameters"
elseif not ({X86=true, AMD64=true, IA64=true})[machine] then
errmsg = "'"..machine.."' is not a recognized machine architecture"
end
if errmsg then
if errmsg then io.stderr:write("Error: "..errmsg.."\n") end
io.stderr:write[[
Usage: mkproxy <reallib> <fakelib> [<machine>]
reallib The name of the existing dll that you want to use.
fakelib The name of the fake dll that you want to create and that
will call the reallib instead.
machine The hardware architecture of your windows version among:
X86, AMD64, IA64
default: X86
Example: mkforwardlib lua51.dll lua5.1.dll X86
]]
os.exit(0)
end
local function readsyms()
local syms = {}
local f = assert(io.popen('dumpbin /exports '..arg[1]))
local s
s = f:read()
while s do
if s:find(" ordinal hint RVA name") == 1 then
assert(f:read() == "")
for s in f:lines() do
if s == "" then
f:close(f)
return syms
end
local sym = s:match("%s+%d+%s+%x+%s+%x+%s+([^%s]+)")
if sym then
table.insert(syms, sym)
end
end
end
s = f:read()
end
close(f)
return nil
end
local command = {
"link.exe -dll -nologo -noentry -machine:" .. machine .. " -incremental:no -nodefaultlib \z
-out:"..fakelib..".dll -implib:"..fakelib..".lib",
}
local symbols = readsyms()
for _,symbol in ipairs(symbols) do
table.insert(command," /export:"..symbol.."="..reallib.."."..symbol)
end
print('"'..table.concat(command)..'"')
os.execute('"'..table.concat(command)..'"')