Old 27th May 2004, 11:25   #1
rincewind
Junior Member
 
Join Date: May 2004
Location: Norway
Posts: 2
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!!
rincewind is offline   Reply With Quote
Old 28th May 2004, 00:19   #2
deguix
Major Dude
 
deguix's Avatar
 
Join Date: Dec 2002
Location: Everett - MA, USA
Posts: 1,354
Send a message via ICQ to 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):

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

My Wiki Pages

Working now on:
New projects. (language: any)
deguix is offline   Reply With Quote
Old 28th May 2004, 07:17   #3
rincewind
Junior Member
 
Join Date: May 2004
Location: Norway
Posts: 2
Quote:
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):

code:
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.
rincewind is offline   Reply With Quote
Old 28th May 2004, 08:48   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
That's not exact deguix. Please refer to the new System documentation:

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

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Reply
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