Please file a bug report about this
There used to be an entire section about structure alignment as follows
===Structure Alignment===
‘‘Structure alignment’’ refers to aligning the data at a memory offset equal to some multiple of the word size. Data alignment can increase the computer’s performance.
Structures can be aligned using Attributes. You add the attribute “StructureAlignment” to a structure and use one of the legal values: 0, 1, 2, 4, 8, 16, 32, 64, and 128 as the value. A value of 0 indicates that the compiler should perform a natural alignment, which ensures that the structure will be laid out correctly for a given platform’s ABI rules.
To specify a structure alignment, add an attribute to the Attribute List in the Inspector. Specify “StructureAlignment” in the Name field and enter the desired alignment value.
the trick here will be how the MS apis expect things aligned
and that will be CRUCIAL
I have no idea if they will expect packed or not (StructureAlignment 1)
And to be honest I would be kind of surprised if they do
But IF they do then you could define 2 structures that end up, in total # of bytes, being the same size
For instance you could have structure1 that is
field1 as int32
field2 as string*10
field3 as uint8
and structure2 that is
field1 as uint8
field2 as int32
field3 as string*10
when these are both set to PACKED alignment they both occupy 15 consecutive bytes
And that means you can do
dim s1 as structure1
s1.field1 = &h0102030405060708
s1.field2 = "1234567890"
s1.field3 = &h88
dim s2 as structure2 = Ctype(s1, structure2)
break
and basically reinterpret those bytes using the second structure’s layout (which is kind of what a union does)
What I dont know off the type of my head is whether a union compiled for the Windows API is PACKED or not
If not then this likely wont work because you get different padding bytes in different places and so the structures may end up being different total #'s of bytes (ie/ Here the first with structure alignment 0 is 16 bytes and the second 20)
Thanks for thinking about it Norman. I think the problem will be that the structs are so vastly different it will be a pain to pick apart the data. I get an EventType returned on all different events so I should be able to use that to pick apart the memoryblock, it just wont be as elegant as using structures. I’ll see if Christian wants to look into it as an upgrade to MSB Util before I Module for this. Thanks again.
[quote=321287:@]TBH though, the StructureAlignment reference was just a fish to see if there was some other functionality that wasn’t documented that could help me
[/quote]
Its hidden for a reason
JK - I’m not aware of anything that was omitted/skipped like this that might help
Being able to do a “reinterpret” cast is about as close as I could think of