Jump to content

SHA1 dll call


Recommended Posts

Hi!

I just found this MD5/SHA1 dll and I can't figure out why it's not working calling it...

Here's my code:

Dim $file="test.jpg"
Dim $hash
$t=DllCall("hashLib.dll","int","FileSHA1","str",$file,"int*",$hash)
If @error Then MsgBox(16,"Error","Error calling dll")
MsgBox(0,$t,$hash)

I've also tried with str* and all kinds of types instead of int* but nothings works :)

Notice that I don't get a @error, it's just that $hash and $t is empty

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

I don't know what functions and what syntaxes they have that exists in that dll of yours, but I see one error in the MsgBox you have at the end:

If the function call fails then @error is set to 1. Otherwise an array is returned that contains the function return value and a copy of all the parameters (including parameters that the function may have modified when passed by reference).

$return[0] = function return value

$return[1] = param1

$return[2] = param2

that means, change:

MsgBox(0,$t,$hash)

To

MsgBox(0,$t[0],$hash)
Link to comment
Share on other sites

Fixed.

This is the textfile that was included in the download (The dll is made for some wacked out script language)

HashLib for Macro Scheduler.

Copyright MJT Net Ltd 2006

Provides following functions:

FileMD5 - Return MD5 hash of a file

FileSHA1 - Return SHA1 hash of a file

StringMD5 - Return MD5 hash of a string

StringSHA1 - Return SHA1 hash of a string

All functions take two parameters:

File/String,return_buffer

Functions return length of hash or zero if an error occurred.

Usage examples:

//Put Hashlib.dll in script directory

Let>HashLib=%SCRIPT_DIR%\HashLib.dll

//Get SHA1 hash of a file

LibFunc>Hashlib,FileSHA1,r,c:\somefile.exe,buf

Mid>r2,1,r,hash

MessageModal>Hash: %hash%

//Get MD5 hash of a file

LibFunc>Hashlib,FileMD5,r,c:\somefile.exe,buf

Mid>r2,1,r,hash

MessageModal>Hash: %hash%

//Get MD5 hash of a string

LibFunc>Hashlib,StringMD5,r,Hello World,buf

Mid>r2,1,r,hash

MessageModal>Hash: %hash%

//Get SHA1 hash of a file

LibFunc>Hashlib,StringSHA1,r,Hello World,buf

Mid>r2,1,r,hash

MessageModal>Hash: %hash%

Maybe the dll only works in this language, but I since it's an dll I kind of thought that it should work in autoit

Broken link? PM me and I'll send you the file!

Link to comment
Share on other sites

hash is returned in array from DllCall.

a good example of why its best to use ConsoleWrite to view array elements returned from DllCall

for some reason this works.

you would think $hash probably needs a struct.

perhaps just used as buffer then emptied?

need a 'Siao' calibre answer here.

Edit: replacing $hash with "" or 0 also works

$t = DllCall("hashLib.dll","int","FileSHA1","str",$file,"str",0)
$t = DllCall("hashLib.dll","int","FileSHA1","str",$file,"str","")oÝ÷ Ù«­¢+Ù¥´ÀÌØí¥±ôÅÕ½ÐíÑÍй©ÁÅÕ½Ðì)¥´ÀÌØí¡Í °ÀÌØíÐ(ÀÌØíÐô±±
±° ÅÕ½Ðí¡Í¡1¥¹±°ÅÕ½Ðì°ÅÕ½Ðí¥¹ÐÅÕ½Ðì°ÅÕ½Ðí¥±M!ÄÅÕ½Ðì°ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÀÌØí¥±°ÅÕ½ÐíÍÑÈÅÕ½Ðì°ÀÌØí¡Í ¤)
½¹Í½±]É¥Ñ Ìäì´ÐìÀÌØíÑlÁtôÌäìµÀìÀÌØíÑlÁtµÀìɱµÀìÌäìÐìÉɽȽèÌäìµÀìÉɽȵÀìɱ¤ìÉÑÕɸ½)
½¹Í½±]É¥Ñ Ìäì´ÐìÀÌØíÑlÅtôÌäìµÀìÀÌØíÑlÅtµÀìɱµÀìɱ¤ì¥±¹µ)
½¹Í½±]É¥Ñ Ìäì´ÐìÀÌØíÑlÉtôÌäìµÀìÀÌØíÑlÉtµÀìɱµÀìɱ¤ì¡Í )
½¹Í½±]É¥Ñ Ìäì´ÐìÀÌØí¡Í ôÌäìµÀìÀÌØí¡Í µÀìɱµÀìɱ¤((ìչѥ½¸ÉÑÕɸٱÕèÀÌØíÑlÁt(ìÌÈ´¥±5Ô(ìÐÀ´¥±M!Ä(ìÌÈ´MÑÉ¥¹5Ô(ìÐÀ´MÑÉ¥¹M!Ä
Edited by rover

I see fascists...

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...