Page 1 of 1

passing a string array to an external function

Posted: Tue Sep 11, 2012 4:19 am
by ghosttie
I'm trying to create an external function for this method exported by a DLL:

Code: Select all

int gs_main_init_with_args(gs_main_instance * minst, int argc, char *argv[]);
The last parameter is a string array, but I'm not sure how to send that using a JADE external function.

Do I need to use globalAlloc/rtlMoveMemory to create a memory location containing each string and then another one for the array of pointers to those locations?

Re: passing a string array to an external function

Posted: Tue Sep 11, 2012 9:30 am
by allistar
That's a tricky one. You could try geting the memory address of each of the Strings and then create a Binary with the memory addresses padded together. You'll need to work out the size of a MemoryAddress to cater for 32 vs 64 bit.

If this does not work then the approach I would take is create a wrapper external function which takes the inputs in a form more friendly to JADE. Using an external method you could actually pass in a StringArray, though this would prevent you from running it from a thin client - it would have to run on a node. Another option is to pack the Strings together into a single String and then unpack them in the external function. Not nice, but doable.