I was trying to read a bitmap's info (on the first 54 bytes) , however , everything I got was just zeroes , except for the first two attributes:



invoke GetWindowText,HTxtPath,ADDR buffer,sizeof buffer
invoke CreateFile,ADDR buffer,\
GENERIC_READ or GENERIC_WRITE ,\
FILE_SHARE_READ or FILE_SHARE_WRITE,\
NULL,OPEN_EXISTING,FILE_ATTRIBUTE_ARCHIVE,\
NULL
mov hFile,eax
invoke GlobalAlloc,GMEM_MOVEABLE or GMEM_ZEROINIT,MEMSIZE
mov hMemory,eax
invoke GlobalLock,hMemory
mov pMemory,eax

invoke ReadFile,hFile,pMemory,sizeof Fileheader,ADDR SizeReadWrite,NULL
Debg SizeReadWrite


Debg [pMemory+Fileheader.Type1]
Debg [pMemory+Fileheader.Size1]
Debg [pMemory+Fileheader.OffBits]
Debg [pMemory+Fileheader.StructSize]
Debg [pMemory+Fileheader.Width1]
Debg [pMemory+Fileheader.Height]
Debg [pMemory+Fileheader.Planes]
Debg [pMemory+Fileheader.BitCount]
Debg [pMemory+Fileheader.Compression]
Debg [pMemory+Fileheader.SizeImage]
Debg [pMemory+Fileheader.XPelsPerMeter]
Debg [pMemory+Fileheader.YPelsPerMeter]
Debg [pMemory+Fileheader.ClrUsed]
Debg [pMemory+Fileheader.ClrImportant]


invoke CloseHandle,hFile
invoke GlobalUnlock,pMemory
invoke GlobalFree,hMemory


Debg is used to show a value in a messagebox.
Is there something wrong with my code?

bar.
Posted on 2004-09-22 12:35:05 by realcr
I would reference them like this:



mov ecx, pMemory
mov edx, Fileheader ;the struct reference
pushad ;save regs
...
popad ;restore regs for immediate use
Debg [ecx+edx].Type1
Debg [ecx+edx].Size1

..
..
etc

or..

mov ecx, pMemory
add ecx, Fileheader
Debg [ecx].Type1
Debg [ecx].Size1


Can't use memory locations as indexes, have to use registers. Don't know why or maybe I'm wrong.
Posted on 2004-09-22 14:53:18 by drarem
Tnx drarem , it is now working perfectly:



mov ecx,pMemory
mov edx,Fileheader.Type1
Debg [ecx+edx]


I don't know why it didn't work before either...

bar.
Posted on 2004-09-22 15:34:21 by realcr