The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: Jimg on February 06, 2009, 05:58:02 PM

Title: GetObject Fails if Bitmap Alignment not even
Post by: Jimg on February 06, 2009, 05:58:02 PM
After screwing around for a few hours, I finally found out what was causing the problem with my program, and I thought I'd document it here in case it comes up for someone else.

The GetObject api fails if the BITMAP memory does not start on an even word boundary.

.data?
align 4
hBmp dd ?
tstbyte db ?
btmap   BITMAP <>  ; misaligned bitmap
.code
.
.
.
inv GetObject,hBmp,sizeof btmap,addr btmap

Works fine if I align btmap, otherwise it just returns a zero, and GetLastError returns "Error code 0, the operation completed successfully".