Skip to content
⌘ NSIS Forum Archive

Stuck at NSIS script

4 posts

FrioDcoier#

Stuck at NSIS script

I've problem understanding NSIS script which I got from extracting with 7zip from some installer. I've several questions:
  • Does .onInit function executes before anything?
  • What is meaning of System::Call "* (&t256) p .r5 " call? as I know from the documentation is creates new structure but what is &t256 ?
  • As I know r0-r10 are registers, can I get value of r0 if r0 is pointer to some string, I need string, not pointer itself. Messagebox MB_OK "$r0" prints pointers
  • There is calls like *$1(&t255 .r0) I want to get value of $1.


Thank you
JasonFriday13#
Originally Posted by FrioDcoier View Post
Does .onInit function executes before anything?
Apart from some required dll loading and setting runtime variables (like $PROGRAMFILES), .onInit is the first script function called when an installer runs.

Originally Posted by FrioDcoier
What is meaning of System::Call "* (&t256) p .r5 " call? as I know from the documentation is creates new structure but what is &t256 ?
Similar to C, & means the address of the memory, t means it's a tchar (one byte for ansi, two bytes for unicode), and 256 is the length. p is the return type (pointer sized) and the dot means it's the output of the call. r5 is the variable to put it in. You could use .s to put it on the stack, then pop it off using Pop $5, but the first way is better because you can use $5 directly.

Originally Posted by FrioDcoier
As I know r0-r10 are registers, can I get value of r0 if r0 is pointer to some string, I need string, not pointer itself. Messagebox MB_OK "$r0" prints pointers
In the system plugin, variables are named a bit differently. $0 to $9 are labelled r0 to r9, and $r0 to $r9 are labelled r10 to r19.

You need another call to get the string, I don't know the correct syntax but something like this ($0 is the address, the 255 is the length to get):
system::call "*$0(&t255 .r1)"
Messagebox MB_OK "$1"
Originally Posted by FrioDcoier
There is calls like *$1(&t255 .r0) I want to get value of $1.
In this case, $1 is just the pointer to the data, and it looks like it's retrieving the data from the pointer in $1, and putting it in $0 (.r0).
FrioDcoier#
Thank you, your answer is very helpful. just one more question. What is the meaning of following two calls?

System::Call "*(i) p .r2"
System::Call "*(i 458126, i 0) p .r1"

there is call System::Call "user32::wsprintf(p r1, t '%s\checkfile', t o)"
after this call r1 should point to some string, how can I print this string?
MessageBox MB_OK "$1" prints just address
Anders#
System::Call "*(i) p .r2"
System::Call "*(i 458126, i 0) p .r1"
Allocates a 4 byte struct and a initialized 8 byte struct.

I told you how to get the string from a pointer in my Stackoverflow answer and I don't feel like repeating myself here.