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.
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.;; 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
What's wrong in my code?