SDStudio is designed to fast and CPU/Memory efficient applications.
Therefore, things working different in this environment.
When you use that function, it makes everything in background, maybe it might be looking simply to use,
but you have no control over the process.
So, SDStudio allows developer to create these steps their selves. as they wish
In short you need to create a memory entry for every argument and return value, regardless of if an argument is not a pointer,
FFI lib automatically handles these,
It also allows you to load a library only once, instead of a load call on every function call.
In addition to this getting function pointer and defining args on every function call,
So, in SDStudio you do these only once and call function as much as you want.
Based on your question, it is unclear if your DLL is a UNICODE or ANSI dll , and what is pushed as the arguments if it is a number or string
My reply is as a general reply, and might not fit your exact requirement but, you can easily adjust based on your needs.
For every argument you need to create a memory pointer using FFI:MemoryNew and provide its return value as real argument.
You need to do this for return value as well, and after function call succeeded you can get these values using FFI:MemoryGet function.
In short you will use memory addresses as the arguments and return values
Here is a simple code to get you started, on my tests it returns some characters, but like i said it is unclear if your DLL is Unicode or Ansi or exact arg types etc..
Code: Select all
local hLibrary = FFI:LoadLibrary("L2N.dll");
local hFunction = FFI:GetFunction(hLibrary,ABI_STDCALL,"Number2Letter",WCHAR_PTR,{WCHAR_PTR});
local hArg1 = FFI:MemoryNew(WCHAR_PTR,3,-1,"hello");
local hReturn = FFI:MemoryNew(WCHAR_PTR,100,100,"");
local hResult = FFI:CallFunction(hFunction,hReturn,hArg1);
local nResult = Dialog:MessageBox("Info",FFI:MemoryGet(hReturn),MB_OK,MB_ICONINFORMATION,MB_DEFOPTION1);