including a binary file to memory and testing the lenght of it

Started by hmi222, July 13, 2009, 07:33:49 PM

Previous topic - Next topic

hmi222

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

dedndave

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

hmi222

not reading an external file...
file should be integrated as a binary in the exe...



dedndave


Vortex

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.

hmi222

Moved along in masm folder...
bintodb is the right thing!!!
:U

BlackVortex

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)

hutch--

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.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Ficko

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


Vortex

Hi Ficko,

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

donkey

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.
"Ahhh, what an awful dream. Ones and zeroes everywhere...[shudder] and I thought I saw a two." -- Bender
"It was just a dream, Bender. There's no such thing as two". -- Fry
-- Futurama

Donkey's Stable

BlackVortex

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 !