News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

are you sure that 4+4+1=9 ?

Started by TouEnMasm, September 06, 2012, 11:04:06 PM

Previous topic - Next topic

jj2007

There are a number of options, see snippet below for testing. The question is which size the API expects if it throws an error.

include \masm32\include\masm32rt.inc

STORAGE_PROPERTY_QUERY STRUCT ;DWORD
  PropertyId DWORD ?
  QueryType DWORD ?
  AdditionalParameters BYTE ?
;  manual_padding db (DWORD-1) dup(?)
STORAGE_PROPERTY_QUERY ENDS

.code
spq STORAGE_PROPERTY_QUERY <>
dummy dd ?

start: mov eax, offset dummy
sub eax, offset spq
print str$(eax), " bytes in memory", 13, 10
print str$(sizeof spq), " size of spq", 13, 10
print str$(sizeof STORAGE_PROPERTY_QUERY), " size of STORAGE_PROPERTY_QUERY", 13, 10
print str$(STORAGE_PROPERTY_QUERY), " STORAGE_PROPERTY_QUERY", 13, 10
inkey " "
exit

end start

MichaelW

There won't always be an error reported. Sometimes the misalignment will just cause a hard to diagnose problem. I think the only reasonable and reliable way around this problem is to check each structure definition against a Microsoft compiler and header file.

Well Microsoft, here's another nice mess you've gotten us into.

TouEnMasm

#17
I have modified the "ready to use sdk" (windows.inc subforum).
Now he give the same alignment to the structures than the c++.
If it is not enough,PARTITION_INFORMATION  seem to be a special case,the defaut alignment of DWORD can be change to QWORD in the translate.inc file.

Quote
   ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   DefaultAlignement equ <DWORD>
   DEFALIGNMASM TEXTEQU  DefaultAlignement
   ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
change to
Quote
   ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
   DefaultAlignement equ <QWORD>
   DEFALIGNMASM TEXTEQU  DefaultAlignement
   ;@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
and all the structures with no alignment specify are qword align
Specified alignment can be BYTE,WORD,DWORD or QWORD.





Fa is a musical note to play with CL