Old 5th November 2017, 06:18   #1
FrioDcoier
Junior Member
 
Join Date: Nov 2017
Posts: 2
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
FrioDcoier is offline   Reply With Quote
Old 5th November 2017, 07:59   #2
JasonFriday13
Major Dude
 
JasonFriday13's Avatar
 
Join Date: May 2005
Location: New Zealand
Posts: 866
Quote:
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.

Quote:
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.

Quote:
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):
Quote:
system::call "*$0(&t255 .r1)"
Messagebox MB_OK "$1"
Quote:
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).

"Only a MouseHelmet will save you from a MouseTrap" -Jason Ross (Me)
NSIS 3 POSIX Ninja
Wiki Profile
JasonFriday13 is offline   Reply With Quote
Old 5th November 2017, 19:25   #3
FrioDcoier
Junior Member
 
Join Date: Nov 2017
Posts: 2
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
FrioDcoier is offline   Reply With Quote
Old 6th November 2017, 01:39   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 4,891
Quote:
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.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
Reply
Go Back   Winamp & SHOUTcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump