I, in MASM32 there is a tool, wich can convert exe files(for example) to a DB string.
When I write the string to write a copy of the file, its not identical with the origan file ?

What now ?
Posted on 2003-03-22 06:57:13 by Forginforcer
Bin2DB works. Check your code, it's incorrect. Will you be
so kind to give us an excerpt of the part that writes the
data to a file?

How do you determine the size of the db array?



aweX <-
Posted on 2003-03-22 08:04:26 by aweX
Hi, the DB string is to lang, that it would possible to post it:

File1 DB .....
DB .....

Filelen EQU ($-File1)

INVOKE CreateFile, ADDR FILE, GENERIC_READ OR GENERIC_WRITE, NULL, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
MOV Filehandle, EAX
INVOKE WriteFile, Filehandle, ADDR File1, Filelen, ADDR DWORD_bwritten, NULL
invoke CloseHandle, Filehandle

so thats all.

Bye !
Posted on 2003-03-22 08:08:19 by Forginforcer
Hi!

I don't know what this should be: Filelen EQU ($-File1)
This is not good you should maybe use the real size, check it out somwhere.
And then try first with a short file, where the DB-String is not so long. I have here another Prog with which you can do your bin2db thing. It is a console Program with Parameters. Just execute it with the MS-DOS Input Console.

bye...
Posted on 2003-03-22 12:33:09 by ChigpA
@Red Forginforcer: How much bytes is the input file and how much the output file?
Posted on 2003-03-23 00:04:30 by aweX
[size=9].CODE


data_start db 77,90,144,0,3,0,0,0,4,0,0,0,255,255,0,0
db 184,0,0,0,0,0,0,0,64,0,0,0,0,0,0,0
...

data_len equ $ - data_start

start:

invoke CreateFile, OFFSET filename, GENERIC_WRITE, 0, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL
push eax
invoke WriteFile, eax, OFFSET data_start, data_len, OFFSET bytewritten, NULL
call CloseHandle

....
[/size]
Everything seems to work perfectly... There's nothing wrong with the code.
Posted on 2003-03-23 00:15:47 by arkane
red,

With bintodb.exe, it will always write the correct number of bytes into the editor and it will display the size at the top of the editor.

; H:\MASM32\Prostart.exe 40448 bytes

This is the result of running it on the Prostart.exe file.

Use that length when you write the file to disk. All you need to do is put a label at the beginning of the DB sequence and read from that label with the length that is at the top.

This will give you byte perfect reproduction of the file you opened in bintodb.exe.

If you want to write your own version, look in the example code for a file called TABLE.ASM and copy out of it the algorithm called "AsciiDump".

It is faster tan the one I used in "bintodb.exe" when I wrote it a few years ago.

Regards,

hutch@movsd.com
Posted on 2003-03-24 01:14:24 by hutch--
Red Forginforcer,

You can use also f0dder's bin2o (binary to object) tool.

http://www.asmcommunity.net/board/index.php?topic=3722&highlight=bin2o

Regards,

Vortex
Posted on 2003-03-24 04:45:15 by Vortex