Archive: newbie


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.


This is explained in the system plug-in readme.


MSG, unfortunately I still don't get it...


How is $1 related to r1? $1 == r1????
From the NSIS System Plug-in documentation:
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
# 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.

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


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:
# 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

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


pengyou and Afrow UK, thank you both very much!
I owe you a six pack :-)


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?


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