cffi-lua icon indicating copy to clipboard operation
cffi-lua copied to clipboard

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

Open metaworm opened this issue 4 years ago • 3 comments

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

  • make ffi_dl_handle more large, such as static void *ffi_dl_handle[1000];, or use std::vector
  • store the handle returned by LoadLibraryExA in lib::load(...) into ffi_dl_handle

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

metaworm avatar Oct 26 '21 04:10 metaworm

luajit does not implement this behavior either, fwiw

q66 avatar Oct 26 '21 04:10 q66

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

q66 avatar Oct 26 '21 04:10 q66

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

There really isn't a way like dlopen on Windows

metaworm avatar Oct 26 '21 05:10 metaworm