Hello,

i have to open a exe..-file and printout with a MessageBox
the two first bytes (MZ or ZM)...

http://eimer.ch/users/cre/win32asm/PrintFirstBytes.txt


the CreateFile works, i have debug it,
but the ReadFile doesn't write in the buffer the value,
why?

thx, cre
Posted on 2004-09-20 03:39:59 by cre
Hi, cre,

the reason is that you are defining ReadByte (number of bytes read) as "dw" (two bytes), immediately followed by the buffer ReadBuffer.
The system will initally put "MZ" inside your buffer, and will return 1 in EAX, but will next overwrite "MZ" with the number of bytes read 02 00 00 00 (4 bytes long).
By the way, also FileHandle must be defined as a long, not a word...

Regards, bilbo
Posted on 2004-09-20 04:22:01 by bilbo