flat assembler
Message board for the users of flat assembler.
Index
> Windows > Struct padding question (sorry!) |
Author |
|
tripledot 08 Dec 2011, 13:24
Quote: Controlling Structure Packing http://msdn.microsoft.com/en-us/library/71kf49f1.aspx Hmmm... after a bit more reading it seems like the Windows SDK wants to be compiled with "8-byte struct packing". I take this to mean that struct members should all be padded to 8 bytes in length. Why then, is this completely ignored in FASM's Windows includes? What am I missing? |
|||
08 Dec 2011, 13:24 |
|
AsmGuru62 08 Dec 2011, 15:21
Assume you have 8 consequtive fields in a structure - every field is a BYTE (like in LOGFONT structure) - do every BYTE field is padded to 8 bytes, making every field of 8 bytes in length? Probably not.
|
|||
08 Dec 2011, 15:21 |
|
tripledot 08 Dec 2011, 15:29
No, I thought it was odd. But there is a lot of conflicting documentation out there, and it's quite hard to track down any "#pragma pack"s in the Windows headers. I wasn't sure whether some of the more common structs (such as those in the FASM includes) were more tightly packed, but that others might have to be heavily padded...
I'm glad somebody replied. I knew it was a dumb-arsed question, but there's no need to be condescending about it. The quote above (from MSDN regarding 64-bit code) is a little misleading, no? You didn't really give me any useful information though... am I to assume that all Windows struct members are to be padded to their natural boundary? (e.g. mod2 for word, mod4 for dword, mod8 for qword, etc.)? |
|||
08 Dec 2011, 15:29 |
|
AsmGuru62 08 Dec 2011, 17:33
I actually did not code for x64 (yet), so I really can't say... my apologies.
If I really needed that information - I would have built the x64 application and looked at these Win64 structures (like WNDCLASS, PAINTSTRUCT, etc.) in debugger and then field offsets would have revealed themselves. |
|||
08 Dec 2011, 17:33 |
|
tripledot 09 Dec 2011, 09:41
Thanks - and sorry I was crabby.
Yes, that would be a good approach! As it is I'm really struggling with MSVC - I'm learning assembly because it's so much simpler than the bastard syntax of C/++/#!!! Just getting a project to build in MSVC is a nightmare. I did find this last night though, in case it helps anyone else: http://www.godevtool.com/GoasmHelp/64bits.htm#structs It would be awesome if a macro magician could extend the struct macro to do this (hint) |
|||
09 Dec 2011, 09:41 |
|
AsmGuru62 09 Dec 2011, 11:44
Great link! Thanks.
So, not every type extended to 64-bits, but only handles and pointers. Looks like a RECT structure (containing 4 UINTs) is the same size as in 32-bits. |
|||
09 Dec 2011, 11:44 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.