Skip to content
⌘ NSIS Forum Archive

System::Call, correct syntax for e option parameter.

2 posts

g.u.l.#

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"

fails.

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
pop $LAST_ERR_CODE

;; 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
StrCpy $USERNAME $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?
Anders#
You should not allocate, t type uses the registers buffer directly.

What is the contents of $LAST_ERR_CODE?