Archive: Problem with a newly written plugin


Problem with a newly written plugin
Hi!

A friend of mine wrote a plugin to allow me to encode and encrypt passwords.

The idea is that I need to MD5 hash a password and then convert it to hexadecimal or Base64 for storage in an XML file.
This plugin works great when I execute the installer on my own computer. However, on other (newly installed) computers, it just doesn't and returns the un-encrypted password.

For the following code:


Encoder::ToBase64 "Hello, world!"
Pop $1
DetailPrint "Base64 encode: $\"$1$\""

Encoder::FromBase64 $1
Pop $2
DetailPrint "Base64 decode: $\"$2$\""

Encoder::ToHex "Hello, world!"
Pop $3
DetailPrint "Hex encode: $\"$3$\""

Encoder::FromHex $3
Pop $4
DetailPrint "Hex decode: $\"$4$\""

Encoder::MD5Hash "Hello, world!"
Pop $5
DetailPrint "MD5: $\"$5$\""


The expected output is:

Base64 encode: "SGVsbG8sIHdvcmxkIQ=="
Base64 decode: "Hello, world!"
Hex encode: "48656c6c6f2c20776f726c6421"
Hex decode: "Hello, world!"
MD5: "lÓUmë ¥KÊ L9G˜9"


but instead I get:

C:\DOCUME~1\TestUser\LOCALS~1\Temp\nsq2F.tmp\Encoder.dll
C:\DOCUME~1\TestUser\LOCALS~1\Temp\nsq2F.tmp\Encoder.dll
C:\DOCUME~1\TestUser\LOCALS~1\Temp\nsq2F.tmp\Encoder.dll
Base64 encode: "Hello, world!"
C:\DOCUME~1\TestUser\LOCALS~1\Temp\nsq2F.tmp\Encoder.dll
Base64 decode: "Hello, world!"
C:\DOCUME~1\TestUser\LOCALS~1\Temp\nsq2F.tmp\Encoder.dll
Hex encode: "Hello, world!"
C:\DOCUME~1\TestUser\LOCALS~1\Temp\nsq2F.tmp\Encoder.dll
Hex decode: "Hello, world!"
C:\DOCUME~1\TestUser\LOCALS~1\Temp\nsq2F.tmp\Encoder.dll
MD5: "Hello, world!"


So clearly something doesn't quite work. Already, I can't quite figure out why I get so many paths repeated over and over again
Unfortunately, my friend is not available anymore to help and I'm not versed into the dark arts of C++ and plugin writing.

I would be eternally grateful if someone could have a look at it and see what's going wrong.
As soon as something is stable and working, I'll add it to the Wiki.

I attach the sources and compiled plugin.
(BTW, my friend commented that "the included exdll.h is not the same on from the Nullsoft SDK, it has a couple of my own signatures in so make sure you reference the right
one if you do a build!")

From a quick look, this line in exdll:

#define NSISPlugin(name)        void __declspec(dllexport)
should be:
#define NSISPlugin(name)        extern "C" void __declspec(dllexport)
because the source is a .cpp file. It appears it dosen't make a difference to the plugin at the moment. I will spend the next hour or so looking though the code for you.

The base64 routines would not compile on my machine, so I commented out the references to it to compile it.

I have attached a test NSIS .exe showing the hex and MD5 conversion. The next step is to find a base 64 converter on the internet.


I though I might as well add the modified code that made the example above possible.

Note: make that change to exdll that I noted above.