q66 / cffi-lua

A portable C FFI for Lua 5.1+
MIT License
181 stars 24 forks source link

global load `ffi.load(..., true)` not work on Windows #29

Closed metaworm closed 1 year ago

metaworm commented 3 years ago

It seems that it hasn't been implement yet. https://github.com/q66/cffi-lua/blob/master/src/lib.cc#L258

Maybe it can be implemented in the following ways

If there's no problem, i will try do it

q66 commented 3 years ago

luajit does not implement this behavior either, fwiw

q66 commented 3 years ago

I don't really like the idea of having a large static table, and allocating it dynamically does not really cut it either, IMO relying on this on windows with the way dll's work sounds wrong

the ffi is a relatively thin layer on top of the native API for this; if windows does not offer a native way to export symbols into global namespace then it should remain a no-op - POSIX dlopen does support this, so it's there

metaworm commented 3 years ago

All right. Another way is SymFromName, but rely on the dbghelp.dll.

There really isn't a way like dlopen on Windows