99999999
21st February 2008 23:43 UTC
Callback from a Plugin back into NSIS?
Is it possible with NSIS, to make callback which is callable from a plugin, while the plugin is doing a very long task.
So effectively the pseudo code would look something like:
Function ProgressCallback
Pop $0
${Log} "$0"
FunctionEnd
AddressOf $1 ProgressCallback
Plugin::DoLongTask $1
The intention here, is that there is a very long process taking place, and that I want to callback into the NSIS install script to have it send the progress reports to our install manager.
Obviously the DoLongTask of the plugin would then use address $1 to make the callback somehow. The "AddressOf" command above is just my own pseudo code, and obviously not real as well.
Anders
22nd February 2008 00:12 UTC
in the nsis code, you use GetFunctionAddress to get the address, in the plugin code, you call ExecuteCodeSegment (part of the extra parameter struct passed to plugin exports) (you also subtract 1 from the address you get from GetFunctionAddress IIRC)
99999999
22nd February 2008 00:20 UTC
Thanks very much!
99999999
4th March 2008 00:29 UTC
Hmm okay, this works fine when I pass data into the NSIS script. However it appears, that using popstack, and getuservariable, I am unable to get any data back from the NSIS script.
Is this correct? Or am I doing something wrong?
Anders
4th March 2008 00:46 UTC
no, could get data back, save "result" from the nsis function in a specific register or push it to the stack, then read it back in the plugin when the nsis function call returns
99999999
4th March 2008 01:01 UTC
Hmm that's what I am doing the callback does that exactly. Now I realize actually that in the callback functions, I am unable to get data off the stack either, or from the registers.
What appears to happen from my perspective, is that NSIS engine, and my plugin appear to have two seperate copies of the stack and registers set.
kichik
4th March 2008 17:14 UTC
You'll have to add some code examples to that statement to get a solution.