The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: hmi222 on July 13, 2009, 07:33:49 PM

Title: including a binary file to memory and testing the lenght of it
Post by: hmi222 on July 13, 2009, 07:33:49 PM
Hello...
Does anybody know how to include a binary file to memory and testing its length.

for example in Purebasic:

datasection:
sound: includebinary "sound.xm"
sondend:
endatasection

lenght.l= ?soundend-?sound


How to do that with masm without using as Resource?

Thanx in advance
Title: Re: including a binary file to memory and testing the lenght of it
Post by: dedndave on July 13, 2009, 07:57:01 PM
you could simply open it as a file and read it into an allocated buffer
if you only want to verify the size, you could use FindFirstFile
Title: Re: including a binary file to memory and testing the lenght of it
Post by: hmi222 on July 13, 2009, 08:03:53 PM
not reading an external file...
file should be integrated as a binary in the exe...


Title: Re: including a binary file to memory and testing the lenght of it
Post by: dedndave on July 13, 2009, 08:06:22 PM
then it is a resource
or - it is hard-defined in data
Title: Re: including a binary file to memory and testing the lenght of it
Post by: Vortex on July 13, 2009, 08:06:42 PM
Hi hmi222,

Have a look at the fda.exe and fda2.exe utilities coming with the Masm32 installation. fda inserts binary files into the .data section.
Title: Re: including a binary file to memory and testing the lenght of it
Post by: hmi222 on July 13, 2009, 08:31:52 PM
Moved along in masm folder...
bintodb is the right thing!!!
:U
Title: Re: including a binary file to memory and testing the lenght of it
Post by: BlackVortex on July 14, 2009, 06:32:39 AM
Meeehhh, I hate converting to db and putting it in my source. I prefer to keep it as a resource file, so I can easily comment it out, or change its name to point to another file, or change the file itself. (well, no need for extra tools also)
Title: Re: including a binary file to memory and testing the lenght of it
Post by: hutch-- on July 14, 2009, 09:43:26 AM
Have a look at eiother FDA utilities, they create an object module that you link into the finished binary and it creates an include file for both the data label and the data length. I literally wrote them to embed any length file into an EXE/DLL file without the limitations of the DB format or the nuisance value of putting the file into resources.
Title: Re: including a binary file to memory and testing the lenght of it
Post by: Ficko on July 14, 2009, 09:56:07 AM
Maybe there is a simple solution in JWASM -never tryed muss say-

In "Hystory.txt" it says:

"- INCBIN directive added."

May that's something borrowed from NASM. :bg

Title: Re: including a binary file to memory and testing the lenght of it
Post by: Vortex on July 14, 2009, 04:58:19 PM
Hi Ficko,

Jwasm's INCBIN directive works fine. Pelle's Macro Assembler supports the INCBIN statement too.
Title: Re: including a binary file to memory and testing the lenght of it
Post by: donkey on July 14, 2009, 05:59:05 PM
Quote from: Vortex on July 14, 2009, 04:58:19 PM
Hi Ficko,

Jwasm's INCBIN directive works fine. Pelle's Macro Assembler supports the INCBIN statement too.

GoAsm supports INCBIN as well, the SIZEOF directive will give the size of the file.
Title: Re: including a binary file to memory and testing the lenght of it
Post by: BlackVortex on July 15, 2009, 09:07:38 AM
Quote from: donkey on July 14, 2009, 05:59:05 PM
Quote from: Vortex on July 14, 2009, 04:58:19 PM
Hi Ficko,

Jwasm's INCBIN directive works fine. Pelle's Macro Assembler supports the INCBIN statement too.

GoAsm supports INCBIN as well, the SIZEOF directive will give the size of the file.
Wow !   :U

Made a mental note to use this !