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:
Debg is used to show a value in a messagebox.
Is there something wrong with my code?
bar.
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.
I would reference them like this:
Can't use memory locations as indexes, have to use registers. Don't know why or maybe I'm wrong.
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.
Tnx drarem , it is now working perfectly:
I don't know why it didn't work before either...
bar.
mov ecx,pMemory
mov edx,Fileheader.Type1
Debg [ecx+edx]
I don't know why it didn't work before either...
bar.