flat assembler
Message board for the users of flat assembler.

Index > Windows > Creating a md5 Hash with FRESH IDE.

Author
Thread Post new topic Reply to topic
clamicun



Joined: 04 Dec 2013
Posts: 77
Location: Muenster NRW Germany
clamicun 09 Jul 2014, 03:26
"
"

; JohnFound... The proc 'DataMD5' computes a MD5 hash of the data block from [.pData] with length in [.pLen].
; Returns new string handle in eax containing the hash of the data.


stdcall DataMD5 ,the_string,[the_length]

"
"

works !!! (everything from JohnFound works)

eax gives me a 10 digit number.
Here I am with the result in eax.

But ...

What I do not understand is what to do with this number ...

;JohnFound ********************************************
; proc 'DataMD5' returns a new string handle in eax - containing the hash of the data.
;******************************************************

new string HANDLE to what ???

If this means that I have to convert 'eax' into a string ... second problem !!

;===============
To use 'itoa' with FASMW it would be more or less like this ...

library msvcrt,'MSVCRT.DLL'

import msvcrt,\
itoa,'_itoa'

;-----
cinvoke itoa,[...],.._Buffer,10d
;-----
;===============

In Fresh IDE there is no 'msvcrt,'MSVCRT.INC' ...
But there is CRTDLL.INC - containing - _itoa, <NONE>, '_itoa', \

I do not succeed to import this.
And there must be a reason, because 'crtdll.inc' is not included in 'allimports.asm'.


OK amigos ...

First (important) answer (if you please) ... What to do with the returned 'EAX' from proc DataMD5 ?

Second (less important) ... the itoa import thing.

I would be quite grateful
Post 09 Jul 2014, 03:26
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 09 Jul 2014, 06:03
In FreshLib/StrLib the strings are represented not by addresses, but by handles. That is because the actual address of the string can change when the string grows. These are dynamic strings.

So, DataMD5 and StrMD5 procedures returns a handle of a string, containing the string representation of the MD5 hash. How to handle it?

0. There is no need to call itoa. The returned string already contains the MD5 hash in string form.
1. The current string address can be retrieved by calling StrPtr and passing the handle to it.
2. To free the memory allocated for the string, call StrDel procedure, passing the handle of the string.
Post 09 Jul 2014, 06:03
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
clamicun



Joined: 04 Dec 2013
Posts: 77
Location: Muenster NRW Germany
clamicun 09 Jul 2014, 06:24
Jesus,
thank you JF. That was a very fast answer.
Ok. I got it.
Post 09 Jul 2014, 06:24
View user's profile Send private message Reply with quote
JohnFound



Joined: 16 Jun 2003
Posts: 3499
Location: Bulgaria
JohnFound 09 Jul 2014, 06:31
How to import functions from dynamic libraries in FreshLib.

1. Create a file with the description of the imported functions. The description uses the macro "import_proto":
Code:
macro import_proto library, [iname, arg, ename]    


Here:
- "library" is the name of the library. In Linux it is a string, in Windows, just the name of the DLL.
- iname - the name of the function, as imported - this is the label of the function for the program.
- arg - a list of the function arguments, closed in "<" and ">". All arguments must be local - i.e. starting with dot. Can be "<VOID>" if the function has no arguments. Can be "<NONE>" if the arguments are not known, or the user don't want to describe them right now. This list is needed only for the arguments hint feature in Fresh IDE, it is not mandatory, but highly useful.
- ename - string with the name of the function as exported in the DLL.

As an example for this kind of include files see "freshlib/imports/" directory - all files in the subdirectories are of this type (for Linux and for Windows). The user created files can be placed wherever the user wants.

2. In the program, use the macro uses in order to request the use of the dynamic library:
Code:
macro uses [library]    


Here is an example:

Code:
uses User32, kernel32, mylib:"path_to_the_import_file/mylib.inc"    


If the path is not specified (like kernel32 in the above example), the default path "%lib%/imports/%TargetOS%/library#.inc" is used.
Post 09 Jul 2014, 06:31
View user's profile Send private message Visit poster's website ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.