Archive: Calling a dll to encrypt a password


Calling a dll to encrypt a password
I'm trying to get my script to take input from a password box and then pass it to a dll which contains a function that encrypts it. The prototype for the (Delphi) function is this: function IDPEncryptPassword(P: PChar; var MaxLen: integer): LongBool;

However, when the function returns it has not changed the original string, and the debug info prints this. The int I pass into the function has also not changed size (stays 1024). Could anyone please help me out with what I'm doing wrong? I'm an NSIS newbie and don't really have the skills to spot what I'm doing wrong (yet :). The relevant section is this:
;the relevant dll's have been loaded just before this
; read the entered value
ReadIniStr $4 "$PLUGINSDIR\userpass.ini" "Field 3" "State"
WriteINIStr "C:\Infront\IDP\IDP.ini" "Funccall" "Password before" $4
SetPluginUnload alwaysoff
StrCpy $5 ${NSIS_MAX_STRLEN}
; just print out debug info
WriteINIStr "C:\Infront\IDP\IDP.ini" "Funccall" "intsize before" $5

/* This is the problem area!!! */
System::Call 'IDPGenPwd::IDPEncryptPassword(t .r4, *i r5r5)i .r6'
; This is where it's supposed to write the encrypted password
WriteINIStr "C:\Infront\IDP\IDP.ini" "IAS" "Password" $4
; Debug info
WriteINIStr "C:\Infront\IDP\IDP.ini" "Funccall" "Error code" $6
WriteINIStr "C:\Infront\IDP\IDP.ini" "Funccall" "intsize" $5
SetPluginUnload manual
System::Free 0

Attached is the complete script.
Any help is highly appreciated!!


The input will always be returned if an output part doesn't return or if you don't specify to output a value. In this case, you used $5 as input.

If you're expecting an output, you should put a "." before the variable r5 (on System plugin call).

Or if you're expecting an input and an output, you should put two variables (on System plugin call) with a "." before the second one. I'll show what is my point with the correct code (I think, as you explained):

System::Call 'IDPGenPwd::IDPEncryptPassword(t .r4, *i r5 .r5)i .r6'

Originally posted by deguix
The input will always be returned if an output part doesn't return or if you don't specify to output a value. In this case, you used $5 as input.

If you're expecting an output, you should put a "." before the variable r5 (on System plugin call).

Or if you're expecting an input and an output, you should put two variables (on System plugin call) with a "." before the second one. I'll show what is my point with the correct code (I think, as you explained):

System::Call 'IDPGenPwd::IDPEncryptPassword(t .r4, *i r5 .r5)i .r6'
No, it's still not working. When the function now returns the variable r4 which is supposed to contain the encrypted password is blank. What I'm trying to do (in case it was a bit confusing) is to pass in r4 (the string to be converted), and a buffer, r5. When the function returns r4 has been encrypted by the function and r5 contains the length of the new [encrypted] string. What r5 does or doesn't contain isn't really important, just that r4 is converted properly.

That's not exact deguix. Please refer to the new System documentation:

http://nsis.sf.net/System.html