Old 18th September 2020, 15:23   #1
Junior Member
Join Date: Jun 2019
Posts: 8
System::Call, correct syntax for e option parameter.

Hello all,

today we had a user experiencing an uncommon problem, this call

System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2"


I copied the call from the usage examples and this it the first time we see it failing.

I am trying to add ?e to get the result of getLastError on top of the stack, but all I get is the argument to System::Call.

;; this should allocate the buffer
System::Alloc ${NSIS_MAX_STRLEN}
Pop $0
;; We assing here the appropriate message if the call fails
StrCpy $ERRORMESSAGE $(errmsg_get_username)

System::Call "advapi32::GetUserName(t .r0, *i ${NSIS_MAX_STRLEN} r1) i.r2 ? e"

;; this should recover the getLastError output, but gets the above argument to Call

;; The call above returns 0 when fails - we don't care freeing the variable in this case, we are going to die.
IntCmp $2 0 bail_out_errcode 0 0
;; this frees the buffer allocated before.
System::Free $0

And here another doubt. If I am not wrong, I should allocate a buffer to receive the name. But in the example I see no statement for this allocation.

What's wrong in my code?
g.u.l. is offline   Reply With Quote
Old 18th September 2020, 16:04   #2
Anders's Avatar
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,356
You should not allocate, t type uses the registers buffer directly.

What is the contents of $LAST_ERR_CODE?

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote
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