Archive: system.dll pointer usage problem


system.dll pointer usage problem
Hello everyone,

I'm trying to use a dll, I've written for an installer created with NSIS, but I'm stuck.

This is my code:

system::call "my.dll::my_func(*l .r0) i .r1"

The signature of the function written in C is this:
int my_func(long *number);

The function was supposed to write a value to the place pointed by number (eg. *number = 42), which actually works (debugged in the dll source), but it doesn't get into $0, which would be desirable.

This is where I get confused. Am I supposed to allocate memory (create buffer with system::alloc) for $0? Because I'm not allocating any memory in the dll source. Why doesn't the value get back into $0?

Thanks for any help in advance,
Kolos


You're not supposed to allocate memory, System.dll takes care of that. However, System.dll is meant for calling DLLs which are not NSIS plug-in. If the only purpose of this DLL is to pass a value to the installer, you should write a plug-in for NSIS using the skeleton in Contrib\ExDLL.

As for the problem with your current DLL, I suggest you first make sure the DLL is really called. If it's not called, make sure it's somewhere System.dll can find it. The current working directory is a good place (set it using SetOutPath). If the functions is called, attach your script. That specific line seems OK, but the problem might lay in other parts of the script


Change *l to *i. Both long and int are 32 bits, but the System.dll "l" type is 64 bits.