Old 10th March 2010, 10:49   #1
nibble
Junior Member
 
Join Date: Mar 2010
Location: Zagreb
Posts: 5
Unhappy newbie

I did read the documentation as suggested etc.. But, I still don't understand some fundamentals

This a code snippet taken from
http://nsis.sourceforge.net/Docs/System/System.html#faq

# allocate
System::Alloc 32
Pop $1
# call
System::Call "Kernel32::GlobalMemoryStatus(p r1)"
# get
System::Call "*$1(i.r2, i.r3, p.r4, p.r5, p.r6, p.r7, p.r8, p.r9)"
# free
System::Free $1

If I'm correct, $1 holds the pointer to 32 bytes.
We want the GlobalMemoryStatus to fill that memory.
Now, GlobalMemoryStatus takes r1 as an argument. How is $1 related to r1? $1 == r1????

Thank you.
nibble is offline   Reply With Quote
Old 10th March 2010, 11:11   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
This is explained in the system plug-in readme.
MSG is offline   Reply With Quote
Old 10th March 2010, 12:30   #3
nibble
Junior Member
 
Join Date: Mar 2010
Location: Zagreb
Posts: 5
MSG, unfortunately I still don't get it...
nibble is offline   Reply With Quote
Old 10th March 2010, 13:35   #4
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
Quote:
How is $1 related to r1? $1 == r1????
From the NSIS System Plug-in documentation:
code:
Available Sources and Destinations

Type Meaning
r0 through r9 $0 through $9 respectively
r10 through r19 $R0 through $R9 respectively
R0 through R9 $R0 through $R9 respectively

The documentation includes sample code
code:
# assuming the struct's memory address is kept in $0
System::Call "*$0(i .r0, i .r1, i .r2, t .r3)"
DetailPrint "first int = $0"
DetailPrint "second int = $1"
DetailPrint "third int = $2"
DetailPrint "string = $3"

There is even a sample script in the Examples\System folder.
pengyou is offline   Reply With Quote
Old 10th March 2010, 14:04   #5
nibble
Junior Member
 
Join Date: Mar 2010
Location: Zagreb
Posts: 5
Call me dumb, but I still don't see a connection between $1 and r1. If the answer is very long and complex, say so.

What makes sense is:

System::Alloc 156 ; // sizeof(OSVERSIONINFOEX)
Pop $0
System::Call "*$0(&i4 156)"
System::Call "kernel32::GetVersionExA (p $0)"

but it doesn't work... So, I guess I'm missing something big here. Perhaps switching to Visual Studio is much better idea...
nibble is offline   Reply With Quote
Old 10th March 2010, 16:01   #6
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
Quote:
but I still don't see a connection between $1 and r1.
If you use .r1 in the system plugin call the plugin will use the NSIS variable called $1. If you use .r11 in the call then the plugin will use $R1. If you use .R1 then the plugin will use $R1.

Here is the sample code from my last reply:
code:
# assuming the struct's memory address is kept in $0
System::Call "*$0(i .r0, i .r1, i .r2, t .r3)"
DetailPrint "first int = $0"
DetailPrint "second int = $1"
DetailPrint "third int = $2"
DetailPrint "string = $3"

Notice that the system plugin call uses .r0 and .r1 and .r2 and .r3 and that the DetailPrint commands refer to $0, $1, $2 and $3
pengyou is offline   Reply With Quote
Old 10th March 2010, 16:15   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
If you specify $0 instead of .r0 then you're passing the string value of $0. Passing .r0 tells System to internally use the actual contents of $0.

Stu
Afrow UK is offline   Reply With Quote
Old 11th March 2010, 06:47   #8
nibble
Junior Member
 
Join Date: Mar 2010
Location: Zagreb
Posts: 5
pengyou and Afrow UK, thank you both very much!
I owe you a six pack :-)
nibble is offline   Reply With Quote
Old 11th March 2010, 09:21   #9
nibble
Junior Member
 
Join Date: Mar 2010
Location: Zagreb
Posts: 5
System::Alloc 284 ; // sizeof(OSVERSIONINFOEX)
Pop $0

${If} $0 <> 0
System::Call "*$0(&i4 284)"
System::Call "kernel32::GetVersionExW (p r0)"
${EndIf}

System::Alloc 36 ; // sizeof(SYSTEM_INFO)
Pop $1

${If} $1 <> 0
System::Call "kernel32::GetNativeSystemInfo (p r1)"
${EndIf}

System::Call "*$0(i, i.R2, i.R3)"
System::Call "*$1(&i2.R4)"

System::Free $1
System::Free $0

MessageBox MB_ICONINFORMATION|MB_OK "$R2,$R3,$R4" /SD IDOK

R2, R3 and R4 are zero. Any suggestions/comments?
nibble is offline   Reply With Quote
Old 11th March 2010, 10:51   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Get rid of the spaces after your function names. And there is no 'p'.

GetVersionExW (p r0)
->
GetVersionExW(ir0)

You can look at WinVer.nsh for usage of GetVersionEx.

Stu
Afrow UK 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