Hi,

because of Problems while reading data from an exe-file, I think I have to read the file binary. - But how ?

How to read a file binary ?

Greets BBB
Posted on 2003-08-29 15:53:53 by Bubu-Boy
CreateFilea -> ReadFile ..... simple stuff 'non binary' file access is generally some high level junk (basic for example).. all files are really opened as binary in win32
Posted on 2003-08-29 16:12:51 by evlncrn8
Use the raw API functions CreateFile and ReadFile.

If you are already using those functions, just treat the data you read as binary data.
Posted on 2003-08-29 16:16:30 by tenkey
thanks fort the quick answer.

The problem is, when I send it (send) the data get deformed:
And When I want to see, what an exe-file contains(messagebox) something else were shown.
In adition i send the data and after reciefing the data get deformed again.

uff

Greets BBB
Posted on 2003-08-30 01:05:11 by Bubu-Boy
There is a difference between binary and text files, it has to do with byte ordering, just remember that if you write a DWORD to a file the byte order will be reversed:

DWORD1 = 01020304
DWORD2 = AABBCCDD

in the file it will be

04030201DDCCBBAA

If you try to read it as a string it will come out backwards in the same way as if you copy a dword directly to a text buffer.
Posted on 2003-08-30 01:14:58 by donkey
But why it works with normal data?
when I have normal data, it works "correctly" only some things get deformed.

:mad: :mad: :mad:

hmmm BB
Posted on 2003-08-30 01:21:23 by Bubu-Boy
Bubu-Boy,

I would have to know what you are reading and see a bit of the code to answer that, the answers you will get without that are going to be general. You are asking why your code does not work without providing an example of what you are doing. So for now my answer is "I don't know why your code isn't working".
Posted on 2003-08-30 01:26:50 by donkey
code is comming (I thought it was a general question):



INVOKE CreateFile, Datei, GENERIC_READ , FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL
CMP EAX, -1
JE fehlerausgeben
MOV RFile, EAX

readthefilefurther:


LEA EAX, CSBuffer
LEA EBX, readnumeraddr
PUSH 0 ;lesen
PUSH EBX
PUSH sizeof CSBuffer
PUSH EAX
PUSH RFile
CALL ReadFile
MOV EAX, readnumeraddr

INVOKE MessageBox, NULL, ADDR CSBuffer, ADDR CSBuffer, NULL

CALL DatenSenden1
CMP readnumeraddr, 0
JA readthefilefurther

INVOKE MessageBox, NULL, ADDR CSBuffer, ADDR CSBuffer, NULL

fehlerausgeben:
PUSH 0
LEA EAX, CMD
PUSH EAX
PUSH EAX
CALL MessageBox
KeinFehlerzdfgzdfgdfg:




MfG BB

When you need the datadefinitions, yust say a word.
Posted on 2003-08-30 01:44:51 by Bubu-Boy
now there are some bugs, because I tryed every thing out.
Dont think, that it was my first code, that I wrote :grin:

Greets BBB
Posted on 2003-08-30 01:48:11 by Bubu-Boy
actually, easiest way for you to double check that you read the file right (because im not exactly sure what you mean by 'deformed')...

load your file into a hex editor (hiew, or hexworkshop (www.bpsoft.com))
and see what that program shows for say the first 100 bytes
now in your program read the 100 bytes from the file, view what you read in a debugger and see if they match (they should), now try saving what you read in from the file to another file and then again compare what you now wrote to the file against the original data
Posted on 2003-08-30 08:14:34 by evlncrn8