Archive: MD5 plugin


MD5 plugin
I needed a MD5 plugin for an auto-updater (see it in action here) I've made with NSIS, and since I didn't find any, I made my own :). I haven't renamed a bunch of stuff from the original exdll, so just ignore that. I used MSVC++ .NET to make it, so if you have VC++ 6, you might have to convert it using the converter over at www.CodeProject.com, or start the project from scratch.

The final size of the dll is 40.5kb using VC++ .NET Standard, and 22.5kb after packing it with UPX. I've tried to make it smaller, with no avail. If anyone can cut in half (or more :)) its size, you have my undying gratitude :)

Enjoy!


I don't know how this is done with VC7, but you shouldn't link to the default libraries (libc). If you do this you won't be able to use any libc functions including memset (use mini_memset from NSIS sources), sprintf (use wsprintf), strncat (use lstrcat instead [no n, but this can be done manually]), strcpy (use lstrcpy), new and delete (you will have to define your own [IO does that]), strlen (use lstrlen instead), fopen and friends (use CreateFile, CloseFile, ReadFile and WriteFile instead), and memcpy (use mini_memcpy or my_memcpy from one of NSIS contribs). There are more functions you can't use, but those are the ones I have found in your source code. After you dump libc your DLL will be cut at least in half.

You should also rename DllMain back to _DllMainCRTStartup and set the entry point to _DllMainCRTStartup.

Nice idea BTW, submit it to Sunjammer's NSIS Archive when it's ready (and the new archive is ready too).


Thanks for the tips! I actually did specify no default, and then manually added in libc.lib. That brought it down from 50kb to 40kb. I'll try what you said, and see if I can get it to work :)

BTW, why did you suggest for me to rename the entry point? What does that do?


It makes it smaller too.


Goody :)


It won't let me use new or delete, either; I think I'll let someone else do the conversion. I'm not THAT desperate :)


new and delete (you will have to define your own [IO does that])
;)

Matthew "IGx89" Lieder
Author

KJD (archive)
-Modified to reduce size and use exdll.h
(reduced to about 6KB uncompressed, by removing CRTL dependency)

Davy Durham
-MD5.cpp fix (correct for loop used to replace memset, exceeded bounds)

Shengalts Aleksander aka Instructor
-New command: "GetMD5Random" for generate random MD5sum
-Changed names: "GetFileMD5" -> "GetMD5File", "GetMD5" -> "GetMD5String"
-Fixed: string lenght error


md5dll 0.3


Apologies for the huge bump, but I was wondering if it was possible to see some sort of progress while calculating a checksum?

On older machines, it could take quite some time to calculate a checksum for a file in the 10's of MB range, let alone larger files. So it would be nice if such progress display could be added.

I will probably use a Banner of some sort displaying "Verifying files, please wait..." or something in the meantime though, but it's not a solution I'm all that happy about : P

I feel like the user should know at all times that the installer is progressing.

Thank you very much for your time.


version 1.1 seems has a bug: the result can only be pop to $0. I tried the following code:


StrCpy $0 "D0"
StrCpy $1 "D1"
Crypto::HashFile "MD5" "$WINDIR\notepad.exe"
Pop $1
DetailPrint $0
DetailPrint $1

The output is:

DAF60E13E96ECB67F0EDAA89C6B01B8D
D1

you're referring to the Crypto plugin. This thread is for the MD5 plugin. For the Crypto thread, see:
http://forums.winamp.com/showthread.php?postid=1346355

Plugin URLs:
Crypto: http://nsis.sourceforge.net/Crypto_plug-in
MD5: http://nsis.sourceforge.net/MD5_plugin

For what it's worth - I did duplicate the behavior you saw - the Crypto thread seems to have other posts referring to the 'empty' result as well. I'd guess that nothing actually gets set on the stack (as the Pop results in the Errors flag being set) and instead the Crypto plugin dumps its result in $0 directly. Not a huge issue (although not encouraged), but something that should probably be noted in the docs.